summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-01 12:41:48 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-01 12:41:48 -0700
commitae082c3cb8a1ba7f8efb95ce690b012ffa7a79cd (patch)
tree1b4eacab0989aa6423cc1e617393fe0586eb6938
parentea6124dd2f48cafd8333d03705a8c8a9c201553d (diff)
downloadinfinitytier-ae082c3cb8a1ba7f8efb95ce690b012ffa7a79cd.tar.gz
infinitytier-ae082c3cb8a1ba7f8efb95ce690b012ffa7a79cd.zip
Yay... now everything compiles! Getting close to testing on this. Still have not added backward compatibility support for relaying of multicasts to 0.9.X clients yet but that will be easy. Will test with heterogenous 1.0.0 clients only first.
-rw-r--r--node/Network.hpp10
-rw-r--r--node/Node.cpp18
-rw-r--r--node/NodeConfig.cpp2
-rw-r--r--node/Service.cpp2
-rw-r--r--node/SoftwareUpdater.cpp6
-rw-r--r--node/Switch.cpp26
-rw-r--r--node/Switch.hpp2
7 files changed, 43 insertions, 23 deletions
diff --git a/node/Network.hpp b/node/Network.hpp
index 4b184be6..1d8b92c6 100644
--- a/node/Network.hpp
+++ b/node/Network.hpp
@@ -164,6 +164,16 @@ public:
}
/**
+ * @param mg Multicast group
+ * @return True if this group is among those to which I am subscribed
+ */
+ inline bool wantMulticastGroup(const MulticastGroup &mg) const
+ {
+ Mutex::Lock _l(_lock);
+ return (_myMulticastGroups.count(mg) > 0);
+ }
+
+ /**
* Set or update this network's configuration
*
* This is called in IncomingPacket when an update comes over the wire, or
diff --git a/node/Node.cpp b/node/Node.cpp
index 0573392f..05a490b7 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -383,11 +383,11 @@ Node::ReasonForTermination Node::run()
RR->http = new HttpClient();
RR->antiRec = new AntiRecursion();
RR->mc = new Multicaster();
- RR->sw = new Switch(_r);
- RR->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,_r);
+ RR->sw = new Switch(RR);
+ RR->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,RR);
RR->topology = new Topology(RR,Utils::fileExists((RR->homePath + ZT_PATH_SEPARATOR_S + "iddb.d").c_str()));
try {
- RR->nc = new NodeConfig(_r);
+ RR->nc = new NodeConfig(RR);
} catch (std::exception &exc) {
return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unable to initialize IPC socket: is ZeroTier One already running?");
}
@@ -395,7 +395,7 @@ Node::ReasonForTermination Node::run()
#ifdef ZT_AUTO_UPDATE
if (ZT_DEFAULTS.updateLatestNfoURL.length()) {
- RR->updater = new SoftwareUpdater(_r);
+ RR->updater = new SoftwareUpdater(RR);
RR->updater->cleanOldUpdates(); // clean out updates.d on startup
} else {
LOG("WARNING: unable to enable software updates: latest .nfo URL from ZT_DEFAULTS is empty (does this platform actually support software updates?)");
@@ -443,7 +443,7 @@ Node::ReasonForTermination Node::run()
std::string netconfServicePath(RR->homePath + ZT_PATH_SEPARATOR_S + "services.d" + ZT_PATH_SEPARATOR_S + "netconf.service");
if (Utils::fileExists(netconfServicePath.c_str())) {
LOG("netconf.d/netconf.service appears to exist, starting...");
- RR->netconfService = new Service(RR,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,_r);
+ RR->netconfService = new Service(RR,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,RR);
Dictionary initMessage;
initMessage["type"] = "netconf-init";
initMessage["netconfId"] = RR->identity.toString(true);
@@ -570,7 +570,7 @@ Node::ReasonForTermination Node::run()
try {
std::vector< SharedPtr<Network> > networks(RR->nc->networks());
for(std::vector< SharedPtr<Network> >::const_iterator nw(networks.begin());nw!=networks.end();++nw)
- (*nw)->updateMulticastGroups());
+ (*nw)->updateMulticastGroups();
} catch (std::exception &exc) {
LOG("unexpected exception announcing multicast groups: %s",exc.what());
} catch ( ... ) {
@@ -631,7 +631,7 @@ Node::ReasonForTermination Node::run()
lastRootTopologyFetch = now;
if (!impl->disableRootTopologyUpdates) {
TRACE("fetching root topology from %s",ZT_DEFAULTS.rootTopologyUpdateURL.c_str());
- RR->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,_r);
+ RR->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,RR);
}
}
@@ -715,7 +715,7 @@ bool Node::initialized()
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
- return ((_r)&&(RR->initialized));
+ return ((RR)&&(RR->initialized));
}
uint64_t Node::address()
@@ -723,7 +723,7 @@ uint64_t Node::address()
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
- if ((!_r)||(!RR->initialized))
+ if ((!RR)||(!RR->initialized))
return 0;
return RR->identity.address().toInt();
}
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp
index 0acef7b9..57ecbc65 100644
--- a/node/NodeConfig.cpp
+++ b/node/NodeConfig.cpp
@@ -52,7 +52,7 @@
namespace ZeroTier {
NodeConfig::NodeConfig(const RuntimeEnvironment *renv) :
- _r(renv)
+ RR(renv)
{
{
Mutex::Lock _l(_localConfig_m);
diff --git a/node/Service.cpp b/node/Service.cpp
index d8e4bb2a..09d07b08 100644
--- a/node/Service.cpp
+++ b/node/Service.cpp
@@ -52,7 +52,7 @@
namespace ZeroTier {
Service::Service(const RuntimeEnvironment *renv,const char *name,const char *path,void (*handler)(void *,Service &,const Dictionary &),void *arg) :
- _r(renv),
+ RR(renv),
_path(path),
_name(name),
_arg(arg),
diff --git a/node/SoftwareUpdater.cpp b/node/SoftwareUpdater.cpp
index 1f43a1cd..3826f022 100644
--- a/node/SoftwareUpdater.cpp
+++ b/node/SoftwareUpdater.cpp
@@ -55,7 +55,7 @@
namespace ZeroTier {
SoftwareUpdater::SoftwareUpdater(const RuntimeEnvironment *renv) :
- _r(renv),
+ RR(renv),
_myVersion(packVersion(ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION)),
_lastUpdateAttempt(0),
_status(UPDATE_STATUS_IDLE),
@@ -158,7 +158,7 @@ bool SoftwareUpdater::validateUpdate(
void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body)
{
SoftwareUpdater *upd = (SoftwareUpdater *)arg;
- const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
+ const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->RR;
Mutex::Lock _l(upd->_lock);
if ((upd->_die)||(upd->_status != UPDATE_STATUS_GETTING_NFO)) {
@@ -213,7 +213,7 @@ void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std
void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const std::string &url,const std::string &body)
{
SoftwareUpdater *upd = (SoftwareUpdater *)arg;
- const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
+ const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->RR;
Mutex::Lock _l(upd->_lock);
if (!validateUpdate(body.data(),(unsigned int)body.length(),upd->_signedBy,upd->_signature)) {
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 8439805a..50e31fdc 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -55,7 +55,7 @@
namespace ZeroTier {
Switch::Switch(const RuntimeEnvironment *renv) :
- _r(renv),
+ RR(renv),
_lastBeacon(0)
{
}
@@ -150,7 +150,17 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
TRACE("%s: MULTICAST %s -> %s %s %d",network->tapDeviceName().c_str(),from.toString().c_str(),mg.toString().c_str(),etherTypeName(etherType),(int)data.size());
- network->sendMulticast(mg,from,etherType,data.data(),data.size());
+ RR->mc->send(
+ RR,
+ ((!nconf->isPublic())&&(nconf->com())) ? &(nconf->com()) : (const CertificateOfMembership *)0,
+ network->wantMulticastGroup(mg) ? nconf->multicastLimit() : 0,
+ now,
+ network->id(),
+ mg,
+ from,
+ etherType,
+ data.data(),
+ data.size());
return;
}
@@ -431,8 +441,8 @@ void Switch::doAnythingWaitingForPeer(const SharedPtr<Peer> &peer)
{ // finish processing any packets waiting on peer's public key / identity
Mutex::Lock _l(_rxQueue_m);
- for(std::list< SharedPtr<IncomingPacket> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
- if ((*rxi)->tryDecode(_r))
+ for(std::vector< SharedPtr<IncomingPacket> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
+ if ((*rxi)->tryDecode(RR))
_rxQueue.erase(rxi++);
else ++rxi;
}
@@ -518,7 +528,7 @@ unsigned long Switch::doTimerTasks()
{
Mutex::Lock _l(_rxQueue_m);
- for(std::list< SharedPtr<IncomingPacket> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
+ for(std::vector< SharedPtr<IncomingPacket> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
if ((now - (*i)->receiveTime()) > ZT_RECEIVE_QUEUE_TIMEOUT) {
TRACE("RX %s -> %s timed out",(*i)->source().toString().c_str(),(*i)->destination().toString().c_str());
_rxQueue.erase(i++);
@@ -617,7 +627,7 @@ void Switch::_handleRemotePacketFragment(const SharedPtr<Socket> &fromSock,const
packet->append(dqe->second.frags[f - 1].payload(),dqe->second.frags[f - 1].payloadLength());
_defragQueue.erase(dqe);
- if (!packet->tryDecode(_r)) {
+ if (!packet->tryDecode(RR)) {
Mutex::Lock _l(_rxQueue_m);
_rxQueue.push_back(packet);
}
@@ -684,7 +694,7 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
packet->append(dqe->second.frags[f - 1].payload(),dqe->second.frags[f - 1].payloadLength());
_defragQueue.erase(dqe);
- if (!packet->tryDecode(_r)) {
+ if (!packet->tryDecode(RR)) {
Mutex::Lock _l(_rxQueue_m);
_rxQueue.push_back(packet);
}
@@ -695,7 +705,7 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
} // else this is a duplicate head, ignore
} else {
// Packet is unfragmented, so just process it
- if (!packet->tryDecode(_r)) {
+ if (!packet->tryDecode(RR)) {
Mutex::Lock _l(_rxQueue_m);
_rxQueue.push_back(packet);
}
diff --git a/node/Switch.hpp b/node/Switch.hpp
index 9b3f7cba..6b81b376 100644
--- a/node/Switch.hpp
+++ b/node/Switch.hpp
@@ -216,7 +216,7 @@ private:
const Packet &packet,
bool encrypt);
- const RuntimeEnvironment *const _r;
+ const RuntimeEnvironment *const RR;
volatile uint64_t _lastBeacon;
// Outsanding WHOIS requests and how many retries they've undergone