diff options
Diffstat (limited to 'include/sibs/IpAddress.hpp')
-rw-r--r-- | include/sibs/IpAddress.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/sibs/IpAddress.hpp b/include/sibs/IpAddress.hpp index c3b43c4..4403e83 100644 --- a/include/sibs/IpAddress.hpp +++ b/include/sibs/IpAddress.hpp @@ -2,6 +2,7 @@ #include <stdexcept> #include <string> +#include <unordered_map> #ifndef WIN32 #include <arpa/inet.h> #include <netdb.h> @@ -32,7 +33,19 @@ namespace sibs unsigned short getPort() const; bool operator == (const Ipv4 &other) const; + bool operator != (const Ipv4 &other) const; struct sockaddr_in address; }; + + struct Ipv4Hasher + { + size_t operator()(const Ipv4 &address) const + { + return address.address.sin_addr.s_addr ^ address.address.sin_port; + } + }; + + template <typename ValueType> + using Ipv4Map = std::unordered_map<Ipv4, ValueType, Ipv4Hasher>; } |