From: Gerd v. Egidy Date: Thu, 2 Sep 2004 14:21:54 +0000 (+0000) Subject: libi2ncommon: (gerd) more IP_RANGE operators X-Git-Tag: v2.6~241 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=5deaa5d41ed285a2bc95c45d96a21def70c6194c;p=libi2ncommon libi2ncommon: (gerd) more IP_RANGE operators --- diff --git a/src/ipfunc.cpp b/src/ipfunc.cpp index 1acee8c..9c641e2 100644 --- a/src/ipfunc.cpp +++ b/src/ipfunc.cpp @@ -153,12 +153,6 @@ int IP_RANGE::operator-(const IP_RANGE &other) return turn_ip(ip)-turn_ip(other.ip); } -bool operator==(const IP_RANGE& a, const IP_RANGE& b) -{ - // == even if comparing ranges and nets possible - return (a.ip==b.ip && a.end==b.end); -} - bool operator<(const IP_RANGE& a, const IP_RANGE& b) { return ((IP_RANGE::turn_ip(a.ip) < IP_RANGE::turn_ip(b.ip)) || diff --git a/src/ipfunc.hxx b/src/ipfunc.hxx index b2062d6..bf2bc52 100644 --- a/src/ipfunc.hxx +++ b/src/ipfunc.hxx @@ -19,6 +19,7 @@ class IP_RANGE { friend IP_RANGE operator+(const IP_RANGE &base, const int &ips); friend bool operator==(const IP_RANGE& a, const IP_RANGE& b); + friend bool operator!=(const IP_RANGE& a, const IP_RANGE& b); friend bool operator<(const IP_RANGE& a, const IP_RANGE& b); private: @@ -79,6 +80,20 @@ inline std::string ipfunc_format_ip(unsigned int ip) return IP_RANGE::ip_string(ip); } +inline bool operator==(const IP_RANGE& a, const IP_RANGE& b) +{ + // == even if comparing ranges and nets possible + return (a.ip==b.ip && a.end==b.end); +} + +inline bool operator!=(const IP_RANGE& a, const IP_RANGE& b) +{ + // == even if comparing ranges and nets possible + return !(a.ip==b.ip && a.end==b.end); +} + +bool operator<(const IP_RANGE& a, const IP_RANGE& b); + // DEPRECATED!!! use IP_RANGE instead // mode 0: get network-base-address, other: broadcast-address inline std::string CalculateNetworkAddresses (int mode, const std::string &ip, const std::string &netmask)