OSDN Git Service

DoS耐性を向上
[peercast-im/PeerCastIM.git] / core / common / addrCont.h
diff --git a/core/common/addrCont.h b/core/common/addrCont.h
new file mode 100644 (file)
index 0000000..882c861
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Container type for IP-addr blacklist
+ * 
+ *                        Impl. by Eru
+ */
+
+#ifndef _CORELIB_COMMON_ADDRCONT_H_
+#define _CORELIB_COMMON_ADDRCONT_H_
+
+#include <limits.h>
+
+class addrCont
+{
+public:
+       unsigned int addr;
+       unsigned int count;
+
+       addrCont() : addr(0), count(0)
+       {
+       }
+
+       addrCont(unsigned int addr) : addr(addr), count(0)
+       {
+       }
+
+       addrCont& operator++()
+       {
+               if (this->count < UINT_MAX)
+                       ++(this->count);
+
+               return *this;
+       }
+
+       inline bool operator==(const addrCont &op)
+       {
+               return this->addr == op.addr;
+       }
+
+       inline bool operator==(const unsigned int op)
+       {
+               return this->addr == op;
+       }
+};
+
+#endif