summaryrefslogtreecommitdiff
path: root/node/Network.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-28 16:01:27 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-28 16:01:27 -0400
commit55616388eaa5c43b4316882a5c4ab2e0c132b62e (patch)
tree6e02779f8864c636e6d35609a984d884ae7741b3 /node/Network.cpp
parent8e1b897f0ae8a228799058153e9dda0a18aeb4c1 (diff)
downloadinfinitytier-55616388eaa5c43b4316882a5c4ab2e0c132b62e.tar.gz
infinitytier-55616388eaa5c43b4316882a5c4ab2e0c132b62e.zip
Check network ethernet type whitelist instead of hard-coded ethernet types.
Diffstat (limited to 'node/Network.cpp')
-rw-r--r--node/Network.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/node/Network.cpp b/node/Network.cpp
index 1e436a27..fc52e6d7 100644
--- a/node/Network.cpp
+++ b/node/Network.cpp
@@ -150,10 +150,8 @@ SharedPtr<Network> Network::newInstance(const RuntimeEnvironment *renv,uint64_t
SharedPtr<Network> nw(new Network());
nw->_ready = false; // disable handling of Ethernet frames during construct
nw->_r = renv;
- nw->_rlLimit.bytesPerSecond = ZT_MULTICAST_DEFAULT_BYTES_PER_SECOND;
- nw->_rlLimit.maxBalance = ZT_MULTICAST_DEFAULT_RATE_MAX_BALANCE;
- nw->_rlLimit.minBalance = ZT_MULTICAST_DEFAULT_RATE_MIN_BALANCE;
nw->_tap = new EthernetTap(renv,tag,renv->identity.address().toMAC(),ZT_IF_MTU,&_CBhandleTapData,nw.ptr());
+ memset(nw->_etWhitelist,0,sizeof(nw->_etWhitelist));
nw->_id = id;
nw->_lastConfigUpdate = 0;
nw->_destroyOnDelete = false;
@@ -177,6 +175,11 @@ void Network::setConfiguration(const Network::Config &conf)
_tap->setIps(conf.staticAddresses());
_tap->setDisplayName((std::string("ZeroTier One [") + conf.name() + "]").c_str());
+ memset(_etWhitelist,0,sizeof(_etWhitelist));
+ std::set<unsigned int> wl(conf.etherTypes());
+ for(std::set<unsigned int>::const_iterator t(wl.begin());t!=wl.end();++t)
+ _etWhitelist[*t / 8] |= (unsigned char)(1 << (*t % 8));
+
std::string confPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + toString() + ".conf");
if (!Utils::writeFile(confPath.c_str(),conf.toString())) {
LOG("error: unable to write network configuration file at: %s",confPath.c_str());