From 9180a309862f1d2abb946381b5b92a823913d425 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 24 Sep 2014 09:01:58 -0700 Subject: [PATCH] . --- node/{PacketDecoder.cpp => IncomingPacket.cpp} | 0 node/{PacketDecoder.hpp => IncomingPacket.hpp} | 0 node/MulticastTopology.cpp | 2 +- node/MulticastTopology.hpp | 2 +- node/Network.cpp | 4 +--- node/Network.hpp | 6 ++++++ node/NetworkConfig.cpp | 10 ++++------ node/NetworkConfig.hpp | 9 +++------ objects.mk | 2 +- 9 files changed, 17 insertions(+), 18 deletions(-) rename node/{PacketDecoder.cpp => IncomingPacket.cpp} (100%) rename node/{PacketDecoder.hpp => IncomingPacket.hpp} (100%) diff --git a/node/PacketDecoder.cpp b/node/IncomingPacket.cpp similarity index 100% rename from node/PacketDecoder.cpp rename to node/IncomingPacket.cpp diff --git a/node/PacketDecoder.hpp b/node/IncomingPacket.hpp similarity index 100% rename from node/PacketDecoder.hpp rename to node/IncomingPacket.hpp diff --git a/node/MulticastTopology.cpp b/node/MulticastTopology.cpp index ee6f7954a..e4b1066dc 100644 --- a/node/MulticastTopology.cpp +++ b/node/MulticastTopology.cpp @@ -72,7 +72,7 @@ void MulticastTopology::erase(const MulticastGroup &mg,const Address &member) } } -unsigned int MulticastTopology::want(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn) +unsigned int MulticastTopology::shouldGather(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn) { Mutex::Lock _l(_groups_m); MulticastGroupStatus &gs = _groups[mg]; diff --git a/node/MulticastTopology.hpp b/node/MulticastTopology.hpp index 17013fc1b..8a68f2b20 100644 --- a/node/MulticastTopology.hpp +++ b/node/MulticastTopology.hpp @@ -112,7 +112,7 @@ public: * @param limit The maximum number we want per multicast group on this network * @param updateLastGatheredTimeOnNonzeroReturn If true, reset group's last gathered time to 'now' on non-zero return */ - unsigned int want(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn); + unsigned int shouldGather(const MulticastGroup &mg,uint64_t now,unsigned int limit,bool updateLastGatheredTimeOnNonzeroReturn); /** * Update last gathered members time for a group diff --git a/node/Network.cpp b/node/Network.cpp index d5b042307..8b97562f2 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -281,14 +281,13 @@ bool Network::isAllowed(const Address &peer) const void Network::clean() { + uint64_t now = Utils::now(); { Mutex::Lock _l(_lock); if (_destroyed) return; - uint64_t now = Utils::now(); - if ((_config)&&(_config->isPublic())) { // Open (public) networks do not track certs or cert pushes at all. _membershipCertificates.clear(); @@ -318,7 +317,6 @@ void Network::clean() else ++mg; } } - { _multicastTopology.clean(now,*(_r->topology),(_config) ? _config->multicastLimit() : (unsigned int)ZT_DEFAULT_MULTICAST_LIMIT); } diff --git a/node/Network.hpp b/node/Network.hpp index 3f0b6eb8b..b0af08c77 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -413,6 +413,12 @@ public: */ void setEnabled(bool enabled); + /** + * @return Multicast topology for this network + */ + inline MulticastTopology &mcTopology() { return _multicastTopology; } + inline const MulticastTopology &mcTopology() const { return _multicastTopology; } + /** * Destroy this network * diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp index c78dd995f..8b85cd87a 100644 --- a/node/NetworkConfig.cpp +++ b/node/NetworkConfig.cpp @@ -85,18 +85,16 @@ void NetworkConfig::_fromDictionary(const Dictionary &d) _timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str()); _issuedTo = Address(d.get(ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO)); - _multicastPrefixBits = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_PREFIX_BITS,zero).c_str()); - if (!_multicastPrefixBits) - _multicastPrefixBits = ZT_DEFAULT_MULTICAST_PREFIX_BITS; - _multicastDepth = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_DEPTH,zero).c_str()); - if (!_multicastDepth) - _multicastDepth = ZT_DEFAULT_MULTICAST_DEPTH; + _multicastLimit = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT,zero).c_str()); + if (_multicastLimit == 0) _multicastLimit = ZT_DEFAULT_MULTICAST_LIMIT; _allowPassiveBridging = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOW_PASSIVE_BRIDGING,zero).c_str()) != 0); _private = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_PRIVATE,one).c_str()) != 0); _enableBroadcast = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST,one).c_str()) != 0); _name = d.get(ZT_NETWORKCONFIG_DICT_KEY_NAME); _description = d.get(ZT_NETWORKCONFIG_DICT_KEY_DESC,std::string()); + // In dictionary IPs are split into V4 and V6 addresses, but we don't really + // need that so merge them here. std::string ipAddrs(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV4_STATIC,std::string())); { std::string v6s(d.get(ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC,std::string())); diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index a6f668aac..e0e9b3a9b 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -52,8 +52,7 @@ namespace ZeroTier { #define ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID "nwid" #define ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP "ts" #define ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO "id" -#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_PREFIX_BITS "mpb" -#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_DEPTH "md" +#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT "ml" #define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_RATES "mr" #define ZT_NETWORKCONFIG_DICT_KEY_PRIVATE "p" #define ZT_NETWORKCONFIG_DICT_KEY_NAME "n" @@ -116,8 +115,7 @@ public: inline uint64_t networkId() const throw() { return _nwid; } inline uint64_t timestamp() const throw() { return _timestamp; } inline const Address &issuedTo() const throw() { return _issuedTo; } - inline unsigned int multicastPrefixBits() const throw() { return _multicastPrefixBits; } - inline unsigned int multicastDepth() const throw() { return _multicastDepth; } + inline unsigned int multicastLimit() const throw() { return _multicastLimit; } inline const std::map &multicastRates() const throw() { return _multicastRates; } inline bool allowPassiveBridging() const throw() { return _allowPassiveBridging; } inline bool isPublic() const throw() { return (!_private); } @@ -155,8 +153,7 @@ private: uint64_t _nwid; uint64_t _timestamp; Address _issuedTo; - unsigned int _multicastPrefixBits; - unsigned int _multicastDepth; + unsigned int _multicastLimit; bool _allowPassiveBridging; bool _private; bool _enableBroadcast; diff --git a/objects.mk b/objects.mk index 276c89cfe..059ffe897 100644 --- a/objects.mk +++ b/objects.mk @@ -10,6 +10,7 @@ OBJS=\ node/Dictionary.o \ node/HttpClient.o \ node/Identity.o \ + node/IncomingPacket.o \ node/InetAddress.o \ node/Logger.o \ node/MulticastTopology.o \ @@ -18,7 +19,6 @@ OBJS=\ node/Node.o \ node/NodeConfig.o \ node/Packet.o \ - node/PacketDecoder.o \ node/Peer.o \ node/Poly1305.o \ node/RoutingTable.o \