diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-09 20:54:00 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-09 20:54:00 -0700 |
| commit | 068d311ecc7b52f1adaa894864afa54ef49a3e6e (patch) | |
| tree | e62de1256cbc981f159c8b023ce1b6bbbc3f27cd /node/InetAddress.hpp | |
| parent | 38200cc6a55c3b11502a78251c2bdf09960a2a03 (diff) | |
| download | infinitytier-068d311ecc7b52f1adaa894864afa54ef49a3e6e.tar.gz infinitytier-068d311ecc7b52f1adaa894864afa54ef49a3e6e.zip | |
TRACE compile fixes, other fixes, and it basically works! It says HELLO.
Diffstat (limited to 'node/InetAddress.hpp')
| -rw-r--r-- | node/InetAddress.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index 43fcc333..5e4dbfd8 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -354,6 +354,19 @@ struct InetAddress : public sockaddr_storage } /** + * @param a InetAddress to compare again + * @return True if only IP portions are equal (false for non-IP or null addresses) + */ + inline bool ipsEqual(const InetAddress &a) const + { + switch(ss_family) { + case AF_INET: return (reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr == reinterpret_cast<const struct sockaddr_in *>(&a)->sin_addr.s_addr); + case AF_INET6: return (memcmp(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,reinterpret_cast<const struct sockaddr_in6 *>(&a)->sin6_addr.s6_addr,16) == 0); + } + return false; + } + + /** * Set to null/zero */ inline void zero() throw() { memset(this,0,sizeof(InetAddress)); } |
