diff options
Diffstat (limited to 'node')
| -rw-r--r-- | node/Constants.hpp | 4 | ||||
| -rw-r--r-- | node/EthernetTap.hpp | 15 | ||||
| -rw-r--r-- | node/InetAddress.cpp | 18 | ||||
| -rw-r--r-- | node/InetAddress.hpp | 16 | ||||
| -rw-r--r-- | node/Network.cpp | 1 |
5 files changed, 35 insertions, 19 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp index 620f9b0d..8a8c70f2 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -387,12 +387,12 @@ /** * How often to broadcast beacons over physical local LANs */ -#define ZT_BEACON_INTERVAL ZT_PEER_DIRECT_PING_DELAY +#define ZT_BEACON_INTERVAL 30000 /** * Do not respond to any beacon more often than this */ -#define ZT_MIN_BEACON_RESPONSE_INTERVAL (ZT_BEACON_INTERVAL / 64) +#define ZT_MIN_BEACON_RESPONSE_INTERVAL (ZT_BEACON_INTERVAL / 32) /** * Minimum interval between attempts to do a software update diff --git a/node/EthernetTap.hpp b/node/EthernetTap.hpp index 0819fb49..87ab607d 100644 --- a/node/EthernetTap.hpp +++ b/node/EthernetTap.hpp @@ -196,21 +196,6 @@ public: */ virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups) = 0; - /** - * Should this tap device get a pseudo-default-route? - * - * Some platforms (cough Windows) want all "real" network devices to have a - * routing table entry for default, even if it's got a high metric and is - * never used and goes nowhere. If this returns true, the underlying node - * code will use RoutingTable to create one if no default route is - * otherwise defined. - * - * Base class default returns false. Override to return true if needed. - * - * @return True if pseudo-default-route should always exist - */ - virtual bool createPseudoDefaultRoute() const { return false; } - protected: const char *_implName; MAC _mac; 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]; diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index 74e42670..7cfb1abe 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -77,6 +77,16 @@ public: */ static const InetAddress LO6; + /** + * 0.0.0.0/0 + */ + static const InetAddress DEFAULT4; + + /** + * ::/0 + */ + static const InetAddress DEFAULT6; + InetAddress() throw() { memset(&_sa,0,sizeof(_sa)); } InetAddress(const InetAddress &a) throw() { memcpy(&_sa,&a._sa,sizeof(_sa)); } InetAddress(const struct sockaddr *sa) throw() { this->set(sa); } @@ -148,6 +158,12 @@ public: throw(); /** + * @return True if this ip/netmask would represent a default route (e.g. 0.0.0.0/0) + */ + bool isDefaultRoute() const + throw(); + + /** * @return True if this is a loopback address */ inline bool isLoopback() const diff --git a/node/Network.cpp b/node/Network.cpp index c024a54b..b38e9692 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -39,6 +39,7 @@ #include "Buffer.hpp" #include "EthernetTap.hpp" #include "EthernetTapFactory.hpp" +#include "RoutingTable.hpp" #define ZT_NETWORK_CERT_WRITE_BUF_SIZE 131072 |
