mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-09 04:04:13 +00:00
Replace two bools in NetworkConfig with a flags field.
This commit is contained in:
parent
90e1262a8b
commit
e731fc1a3a
@ -52,9 +52,8 @@ NetworkConfig NetworkConfig::createTestNetworkConfig(const Address &self)
|
||||
nc._revision = 1;
|
||||
nc._issuedTo = self;
|
||||
nc._multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
|
||||
nc._allowPassiveBridging = false;
|
||||
nc._flags = ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST;
|
||||
nc._type = ZT_NETWORK_TYPE_PUBLIC;
|
||||
nc._enableBroadcast = true;
|
||||
|
||||
nc._rules[nc._ruleCount].ruleNo = 1;
|
||||
nc._rules[nc._ruleCount].matches = (uint8_t)ZT_NETWORK_RULE_MATCHES_ALL;
|
||||
@ -82,11 +81,11 @@ NetworkConfig NetworkConfig::createTestNetworkConfig(const Address &self)
|
||||
|
||||
void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
|
||||
{
|
||||
Dictionary d(ds,dslen);
|
||||
|
||||
static const std::string zero("0");
|
||||
static const std::string one("1");
|
||||
|
||||
Dictionary d(ds,dslen);
|
||||
|
||||
memset(this,0,sizeof(NetworkConfig));
|
||||
|
||||
// NOTE: d.get(name) throws if not found, d.get(name,default) returns default
|
||||
@ -102,8 +101,9 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
|
||||
_multicastLimit = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT,zero).c_str());
|
||||
if (_multicastLimit == 0) _multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
|
||||
|
||||
_allowPassiveBridging = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOW_PASSIVE_BRIDGING,zero).c_str()) != 0);
|
||||
_enableBroadcast = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST,one).c_str()) != 0);
|
||||
_flags |= ((Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOW_PASSIVE_BRIDGING,zero).c_str()) != 0) ? ZT_NETWORKCONFIG_FLAG_ALLOW_PASSIVE_BRIDGING : 0);
|
||||
_flags |= ((Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST,one).c_str()) != 0) ? ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST : 0);
|
||||
|
||||
_type = (Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_PRIVATE,one).c_str()) != 0) ? ZT_NETWORK_TYPE_PRIVATE : ZT_NETWORK_TYPE_PUBLIC;
|
||||
|
||||
std::string nametmp(d.get(ZT_NETWORKCONFIG_DICT_KEY_NAME,""));
|
||||
|
@ -46,6 +46,16 @@
|
||||
*/
|
||||
#define ZT_NETWORKCONFIG_V2_MARKER_BYTE 0x00
|
||||
|
||||
/**
|
||||
* Flag: allow passive bridging (experimental)
|
||||
*/
|
||||
#define ZT_NETWORKCONFIG_FLAG_ALLOW_PASSIVE_BRIDGING 0x0001
|
||||
|
||||
/**
|
||||
* Flag: enable broadcast
|
||||
*/
|
||||
#define ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST 0x0002
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
#ifdef ZT_SUPPORT_OLD_STYLE_NETCONF
|
||||
@ -189,12 +199,12 @@ public:
|
||||
/**
|
||||
* @return True if passive bridging is allowed (experimental)
|
||||
*/
|
||||
inline bool allowPassiveBridging() const throw() { return _allowPassiveBridging; }
|
||||
inline bool allowPassiveBridging() const throw() { return ((_flags & ZT_NETWORKCONFIG_FLAG_ALLOW_PASSIVE_BRIDGING) != 0); }
|
||||
|
||||
/**
|
||||
* @return True if broadcast (ff:ff:ff:ff:ff:ff) address should work on this network
|
||||
*/
|
||||
inline bool enableBroadcast() const throw() { return _enableBroadcast; }
|
||||
inline bool enableBroadcast() const throw() { return ((_flags & ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST) != 0); }
|
||||
|
||||
/**
|
||||
* @return Type of network (currently public or private)
|
||||
@ -294,7 +304,7 @@ public:
|
||||
*/
|
||||
inline bool permitsBridging(const Address &fromPeer) const
|
||||
{
|
||||
if (_allowPassiveBridging)
|
||||
if ((_flags & ZT_NETWORKCONFIG_FLAG_ALLOW_PASSIVE_BRIDGING) != 0)
|
||||
return true;
|
||||
for(unsigned int i=0;i<_activeBridgeCount;++i) {
|
||||
if (_activeBridges[i] == fromPeer)
|
||||
@ -317,8 +327,7 @@ protected: // protected so that a subclass can fill this out in network controll
|
||||
uint64_t _revision;
|
||||
Address _issuedTo;
|
||||
unsigned int _multicastLimit;
|
||||
bool _allowPassiveBridging;
|
||||
bool _enableBroadcast;
|
||||
unsigned int _flags;
|
||||
ZT_VirtualNetworkType _type;
|
||||
|
||||
char _name[ZT_MAX_NETWORK_SHORT_NAME_LENGTH + 1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user