This commit is contained in:
Adam Ierymenko 2014-09-24 09:01:58 -07:00
parent 61d0f27d2a
commit 9180a30986
9 changed files with 17 additions and 18 deletions

View File

@ -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];

View File

@ -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

View File

@ -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);
}

View File

@ -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
*

View File

@ -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()));

View File

@ -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<MulticastGroup,MulticastRate> &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;

View File

@ -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 \