summaryrefslogtreecommitdiff
path: root/node/NetworkConfig.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-05-06 16:13:11 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-05-06 16:13:11 -0700
commit8b9519f0af8e89ad49e730546abdc2ff94fd2ef8 (patch)
treeed55bee33eadfd08c96e4c0688b577b13912a1af /node/NetworkConfig.cpp
parent529515d1d173e6850c86230106cbfc36e1b9bf97 (diff)
downloadinfinitytier-8b9519f0af8e89ad49e730546abdc2ff94fd2ef8.tar.gz
infinitytier-8b9519f0af8e89ad49e730546abdc2ff94fd2ef8.zip
Simplify a bunch of NetworkConfig stuff by eliminating accessors, also makes network controller easier to refactor.
Diffstat (limited to 'node/NetworkConfig.cpp')
-rw-r--r--node/NetworkConfig.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp
index 14e555f9..ea0bdb7d 100644
--- a/node/NetworkConfig.cpp
+++ b/node/NetworkConfig.cpp
@@ -36,25 +36,25 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
// NOTE: d.get(name) throws if not found, d.get(name,default) returns default
- _nwid = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID,"0").c_str());
- if (!_nwid)
+ networkId = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID,"0").c_str());
+ if (!networkId)
throw std::invalid_argument("configuration contains zero network ID");
- _timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP,"0").c_str());
- _revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older controllers don't send this, so default to 1
- _issuedTo = Address(d.get(ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO,"0"));
+ timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP,"0").c_str());
+ revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older controllers don't send this, so default to 1
+ issuedTo = Address(d.get(ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO,"0"));
- _multicastLimit = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT,zero).c_str());
- if (_multicastLimit == 0) _multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
+ multicastLimit = Utils::hexStrToUInt(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT,zero).c_str());
+ if (multicastLimit == 0) multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
- _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);
+ 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;
+ this->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,""));
for(unsigned long i=0;((i<ZT_MAX_NETWORK_SHORT_NAME_LENGTH)&&(i<nametmp.length()));++i)
- _name[i] = (char)nametmp[i];
+ name[i] = (char)nametmp[i];
// we zeroed the entire structure above and _name is ZT_MAX_NETWORK_SHORT_NAME_LENGTH+1, so it will always null-terminate
std::vector<std::string> activeBridgesSplit(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ACTIVE_BRIDGES,"").c_str(),",","",""));
@@ -63,15 +63,15 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
Address tmp(*a);
if (!tmp.isReserved()) {
uint64_t specialist = tmp.toInt();
- for(unsigned int i=0;i<_specialistCount;++i) {
- if ((_specialists[i] & 0xffffffffffULL) == specialist) {
- _specialists[i] |= ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE;
+ for(unsigned int i=0;i<specialistCount;++i) {
+ if ((specialists[i] & 0xffffffffffULL) == specialist) {
+ specialists[i] |= ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE;
specialist = 0;
break;
}
}
- if ((specialist)&&(_specialistCount < ZT_MAX_NETWORK_SPECIALISTS))
- _specialists[_specialistCount++] = specialist | ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE;
+ if ((specialist)&&(specialistCount < ZT_MAX_NETWORK_SPECIALISTS))
+ specialists[specialistCount++] = specialist | ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE;
}
}
}
@@ -101,11 +101,11 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
continue;
}
if (!addr.isNetwork()) {
- if ((_staticIpCount < ZT_MAX_ZT_ASSIGNED_ADDRESSES)&&(std::find(&(_staticIps[0]),&(_staticIps[_staticIpCount]),addr) == &(_staticIps[_staticIpCount])))
- _staticIps[_staticIpCount++] = addr;
+ if ((staticIpCount < ZT_MAX_ZT_ASSIGNED_ADDRESSES)&&(std::find(&(staticIps[0]),&(staticIps[staticIpCount]),addr) == &(staticIps[staticIpCount])))
+ staticIps[staticIpCount++] = addr;
}
}
- std::sort(&(_staticIps[0]),&(_staticIps[_staticIpCount]));
+ std::sort(&(staticIps[0]),&(staticIps[staticIpCount]));
/* Old versions don't support gateways anyway, so ignore this in old netconfs
std::vector<std::string> gatewaysSplit(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_GATEWAYS,"").c_str(),",","",""));
@@ -135,26 +135,26 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
}
uint64_t specialist = zt.toInt();
- for(unsigned int i=0;i<_specialistCount;++i) {
- if ((_specialists[i] & 0xffffffffffULL) == specialist) {
- _specialists[i] |= ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY;
+ for(unsigned int i=0;i<specialistCount;++i) {
+ if ((specialists[i] & 0xffffffffffULL) == specialist) {
+ specialists[i] |= ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY;
specialist = 0;
break;
}
}
- if ((specialist)&&(_specialistCount < ZT_MAX_NETWORK_SPECIALISTS))
- _specialists[_specialistCount++] = specialist | ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY;
+ if ((specialist)&&(specialistCount < ZT_MAX_NETWORK_SPECIALISTS))
+ specialists[specialistCount++] = specialist | ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY;
- if ((phy[0])&&(_staticCount < ZT_MAX_NETWORK_STATIC_PHYSICAL_ADDRESSES)) {
- _static[_staticCount].zt = zt;
- _static[_staticCount].phy = phy[0];
- ++_staticCount;
+ if ((phy[0])&&(pinnedCount < ZT_MAX_NETWORK_PINNED)) {
+ pinned[pinnedCount].zt = zt;
+ pinned[pinnedCount].phy = phy[0];
+ ++pinnedCount;
}
- if ((phy[1])&&(_staticCount < ZT_MAX_NETWORK_STATIC_PHYSICAL_ADDRESSES)) {
- _static[_staticCount].zt = zt;
- _static[_staticCount].phy = phy[0];
- ++_staticCount;
+ if ((phy[1])&&(pinnedCount < ZT_MAX_NETWORK_PINNED)) {
+ pinned[pinnedCount].zt = zt;
+ pinned[pinnedCount].phy = phy[0];
+ ++pinnedCount;
}
}
}
@@ -162,18 +162,18 @@ void NetworkConfig::fromDictionary(const char *ds,unsigned int dslen)
std::vector<std::string> ets(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES,"").c_str(),",","",""));
for(std::vector<std::string>::const_iterator et(ets.begin());et!=ets.end();++et) {
unsigned int et2 = Utils::hexStrToUInt(et->c_str()) & 0xffff;
- if ((_ruleCount + 1) < ZT_MAX_NETWORK_RULES) {
+ if ((ruleCount + 1) < ZT_MAX_NETWORK_RULES) {
if (et2) {
- _rules[_ruleCount].t = ZT_NETWORK_RULE_MATCH_ETHERTYPE;
- _rules[_ruleCount].v.etherType = (uint16_t)et2;
- ++_ruleCount;
+ rules[ruleCount].t = ZT_NETWORK_RULE_MATCH_ETHERTYPE;
+ rules[ruleCount].v.etherType = (uint16_t)et2;
+ ++ruleCount;
}
- _rules[_ruleCount].t = ZT_NETWORK_RULE_ACTION_ACCEPT;
- ++_ruleCount;
+ rules[ruleCount].t = ZT_NETWORK_RULE_ACTION_ACCEPT;
+ ++ruleCount;
}
}
- _com.fromString(d.get(ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP,std::string()));
+ this->com.fromString(d.get(ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP,std::string()));
}
#endif // ZT_SUPPORT_OLD_STYLE_NETCONF