From f8d4611d15b18bf505de9ca82d74f5102fc57024 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 12 Aug 2014 17:20:34 -0700 Subject: (1) Tweak LAN locator beacon frequencies, (2) Windows virtual networks now show up as *real* networks and prompt the user to set their location and firewall status (public, private, home/work, etc.). The hack used to achieve #2 should not be examined by children or those suffering from epilepsy or heart conditions. --- node/InetAddress.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'node/InetAddress.cpp') diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp index 9ff5acea..88ab6e49 100644 --- a/node/InetAddress.cpp +++ b/node/InetAddress.cpp @@ -39,6 +39,8 @@ namespace ZeroTier { const InetAddress InetAddress::LO4("127.0.0.1",0); const InetAddress InetAddress::LO6("::1",0); +const InetAddress InetAddress::DEFAULT4((uint32_t)0,0); +const InetAddress InetAddress::DEFAULT6((const void *)0,16,0); void InetAddress::set(const std::string &ip,unsigned int port) throw() @@ -63,11 +65,13 @@ void InetAddress::set(const void *ipBytes,unsigned int ipLen,unsigned int port) memset(&_sa,0,sizeof(_sa)); if (ipLen == 4) { setV4(); - memcpy(rawIpData(),ipBytes,4); + if (ipBytes) + memcpy(rawIpData(),ipBytes,4); setPort(port); } else if (ipLen == 16) { setV6(); - memcpy(rawIpData(),ipBytes,16); + if (ipBytes) + memcpy(rawIpData(),ipBytes,16); setPort(port); } } @@ -91,6 +95,16 @@ bool InetAddress::isLinkLocal() const return false; } +bool InetAddress::isDefaultRoute() const + throw() +{ + if (_sa.saddr.sa_family == AF_INET) + return ((_sa.sin.sin_addr.s_addr == 0)&&(_sa.sin.sin_port == 0)); + else if (_sa.saddr.sa_family == AF_INET6) + return ((Utils::isZero(_sa.sin6.sin6_addr.s6_addr,16))&&(_sa.sin6.sin6_port == 0)); + return false; +} + std::string InetAddress::toString() const { char buf[128],buf2[128]; -- cgit v1.2.3