diff --git a/src/ip_utils.h b/src/ip_utils.h index 3cb36182f04df9d74d12a69dcc4703561635a79b..63a1cfc50ad083e029c9a3b3105c87151ff89341 100644 --- a/src/ip_utils.h +++ b/src/ip_utils.h @@ -104,12 +104,8 @@ public: addr.addr.sa_family = AF_UNSPEC; } - inline bool operator==(const IpAddr& other) const { - return pj_sockaddr_cmp(&addr, &other.addr) == 0; - } - // Is defined - inline operator bool() const { + inline explicit operator bool() const { return isIpv4() or isIpv6(); } @@ -226,6 +222,10 @@ private: pj_sockaddr addr; }; +// IpAddr helpers +inline bool operator==(const IpAddr& lhs, const IpAddr& rhs) { return !pj_sockaddr_cmp(&lhs, &rhs); } +inline bool operator!=(const IpAddr& lhs, const IpAddr& rhs) { return !(lhs == rhs); } + namespace ip_utils { static const char *const DEFAULT_INTERFACE = "default";