From 55616388eaa5c43b4316882a5c4ab2e0c132b62e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 28 Aug 2013 16:01:27 -0400 Subject: Check network ethernet type whitelist instead of hard-coded ethernet types. --- node/Network.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'node/Network.cpp') 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::newInstance(const RuntimeEnvironment *renv,uint64_t SharedPtr 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 wl(conf.etherTypes()); + for(std::set::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()); -- cgit v1.2.3