diff options
Diffstat (limited to 'zerotierone/node/InetAddress.hpp')
| -rw-r--r-- | zerotierone/node/InetAddress.hpp | 83 |
1 files changed, 6 insertions, 77 deletions
diff --git a/zerotierone/node/InetAddress.hpp b/zerotierone/node/InetAddress.hpp index 6f070fb..b60a5a3 100644 --- a/zerotierone/node/InetAddress.hpp +++ b/zerotierone/node/InetAddress.hpp @@ -231,6 +231,7 @@ struct InetAddress : public sockaddr_storage * @param port Port, 0 to 65535 */ inline void setPort(unsigned int port) + throw() { switch(ss_family) { case AF_INET: @@ -243,25 +244,6 @@ struct InetAddress : public sockaddr_storage } /** - * @return True if this network/netmask route describes a default route (e.g. 0.0.0.0/0) - */ - inline bool isDefaultRoute() const - { - switch(ss_family) { - case AF_INET: - return ( (reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr == 0) && (reinterpret_cast<const struct sockaddr_in *>(this)->sin_port == 0) ); - case AF_INET6: - const uint8_t *ipb = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr); - for(int i=0;i<16;++i) { - if (ipb[i]) - return false; - } - return (reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_port == 0); - } - return false; - } - - /** * @return ASCII IP/port format representation */ std::string toString() const; @@ -301,19 +283,6 @@ struct InetAddress : public sockaddr_storage inline unsigned int netmaskBits() const throw() { return port(); } /** - * @return True if netmask bits is valid for the address type - */ - inline bool netmaskBitsValid() const - { - const unsigned int n = port(); - switch(ss_family) { - case AF_INET: return (n <= 32); - case AF_INET6: return (n <= 128); - } - return false; - } - - /** * Alias for port() * * This just aliases port() because for gateways we use this field to @@ -369,6 +338,7 @@ struct InetAddress : public sockaddr_storage * @return pointer to raw address bytes or NULL if not available */ inline const void *rawIpData() const + throw() { switch(ss_family) { case AF_INET: return (const void *)&(reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr); @@ -378,25 +348,6 @@ struct InetAddress : public sockaddr_storage } /** - * @return InetAddress containing only the IP portion of this address and a zero port, or NULL if not IPv4 or IPv6 - */ - inline InetAddress ipOnly() const - { - InetAddress r; - switch(ss_family) { - case AF_INET: - r.ss_family = AF_INET; - reinterpret_cast<struct sockaddr_in *>(&r)->sin_addr.s_addr = reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr; - break; - case AF_INET6: - r.ss_family = AF_INET6; - memcpy(reinterpret_cast<struct sockaddr_in6 *>(&r)->sin6_addr.s6_addr,reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,16); - break; - } - return r; - } - - /** * Performs an IP-only comparison or, if that is impossible, a memcmp() * * @param a InetAddress to compare again @@ -414,25 +365,6 @@ struct InetAddress : public sockaddr_storage return false; } - inline unsigned long hashCode() const - { - if (ss_family == AF_INET) { - return ((unsigned long)reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr + (unsigned long)reinterpret_cast<const struct sockaddr_in *>(this)->sin_port); - } else if (ss_family == AF_INET6) { - unsigned long tmp = reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_port; - const uint8_t *a = reinterpret_cast<const uint8_t *>(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr); - for(long i=0;i<16;++i) - reinterpret_cast<uint8_t *>(&tmp)[i % sizeof(tmp)] ^= a[i]; - return tmp; - } else { - unsigned long tmp = reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_port; - const uint8_t *a = reinterpret_cast<const uint8_t *>(this); - for(long i=0;i<sizeof(InetAddress);++i) - reinterpret_cast<uint8_t *>(&tmp)[i % sizeof(tmp)] ^= a[i]; - return tmp; - } - } - /** * Set to null/zero */ @@ -521,7 +453,8 @@ struct InetAddress : public sockaddr_storage * @param mac MAC address seed * @return IPv6 link-local address */ - static InetAddress makeIpv6LinkLocal(const MAC &mac); + static InetAddress makeIpv6LinkLocal(const MAC &mac) + throw(); /** * Compute private IPv6 unicast address from network ID and ZeroTier address @@ -564,12 +497,8 @@ struct InetAddress : public sockaddr_storage * @param zeroTierAddress 40-bit device address (in least significant 40 bits, highest 24 bits ignored) * @return IPv6 private unicast address with /88 netmask */ - static InetAddress makeIpv6rfc4193(uint64_t nwid,uint64_t zeroTierAddress); - - /** - * Compute a private IPv6 "6plane" unicast address from network ID and ZeroTier address - */ - static InetAddress makeIpv66plane(uint64_t nwid,uint64_t zeroTierAddress); + static InetAddress makeIpv6rfc4193(uint64_t nwid,uint64_t zeroTierAddress) + throw(); }; } // namespace ZeroTier |
