Browse Source

Rename the ubiquitous _r pointer to RuntimeEnvironment to RR just to be a little more consistent about using _ to denote private member variables.

Adam Ierymenko 11 years ago
parent
commit
81b12b6826

+ 105 - 105
node/IncomingPacket.cpp

@@ -45,28 +45,28 @@
 
 
 namespace ZeroTier {
 namespace ZeroTier {
 
 
-bool IncomingPacket::tryDecode(const RuntimeEnvironment *_r)
+bool IncomingPacket::tryDecode(const RuntimeEnvironment *RR)
 {
 {
 	if ((!encrypted())&&(verb() == Packet::VERB_HELLO)) {
 	if ((!encrypted())&&(verb() == Packet::VERB_HELLO)) {
 		// Unencrypted HELLOs are handled here since they are used to
 		// Unencrypted HELLOs are handled here since they are used to
 		// populate our identity cache in the first place. _doHELLO() is special
 		// populate our identity cache in the first place. _doHELLO() is special
 		// in that it contains its own authentication logic.
 		// in that it contains its own authentication logic.
 		//TRACE("<< HELLO from %s(%s) (normal unencrypted HELLO)",source().toString().c_str(),_remoteAddress.toString().c_str());
 		//TRACE("<< HELLO from %s(%s) (normal unencrypted HELLO)",source().toString().c_str(),_remoteAddress.toString().c_str());
-		return _doHELLO(_r);
+		return _doHELLO(RR);
 	}
 	}
 
 
-	SharedPtr<Peer> peer = _r->topology->getPeer(source());
+	SharedPtr<Peer> peer = RR->topology->getPeer(source());
 	if (peer) {
 	if (peer) {
 		// Resume saved intermediate decode state?
 		// Resume saved intermediate decode state?
 		if (_step == DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP) {
 		if (_step == DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP) {
 			// In this state we have already authenticated and decrypted the
 			// In this state we have already authenticated and decrypted the
 			// packet and are waiting for the lookup of the original sender
 			// packet and are waiting for the lookup of the original sender
 			// for a multicast frame. So check to see if we've got it.
 			// for a multicast frame. So check to see if we've got it.
-			return _doMULTICAST_FRAME(_r,peer);
+			return _doP5_MULTICAST_FRAME(RR,peer);
 		} else if (_step == DECODE_WAITING_FOR_NETWORK_MEMBERSHIP_CERTIFICATE_SIGNER_LOOKUP) {
 		} else if (_step == DECODE_WAITING_FOR_NETWORK_MEMBERSHIP_CERTIFICATE_SIGNER_LOOKUP) {
 			// In this state we have already authenticated and decoded the
 			// In this state we have already authenticated and decoded the
 			// packet and we're waiting for the identity of the cert's signer.
 			// packet and we're waiting for the identity of the cert's signer.
-			return _doNETWORK_MEMBERSHIP_CERTIFICATE(_r,peer);
+			return _doNETWORK_MEMBERSHIP_CERTIFICATE(RR,peer);
 		} // else this is the initial decode pass, so validate packet et. al.
 		} // else this is the initial decode pass, so validate packet et. al.
 
 
 		if (!dearmor(peer->key())) {
 		if (!dearmor(peer->key())) {
@@ -83,41 +83,41 @@ bool IncomingPacket::tryDecode(const RuntimeEnvironment *_r)
 		switch(verb()) {
 		switch(verb()) {
 			//case Packet::VERB_NOP:
 			//case Packet::VERB_NOP:
 			default: // ignore unknown verbs, but if they pass auth check they are still valid
 			default: // ignore unknown verbs, but if they pass auth check they are still valid
-				peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),verb(),0,Packet::VERB_NOP,Utils::now());
+				peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),verb(),0,Packet::VERB_NOP,Utils::now());
 				return true;
 				return true;
 			case Packet::VERB_HELLO:
 			case Packet::VERB_HELLO:
-				return _doHELLO(_r);
+				return _doHELLO(RR);
 			case Packet::VERB_ERROR:
 			case Packet::VERB_ERROR:
-				return _doERROR(_r,peer);
+				return _doERROR(RR,peer);
 			case Packet::VERB_OK:
 			case Packet::VERB_OK:
-				return _doOK(_r,peer);
+				return _doOK(RR,peer);
 			case Packet::VERB_WHOIS:
 			case Packet::VERB_WHOIS:
-				return _doWHOIS(_r,peer);
+				return _doWHOIS(RR,peer);
 			case Packet::VERB_RENDEZVOUS:
 			case Packet::VERB_RENDEZVOUS:
-				return _doRENDEZVOUS(_r,peer);
+				return _doRENDEZVOUS(RR,peer);
 			case Packet::VERB_FRAME:
 			case Packet::VERB_FRAME:
-				return _doFRAME(_r,peer);
+				return _doFRAME(RR,peer);
 			case Packet::VERB_EXT_FRAME:
 			case Packet::VERB_EXT_FRAME:
-				return _doEXT_FRAME(_r,peer);
+				return _doEXT_FRAME(RR,peer);
 			case Packet::VERB_P5_MULTICAST_FRAME:
 			case Packet::VERB_P5_MULTICAST_FRAME:
-				return _doP5_MULTICAST_FRAME(_r,peer);
+				return _doP5_MULTICAST_FRAME(RR,peer);
 			case Packet::VERB_MULTICAST_LIKE:
 			case Packet::VERB_MULTICAST_LIKE:
-				return _doMULTICAST_LIKE(_r,peer);
+				return _doMULTICAST_LIKE(RR,peer);
 			case Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE:
 			case Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE:
-				return _doNETWORK_MEMBERSHIP_CERTIFICATE(_r,peer);
+				return _doNETWORK_MEMBERSHIP_CERTIFICATE(RR,peer);
 			case Packet::VERB_NETWORK_CONFIG_REQUEST:
 			case Packet::VERB_NETWORK_CONFIG_REQUEST:
-				return _doNETWORK_CONFIG_REQUEST(_r,peer);
+				return _doNETWORK_CONFIG_REQUEST(RR,peer);
 			case Packet::VERB_NETWORK_CONFIG_REFRESH:
 			case Packet::VERB_NETWORK_CONFIG_REFRESH:
-				return _doNETWORK_CONFIG_REFRESH(_r,peer);
+				return _doNETWORK_CONFIG_REFRESH(RR,peer);
 		}
 		}
 	} else {
 	} else {
 		_step = DECODE_WAITING_FOR_SENDER_LOOKUP; // should already be this...
 		_step = DECODE_WAITING_FOR_SENDER_LOOKUP; // should already be this...
-		_r->sw->requestWhois(source());
+		RR->sw->requestWhois(source());
 		return false;
 		return false;
 	}
 	}
 }
 }
 
 
-bool IncomingPacket::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doERROR(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_ERROR_IDX_IN_RE_VERB];
 		Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_ERROR_IDX_IN_RE_VERB];
@@ -129,25 +129,25 @@ bool IncomingPacket::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 		switch(errorCode) {
 		switch(errorCode) {
 			case Packet::ERROR_OBJ_NOT_FOUND:
 			case Packet::ERROR_OBJ_NOT_FOUND:
 				if (inReVerb == Packet::VERB_WHOIS) {
 				if (inReVerb == Packet::VERB_WHOIS) {
-					if (_r->topology->isSupernode(source()))
-						_r->sw->cancelWhoisRequest(Address(field(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH));
+					if (RR->topology->isSupernode(source()))
+						RR->sw->cancelWhoisRequest(Address(field(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH));
 				} else if (inReVerb == Packet::VERB_NETWORK_CONFIG_REQUEST) {
 				} else if (inReVerb == Packet::VERB_NETWORK_CONFIG_REQUEST) {
-					SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
+					SharedPtr<Network> network(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
 					if ((network)&&(network->controller() == source()))
 					if ((network)&&(network->controller() == source()))
 						network->setNotFound();
 						network->setNotFound();
 				}
 				}
 				break;
 				break;
 			case Packet::ERROR_IDENTITY_COLLISION:
 			case Packet::ERROR_IDENTITY_COLLISION:
 				// TODO: if it comes from a supernode, regenerate a new identity
 				// TODO: if it comes from a supernode, regenerate a new identity
-				// if (_r->topology->isSupernode(source())) {}
+				// if (RR->topology->isSupernode(source())) {}
 				break;
 				break;
 			case Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE: {
 			case Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE: {
-				SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
+				SharedPtr<Network> network(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
 				if (network)
 				if (network)
 					network->pushMembershipCertificate(source(),true,Utils::now());
 					network->pushMembershipCertificate(source(),true,Utils::now());
 			}	break;
 			}	break;
 			case Packet::ERROR_NETWORK_ACCESS_DENIED_: {
 			case Packet::ERROR_NETWORK_ACCESS_DENIED_: {
-				SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
+				SharedPtr<Network> network(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
 				if ((network)&&(network->controller() == source()))
 				if ((network)&&(network->controller() == source()))
 					network->setAccessDenied();
 					network->setAccessDenied();
 			}	break;
 			}	break;
@@ -155,7 +155,7 @@ bool IncomingPacket::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 				break;
 				break;
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_ERROR,inRePacketId,inReVerb,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_ERROR,inRePacketId,inReVerb,Utils::now());
 	} catch (std::exception &ex) {
 	} catch (std::exception &ex) {
 		TRACE("dropped ERROR from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 		TRACE("dropped ERROR from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -164,7 +164,7 @@ bool IncomingPacket::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
+bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR)
 {
 {
 	try {
 	try {
 		unsigned int protoVersion = (*this)[ZT_PROTO_VERB_HELLO_IDX_PROTOCOL_VERSION];
 		unsigned int protoVersion = (*this)[ZT_PROTO_VERB_HELLO_IDX_PROTOCOL_VERSION];
@@ -184,17 +184,17 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
 		}
 		}
 
 
 		// Do we already have this peer?
 		// Do we already have this peer?
-		SharedPtr<Peer> peer(_r->topology->getPeer(id.address()));
+		SharedPtr<Peer> peer(RR->topology->getPeer(id.address()));
 		if (peer) {
 		if (peer) {
 			// Check to make sure this isn't a colliding identity (different key,
 			// Check to make sure this isn't a colliding identity (different key,
 			// but same address). The odds are spectacularly low but it could happen.
 			// but same address). The odds are spectacularly low but it could happen.
 			// Could also be a sign of someone doing something nasty.
 			// Could also be a sign of someone doing something nasty.
 			if (peer->identity() != id) {
 			if (peer->identity() != id) {
 				unsigned char key[ZT_PEER_SECRET_KEY_LENGTH];
 				unsigned char key[ZT_PEER_SECRET_KEY_LENGTH];
-				if (_r->identity.agree(id,key,ZT_PEER_SECRET_KEY_LENGTH)) {
+				if (RR->identity.agree(id,key,ZT_PEER_SECRET_KEY_LENGTH)) {
 					if (dearmor(key)) { // ensure packet is authentic, otherwise drop
 					if (dearmor(key)) { // ensure packet is authentic, otherwise drop
 						LOG("rejected HELLO from %s(%s): address already claimed",source().toString().c_str(),_remoteAddress.toString().c_str());
 						LOG("rejected HELLO from %s(%s): address already claimed",source().toString().c_str(),_remoteAddress.toString().c_str());
-						Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+						Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 						outp.append((unsigned char)Packet::VERB_HELLO);
 						outp.append((unsigned char)Packet::VERB_HELLO);
 						outp.append(packetId());
 						outp.append(packetId());
 						outp.append((unsigned char)Packet::ERROR_IDENTITY_COLLISION);
 						outp.append((unsigned char)Packet::ERROR_IDENTITY_COLLISION);
@@ -215,13 +215,13 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
 			// If we don't have a peer record on file, check the identity cache (if
 			// If we don't have a peer record on file, check the identity cache (if
 			// we have one) to see if we have a cached identity. Then check that for
 			// we have one) to see if we have a cached identity. Then check that for
 			// collision before adding a new peer.
 			// collision before adding a new peer.
-			Identity alreadyHaveCachedId(_r->topology->getIdentity(id.address()));
+			Identity alreadyHaveCachedId(RR->topology->getIdentity(id.address()));
 			if ((alreadyHaveCachedId)&&(id != alreadyHaveCachedId)) {
 			if ((alreadyHaveCachedId)&&(id != alreadyHaveCachedId)) {
 				unsigned char key[ZT_PEER_SECRET_KEY_LENGTH];
 				unsigned char key[ZT_PEER_SECRET_KEY_LENGTH];
-				if (_r->identity.agree(id,key,ZT_PEER_SECRET_KEY_LENGTH)) {
+				if (RR->identity.agree(id,key,ZT_PEER_SECRET_KEY_LENGTH)) {
 					if (dearmor(key)) { // ensure packet is authentic, otherwise drop
 					if (dearmor(key)) { // ensure packet is authentic, otherwise drop
 						LOG("rejected HELLO from %s(%s): address already claimed",source().toString().c_str(),_remoteAddress.toString().c_str());
 						LOG("rejected HELLO from %s(%s): address already claimed",source().toString().c_str(),_remoteAddress.toString().c_str());
-						Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+						Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 						outp.append((unsigned char)Packet::VERB_HELLO);
 						outp.append((unsigned char)Packet::VERB_HELLO);
 						outp.append(packetId());
 						outp.append(packetId());
 						outp.append((unsigned char)Packet::ERROR_IDENTITY_COLLISION);
 						outp.append((unsigned char)Packet::ERROR_IDENTITY_COLLISION);
@@ -237,23 +237,23 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
 			} // else continue since identity is already known and matches
 			} // else continue since identity is already known and matches
 
 
 			// If this is a new peer, learn it
 			// If this is a new peer, learn it
-			SharedPtr<Peer> newPeer(new Peer(_r->identity,id));
+			SharedPtr<Peer> newPeer(new Peer(RR->identity,id));
 			if (!dearmor(newPeer->key())) {
 			if (!dearmor(newPeer->key())) {
 				LOG("rejected HELLO from %s(%s): packet failed authentication",source().toString().c_str(),_remoteAddress.toString().c_str());
 				LOG("rejected HELLO from %s(%s): packet failed authentication",source().toString().c_str(),_remoteAddress.toString().c_str());
 				return true;
 				return true;
 			}
 			}
-			peer = _r->topology->addPeer(newPeer);
+			peer = RR->topology->addPeer(newPeer);
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_HELLO,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_HELLO,0,Packet::VERB_NOP,Utils::now());
 		peer->setRemoteVersion(vMajor,vMinor,vRevision);
 		peer->setRemoteVersion(vMajor,vMinor,vRevision);
 
 
 		// If a supernode has a version higher than ours, this causes a software
 		// If a supernode has a version higher than ours, this causes a software
 		// update check to run now.
 		// update check to run now.
-		if ((_r->updater)&&(_r->topology->isSupernode(peer->address())))
-			_r->updater->sawRemoteVersion(vMajor,vMinor,vRevision);
+		if ((RR->updater)&&(RR->topology->isSupernode(peer->address())))
+			RR->updater->sawRemoteVersion(vMajor,vMinor,vRevision);
 
 
-		Packet outp(source(),_r->identity.address(),Packet::VERB_OK);
+		Packet outp(source(),RR->identity.address(),Packet::VERB_OK);
 		outp.append((unsigned char)Packet::VERB_HELLO);
 		outp.append((unsigned char)Packet::VERB_HELLO);
 		outp.append(packetId());
 		outp.append(packetId());
 		outp.append(timestamp);
 		outp.append(timestamp);
@@ -271,7 +271,7 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_OK_IDX_IN_RE_VERB];
 		Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_OK_IDX_IN_RE_VERB];
@@ -293,21 +293,21 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &p
 				// update check to run now. This might bum-rush download.zerotier.com, but
 				// update check to run now. This might bum-rush download.zerotier.com, but
 				// it's hosted on S3 so hopefully it can take it. This should cause updates
 				// it's hosted on S3 so hopefully it can take it. This should cause updates
 				// to propagate out very quickly.
 				// to propagate out very quickly.
-				if ((_r->updater)&&(_r->topology->isSupernode(peer->address())))
-					_r->updater->sawRemoteVersion(vMajor,vMinor,vRevision);
+				if ((RR->updater)&&(RR->topology->isSupernode(peer->address())))
+					RR->updater->sawRemoteVersion(vMajor,vMinor,vRevision);
 			}	break;
 			}	break;
 			case Packet::VERB_WHOIS: {
 			case Packet::VERB_WHOIS: {
 				// Right now only supernodes are allowed to send OK(WHOIS) to prevent
 				// Right now only supernodes are allowed to send OK(WHOIS) to prevent
 				// poisoning attacks. Further decentralization will require some other
 				// poisoning attacks. Further decentralization will require some other
 				// kind of trust mechanism.
 				// kind of trust mechanism.
-				if (_r->topology->isSupernode(source())) {
+				if (RR->topology->isSupernode(source())) {
 					Identity id(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY);
 					Identity id(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY);
 					if (id.locallyValidate())
 					if (id.locallyValidate())
-						_r->sw->doAnythingWaitingForPeer(_r->topology->addPeer(SharedPtr<Peer>(new Peer(_r->identity,id))));
+						RR->sw->doAnythingWaitingForPeer(RR->topology->addPeer(SharedPtr<Peer>(new Peer(RR->identity,id))));
 				}
 				}
 			} break;
 			} break;
 			case Packet::VERB_NETWORK_CONFIG_REQUEST: {
 			case Packet::VERB_NETWORK_CONFIG_REQUEST: {
-				SharedPtr<Network> nw(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_NETWORK_ID)));
+				SharedPtr<Network> nw(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_NETWORK_ID)));
 				if ((nw)&&(nw->controller() == source())) {
 				if ((nw)&&(nw->controller() == source())) {
 					// OK(NETWORK_CONFIG_REQUEST) is only accepted from a network's
 					// OK(NETWORK_CONFIG_REQUEST) is only accepted from a network's
 					// controller.
 					// controller.
@@ -323,7 +323,7 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &p
 				break;
 				break;
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_OK,inRePacketId,inReVerb,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_OK,inRePacketId,inReVerb,Utils::now());
 	} catch (std::exception &ex) {
 	} catch (std::exception &ex) {
 		TRACE("dropped OK from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 		TRACE("dropped OK from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -332,13 +332,13 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &p
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		if (payloadLength() == ZT_ADDRESS_LENGTH) {
 		if (payloadLength() == ZT_ADDRESS_LENGTH) {
-			Identity id(_r->topology->getIdentity(Address(payload(),ZT_ADDRESS_LENGTH)));
+			Identity id(RR->topology->getIdentity(Address(payload(),ZT_ADDRESS_LENGTH)));
 			if (id) {
 			if (id) {
-				Packet outp(source(),_r->identity.address(),Packet::VERB_OK);
+				Packet outp(source(),RR->identity.address(),Packet::VERB_OK);
 				outp.append((unsigned char)Packet::VERB_WHOIS);
 				outp.append((unsigned char)Packet::VERB_WHOIS);
 				outp.append(packetId());
 				outp.append(packetId());
 				id.serialize(outp,false);
 				id.serialize(outp,false);
@@ -346,7 +346,7 @@ bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 				_fromSock->send(_remoteAddress,outp.data(),outp.size());
 				_fromSock->send(_remoteAddress,outp.data(),outp.size());
 				//TRACE("sent WHOIS response to %s for %s",source().toString().c_str(),Address(payload(),ZT_ADDRESS_LENGTH).toString().c_str());
 				//TRACE("sent WHOIS response to %s for %s",source().toString().c_str(),Address(payload(),ZT_ADDRESS_LENGTH).toString().c_str());
 			} else {
 			} else {
-				Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+				Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 				outp.append((unsigned char)Packet::VERB_WHOIS);
 				outp.append((unsigned char)Packet::VERB_WHOIS);
 				outp.append(packetId());
 				outp.append(packetId());
 				outp.append((unsigned char)Packet::ERROR_OBJ_NOT_FOUND);
 				outp.append((unsigned char)Packet::ERROR_OBJ_NOT_FOUND);
@@ -359,14 +359,14 @@ bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 			TRACE("dropped WHOIS from %s(%s): missing or invalid address",source().toString().c_str(),_remoteAddress.toString().c_str());
 			TRACE("dropped WHOIS from %s(%s): missing or invalid address",source().toString().c_str(),_remoteAddress.toString().c_str());
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_WHOIS,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_WHOIS,0,Packet::VERB_NOP,Utils::now());
 	} catch ( ... ) {
 	} catch ( ... ) {
 		TRACE("dropped WHOIS from %s(%s): unexpected exception",source().toString().c_str(),_remoteAddress.toString().c_str());
 		TRACE("dropped WHOIS from %s(%s): unexpected exception",source().toString().c_str(),_remoteAddress.toString().c_str());
 	}
 	}
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		/*
 		/*
@@ -382,17 +382,17 @@ bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<
 		 * So if we diversify relays, we'll need some way of deciding whether the
 		 * So if we diversify relays, we'll need some way of deciding whether the
 		 * sender is someone we should trust with a RENDEZVOUS hint.
 		 * sender is someone we should trust with a RENDEZVOUS hint.
 		 */
 		 */
-		if (_r->topology->isSupernode(source())) {
+		if (RR->topology->isSupernode(source())) {
 			Address with(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ZTADDRESS,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH);
 			Address with(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ZTADDRESS,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH);
-			SharedPtr<Peer> withPeer(_r->topology->getPeer(with));
+			SharedPtr<Peer> withPeer(RR->topology->getPeer(with));
 			if (withPeer) {
 			if (withPeer) {
 				unsigned int port = at<uint16_t>(ZT_PROTO_VERB_RENDEZVOUS_IDX_PORT);
 				unsigned int port = at<uint16_t>(ZT_PROTO_VERB_RENDEZVOUS_IDX_PORT);
 				unsigned int addrlen = (*this)[ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRLEN];
 				unsigned int addrlen = (*this)[ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRLEN];
 				if ((port > 0)&&((addrlen == 4)||(addrlen == 16))) {
 				if ((port > 0)&&((addrlen == 4)||(addrlen == 16))) {
 					InetAddress atAddr(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRESS,addrlen),addrlen,port);
 					InetAddress atAddr(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRESS,addrlen),addrlen,port);
 					TRACE("RENDEZVOUS from %s says %s might be at %s, starting NAT-t",source().toString().c_str(),with.toString().c_str(),atAddr.toString().c_str());
 					TRACE("RENDEZVOUS from %s says %s might be at %s, starting NAT-t",source().toString().c_str(),with.toString().c_str(),atAddr.toString().c_str());
-					peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_RENDEZVOUS,0,Packet::VERB_NOP,Utils::now());
-					_r->sw->contact(withPeer,atAddr);
+					peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_RENDEZVOUS,0,Packet::VERB_NOP,Utils::now());
+					RR->sw->contact(withPeer,atAddr);
 				} else {
 				} else {
 					TRACE("dropped corrupt RENDEZVOUS from %s(%s) (bad address or port)",source().toString().c_str(),_remoteAddress.toString().c_str());
 					TRACE("dropped corrupt RENDEZVOUS from %s(%s) (bad address or port)",source().toString().c_str(),_remoteAddress.toString().c_str());
 				}
 				}
@@ -410,15 +410,15 @@ bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doFRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
-		SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_FRAME_IDX_NETWORK_ID)));
+		SharedPtr<Network> network(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_FRAME_IDX_NETWORK_ID)));
 		if (network) {
 		if (network) {
 			if (size() > ZT_PROTO_VERB_FRAME_IDX_PAYLOAD) {
 			if (size() > ZT_PROTO_VERB_FRAME_IDX_PAYLOAD) {
 				if (!network->isAllowed(peer->address())) {
 				if (!network->isAllowed(peer->address())) {
 					TRACE("dropped FRAME from %s(%s): not a member of private network %.16llx",peer->address().toString().c_str(),_remoteAddress.toString().c_str(),(unsigned long long)network->id());
 					TRACE("dropped FRAME from %s(%s): not a member of private network %.16llx",peer->address().toString().c_str(),_remoteAddress.toString().c_str(),(unsigned long long)network->id());
-					_sendErrorNeedCertificate(_r,peer,network->id());
+					_sendErrorNeedCertificate(RR,peer,network->id());
 					return true;
 					return true;
 				}
 				}
 
 
@@ -433,9 +433,9 @@ bool IncomingPacket::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 				/* Source moves "closer" to us in multicast propagation priority when
 				/* Source moves "closer" to us in multicast propagation priority when
 				 * we receive unicast frames from it. This is called "implicit social
 				 * we receive unicast frames from it. This is called "implicit social
 				 * ordering" in other docs. */
 				 * ordering" in other docs. */
-				_r->mc->bringCloser(network->id(),peer->address());
+				RR->mc->bringCloser(network->id(),peer->address());
 
 
-				peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_FRAME,0,Packet::VERB_NOP,Utils::now());
+				peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_FRAME,0,Packet::VERB_NOP,Utils::now());
 				return true;
 				return true;
 			}
 			}
 		} else {
 		} else {
@@ -449,10 +449,10 @@ bool IncomingPacket::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer>
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
-		SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_EXT_FRAME_IDX_NETWORK_ID)));
+		SharedPtr<Network> network(RR->nc->network(at<uint64_t>(ZT_PROTO_VERB_EXT_FRAME_IDX_NETWORK_ID)));
 		if (network) {
 		if (network) {
 			if (size() > ZT_PROTO_VERB_EXT_FRAME_IDX_PAYLOAD) {
 			if (size() > ZT_PROTO_VERB_EXT_FRAME_IDX_PAYLOAD) {
 				if ((*this)[ZT_PROTO_VERB_EXT_FRAME_IDX_FLAGS] != 0) {
 				if ((*this)[ZT_PROTO_VERB_EXT_FRAME_IDX_FLAGS] != 0) {
@@ -462,7 +462,7 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<P
 
 
 				if (!network->isAllowed(peer->address())) {
 				if (!network->isAllowed(peer->address())) {
 					TRACE("dropped EXT_FRAME from %s(%s): not a member of private network %.16llx",peer->address().toString().c_str(),_remoteAddress.toString().c_str(),network->id());
 					TRACE("dropped EXT_FRAME from %s(%s): not a member of private network %.16llx",peer->address().toString().c_str(),_remoteAddress.toString().c_str(),network->id());
-					_sendErrorNeedCertificate(_r,peer,network->id());
+					_sendErrorNeedCertificate(RR,peer,network->id());
 					return true;
 					return true;
 				}
 				}
 
 
@@ -492,7 +492,7 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<P
 
 
 				// If it's not to us, we must be allowed to bridge into this network
 				// If it's not to us, we must be allowed to bridge into this network
 				if (to != network->mac()) {
 				if (to != network->mac()) {
-					if (!network->permitsBridging(_r->identity.address())) {
+					if (!network->permitsBridging(RR->identity.address())) {
 						TRACE("dropped EXT_FRAME from %s@%s(%s) to %s: I cannot bridge to %.16llx or bridging disabled on network",from.toString().c_str(),peer->address().toString().c_str(),_remoteAddress.toString().c_str(),to.toString().c_str(),network->id());
 						TRACE("dropped EXT_FRAME from %s@%s(%s) to %s: I cannot bridge to %.16llx or bridging disabled on network",from.toString().c_str(),peer->address().toString().c_str(),_remoteAddress.toString().c_str(),to.toString().c_str(),network->id());
 						return true;
 						return true;
 					}
 					}
@@ -503,9 +503,9 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<P
 				/* Source moves "closer" to us in multicast propagation priority when
 				/* Source moves "closer" to us in multicast propagation priority when
 				 * we receive unicast frames from it. This is called "implicit social
 				 * we receive unicast frames from it. This is called "implicit social
 				 * ordering" in other docs. */
 				 * ordering" in other docs. */
-				_r->mc->bringCloser(network->id(),peer->address());
+				RR->mc->bringCloser(network->id(),peer->address());
 
 
-				peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_EXT_FRAME,0,Packet::VERB_NOP,Utils::now());
+				peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_EXT_FRAME,0,Packet::VERB_NOP,Utils::now());
 			}
 			}
 		} else {
 		} else {
 			TRACE("dropped EXT_FRAME from %s(%s): we are not connected to network %.16llx",source().toString().c_str(),_remoteAddress.toString().c_str(),at<uint64_t>(ZT_PROTO_VERB_FRAME_IDX_NETWORK_ID));
 			TRACE("dropped EXT_FRAME from %s(%s): we are not connected to network %.16llx",source().toString().c_str(),_remoteAddress.toString().c_str(),at<uint64_t>(ZT_PROTO_VERB_FRAME_IDX_NETWORK_ID));
@@ -518,14 +518,14 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<P
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		Address origin(Address(field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_ORIGIN,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_ORIGIN),ZT_ADDRESS_LENGTH));
 		Address origin(Address(field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_ORIGIN,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_ORIGIN),ZT_ADDRESS_LENGTH));
-		SharedPtr<Peer> originPeer(_r->topology->getPeer(origin));
+		SharedPtr<Peer> originPeer(RR->topology->getPeer(origin));
 		if (!originPeer) {
 		if (!originPeer) {
 			// We must have the origin's identity in order to authenticate a multicast
 			// We must have the origin's identity in order to authenticate a multicast
-			_r->sw->requestWhois(origin);
+			RR->sw->requestWhois(origin);
 			_step = DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP; // causes processing to come back here
 			_step = DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP; // causes processing to come back here
 			return false;
 			return false;
 		}
 		}
@@ -555,7 +555,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 			return true;
 			return true;
 		}
 		}
 
 
-		SharedPtr<Network> network(_r->nc->network(nwid));
+		SharedPtr<Network> network(RR->nc->network(nwid));
 		SharedPtr<NetworkConfig> nconf;
 		SharedPtr<NetworkConfig> nconf;
 		if (network)
 		if (network)
 			nconf = network->config2();
 			nconf = network->config2();
@@ -571,12 +571,12 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 			CertificateOfMembership originCom(*this,ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen + 2 + signatureLen);
 			CertificateOfMembership originCom(*this,ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen + 2 + signatureLen);
 			Address comSignedBy(originCom.signedBy());
 			Address comSignedBy(originCom.signedBy());
 			if ((originCom.networkId() == nwid)&&(comSignedBy == network->controller())) {
 			if ((originCom.networkId() == nwid)&&(comSignedBy == network->controller())) {
-				SharedPtr<Peer> comSigningPeer(_r->topology->getPeer(comSignedBy));
+				SharedPtr<Peer> comSigningPeer(RR->topology->getPeer(comSignedBy));
 				if (!comSigningPeer) {
 				if (!comSigningPeer) {
 					// Technically this should never happen because the COM should be signed by
 					// Technically this should never happen because the COM should be signed by
 					// the master for this network (in current usage) and we ought to already have
 					// the master for this network (in current usage) and we ought to already have
 					// that cached. But handle it anyway.
 					// that cached. But handle it anyway.
-					_r->sw->requestWhois(comSignedBy);
+					RR->sw->requestWhois(comSignedBy);
 					_step = DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP; // causes processing to come back here
 					_step = DECODE_WAITING_FOR_MULTICAST_FRAME_ORIGINAL_SENDER_LOOKUP; // causes processing to come back here
 					return false;
 					return false;
 				} else if (originCom.verify(comSigningPeer->identity())) {
 				} else if (originCom.verify(comSigningPeer->identity())) {
@@ -614,16 +614,16 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 		}
 		}
 
 
 		// At this point the frame is basically valid, so we can call it a receive
 		// At this point the frame is basically valid, so we can call it a receive
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_MULTICAST_FRAME,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_MULTICAST_FRAME,0,Packet::VERB_NOP,Utils::now());
 
 
 		// This gets updated later in most cases but start with the global limit.
 		// This gets updated later in most cases but start with the global limit.
 		unsigned int maxDepth = ZT_MULTICAST_GLOBAL_MAX_DEPTH;
 		unsigned int maxDepth = ZT_MULTICAST_GLOBAL_MAX_DEPTH;
 
 
-		if ((origin == _r->identity.address())||(_r->mc->deduplicate(nwid,guid))) {
+		if ((origin == RR->identity.address())||(RR->mc->deduplicate(nwid,guid))) {
 			// This is a boomerang or a duplicate of a multicast we've already seen. Ordinary
 			// This is a boomerang or a duplicate of a multicast we've already seen. Ordinary
 			// nodes drop these, while supernodes will keep propagating them since they can
 			// nodes drop these, while supernodes will keep propagating them since they can
 			// act as bridges between sparse multicast networks more than once.
 			// act as bridges between sparse multicast networks more than once.
-			if (!_r->topology->amSupernode()) {
+			if (!RR->topology->amSupernode()) {
 				TRACE("dropped MULTICAST_FRAME from %s(%s): duplicate",source().toString().c_str(),_remoteAddress.toString().c_str());
 				TRACE("dropped MULTICAST_FRAME from %s(%s): duplicate",source().toString().c_str(),_remoteAddress.toString().c_str());
 				return true;
 				return true;
 			}
 			}
@@ -640,7 +640,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 
 
 				if (!network->isAllowed(origin)) {
 				if (!network->isAllowed(origin)) {
 					// Papers, please...
 					// Papers, please...
-					Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+					Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 					outp.append((unsigned char)Packet::VERB_MULTICAST_FRAME);
 					outp.append((unsigned char)Packet::VERB_MULTICAST_FRAME);
 					outp.append(packetId());
 					outp.append(packetId());
 					outp.append((unsigned char)Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE);
 					outp.append((unsigned char)Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE);
@@ -720,7 +720,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 			origin,
 			origin,
 			prefixBits,
 			prefixBits,
 			prefix,
 			prefix,
-			_r->topology,
+			RR->topology,
 			Utils::now());
 			Utils::now());
 		if (nconf) {
 		if (nconf) {
 			for(std::set<Address>::const_iterator ab(nconf->activeBridges().begin());ab!=nconf->activeBridges().end();++ab) {
 			for(std::set<Address>::const_iterator ab(nconf->activeBridges().begin());ab!=nconf->activeBridges().end();++ab) {
@@ -728,7 +728,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 					break;
 					break;
 			}
 			}
 		}
 		}
-		_r->mc->getNextHops(nwid,dest,appender);
+		RR->mc->getNextHops(nwid,dest,appender);
 
 
 		// Zero-terminate new FIFO if not completely full. We pad the remainder with
 		// Zero-terminate new FIFO if not completely full. We pad the remainder with
 		// zeroes because this improves data compression ratios.
 		// zeroes because this improves data compression ratios.
@@ -737,12 +737,12 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 
 
 		// First element in newFifo[] is next hop
 		// First element in newFifo[] is next hop
 		Address nextHop(newFifo,ZT_ADDRESS_LENGTH);
 		Address nextHop(newFifo,ZT_ADDRESS_LENGTH);
-		if ((!nextHop)&&(!_r->topology->amSupernode())) {
-			SharedPtr<Peer> supernode(_r->topology->getBestSupernode(&origin,1,true));
+		if ((!nextHop)&&(!RR->topology->amSupernode())) {
+			SharedPtr<Peer> supernode(RR->topology->getBestSupernode(&origin,1,true));
 			if (supernode)
 			if (supernode)
 				nextHop = supernode->address();
 				nextHop = supernode->address();
 		}
 		}
-		if ((!nextHop)||(nextHop == _r->identity.address())) { // check against our addr is a sanity check
+		if ((!nextHop)||(nextHop == RR->identity.address())) { // check against our addr is a sanity check
 			//TRACE("not forwarding MULTICAST_FRAME from %s(%s): no next hop",source().toString().c_str(),_remoteAddress.toString().c_str());
 			//TRACE("not forwarding MULTICAST_FRAME from %s(%s): no next hop",source().toString().c_str(),_remoteAddress.toString().c_str());
 			return true;
 			return true;
 		}
 		}
@@ -753,9 +753,9 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 		// Send to next hop, reusing this packet as scratch space
 		// Send to next hop, reusing this packet as scratch space
 		newInitializationVector();
 		newInitializationVector();
 		setDestination(nextHop);
 		setDestination(nextHop);
-		setSource(_r->identity.address());
+		setSource(RR->identity.address());
 		compress(); // note: bloom filters and empty FIFOs are highly compressable!
 		compress(); // note: bloom filters and empty FIFOs are highly compressable!
-		_r->sw->send(*this,true);
+		RR->sw->send(*this,true);
 
 
 		return true;
 		return true;
 	} catch (std::exception &ex) {
 	} catch (std::exception &ex) {
@@ -767,7 +767,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Share
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		Address src(source());
 		Address src(source());
@@ -776,15 +776,15 @@ bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const Shared
 		// Iterate through 18-byte network,MAC,ADI tuples
 		// Iterate through 18-byte network,MAC,ADI tuples
 		for(unsigned int ptr=ZT_PACKET_IDX_PAYLOAD;ptr<size();ptr+=18) {
 		for(unsigned int ptr=ZT_PACKET_IDX_PAYLOAD;ptr<size();ptr+=18) {
 			uint64_t nwid = at<uint64_t>(ptr);
 			uint64_t nwid = at<uint64_t>(ptr);
-			SharedPtr<Network> network(_r->nc->network(nwid));
-			if ((_r->topology->amSupernode())||((network)&&(network->isAllowed(peer->address())))) {
-				_r->mc->likesGroup(nwid,src,MulticastGroup(MAC(field(ptr + 8,6),6),at<uint32_t>(ptr + 14)),now);
+			SharedPtr<Network> network(RR->nc->network(nwid));
+			if ((RR->topology->amSupernode())||((network)&&(network->isAllowed(peer->address())))) {
+				RR->mc->likesGroup(nwid,src,MulticastGroup(MAC(field(ptr + 8,6),6),at<uint32_t>(ptr + 14)),now);
 				if (network)
 				if (network)
 					network->pushMembershipCertificate(peer->address(),false,now);
 					network->pushMembershipCertificate(peer->address(),false,now);
 			}
 			}
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_MULTICAST_LIKE,0,Packet::VERB_NOP,now);
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_MULTICAST_LIKE,0,Packet::VERB_NOP,now);
 	} catch (std::exception &ex) {
 	} catch (std::exception &ex) {
 		TRACE("dropped MULTICAST_LIKE from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 		TRACE("dropped MULTICAST_LIKE from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -793,7 +793,7 @@ bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const Shared
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		CertificateOfMembership com;
 		CertificateOfMembership com;
@@ -802,25 +802,25 @@ bool IncomingPacket::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment
 		while (ptr < size()) {
 		while (ptr < size()) {
 			ptr += com.deserialize(*this,ptr);
 			ptr += com.deserialize(*this,ptr);
 			if ((com.hasRequiredFields())&&(com.signedBy())) {
 			if ((com.hasRequiredFields())&&(com.signedBy())) {
-				SharedPtr<Peer> signer(_r->topology->getPeer(com.signedBy()));
+				SharedPtr<Peer> signer(RR->topology->getPeer(com.signedBy()));
 				if (signer) {
 				if (signer) {
 					if (com.verify(signer->identity())) {
 					if (com.verify(signer->identity())) {
 						uint64_t nwid = com.networkId();
 						uint64_t nwid = com.networkId();
-						SharedPtr<Network> network(_r->nc->network(nwid));
+						SharedPtr<Network> network(RR->nc->network(nwid));
 						if (network) {
 						if (network) {
 							if (network->controller() == signer)
 							if (network->controller() == signer)
 								network->addMembershipCertificate(com);
 								network->addMembershipCertificate(com);
 						}
 						}
 					}
 					}
 				} else {
 				} else {
-					_r->sw->requestWhois(com.signedBy());
+					RR->sw->requestWhois(com.signedBy());
 					_step = DECODE_WAITING_FOR_NETWORK_MEMBERSHIP_CERTIFICATE_SIGNER_LOOKUP;
 					_step = DECODE_WAITING_FOR_NETWORK_MEMBERSHIP_CERTIFICATE_SIGNER_LOOKUP;
 					return false;
 					return false;
 				}
 				}
 			}
 			}
 		}
 		}
 
 
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE,0,Packet::VERB_NOP,Utils::now());
 	} catch (std::exception &ex) {
 	} catch (std::exception &ex) {
 		TRACE("dropped NETWORK_MEMBERSHIP_CERTIFICATE from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 		TRACE("dropped NETWORK_MEMBERSHIP_CERTIFICATE from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -829,12 +829,12 @@ bool IncomingPacket::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_NETWORK_ID);
 		uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_NETWORK_ID);
 #ifndef __WINDOWS__
 #ifndef __WINDOWS__
-		if (_r->netconfService) {
+		if (RR->netconfService) {
 			char tmp[128];
 			char tmp[128];
 			unsigned int dictLen = at<uint16_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_DICT_LEN);
 			unsigned int dictLen = at<uint16_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_DICT_LEN);
 
 
@@ -850,10 +850,10 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,cons
 			if (!hops())
 			if (!hops())
 				request["from"] = _remoteAddress.toString();
 				request["from"] = _remoteAddress.toString();
 			//TRACE("to netconf:\n%s",request.toString().c_str());
 			//TRACE("to netconf:\n%s",request.toString().c_str());
-			_r->netconfService->send(request);
+			RR->netconfService->send(request);
 		} else {
 		} else {
 #endif // !__WINDOWS__
 #endif // !__WINDOWS__
-			Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+			Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 			outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 			outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 			outp.append(packetId());
 			outp.append(packetId());
 			outp.append((unsigned char)Packet::ERROR_UNSUPPORTED_OPERATION);
 			outp.append((unsigned char)Packet::ERROR_UNSUPPORTED_OPERATION);
@@ -863,7 +863,7 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,cons
 #ifndef __WINDOWS__
 #ifndef __WINDOWS__
 		}
 		}
 #endif // !__WINDOWS__
 #endif // !__WINDOWS__
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP,Utils::now());
 	} catch (std::exception &exc) {
 	} catch (std::exception &exc) {
 		TRACE("dropped NETWORK_CONFIG_REQUEST from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
 		TRACE("dropped NETWORK_CONFIG_REQUEST from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -872,19 +872,19 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,cons
 	return true;
 	return true;
 }
 }
 
 
-bool IncomingPacket::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
+bool IncomingPacket::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
 {
 {
 	try {
 	try {
 		unsigned int ptr = ZT_PACKET_IDX_PAYLOAD;
 		unsigned int ptr = ZT_PACKET_IDX_PAYLOAD;
 		while ((ptr + sizeof(uint64_t)) <= size()) {
 		while ((ptr + sizeof(uint64_t)) <= size()) {
 			uint64_t nwid = at<uint64_t>(ptr); ptr += sizeof(uint64_t);
 			uint64_t nwid = at<uint64_t>(ptr); ptr += sizeof(uint64_t);
-			SharedPtr<Network> nw(_r->nc->network(nwid));
+			SharedPtr<Network> nw(RR->nc->network(nwid));
 			if ((nw)&&(source() == nw->controller())) { // only respond to requests from controller
 			if ((nw)&&(source() == nw->controller())) { // only respond to requests from controller
 				TRACE("NETWORK_CONFIG_REFRESH from %s, refreshing network %.16llx",source().toString().c_str(),nwid);
 				TRACE("NETWORK_CONFIG_REFRESH from %s, refreshing network %.16llx",source().toString().c_str(),nwid);
 				nw->requestConfiguration();
 				nw->requestConfiguration();
 			}
 			}
 		}
 		}
-		peer->receive(_r,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_CONFIG_REFRESH,0,Packet::VERB_NOP,Utils::now());
+		peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_NETWORK_CONFIG_REFRESH,0,Packet::VERB_NOP,Utils::now());
 	} catch (std::exception &exc) {
 	} catch (std::exception &exc) {
 		TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
 		TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -893,9 +893,9 @@ bool IncomingPacket::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,cons
 	return true;
 	return true;
 }
 }
 
 
-void IncomingPacket::_sendErrorNeedCertificate(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer,uint64_t nwid)
+void IncomingPacket::_sendErrorNeedCertificate(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid)
 {
 {
-	Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
+	Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR);
 	outp.append((unsigned char)verb());
 	outp.append((unsigned char)verb());
 	outp.append(packetId());
 	outp.append(packetId());
 	outp.append((unsigned char)Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE);
 	outp.append((unsigned char)Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE);

+ 15 - 15
node/IncomingPacket.hpp

@@ -102,7 +102,7 @@ public:
 	 * @throws std::out_of_range Range error processing packet (should be discarded)
 	 * @throws std::out_of_range Range error processing packet (should be discarded)
 	 * @throws std::runtime_error Other error processing packet (should be discarded)
 	 * @throws std::runtime_error Other error processing packet (should be discarded)
 	 */
 	 */
-	bool tryDecode(const RuntimeEnvironment *_r);
+	bool tryDecode(const RuntimeEnvironment *RR);
 
 
 	/**
 	/**
 	 * @return Time of packet receipt / start of decode
 	 * @return Time of packet receipt / start of decode
@@ -112,20 +112,20 @@ public:
 private:
 private:
 	// These are called internally to handle packet contents once it has
 	// These are called internally to handle packet contents once it has
 	// been authenticated, decrypted, decompressed, and classified.
 	// been authenticated, decrypted, decompressed, and classified.
-	bool _doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doHELLO(const RuntimeEnvironment *_r);
-	bool _doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doP5_MULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-	bool _doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
-
-	void _sendErrorNeedCertificate(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer,uint64_t nwid);
+	bool _doERROR(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doHELLO(const RuntimeEnvironment *RR);
+	bool _doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doWHOIS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doRENDEZVOUS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doFRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doEXT_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doP5_MULTICAST_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doMULTICAST_LIKE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+	bool _doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
+
+	void _sendErrorNeedCertificate(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid);
 
 
 	uint64_t _receiveTime;
 	uint64_t _receiveTime;
 	SharedPtr<Socket> _fromSock;
 	SharedPtr<Socket> _fromSock;

+ 2 - 2
node/Logger.hpp

@@ -37,11 +37,11 @@
 #include "Mutex.hpp"
 #include "Mutex.hpp"
 
 
 #undef LOG
 #undef LOG
-#define LOG(f,...) if (_r->log) _r->log->log(f,##__VA_ARGS__)
+#define LOG(f,...) if (RR->log) RR->log->log(f,##__VA_ARGS__)
 
 
 #undef TRACE
 #undef TRACE
 #ifdef ZT_TRACE
 #ifdef ZT_TRACE
-#define TRACE(f,...) if (_r->log) _r->log->trace(__FILE__,__LINE__,f,##__VA_ARGS__)
+#define TRACE(f,...) if (RR->log) RR->log->trace(__FILE__,__LINE__,f,##__VA_ARGS__)
 #else
 #else
 #define TRACE(f,...) {}
 #define TRACE(f,...) {}
 #endif
 #endif

+ 20 - 20
node/Network.cpp

@@ -73,12 +73,12 @@ Network::~Network()
 	{
 	{
 		Mutex::Lock _l(_lock);
 		Mutex::Lock _l(_lock);
 		if (_tap)
 		if (_tap)
-			_r->tapFactory->close(_tap,_destroyed);
+			RR->tapFactory->close(_tap,_destroyed);
 	}
 	}
 
 
 	if (_destroyed) {
 	if (_destroyed) {
-		Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf"));
-		Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts"));
+		Utils::rm(std::string(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf"));
+		Utils::rm(std::string(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts"));
 	} else {
 	} else {
 		clean();
 		clean();
 		_dumpMulticastCerts();
 		_dumpMulticastCerts();
@@ -149,7 +149,7 @@ bool Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
 
 
 	try {
 	try {
 		SharedPtr<NetworkConfig> newConfig(new NetworkConfig(conf)); // throws if invalid
 		SharedPtr<NetworkConfig> newConfig(new NetworkConfig(conf)); // throws if invalid
-		if ((newConfig->networkId() == _id)&&(newConfig->issuedTo() == _r->identity.address())) {
+		if ((newConfig->networkId() == _id)&&(newConfig->issuedTo() == RR->identity.address())) {
 			std::set<InetAddress> oldStaticIps;
 			std::set<InetAddress> oldStaticIps;
 			if (_config)
 			if (_config)
 				oldStaticIps = _config->staticIps();
 				oldStaticIps = _config->staticIps();
@@ -160,7 +160,7 @@ bool Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
 			_netconfFailure = NETCONF_FAILURE_NONE;
 			_netconfFailure = NETCONF_FAILURE_NONE;
 
 
 			if (saveToDisk) {
 			if (saveToDisk) {
-				std::string confPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf");
+				std::string confPath(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf");
 				if (!Utils::writeFile(confPath.c_str(),conf.toString())) {
 				if (!Utils::writeFile(confPath.c_str(),conf.toString())) {
 					LOG("error: unable to write network configuration file at: %s",confPath.c_str());
 					LOG("error: unable to write network configuration file at: %s",confPath.c_str());
 				} else {
 				} else {
@@ -226,17 +226,17 @@ bool Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
 
 
 void Network::requestConfiguration()
 void Network::requestConfiguration()
 {
 {
-	if (controller() == _r->identity.address()) {
+	if (controller() == RR->identity.address()) {
 		// netconf master cannot be a member of its own nets
 		// netconf master cannot be a member of its own nets
 		LOG("unable to request network configuration for network %.16llx: I am the network master, cannot query self",(unsigned long long)_id);
 		LOG("unable to request network configuration for network %.16llx: I am the network master, cannot query self",(unsigned long long)_id);
 		return;
 		return;
 	}
 	}
 
 
 	TRACE("requesting netconf for network %.16llx from netconf master %s",(unsigned long long)_id,controller().toString().c_str());
 	TRACE("requesting netconf for network %.16llx from netconf master %s",(unsigned long long)_id,controller().toString().c_str());
-	Packet outp(controller(),_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
+	Packet outp(controller(),RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
 	outp.append((uint64_t)_id);
 	outp.append((uint64_t)_id);
 	outp.append((uint16_t)0); // no meta-data
 	outp.append((uint16_t)0); // no meta-data
-	_r->sw->send(outp,true);
+	RR->sw->send(outp,true);
 }
 }
 
 
 void Network::addMembershipCertificate(const CertificateOfMembership &cert)
 void Network::addMembershipCertificate(const CertificateOfMembership &cert)
@@ -318,7 +318,7 @@ void Network::clean()
 		}
 		}
 	}
 	}
 	{
 	{
-		_multicastTopology.clean(now,*(_r->topology),(_config) ? _config->multicastLimit() : (unsigned int)ZT_DEFAULT_MULTICAST_LIMIT);
+		_multicastTopology.clean(now,*(RR->topology),(_config) ? _config->multicastLimit() : (unsigned int)ZT_DEFAULT_MULTICAST_LIMIT);
 	}
 	}
 }
 }
 
 
@@ -343,12 +343,12 @@ void Network::_CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned
 	if ((!((Network *)arg)->_enabled)||(((Network *)arg)->status() != NETWORK_OK))
 	if ((!((Network *)arg)->_enabled)||(((Network *)arg)->status() != NETWORK_OK))
 		return;
 		return;
 
 
-	const RuntimeEnvironment *_r = ((Network *)arg)->_r;
-	if (_r->shutdownInProgress)
+	const RuntimeEnvironment *RR = ((Network *)arg)->_r;
+	if (RR->shutdownInProgress)
 		return;
 		return;
 
 
 	try {
 	try {
-		_r->sw->onLocalEthernet(SharedPtr<Network>((Network *)arg),from,to,etherType,data);
+		RR->sw->onLocalEthernet(SharedPtr<Network>((Network *)arg),from,to,etherType,data);
 	} catch (std::exception &exc) {
 	} catch (std::exception &exc) {
 		TRACE("unexpected exception handling local packet: %s",exc.what());
 		TRACE("unexpected exception handling local packet: %s",exc.what());
 	} catch ( ... ) {
 	} catch ( ... ) {
@@ -369,9 +369,9 @@ void Network::_pushMembershipCertificate(const Address &peer,bool force,uint64_t
 		lastPushed = now;
 		lastPushed = now;
 		TRACE("pushing membership cert for %.16llx to %s",(unsigned long long)_id,peer.toString().c_str());
 		TRACE("pushing membership cert for %.16llx to %s",(unsigned long long)_id,peer.toString().c_str());
 
 
-		Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
+		Packet outp(peer,RR->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
 		_config->com().serialize(outp);
 		_config->com().serialize(outp);
-		_r->sw->send(outp,true);
+		RR->sw->send(outp,true);
 	}
 	}
 }
 }
 
 
@@ -388,7 +388,7 @@ void Network::threadMain()
 		std::string desiredDevice(_nc->getLocalConfig(lcentry));
 		std::string desiredDevice(_nc->getLocalConfig(lcentry));
 		_mkNetworkFriendlyName(fname,sizeof(fname));
 		_mkNetworkFriendlyName(fname,sizeof(fname));
 
 
-		t = _r->tapFactory->open(_mac,ZT_IF_MTU,ZT_DEFAULT_IF_METRIC,_id,(desiredDevice.length() > 0) ? desiredDevice.c_str() : (const char *)0,fname,_CBhandleTapData,this);
+		t = RR->tapFactory->open(_mac,ZT_IF_MTU,ZT_DEFAULT_IF_METRIC,_id,(desiredDevice.length() > 0) ? desiredDevice.c_str() : (const char *)0,fname,_CBhandleTapData,this);
 
 
 		std::string dn(t->deviceName());
 		std::string dn(t->deviceName());
 		if ((dn.length())&&(dn != desiredDevice))
 		if ((dn.length())&&(dn != desiredDevice))
@@ -408,7 +408,7 @@ void Network::threadMain()
 	{
 	{
 		Mutex::Lock _l(_lock);
 		Mutex::Lock _l(_lock);
 		if (_tap) // the tap creation thread can technically be re-launched, though this isn't done right now
 		if (_tap) // the tap creation thread can technically be re-launched, though this isn't done right now
-			_r->tapFactory->close(_tap,false);
+			RR->tapFactory->close(_tap,false);
 		_tap = t;
 		_tap = t;
 		if (t) {
 		if (t) {
 			if (_config) {
 			if (_config) {
@@ -465,7 +465,7 @@ void Network::destroy()
 	_setupThread = Thread();
 	_setupThread = Thread();
 
 
 	if (_tap)
 	if (_tap)
-		_r->tapFactory->close(_tap,true);
+		RR->tapFactory->close(_tap,true);
 	_tap = (EthernetTap *)0;
 	_tap = (EthernetTap *)0;
 }
 }
 
 
@@ -474,8 +474,8 @@ void Network::_restoreState()
 	Buffer<ZT_NETWORK_CERT_WRITE_BUF_SIZE> buf;
 	Buffer<ZT_NETWORK_CERT_WRITE_BUF_SIZE> buf;
 
 
 	std::string idstr(idString());
 	std::string idstr(idString());
-	std::string confPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idstr + ".conf");
-	std::string mcdbPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idstr + ".mcerts");
+	std::string confPath(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idstr + ".conf");
+	std::string mcdbPath(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idstr + ".mcerts");
 
 
 	// Read configuration file containing last config from netconf master
 	// Read configuration file containing last config from netconf master
 	{
 	{
@@ -540,7 +540,7 @@ void Network::_restoreState()
 void Network::_dumpMulticastCerts()
 void Network::_dumpMulticastCerts()
 {
 {
 	Buffer<ZT_NETWORK_CERT_WRITE_BUF_SIZE> buf;
 	Buffer<ZT_NETWORK_CERT_WRITE_BUF_SIZE> buf;
-	std::string mcdbPath(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts");
+	std::string mcdbPath(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".mcerts");
 	Mutex::Lock _l(_lock);
 	Mutex::Lock _l(_lock);
 
 
 	if (!_config)
 	if (!_config)

+ 1 - 1
node/Network.hpp

@@ -446,7 +446,7 @@ private:
 	uint64_t _id;
 	uint64_t _id;
 	NodeConfig *_nc; // parent NodeConfig object
 	NodeConfig *_nc; // parent NodeConfig object
 	MAC _mac; // local MAC address
 	MAC _mac; // local MAC address
-	const RuntimeEnvironment *_r;
+	const RuntimeEnvironment *RR;
 	EthernetTap *volatile _tap; // tap device or NULL if not initialized yet
 	EthernetTap *volatile _tap; // tap device or NULL if not initialized yet
 	volatile bool _enabled;
 	volatile bool _enabled;
 
 

+ 107 - 107
node/Node.cpp

@@ -96,7 +96,7 @@ struct _NodeImpl
 	// This function performs final node tear-down
 	// This function performs final node tear-down
 	inline Node::ReasonForTermination terminate()
 	inline Node::ReasonForTermination terminate()
 	{
 	{
-		RuntimeEnvironment *_r = &renv;
+		RuntimeEnvironment *RR = &renv;
 		LOG("terminating: %s",reasonForTerminationStr.c_str());
 		LOG("terminating: %s",reasonForTerminationStr.c_str());
 
 
 		renv.shutdownInProgress = true;
 		renv.shutdownInProgress = true;
@@ -133,7 +133,7 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
 {
 {
 	if (!renv)
 	if (!renv)
 		return; // sanity check
 		return; // sanity check
-	const RuntimeEnvironment *_r = (const RuntimeEnvironment *)renv;
+	const RuntimeEnvironment *RR = (const RuntimeEnvironment *)renv;
 
 
 	try {
 	try {
 		//TRACE("from netconf:\n%s",msg.toString().c_str());
 		//TRACE("from netconf:\n%s",msg.toString().c_str());
@@ -142,8 +142,8 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
 			LOG("received 'ready' from netconf.service, sending netconf-init with identity information...");
 			LOG("received 'ready' from netconf.service, sending netconf-init with identity information...");
 			Dictionary initMessage;
 			Dictionary initMessage;
 			initMessage["type"] = "netconf-init";
 			initMessage["type"] = "netconf-init";
-			initMessage["netconfId"] = _r->identity.toString(true);
-			_r->netconfService->send(initMessage);
+			initMessage["netconfId"] = RR->identity.toString(true);
+			RR->netconfService->send(initMessage);
 		} else if (type == "netconf-response") {
 		} else if (type == "netconf-response") {
 			uint64_t inRePacketId = strtoull(msg.get("requestId").c_str(),(char **)0,16);
 			uint64_t inRePacketId = strtoull(msg.get("requestId").c_str(),(char **)0,16);
 			uint64_t nwid = strtoull(msg.get("nwid").c_str(),(char **)0,16);
 			uint64_t nwid = strtoull(msg.get("nwid").c_str(),(char **)0,16);
@@ -158,23 +158,23 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
 					else if (err == "ACCESS_DENIED")
 					else if (err == "ACCESS_DENIED")
 						errCode = Packet::ERROR_NETWORK_ACCESS_DENIED_;
 						errCode = Packet::ERROR_NETWORK_ACCESS_DENIED_;
 
 
-					Packet outp(peerAddress,_r->identity.address(),Packet::VERB_ERROR);
+					Packet outp(peerAddress,RR->identity.address(),Packet::VERB_ERROR);
 					outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 					outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 					outp.append(inRePacketId);
 					outp.append(inRePacketId);
 					outp.append((unsigned char)errCode);
 					outp.append((unsigned char)errCode);
 					outp.append(nwid);
 					outp.append(nwid);
-					_r->sw->send(outp,true);
+					RR->sw->send(outp,true);
 				} else if (msg.contains("netconf")) {
 				} else if (msg.contains("netconf")) {
 					const std::string &netconf = msg.get("netconf");
 					const std::string &netconf = msg.get("netconf");
 					if (netconf.length() < 2048) { // sanity check
 					if (netconf.length() < 2048) { // sanity check
-						Packet outp(peerAddress,_r->identity.address(),Packet::VERB_OK);
+						Packet outp(peerAddress,RR->identity.address(),Packet::VERB_OK);
 						outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 						outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
 						outp.append(inRePacketId);
 						outp.append(inRePacketId);
 						outp.append(nwid);
 						outp.append(nwid);
 						outp.append((uint16_t)netconf.length());
 						outp.append((uint16_t)netconf.length());
 						outp.append(netconf.data(),netconf.length());
 						outp.append(netconf.data(),netconf.length());
 						outp.compress();
 						outp.compress();
-						_r->sw->send(outp,true);
+						RR->sw->send(outp,true);
 					}
 					}
 				}
 				}
 			}
 			}
@@ -184,7 +184,7 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
 				for(Dictionary::iterator t(to.begin());t!=to.end();++t) {
 				for(Dictionary::iterator t(to.begin());t!=to.end();++t) {
 					Address ztaddr(t->first);
 					Address ztaddr(t->first);
 					if (ztaddr) {
 					if (ztaddr) {
-						Packet outp(ztaddr,_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
+						Packet outp(ztaddr,RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
 
 
 						char *saveptr = (char *)0;
 						char *saveptr = (char *)0;
 						// Note: this loop trashes t->second, which is quasi-legal C++ but
 						// Note: this loop trashes t->second, which is quasi-legal C++ but
@@ -194,15 +194,15 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
 							uint64_t nwid = Utils::hexStrToU64(p);
 							uint64_t nwid = Utils::hexStrToU64(p);
 							if (nwid) {
 							if (nwid) {
 								if ((outp.size() + sizeof(uint64_t)) >= ZT_UDP_DEFAULT_PAYLOAD_MTU) {
 								if ((outp.size() + sizeof(uint64_t)) >= ZT_UDP_DEFAULT_PAYLOAD_MTU) {
-									_r->sw->send(outp,true);
-									outp.reset(ztaddr,_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
+									RR->sw->send(outp,true);
+									outp.reset(ztaddr,RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
 								}
 								}
 								outp.append(nwid);
 								outp.append(nwid);
 							}
 							}
 						}
 						}
 
 
 						if (outp.payloadLength())
 						if (outp.payloadLength())
-							_r->sw->send(outp,true);
+							RR->sw->send(outp,true);
 					}
 					}
 				}
 				}
 			}
 			}
@@ -268,15 +268,15 @@ Node::~Node()
 
 
 static void _CBztTraffic(const SharedPtr<Socket> &fromSock,void *arg,const InetAddress &from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> &data)
 static void _CBztTraffic(const SharedPtr<Socket> &fromSock,void *arg,const InetAddress &from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> &data)
 {
 {
-	const RuntimeEnvironment *_r = (const RuntimeEnvironment *)arg;
-	if ((_r->sw)&&(!_r->shutdownInProgress))
-		_r->sw->onRemotePacket(fromSock,from,data);
+	const RuntimeEnvironment *RR = (const RuntimeEnvironment *)arg;
+	if ((RR->sw)&&(!RR->shutdownInProgress))
+		RR->sw->onRemotePacket(fromSock,from,data);
 }
 }
 
 
 static void _cbHandleGetRootTopology(void *arg,int code,const std::string &url,const std::string &body)
 static void _cbHandleGetRootTopology(void *arg,int code,const std::string &url,const std::string &body)
 {
 {
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)arg;
-	if (_r->shutdownInProgress)
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)arg;
+	if (RR->shutdownInProgress)
 		return;
 		return;
 
 
 	if ((code != 200)||(body.length() == 0)) {
 	if ((code != 200)||(body.length() == 0)) {
@@ -292,7 +292,7 @@ static void _cbHandleGetRootTopology(void *arg,int code,const std::string &url,c
 		}
 		}
 
 
 		{
 		{
-			std::string rootTopologyPath(_r->homePath + ZT_PATH_SEPARATOR_S + "root-topology");
+			std::string rootTopologyPath(RR->homePath + ZT_PATH_SEPARATOR_S + "root-topology");
 			std::string rootTopology;
 			std::string rootTopology;
 			if (Utils::readFile(rootTopologyPath.c_str(),rootTopology)) {
 			if (Utils::readFile(rootTopologyPath.c_str(),rootTopology)) {
 				Dictionary alreadyHave(rootTopology);
 				Dictionary alreadyHave(rootTopology);
@@ -307,7 +307,7 @@ static void _cbHandleGetRootTopology(void *arg,int code,const std::string &url,c
 			Utils::writeFile(rootTopologyPath.c_str(),body);
 			Utils::writeFile(rootTopologyPath.c_str(),body);
 		}
 		}
 
 
-		_r->topology->setSupernodes(Dictionary(rt.get("supernodes")));
+		RR->topology->setSupernodes(Dictionary(rt.get("supernodes")));
 	} catch ( ... ) {
 	} catch ( ... ) {
 		LOG("discarded invalid root topology update from %s (format invalid)",url.c_str());
 		LOG("discarded invalid root topology update from %s (format invalid)",url.c_str());
 		return;
 		return;
@@ -318,50 +318,50 @@ Node::ReasonForTermination Node::run()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 
 
 	impl->started = true;
 	impl->started = true;
 	impl->running = true;
 	impl->running = true;
 
 
 	try {
 	try {
 #ifdef ZT_LOG_STDOUT
 #ifdef ZT_LOG_STDOUT
-		_r->log = new Logger((const char *)0,(const char *)0,0);
+		RR->log = new Logger((const char *)0,(const char *)0,0);
 #else
 #else
-		_r->log = new Logger((_r->homePath + ZT_PATH_SEPARATOR_S + "node.log").c_str(),(const char *)0,131072);
+		RR->log = new Logger((RR->homePath + ZT_PATH_SEPARATOR_S + "node.log").c_str(),(const char *)0,131072);
 #endif
 #endif
 
 
 		LOG("starting version %s",versionString());
 		LOG("starting version %s",versionString());
 
 
 		// Create non-crypto PRNG right away in case other code in init wants to use it
 		// Create non-crypto PRNG right away in case other code in init wants to use it
-		_r->prng = new CMWC4096();
+		RR->prng = new CMWC4096();
 
 
 		// Read identity public and secret, generating if not present
 		// Read identity public and secret, generating if not present
 		{
 		{
 			bool gotId = false;
 			bool gotId = false;
-			std::string identitySecretPath(_r->homePath + ZT_PATH_SEPARATOR_S + "identity.secret");
-			std::string identityPublicPath(_r->homePath + ZT_PATH_SEPARATOR_S + "identity.public");
+			std::string identitySecretPath(RR->homePath + ZT_PATH_SEPARATOR_S + "identity.secret");
+			std::string identityPublicPath(RR->homePath + ZT_PATH_SEPARATOR_S + "identity.public");
 			std::string idser;
 			std::string idser;
 			if (Utils::readFile(identitySecretPath.c_str(),idser))
 			if (Utils::readFile(identitySecretPath.c_str(),idser))
-				gotId = _r->identity.fromString(idser);
-			if ((gotId)&&(!_r->identity.locallyValidate()))
+				gotId = RR->identity.fromString(idser);
+			if ((gotId)&&(!RR->identity.locallyValidate()))
 				gotId = false;
 				gotId = false;
 			if (gotId) {
 			if (gotId) {
 				// Make sure identity.public matches identity.secret
 				// Make sure identity.public matches identity.secret
 				idser = std::string();
 				idser = std::string();
 				Utils::readFile(identityPublicPath.c_str(),idser);
 				Utils::readFile(identityPublicPath.c_str(),idser);
-				std::string pubid(_r->identity.toString(false));
+				std::string pubid(RR->identity.toString(false));
 				if (idser != pubid) {
 				if (idser != pubid) {
 					if (!Utils::writeFile(identityPublicPath.c_str(),pubid))
 					if (!Utils::writeFile(identityPublicPath.c_str(),pubid))
 						return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.public (home path not writable?)");
 						return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.public (home path not writable?)");
 				}
 				}
 			} else {
 			} else {
 				LOG("no identity found or identity invalid, generating one... this might take a few seconds...");
 				LOG("no identity found or identity invalid, generating one... this might take a few seconds...");
-				_r->identity.generate();
-				LOG("generated new identity: %s",_r->identity.address().toString().c_str());
-				idser = _r->identity.toString(true);
+				RR->identity.generate();
+				LOG("generated new identity: %s",RR->identity.address().toString().c_str());
+				idser = RR->identity.toString(true);
 				if (!Utils::writeFile(identitySecretPath.c_str(),idser))
 				if (!Utils::writeFile(identitySecretPath.c_str(),idser))
 					return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.secret (home path not writable?)");
 					return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.secret (home path not writable?)");
-				idser = _r->identity.toString(false);
+				idser = RR->identity.toString(false);
 				if (!Utils::writeFile(identityPublicPath.c_str(),idser))
 				if (!Utils::writeFile(identityPublicPath.c_str(),idser))
 					return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.public (home path not writable?)");
 					return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write identity.public (home path not writable?)");
 			}
 			}
@@ -370,7 +370,7 @@ Node::ReasonForTermination Node::run()
 
 
 		// Make sure networks.d exists
 		// Make sure networks.d exists
 		{
 		{
-			std::string networksDotD(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d");
+			std::string networksDotD(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d");
 #ifdef __WINDOWS__
 #ifdef __WINDOWS__
 			CreateDirectoryA(networksDotD.c_str(),NULL);
 			CreateDirectoryA(networksDotD.c_str(),NULL);
 #else
 #else
@@ -378,22 +378,22 @@ Node::ReasonForTermination Node::run()
 #endif
 #endif
 		}
 		}
 
 
-		_r->http = new HttpClient();
-		_r->antiRec = new AntiRecursion();
-		_r->sw = new Switch(_r);
-		_r->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,_r);
-		_r->topology = new Topology(_r,Utils::fileExists((_r->homePath + ZT_PATH_SEPARATOR_S + "iddb.d").c_str()));
+		RR->http = new HttpClient();
+		RR->antiRec = new AntiRecursion();
+		RR->sw = new Switch(_r);
+		RR->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,_r);
+		RR->topology = new Topology(RR,Utils::fileExists((RR->homePath + ZT_PATH_SEPARATOR_S + "iddb.d").c_str()));
 		try {
 		try {
-			_r->nc = new NodeConfig(_r);
+			RR->nc = new NodeConfig(_r);
 		} catch (std::exception &exc) {
 		} catch (std::exception &exc) {
 			return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unable to initialize IPC socket: is ZeroTier One already running?");
 			return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unable to initialize IPC socket: is ZeroTier One already running?");
 		}
 		}
-		_r->node = this;
+		RR->node = this;
 
 
 #ifdef ZT_AUTO_UPDATE
 #ifdef ZT_AUTO_UPDATE
 		if (ZT_DEFAULTS.updateLatestNfoURL.length()) {
 		if (ZT_DEFAULTS.updateLatestNfoURL.length()) {
-			_r->updater = new SoftwareUpdater(_r);
-			_r->updater->cleanOldUpdates(); // clean out updates.d on startup
+			RR->updater = new SoftwareUpdater(_r);
+			RR->updater->cleanOldUpdates(); // clean out updates.d on startup
 		} else {
 		} else {
 			LOG("WARNING: unable to enable software updates: latest .nfo URL from ZT_DEFAULTS is empty (does this platform actually support software updates?)");
 			LOG("WARNING: unable to enable software updates: latest .nfo URL from ZT_DEFAULTS is empty (does this platform actually support software updates?)");
 		}
 		}
@@ -401,7 +401,7 @@ Node::ReasonForTermination Node::run()
 
 
 		// Initialize root topology from defaults or root-toplogy file in home path on disk
 		// Initialize root topology from defaults or root-toplogy file in home path on disk
 		{
 		{
-			std::string rootTopologyPath(_r->homePath + ZT_PATH_SEPARATOR_S + "root-topology");
+			std::string rootTopologyPath(RR->homePath + ZT_PATH_SEPARATOR_S + "root-topology");
 			std::string rootTopology;
 			std::string rootTopology;
 			if (!Utils::readFile(rootTopologyPath.c_str(),rootTopology))
 			if (!Utils::readFile(rootTopologyPath.c_str(),rootTopology))
 				rootTopology = ZT_DEFAULTS.defaultRootTopology;
 				rootTopology = ZT_DEFAULTS.defaultRootTopology;
@@ -410,7 +410,7 @@ Node::ReasonForTermination Node::run()
 
 
 				if (Topology::authenticateRootTopology(rt)) {
 				if (Topology::authenticateRootTopology(rt)) {
 					// Set supernodes if root topology signature is valid
 					// Set supernodes if root topology signature is valid
-					_r->topology->setSupernodes(Dictionary(rt.get("supernodes",""))); // set supernodes from root-topology
+					RR->topology->setSupernodes(Dictionary(rt.get("supernodes",""))); // set supernodes from root-topology
 
 
 					// If root-topology contains noupdate=1, disable further updates and only use what was on disk
 					// If root-topology contains noupdate=1, disable further updates and only use what was on disk
 					impl->disableRootTopologyUpdates = (Utils::strToInt(rt.get("noupdate","0").c_str()) > 0);
 					impl->disableRootTopologyUpdates = (Utils::strToInt(rt.get("noupdate","0").c_str()) > 0);
@@ -418,7 +418,7 @@ Node::ReasonForTermination Node::run()
 					// Revert to built-in defaults if root topology fails signature check
 					// Revert to built-in defaults if root topology fails signature check
 					LOG("%s failed signature check, using built-in defaults instead",rootTopologyPath.c_str());
 					LOG("%s failed signature check, using built-in defaults instead",rootTopologyPath.c_str());
 					Utils::rm(rootTopologyPath.c_str());
 					Utils::rm(rootTopologyPath.c_str());
-					_r->topology->setSupernodes(Dictionary(Dictionary(ZT_DEFAULTS.defaultRootTopology).get("supernodes","")));
+					RR->topology->setSupernodes(Dictionary(Dictionary(ZT_DEFAULTS.defaultRootTopology).get("supernodes","")));
 					impl->disableRootTopologyUpdates = false;
 					impl->disableRootTopologyUpdates = false;
 				}
 				}
 			} catch ( ... ) {
 			} catch ( ... ) {
@@ -437,14 +437,14 @@ Node::ReasonForTermination Node::run()
 	// right now and isn't available on Windows.
 	// right now and isn't available on Windows.
 #ifndef __WINDOWS__
 #ifndef __WINDOWS__
 	try {
 	try {
-		std::string netconfServicePath(_r->homePath + ZT_PATH_SEPARATOR_S + "services.d" + ZT_PATH_SEPARATOR_S + "netconf.service");
+		std::string netconfServicePath(RR->homePath + ZT_PATH_SEPARATOR_S + "services.d" + ZT_PATH_SEPARATOR_S + "netconf.service");
 		if (Utils::fileExists(netconfServicePath.c_str())) {
 		if (Utils::fileExists(netconfServicePath.c_str())) {
 			LOG("netconf.d/netconf.service appears to exist, starting...");
 			LOG("netconf.d/netconf.service appears to exist, starting...");
-			_r->netconfService = new Service(_r,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,_r);
+			RR->netconfService = new Service(RR,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,_r);
 			Dictionary initMessage;
 			Dictionary initMessage;
 			initMessage["type"] = "netconf-init";
 			initMessage["type"] = "netconf-init";
-			initMessage["netconfId"] = _r->identity.toString(true);
-			_r->netconfService->send(initMessage);
+			initMessage["netconfId"] = RR->identity.toString(true);
+			RR->netconfService->send(initMessage);
 		}
 		}
 	} catch ( ... ) {
 	} catch ( ... ) {
 		LOG("unexpected exception attempting to start services");
 		LOG("unexpected exception attempting to start services");
@@ -458,7 +458,7 @@ Node::ReasonForTermination Node::run()
 		 * Info.plist file inside the ZeroTier One application. This causes the
 		 * Info.plist file inside the ZeroTier One application. This causes the
 		 * service to die when the user throws away the app, allowing uninstallation
 		 * service to die when the user throws away the app, allowing uninstallation
 		 * in the natural Mac way. */
 		 * in the natural Mac way. */
-		std::string shutdownIfUnreadablePath(_r->homePath + ZT_PATH_SEPARATOR_S + "shutdownIfUnreadable");
+		std::string shutdownIfUnreadablePath(RR->homePath + ZT_PATH_SEPARATOR_S + "shutdownIfUnreadable");
 
 
 		uint64_t lastNetworkAutoconfCheck = Utils::now() - 5000ULL; // check autoconf again after 5s for startup
 		uint64_t lastNetworkAutoconfCheck = Utils::now() - 5000ULL; // check autoconf again after 5s for startup
 		uint64_t lastPingCheck = 0;
 		uint64_t lastPingCheck = 0;
@@ -472,10 +472,10 @@ Node::ReasonForTermination Node::run()
 		long lastDelayDelta = 0;
 		long lastDelayDelta = 0;
 
 
 		uint64_t networkConfigurationFingerprint = 0;
 		uint64_t networkConfigurationFingerprint = 0;
-		_r->timeOfLastResynchronize = Utils::now();
+		RR->timeOfLastResynchronize = Utils::now();
 
 
 		// We are up and running
 		// We are up and running
-		_r->initialized = true;
+		RR->initialized = true;
 
 
 		while (impl->reasonForTermination == NODE_RUNNING) {
 		while (impl->reasonForTermination == NODE_RUNNING) {
 			uint64_t now = Utils::now();
 			uint64_t now = Utils::now();
@@ -507,7 +507,7 @@ Node::ReasonForTermination Node::run()
 			// If our network environment looks like it changed, resynchronize.
 			// If our network environment looks like it changed, resynchronize.
 			if ((resynchronize)||((now - lastNetworkFingerprintCheck) >= ZT_NETWORK_FINGERPRINT_CHECK_DELAY)) {
 			if ((resynchronize)||((now - lastNetworkFingerprintCheck) >= ZT_NETWORK_FINGERPRINT_CHECK_DELAY)) {
 				lastNetworkFingerprintCheck = now;
 				lastNetworkFingerprintCheck = now;
-				uint64_t fp = _r->routingTable->networkEnvironmentFingerprint(_r->nc->networkTapDeviceNames());
+				uint64_t fp = RR->routingTable->networkEnvironmentFingerprint(RR->nc->networkTapDeviceNames());
 				if (fp != networkConfigurationFingerprint) {
 				if (fp != networkConfigurationFingerprint) {
 					LOG("netconf fingerprint change: %.16llx != %.16llx, resyncing with network",networkConfigurationFingerprint,fp);
 					LOG("netconf fingerprint change: %.16llx != %.16llx, resyncing with network",networkConfigurationFingerprint,fp);
 					networkConfigurationFingerprint = fp;
 					networkConfigurationFingerprint = fp;
@@ -516,7 +516,7 @@ Node::ReasonForTermination Node::run()
 			}
 			}
 
 
 			// Supernodes do not resynchronize unless explicitly ordered via SIGHUP.
 			// Supernodes do not resynchronize unless explicitly ordered via SIGHUP.
-			if ((resynchronize)&&(_r->topology->amSupernode()))
+			if ((resynchronize)&&(RR->topology->amSupernode()))
 				resynchronize = false;
 				resynchronize = false;
 
 
 			// Check for SIGHUP / force resync.
 			// Check for SIGHUP / force resync.
@@ -527,8 +527,8 @@ Node::ReasonForTermination Node::run()
 			}
 			}
 
 
 			if (resynchronize) {
 			if (resynchronize) {
-				_r->tcpTunnelingEnabled = false; // turn off TCP tunneling master switch at first, will be reenabled on persistent UDP failure
-				_r->timeOfLastResynchronize = now;
+				RR->tcpTunnelingEnabled = false; // turn off TCP tunneling master switch at first, will be reenabled on persistent UDP failure
+				RR->timeOfLastResynchronize = now;
 			}
 			}
 
 
 			/* Supernodes are pinged separately and more aggressively. The
 			/* Supernodes are pinged separately and more aggressively. The
@@ -539,17 +539,17 @@ Node::ReasonForTermination Node::run()
 				lastSupernodePingCheck = now;
 				lastSupernodePingCheck = now;
 
 
 				uint64_t lastReceiveFromAnySupernode = 0; // function object result paramter
 				uint64_t lastReceiveFromAnySupernode = 0; // function object result paramter
-				_r->topology->eachSupernodePeer(Topology::FindMostRecentDirectReceiveTimestamp(lastReceiveFromAnySupernode));
+				RR->topology->eachSupernodePeer(Topology::FindMostRecentDirectReceiveTimestamp(lastReceiveFromAnySupernode));
 
 
 				// Turn on TCP tunneling master switch if we haven't heard anything since before
 				// Turn on TCP tunneling master switch if we haven't heard anything since before
 				// the last resynchronize and we've been trying long enough.
 				// the last resynchronize and we've been trying long enough.
-				uint64_t tlr = _r->timeOfLastResynchronize;
+				uint64_t tlr = RR->timeOfLastResynchronize;
 				if ((lastReceiveFromAnySupernode < tlr)&&((now - tlr) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT)) {
 				if ((lastReceiveFromAnySupernode < tlr)&&((now - tlr) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT)) {
 					TRACE("network still unreachable after %u ms, TCP TUNNELING ENABLED",(unsigned int)ZT_TCP_TUNNEL_FAILOVER_TIMEOUT);
 					TRACE("network still unreachable after %u ms, TCP TUNNELING ENABLED",(unsigned int)ZT_TCP_TUNNEL_FAILOVER_TIMEOUT);
-					_r->tcpTunnelingEnabled = true;
+					RR->tcpTunnelingEnabled = true;
 				}
 				}
 
 
-				_r->topology->eachSupernodePeer(Topology::PingSupernodesThatNeedPing(_r,now));
+				RR->topology->eachSupernodePeer(Topology::PingSupernodesThatNeedPing(RR,now));
 			}
 			}
 
 
 			if (resynchronize) {
 			if (resynchronize) {
@@ -557,8 +557,8 @@ Node::ReasonForTermination Node::run()
 				 * indirectly to regular nodes (to trigger RENDEZVOUS). Also clear
 				 * indirectly to regular nodes (to trigger RENDEZVOUS). Also clear
 				 * learned paths since they're likely no longer valid, and close
 				 * learned paths since they're likely no longer valid, and close
 				 * TCP sockets since they're also likely invalid. */
 				 * TCP sockets since they're also likely invalid. */
-				_r->sm->closeTcpSockets();
-				_r->topology->eachPeer(Topology::ResetActivePeers(_r,now));
+				RR->sm->closeTcpSockets();
+				RR->topology->eachPeer(Topology::ResetActivePeers(RR,now));
 			} else {
 			} else {
 				/* Periodically check for changes in our local multicast subscriptions
 				/* Periodically check for changes in our local multicast subscriptions
 				 * and broadcast those changes to directly connected peers. */
 				 * and broadcast those changes to directly connected peers. */
@@ -566,13 +566,13 @@ Node::ReasonForTermination Node::run()
 					lastMulticastCheck = now;
 					lastMulticastCheck = now;
 					try {
 					try {
 						std::map< SharedPtr<Network>,std::set<MulticastGroup> > toAnnounce;
 						std::map< SharedPtr<Network>,std::set<MulticastGroup> > toAnnounce;
-						std::vector< SharedPtr<Network> > networks(_r->nc->networks());
+						std::vector< SharedPtr<Network> > networks(RR->nc->networks());
 						for(std::vector< SharedPtr<Network> >::const_iterator nw(networks.begin());nw!=networks.end();++nw) {
 						for(std::vector< SharedPtr<Network> >::const_iterator nw(networks.begin());nw!=networks.end();++nw) {
 							if ((*nw)->updateMulticastGroups())
 							if ((*nw)->updateMulticastGroups())
 								toAnnounce.insert(std::pair< SharedPtr<Network>,std::set<MulticastGroup> >(*nw,(*nw)->multicastGroups()));
 								toAnnounce.insert(std::pair< SharedPtr<Network>,std::set<MulticastGroup> >(*nw,(*nw)->multicastGroups()));
 						}
 						}
 						if (toAnnounce.size())
 						if (toAnnounce.size())
-							_r->sw->announceMulticastGroups(toAnnounce);
+							RR->sw->announceMulticastGroups(toAnnounce);
 					} catch (std::exception &exc) {
 					} catch (std::exception &exc) {
 						LOG("unexpected exception announcing multicast groups: %s",exc.what());
 						LOG("unexpected exception announcing multicast groups: %s",exc.what());
 					} catch ( ... ) {
 					} catch ( ... ) {
@@ -582,10 +582,10 @@ Node::ReasonForTermination Node::run()
 
 
 				/* Periodically ping all our non-stale direct peers unless we're a supernode.
 				/* Periodically ping all our non-stale direct peers unless we're a supernode.
 				 * Supernodes only ping each other (which is done above). */
 				 * Supernodes only ping each other (which is done above). */
-				if ((!_r->topology->amSupernode())&&((now - lastPingCheck) >= ZT_PING_CHECK_DELAY)) {
+				if ((!RR->topology->amSupernode())&&((now - lastPingCheck) >= ZT_PING_CHECK_DELAY)) {
 					lastPingCheck = now;
 					lastPingCheck = now;
 					try {
 					try {
-						_r->topology->eachPeer(Topology::PingPeersThatNeedPing(_r,now));
+						RR->topology->eachPeer(Topology::PingPeersThatNeedPing(RR,now));
 					} catch (std::exception &exc) {
 					} catch (std::exception &exc) {
 						LOG("unexpected exception running ping check cycle: %s",exc.what());
 						LOG("unexpected exception running ping check cycle: %s",exc.what());
 					} catch ( ... ) {
 					} catch ( ... ) {
@@ -597,7 +597,7 @@ Node::ReasonForTermination Node::run()
 			// Update network configurations when needed.
 			// Update network configurations when needed.
 			if ((resynchronize)||((now - lastNetworkAutoconfCheck) >= ZT_NETWORK_AUTOCONF_CHECK_DELAY)) {
 			if ((resynchronize)||((now - lastNetworkAutoconfCheck) >= ZT_NETWORK_AUTOCONF_CHECK_DELAY)) {
 				lastNetworkAutoconfCheck = now;
 				lastNetworkAutoconfCheck = now;
-				std::vector< SharedPtr<Network> > nets(_r->nc->networks());
+				std::vector< SharedPtr<Network> > nets(RR->nc->networks());
 				for(std::vector< SharedPtr<Network> >::iterator n(nets.begin());n!=nets.end();++n) {
 				for(std::vector< SharedPtr<Network> >::iterator n(nets.begin());n!=nets.end();++n) {
 					if ((now - (*n)->lastConfigUpdate()) >= ZT_NETWORK_AUTOCONF_DELAY)
 					if ((now - (*n)->lastConfigUpdate()) >= ZT_NETWORK_AUTOCONF_DELAY)
 						(*n)->requestConfiguration();
 						(*n)->requestConfiguration();
@@ -607,11 +607,11 @@ Node::ReasonForTermination Node::run()
 			// Do periodic tasks in submodules.
 			// Do periodic tasks in submodules.
 			if ((now - lastClean) >= ZT_DB_CLEAN_PERIOD) {
 			if ((now - lastClean) >= ZT_DB_CLEAN_PERIOD) {
 				lastClean = now;
 				lastClean = now;
-				_r->mc->clean();
-				_r->topology->clean();
-				_r->nc->clean();
-				if (_r->updater)
-					_r->updater->checkIfMaxIntervalExceeded(now);
+				RR->mc->clean();
+				RR->topology->clean();
+				RR->nc->clean();
+				if (RR->updater)
+					RR->updater->checkIfMaxIntervalExceeded(now);
 			}
 			}
 
 
 			// Send beacons to physical local LANs
 			// Send beacons to physical local LANs
@@ -619,13 +619,13 @@ Node::ReasonForTermination Node::run()
 				lastBeacon = now;
 				lastBeacon = now;
 				char bcn[ZT_PROTO_BEACON_LENGTH];
 				char bcn[ZT_PROTO_BEACON_LENGTH];
 				void *bcnptr = bcn;
 				void *bcnptr = bcn;
-				*((uint32_t *)(bcnptr)) = _r->prng->next32();
+				*((uint32_t *)(bcnptr)) = RR->prng->next32();
 				bcnptr = bcn + 4;
 				bcnptr = bcn + 4;
-				*((uint32_t *)(bcnptr)) = _r->prng->next32();
-				_r->identity.address().copyTo(bcn + ZT_PROTO_BEACON_IDX_ADDRESS,ZT_ADDRESS_LENGTH);
+				*((uint32_t *)(bcnptr)) = RR->prng->next32();
+				RR->identity.address().copyTo(bcn + ZT_PROTO_BEACON_IDX_ADDRESS,ZT_ADDRESS_LENGTH);
 				TRACE("sending LAN beacon to %s",ZT_DEFAULTS.v4Broadcast.toString().c_str());
 				TRACE("sending LAN beacon to %s",ZT_DEFAULTS.v4Broadcast.toString().c_str());
-				_r->antiRec->logOutgoingZT(bcn,ZT_PROTO_BEACON_LENGTH);
-				_r->sm->send(ZT_DEFAULTS.v4Broadcast,false,false,bcn,ZT_PROTO_BEACON_LENGTH);
+				RR->antiRec->logOutgoingZT(bcn,ZT_PROTO_BEACON_LENGTH);
+				RR->sm->send(ZT_DEFAULTS.v4Broadcast,false,false,bcn,ZT_PROTO_BEACON_LENGTH);
 			}
 			}
 
 
 			// Check for updates to root topology (supernodes) periodically
 			// Check for updates to root topology (supernodes) periodically
@@ -633,15 +633,15 @@ Node::ReasonForTermination Node::run()
 				lastRootTopologyFetch = now;
 				lastRootTopologyFetch = now;
 				if (!impl->disableRootTopologyUpdates) {
 				if (!impl->disableRootTopologyUpdates) {
 					TRACE("fetching root topology from %s",ZT_DEFAULTS.rootTopologyUpdateURL.c_str());
 					TRACE("fetching root topology from %s",ZT_DEFAULTS.rootTopologyUpdateURL.c_str());
-					_r->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,_r);
+					RR->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,_r);
 				}
 				}
 			}
 			}
 
 
 			// Sleep for loop interval or until something interesting happens.
 			// Sleep for loop interval or until something interesting happens.
 			try {
 			try {
-				unsigned long delay = std::min((unsigned long)ZT_MAX_SERVICE_LOOP_INTERVAL,_r->sw->doTimerTasks());
+				unsigned long delay = std::min((unsigned long)ZT_MAX_SERVICE_LOOP_INTERVAL,RR->sw->doTimerTasks());
 				uint64_t start = Utils::now();
 				uint64_t start = Utils::now();
-				_r->sm->poll(delay);
+				RR->sm->poll(delay);
 				lastDelayDelta = (long)(Utils::now() - start) - (long)delay; // used to detect sleep/wake
 				lastDelayDelta = (long)(Utils::now() - start) - (long)delay; // used to detect sleep/wake
 			} catch (std::exception &exc) {
 			} catch (std::exception &exc) {
 				LOG("unexpected exception running Switch doTimerTasks: %s",exc.what());
 				LOG("unexpected exception running Switch doTimerTasks: %s",exc.what());
@@ -686,10 +686,10 @@ bool Node::online()
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	if (!impl->running)
 	if (!impl->running)
 		return false;
 		return false;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
-	uint64_t since = _r->timeOfLastResynchronize;
-	std::vector< SharedPtr<Peer> > snp(_r->topology->supernodePeers());
+	uint64_t since = RR->timeOfLastResynchronize;
+	std::vector< SharedPtr<Peer> > snp(RR->topology->supernodePeers());
 	for(std::vector< SharedPtr<Peer> >::const_iterator sn(snp.begin());sn!=snp.end();++sn) {
 	for(std::vector< SharedPtr<Peer> >::const_iterator sn(snp.begin());sn!=snp.end();++sn) {
 		uint64_t lastRec = (*sn)->lastDirectReceive();
 		uint64_t lastRec = (*sn)->lastDirectReceive();
 		if ((lastRec)&&(lastRec > since)&&((now - lastRec) < ZT_PEER_PATH_ACTIVITY_TIMEOUT))
 		if ((lastRec)&&(lastRec > since)&&((now - lastRec) < ZT_PEER_PATH_ACTIVITY_TIMEOUT))
@@ -716,34 +716,34 @@ bool Node::initialized()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
-	return ((_r)&&(_r->initialized));
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+	return ((_r)&&(RR->initialized));
 }
 }
 
 
 uint64_t Node::address()
 uint64_t Node::address()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
-	if ((!_r)||(!_r->initialized))
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+	if ((!_r)||(!RR->initialized))
 		return 0;
 		return 0;
-	return _r->identity.address().toInt();
+	return RR->identity.address().toInt();
 }
 }
 
 
 void Node::join(uint64_t nwid)
 void Node::join(uint64_t nwid)
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
-	_r->nc->join(nwid);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+	RR->nc->join(nwid);
 }
 }
 
 
 void Node::leave(uint64_t nwid)
 void Node::leave(uint64_t nwid)
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
-	_r->nc->leave(nwid);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+	RR->nc->leave(nwid);
 }
 }
 
 
 struct GatherPeerStatistics
 struct GatherPeerStatistics
@@ -763,22 +763,22 @@ void Node::status(ZT1_Node_Status *status)
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 
 
 	memset(status,0,sizeof(ZT1_Node_Status));
 	memset(status,0,sizeof(ZT1_Node_Status));
 
 
-	Utils::scopy(status->publicIdentity,sizeof(status->publicIdentity),_r->identity.toString(false).c_str());
-	_r->identity.address().toString(status->address,sizeof(status->address));
-	status->rawAddress = _r->identity.address().toInt();
+	Utils::scopy(status->publicIdentity,sizeof(status->publicIdentity),RR->identity.toString(false).c_str());
+	RR->identity.address().toString(status->address,sizeof(status->address));
+	status->rawAddress = RR->identity.address().toInt();
 
 
 	status->knownPeers = 0;
 	status->knownPeers = 0;
-	status->supernodes = _r->topology->numSupernodes();
+	status->supernodes = RR->topology->numSupernodes();
 	status->directlyConnectedPeers = 0;
 	status->directlyConnectedPeers = 0;
 	status->alivePeers = 0;
 	status->alivePeers = 0;
 	GatherPeerStatistics gps;
 	GatherPeerStatistics gps;
 	gps.now = Utils::now();
 	gps.now = Utils::now();
 	gps.status = status;
 	gps.status = status;
-	_r->topology->eachPeer<GatherPeerStatistics &>(gps);
+	RR->topology->eachPeer<GatherPeerStatistics &>(gps);
 
 
 	if (status->alivePeers > 0) {
 	if (status->alivePeers > 0) {
 		double dlsr = (double)status->directlyConnectedPeers / (double)status->alivePeers;
 		double dlsr = (double)status->directlyConnectedPeers / (double)status->alivePeers;
@@ -804,10 +804,10 @@ ZT1_Node_PeerList *Node::listPeers()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 
 
 	CollectPeersAndPaths pp;
 	CollectPeersAndPaths pp;
-	_r->topology->eachPeer<CollectPeersAndPaths &>(pp);
+	RR->topology->eachPeer<CollectPeersAndPaths &>(pp);
 	std::sort(pp.data.begin(),pp.data.end(),SortPeersAndPathsInAscendingAddressOrder());
 	std::sort(pp.data.begin(),pp.data.end(),SortPeersAndPathsInAscendingAddressOrder());
 
 
 	unsigned int returnBufSize = sizeof(ZT1_Node_PeerList);
 	unsigned int returnBufSize = sizeof(ZT1_Node_PeerList);
@@ -889,9 +889,9 @@ ZT1_Node_Network *Node::getNetworkStatus(uint64_t nwid)
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 
 
-	SharedPtr<Network> network(_r->nc->network(nwid));
+	SharedPtr<Network> network(RR->nc->network(nwid));
 	if (!network)
 	if (!network)
 		return (ZT1_Node_Network *)0;
 		return (ZT1_Node_Network *)0;
 	SharedPtr<NetworkConfig> nconf(network->config2());
 	SharedPtr<NetworkConfig> nconf(network->config2());
@@ -929,9 +929,9 @@ ZT1_Node_NetworkList *Node::listNetworks()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
 
 
-	std::vector< SharedPtr<Network> > networks(_r->nc->networks());
+	std::vector< SharedPtr<Network> > networks(RR->nc->networks());
 	std::vector< SharedPtr<NetworkConfig> > nconfs(networks.size());
 	std::vector< SharedPtr<NetworkConfig> > nconfs(networks.size());
 	std::vector< std::set<InetAddress> > ipsv(networks.size());
 	std::vector< std::set<InetAddress> > ipsv(networks.size());
 
 
@@ -990,9 +990,9 @@ bool Node::updateCheck()
 	throw()
 	throw()
 {
 {
 	_NodeImpl *impl = (_NodeImpl *)_impl;
 	_NodeImpl *impl = (_NodeImpl *)_impl;
-	RuntimeEnvironment *_r = (RuntimeEnvironment *)&(impl->renv);
-	if (_r->updater) {
-		_r->updater->checkNow();
+	RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+	if (RR->updater) {
+		RR->updater->checkNow();
 		return true;
 		return true;
 	}
 	}
 	return false;
 	return false;

+ 4 - 4
node/NodeConfig.cpp

@@ -59,7 +59,7 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv) :
 		_readLocalConfig();
 		_readLocalConfig();
 	}
 	}
 
 
-	std::string networksFolder(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d");
+	std::string networksFolder(RR->homePath + ZT_PATH_SEPARATOR_S + "networks.d");
 	std::map<std::string,bool> networksDotD(Utils::listDirectory(networksFolder.c_str()));
 	std::map<std::string,bool> networksDotD(Utils::listDirectory(networksFolder.c_str()));
 	std::vector<uint64_t> configuredNets;
 	std::vector<uint64_t> configuredNets;
 	for(std::map<std::string,bool>::iterator d(networksDotD.begin());d!=networksDotD.end();++d) {
 	for(std::map<std::string,bool>::iterator d(networksDotD.begin());d!=networksDotD.end();++d) {
@@ -75,7 +75,7 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv) :
 
 
 	for(std::vector<uint64_t>::iterator n(configuredNets.begin());n!=configuredNets.end();++n) {
 	for(std::vector<uint64_t>::iterator n(configuredNets.begin());n!=configuredNets.end();++n) {
 		try {
 		try {
-			_networks[*n] = Network::newInstance(_r,this,*n);
+			_networks[*n] = Network::newInstance(RR,this,*n);
 		} catch (std::exception &exc) {
 		} catch (std::exception &exc) {
 			LOG("unable to create network %.16llx: %s",(unsigned long long)*n,exc.what());
 			LOG("unable to create network %.16llx: %s",(unsigned long long)*n,exc.what());
 		} catch ( ... ) {
 		} catch ( ... ) {
@@ -122,7 +122,7 @@ void NodeConfig::clean()
 void NodeConfig::_readLocalConfig()
 void NodeConfig::_readLocalConfig()
 {
 {
 	// assumes _localConfig_m is locked
 	// assumes _localConfig_m is locked
-	std::string localDotConf(_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf");
+	std::string localDotConf(RR->homePath + ZT_PATH_SEPARATOR_S + "local.conf");
 	std::string buf;
 	std::string buf;
 	if (Utils::readFile(localDotConf.c_str(),buf))
 	if (Utils::readFile(localDotConf.c_str(),buf))
 		_localConfig.fromString(buf.c_str());
 		_localConfig.fromString(buf.c_str());
@@ -131,7 +131,7 @@ void NodeConfig::_readLocalConfig()
 void NodeConfig::_writeLocalConfig()
 void NodeConfig::_writeLocalConfig()
 {
 {
 	// assumes _localConfig_m is locked
 	// assumes _localConfig_m is locked
-	Utils::writeFile(((_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf")).c_str(),_localConfig.toString());
+	Utils::writeFile(((RR->homePath + ZT_PATH_SEPARATOR_S + "local.conf")).c_str(),_localConfig.toString());
 }
 }
 
 
 } // namespace ZeroTier
 } // namespace ZeroTier

+ 2 - 2
node/NodeConfig.hpp

@@ -113,7 +113,7 @@ public:
 		SharedPtr<Network> &nw = _networks[nwid];
 		SharedPtr<Network> &nw = _networks[nwid];
 		if (nw)
 		if (nw)
 			return nw;
 			return nw;
-		else return (nw = Network::newInstance(_r,this,nwid));
+		else return (nw = Network::newInstance(RR,this,nwid));
 	}
 	}
 
 
 	/**
 	/**
@@ -166,7 +166,7 @@ public:
 	void _readLocalConfig();
 	void _readLocalConfig();
 	void _writeLocalConfig();
 	void _writeLocalConfig();
 
 
-	const RuntimeEnvironment *_r;
+	const RuntimeEnvironment *RR;
 	Dictionary _localConfig; // persisted as local.conf
 	Dictionary _localConfig; // persisted as local.conf
 	Mutex _localConfig_m;
 	Mutex _localConfig_m;
 	std::map< uint64_t,SharedPtr<Network> > _networks; // persisted in networks.d/
 	std::map< uint64_t,SharedPtr<Network> > _networks; // persisted in networks.d/

+ 11 - 11
node/Peer.cpp

@@ -63,7 +63,7 @@ Peer::Peer(const Identity &myIdentity,const Identity &peerIdentity)
 }
 }
 
 
 void Peer::receive(
 void Peer::receive(
-	const RuntimeEnvironment *_r,
+	const RuntimeEnvironment *RR,
 	const SharedPtr<Socket> &fromSock,
 	const SharedPtr<Socket> &fromSock,
 	const InetAddress &remoteAddr,
 	const InetAddress &remoteAddr,
 	unsigned int hops,
 	unsigned int hops,
@@ -74,7 +74,7 @@ void Peer::receive(
 	uint64_t now)
 	uint64_t now)
 {
 {
 	// Update system-wide last packet receive time
 	// Update system-wide last packet receive time
-	*((const_cast<uint64_t *>(&(_r->timeOfLastPacketReceived)))) = now;
+	*((const_cast<uint64_t *>(&(RR->timeOfLastPacketReceived)))) = now;
 
 
 	// Global last receive time regardless of path
 	// Global last receive time regardless of path
 	_lastReceive = now;
 	_lastReceive = now;
@@ -114,7 +114,7 @@ void Peer::receive(
 		// Lock can't be locked here or it'll recurse and deadlock.
 		// Lock can't be locked here or it'll recurse and deadlock.
 		if ((now - _lastAnnouncedTo) >= ((ZT_MULTICAST_LIKE_EXPIRE / 2) - 1000)) {
 		if ((now - _lastAnnouncedTo) >= ((ZT_MULTICAST_LIKE_EXPIRE / 2) - 1000)) {
 			_lastAnnouncedTo = now;
 			_lastAnnouncedTo = now;
-			_r->sw->announceMulticastGroups(SharedPtr<Peer>(this));
+			RR->sw->announceMulticastGroups(SharedPtr<Peer>(this));
 		}
 		}
 	}
 	}
 
 
@@ -124,7 +124,7 @@ void Peer::receive(
 		_lastMulticastFrame = now;
 		_lastMulticastFrame = now;
 }
 }
 
 
-Path::Type Peer::send(const RuntimeEnvironment *_r,const void *data,unsigned int len,uint64_t now)
+Path::Type Peer::send(const RuntimeEnvironment *RR,const void *data,unsigned int len,uint64_t now)
 {
 {
 	Mutex::Lock _l(_lock);
 	Mutex::Lock _l(_lock);
 
 
@@ -155,8 +155,8 @@ Path::Type Peer::send(const RuntimeEnvironment *_r,const void *data,unsigned int
 	Path *bestPath = (Path *)0;
 	Path *bestPath = (Path *)0;
 	if (bestTcpOutPath) { // we have a TCP out path
 	if (bestTcpOutPath) { // we have a TCP out path
 		if (bestNormalPath) { // we have both paths, decide which to use
 		if (bestNormalPath) { // we have both paths, decide which to use
-			if (_r->tcpTunnelingEnabled) { // TCP tunneling is enabled, so use normal path only if it looks alive
-				if ((bestNormalPathLastReceived > _r->timeOfLastResynchronize)&&((now - bestNormalPathLastReceived) < ZT_PEER_PATH_ACTIVITY_TIMEOUT))
+			if (RR->tcpTunnelingEnabled) { // TCP tunneling is enabled, so use normal path only if it looks alive
+				if ((bestNormalPathLastReceived > RR->timeOfLastResynchronize)&&((now - bestNormalPathLastReceived) < ZT_PEER_PATH_ACTIVITY_TIMEOUT))
 					bestPath = bestNormalPath;
 					bestPath = bestNormalPath;
 				else bestPath = bestTcpOutPath;
 				else bestPath = bestTcpOutPath;
 			} else { // TCP tunneling is disabled, use normal path
 			} else { // TCP tunneling is disabled, use normal path
@@ -171,9 +171,9 @@ Path::Type Peer::send(const RuntimeEnvironment *_r,const void *data,unsigned int
 	if (!bestPath)
 	if (!bestPath)
 		return Path::PATH_TYPE_NULL;
 		return Path::PATH_TYPE_NULL;
 
 
-	_r->antiRec->logOutgoingZT(data,len);
+	RR->antiRec->logOutgoingZT(data,len);
 
 
-	if (_r->sm->send(bestPath->address(),bestPath->tcp(),bestPath->type() == Path::PATH_TYPE_TCP_OUT,data,len)) {
+	if (RR->sm->send(bestPath->address(),bestPath->tcp(),bestPath->type() == Path::PATH_TYPE_TCP_OUT,data,len)) {
 		bestPath->sent(now);
 		bestPath->sent(now);
 		return bestPath->type();
 		return bestPath->type();
 	}
 	}
@@ -181,7 +181,7 @@ Path::Type Peer::send(const RuntimeEnvironment *_r,const void *data,unsigned int
 	return Path::PATH_TYPE_NULL;
 	return Path::PATH_TYPE_NULL;
 }
 }
 
 
-bool Peer::sendPing(const RuntimeEnvironment *_r,uint64_t now)
+bool Peer::sendPing(const RuntimeEnvironment *RR,uint64_t now)
 {
 {
 	bool sent = false;
 	bool sent = false;
 	SharedPtr<Peer> self(this);
 	SharedPtr<Peer> self(this);
@@ -200,14 +200,14 @@ bool Peer::sendPing(const RuntimeEnvironment *_r,uint64_t now)
 			haveNormal = true;
 			haveNormal = true;
 		}
 		}
 	}
 	}
-	const bool useTcpOut = ( (!haveNormal) || ( (_r->tcpTunnelingEnabled) && (lastNormalPingSent > _r->timeOfLastResynchronize) && (lastNormalPingSent > lastNormalReceive) && ((lastNormalPingSent - lastNormalReceive) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) ) );
+	const bool useTcpOut = ( (!haveNormal) || ( (RR->tcpTunnelingEnabled) && (lastNormalPingSent > RR->timeOfLastResynchronize) && (lastNormalPingSent > lastNormalReceive) && ((lastNormalPingSent - lastNormalReceive) >= ZT_TCP_TUNNEL_FAILOVER_TIMEOUT) ) );
 
 
 	TRACE("PING %s (useTcpOut==%d)",_id.address().toString().c_str(),(int)useTcpOut);
 	TRACE("PING %s (useTcpOut==%d)",_id.address().toString().c_str(),(int)useTcpOut);
 
 
 	for(std::vector<Path>::iterator p(_paths.begin());p!=_paths.end();++p) {
 	for(std::vector<Path>::iterator p(_paths.begin());p!=_paths.end();++p) {
 		if ((useTcpOut)||(p->type() != Path::PATH_TYPE_TCP_OUT)) {
 		if ((useTcpOut)||(p->type() != Path::PATH_TYPE_TCP_OUT)) {
 			p->pinged(now); // attempts to ping are logged whether they look successful or not
 			p->pinged(now); // attempts to ping are logged whether they look successful or not
-			if (_r->sw->sendHELLO(self,*p)) {
+			if (RR->sw->sendHELLO(self,*p)) {
 				p->sent(now);
 				p->sent(now);
 				sent = true;
 				sent = true;
 			}
 			}

+ 3 - 3
node/Peer.hpp

@@ -118,7 +118,7 @@ public:
 	 * @param now Current time
 	 * @param now Current time
 	 */
 	 */
 	void receive(
 	void receive(
-		const RuntimeEnvironment *_r,
+		const RuntimeEnvironment *RR,
 		const SharedPtr<Socket> &fromSock,
 		const SharedPtr<Socket> &fromSock,
 		const InetAddress &remoteAddr,
 		const InetAddress &remoteAddr,
 		unsigned int hops,
 		unsigned int hops,
@@ -140,7 +140,7 @@ public:
 	 * @param now Current time
 	 * @param now Current time
 	 * @return Type of path used or Path::PATH_TYPE_NULL on failure
 	 * @return Type of path used or Path::PATH_TYPE_NULL on failure
 	 */
 	 */
-	Path::Type send(const RuntimeEnvironment *_r,const void *data,unsigned int len,uint64_t now);
+	Path::Type send(const RuntimeEnvironment *RR,const void *data,unsigned int len,uint64_t now);
 
 
 	/**
 	/**
 	 * Send HELLO to a peer via all direct paths available
 	 * Send HELLO to a peer via all direct paths available
@@ -152,7 +152,7 @@ public:
 	 * @param now Current time
 	 * @param now Current time
 	 * @return True if send appears successful for at least one address type
 	 * @return True if send appears successful for at least one address type
 	 */
 	 */
-	bool sendPing(const RuntimeEnvironment *_r,uint64_t now);
+	bool sendPing(const RuntimeEnvironment *RR,uint64_t now);
 
 
 	/**
 	/**
 	 * Called periodically by Topology::clean() to remove stale paths and do other cleanup
 	 * Called periodically by Topology::clean() to remove stale paths and do other cleanup

+ 3 - 3
node/Service.cpp

@@ -139,9 +139,9 @@ void Service::threadMain()
 				dup2(in[0],STDIN_FILENO);
 				dup2(in[0],STDIN_FILENO);
 				dup2(out[1],STDOUT_FILENO);
 				dup2(out[1],STDOUT_FILENO);
 				dup2(err[1],STDERR_FILENO);
 				dup2(err[1],STDERR_FILENO);
-				setenv("ZT_HOME",_r->homePath.c_str(),1);
-				chdir(_r->homePath.c_str());
-				execl(_path.c_str(),_path.c_str(),_r->homePath.c_str(),(const char *)0);
+				setenv("ZT_HOME",RR->homePath.c_str(),1);
+				chdir(RR->homePath.c_str());
+				execl(_path.c_str(),_path.c_str(),RR->homePath.c_str(),(const char *)0);
 				exit(-1);
 				exit(-1);
 			}
 			}
 		} else {
 		} else {

+ 1 - 1
node/Service.hpp

@@ -99,7 +99,7 @@ public:
 		throw();
 		throw();
 
 
 private:
 private:
-	const RuntimeEnvironment *_r;
+	const RuntimeEnvironment *RR;
 
 
 	Thread _thread;
 	Thread _thread;
 
 

+ 8 - 8
node/SoftwareUpdater.cpp

@@ -79,7 +79,7 @@ SoftwareUpdater::~SoftwareUpdater()
 
 
 void SoftwareUpdater::cleanOldUpdates()
 void SoftwareUpdater::cleanOldUpdates()
 {
 {
-	std::string updatesDir(_r->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
+	std::string updatesDir(RR->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
 	std::map<std::string,bool> dl(Utils::listDirectory(updatesDir.c_str()));
 	std::map<std::string,bool> dl(Utils::listDirectory(updatesDir.c_str()));
 	for(std::map<std::string,bool>::iterator i(dl.begin());i!=dl.end();++i) {
 	for(std::map<std::string,bool>::iterator i(dl.begin());i!=dl.end();++i) {
 		if (!i->second)
 		if (!i->second)
@@ -97,7 +97,7 @@ void SoftwareUpdater::sawRemoteVersion(unsigned int vmaj,unsigned int vmin,unsig
 			if ((now - _lastUpdateAttempt) >= ZT_UPDATE_MIN_INTERVAL) {
 			if ((now - _lastUpdateAttempt) >= ZT_UPDATE_MIN_INTERVAL) {
 				_lastUpdateAttempt = now;
 				_lastUpdateAttempt = now;
 				_status = UPDATE_STATUS_GETTING_NFO;
 				_status = UPDATE_STATUS_GETTING_NFO;
-				_r->http->GET(ZT_DEFAULTS.updateLatestNfoURL,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionInfo,this);
+				RR->http->GET(ZT_DEFAULTS.updateLatestNfoURL,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionInfo,this);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -109,7 +109,7 @@ void SoftwareUpdater::checkNow()
 	if (_status == UPDATE_STATUS_IDLE) {
 	if (_status == UPDATE_STATUS_IDLE) {
 		_lastUpdateAttempt = Utils::now();
 		_lastUpdateAttempt = Utils::now();
 		_status = UPDATE_STATUS_GETTING_NFO;
 		_status = UPDATE_STATUS_GETTING_NFO;
-		_r->http->GET(ZT_DEFAULTS.updateLatestNfoURL,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionInfo,this);
+		RR->http->GET(ZT_DEFAULTS.updateLatestNfoURL,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionInfo,this);
 	}
 	}
 }
 }
 
 
@@ -158,7 +158,7 @@ bool SoftwareUpdater::validateUpdate(
 void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body)
 void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body)
 {
 {
 	SoftwareUpdater *upd = (SoftwareUpdater *)arg;
 	SoftwareUpdater *upd = (SoftwareUpdater *)arg;
-	const RuntimeEnvironment *_r = (const RuntimeEnvironment *)upd->_r;
+	const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
 	Mutex::Lock _l(upd->_lock);
 	Mutex::Lock _l(upd->_lock);
 
 
 	if ((upd->_die)||(upd->_status != UPDATE_STATUS_GETTING_NFO)) {
 	if ((upd->_die)||(upd->_status != UPDATE_STATUS_GETTING_NFO)) {
@@ -203,7 +203,7 @@ void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std
 		upd->_signedBy = signedBy;
 		upd->_signedBy = signedBy;
 		upd->_signature = signature;
 		upd->_signature = signature;
 
 
-		_r->http->GET(url,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionBinary,arg);
+		RR->http->GET(url,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionBinary,arg);
 	} catch ( ... ) {
 	} catch ( ... ) {
 		LOG("software update check failed: .nfo file invalid or missing field(s)");
 		LOG("software update check failed: .nfo file invalid or missing field(s)");
 		upd->_status = UPDATE_STATUS_IDLE;
 		upd->_status = UPDATE_STATUS_IDLE;
@@ -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)
 void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const std::string &url,const std::string &body)
 {
 {
 	SoftwareUpdater *upd = (SoftwareUpdater *)arg;
 	SoftwareUpdater *upd = (SoftwareUpdater *)arg;
-	const RuntimeEnvironment *_r = (const RuntimeEnvironment *)upd->_r;
+	const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
 	Mutex::Lock _l(upd->_lock);
 	Mutex::Lock _l(upd->_lock);
 
 
 	if (!validateUpdate(body.data(),(unsigned int)body.length(),upd->_signedBy,upd->_signature)) {
 	if (!validateUpdate(body.data(),(unsigned int)body.length(),upd->_signedBy,upd->_signature)) {
@@ -228,7 +228,7 @@ void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const s
 		upd->_status = UPDATE_STATUS_IDLE;
 		upd->_status = UPDATE_STATUS_IDLE;
 		return;
 		return;
 	}
 	}
-	std::string updatesDir(_r->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
+	std::string updatesDir(RR->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
 	std::string updateFilename(url.substr(lastSlash + 1));
 	std::string updateFilename(url.substr(lastSlash + 1));
 	if ((updateFilename.length() < 3)||(updateFilename.find("..") != std::string::npos)) {
 	if ((updateFilename.length() < 3)||(updateFilename.find("..") != std::string::npos)) {
 		LOG("software update failed: invalid URL: filename contains invalid characters");
 		LOG("software update failed: invalid URL: filename contains invalid characters");
@@ -274,7 +274,7 @@ void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const s
 	// caller's responsibility (main.c) to pick this up and do the right
 	// caller's responsibility (main.c) to pick this up and do the right
 	// thing.
 	// thing.
 	upd->_status = UPDATE_STATUS_IDLE;
 	upd->_status = UPDATE_STATUS_IDLE;
-	_r->node->terminate(Node::NODE_RESTART_FOR_UPGRADE,updatePath.c_str());
+	RR->node->terminate(Node::NODE_RESTART_FOR_UPGRADE,updatePath.c_str());
 }
 }
 
 
 } // namespace ZeroTier
 } // namespace ZeroTier

+ 1 - 1
node/SoftwareUpdater.hpp

@@ -147,7 +147,7 @@ private:
 	static void _cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body);
 	static void _cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body);
 	static void _cbHandleGetLatestVersionBinary(void *arg,int code,const std::string &url,const std::string &body);
 	static void _cbHandleGetLatestVersionBinary(void *arg,int code,const std::string &url,const std::string &body);
 
 
-	const RuntimeEnvironment *_r;
+	const RuntimeEnvironment *RR;
 	const uint64_t _myVersion;
 	const uint64_t _myVersion;
 	volatile uint64_t _lastUpdateAttempt;
 	volatile uint64_t _lastUpdateAttempt;
 	volatile enum {
 	volatile enum {

+ 64 - 64
node/Switch.cpp

@@ -96,7 +96,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 	 * Note: even when we introduce a more purposeful binding of the main UDP port, this can
 	 * Note: even when we introduce a more purposeful binding of the main UDP port, this can
 	 * still happen because Windows likes to send broadcasts over interfaces that have little
 	 * still happen because Windows likes to send broadcasts over interfaces that have little
 	 * to do with their intended target audience. :P */
 	 * to do with their intended target audience. :P */
-	if (!_r->antiRec->checkEthernetFrame(data.data(),data.size())) {
+	if (!RR->antiRec->checkEthernetFrame(data.data(),data.size())) {
 		TRACE("%s: rejected recursively addressed ZeroTier packet by tail match (type %s, length: %u)",network->tapDeviceName().c_str(),etherTypeName(etherType),data.size());
 		TRACE("%s: rejected recursively addressed ZeroTier packet by tail match (type %s, length: %u)",network->tapDeviceName().c_str(),etherTypeName(etherType),data.size());
 		return;
 		return;
 	}
 	}
@@ -110,7 +110,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 	// Check if this packet is from someone other than the tap -- i.e. bridged in
 	// Check if this packet is from someone other than the tap -- i.e. bridged in
 	bool fromBridged = false;
 	bool fromBridged = false;
 	if (from != network->mac()) {
 	if (from != network->mac()) {
-		if (!network->permitsBridging(_r->identity.address())) {
+		if (!network->permitsBridging(RR->identity.address())) {
 			LOG("%s: %s -> %s %s not forwarded, bridging disabled on %.16llx or this peer not a bridge",network->tapDeviceName().c_str(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),network->id());
 			LOG("%s: %s -> %s %s not forwarded, bridging disabled on %.16llx or this peer not a bridge",network->tapDeviceName().c_str(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),network->id());
 			return;
 			return;
 		}
 		}
@@ -143,7 +143,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 			network->learnBridgedMulticastGroup(mg,now);
 			network->learnBridgedMulticastGroup(mg,now);
 
 
 		// Check multicast/broadcast bandwidth quotas and reject if quota exceeded
 		// Check multicast/broadcast bandwidth quotas and reject if quota exceeded
-		if (!network->updateAndCheckMulticastBalance(_r->identity.address(),mg,data.size())) {
+		if (!network->updateAndCheckMulticastBalance(RR->identity.address(),mg,data.size())) {
 			TRACE("%s: didn't multicast %d bytes, quota exceeded for multicast group %s",network->tapDeviceName().c_str(),(int)data.size(),mg.toString().c_str());
 			TRACE("%s: didn't multicast %d bytes, quota exceeded for multicast group %s",network->tapDeviceName().c_str(),(int)data.size(),mg.toString().c_str());
 			return;
 			return;
 		}
 		}
@@ -152,12 +152,12 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 
 
 		/* old P5 multicast algorithm
 		/* old P5 multicast algorithm
 		const unsigned int mcid = ++_multicastIdCounter & 0xffffff;
 		const unsigned int mcid = ++_multicastIdCounter & 0xffffff;
-		const uint16_t bloomNonce = (uint16_t)(_r->prng->next32() & 0xffff); // doesn't need to be cryptographically strong
+		const uint16_t bloomNonce = (uint16_t)(RR->prng->next32() & 0xffff); // doesn't need to be cryptographically strong
 		unsigned char bloom[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM];
 		unsigned char bloom[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM];
 		unsigned char fifo[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO + ZT_ADDRESS_LENGTH]; // extra ZT_ADDRESS_LENGTH is for first hop, not put in packet but serves as destination for packet
 		unsigned char fifo[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO + ZT_ADDRESS_LENGTH]; // extra ZT_ADDRESS_LENGTH is for first hop, not put in packet but serves as destination for packet
 		unsigned char *const fifoEnd = fifo + sizeof(fifo);
 		unsigned char *const fifoEnd = fifo + sizeof(fifo);
 		const unsigned int signedPartLen = (ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME - ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION) + data.size();
 		const unsigned int signedPartLen = (ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME - ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION) + data.size();
-		const SharedPtr<Peer> supernode(_r->topology->getBestSupernode());
+		const SharedPtr<Peer> supernode(RR->topology->getBestSupernode());
 
 
 		// For each bit prefix send a packet to a list of destinations within it
 		// For each bit prefix send a packet to a list of destinations within it
 		for(unsigned int prefix=0,np=((unsigned int)2 << (nconf->multicastPrefixBits() - 1));prefix<np;++prefix) {
 		for(unsigned int prefix=0,np=((unsigned int)2 << (nconf->multicastPrefixBits() - 1));prefix<np;++prefix) {
@@ -170,16 +170,16 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 				fifoEnd,
 				fifoEnd,
 				bloom,
 				bloom,
 				bloomNonce,
 				bloomNonce,
-				_r->identity.address(),
+				RR->identity.address(),
 				nconf->multicastPrefixBits(),
 				nconf->multicastPrefixBits(),
 				prefix,
 				prefix,
-				_r->topology,
+				RR->topology,
 				now);
 				now);
 			for(std::set<Address>::const_iterator ab(nconf->activeBridges().begin());ab!=nconf->activeBridges().end();++ab) {
 			for(std::set<Address>::const_iterator ab(nconf->activeBridges().begin());ab!=nconf->activeBridges().end();++ab) {
 				if (!appender(*ab))
 				if (!appender(*ab))
 					break;
 					break;
 			}
 			}
-			_r->mc->getNextHops(network->id(),mg,appender);
+			RR->mc->getNextHops(network->id(),mg,appender);
 
 
 			// Pad remainder of FIFO with zeroes
 			// Pad remainder of FIFO with zeroes
 			while (fifoPtr != fifoEnd)
 			while (fifoPtr != fifoEnd)
@@ -193,7 +193,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 				else continue; // nowhere to go
 				else continue; // nowhere to go
 			}
 			}
 
 
-			Packet outp(firstHop,_r->identity.address(),Packet::VERB_MULTICAST_FRAME);
+			Packet outp(firstHop,RR->identity.address(),Packet::VERB_MULTICAST_FRAME);
 			outp.append((uint16_t)0);
 			outp.append((uint16_t)0);
 			outp.append(fifo + ZT_ADDRESS_LENGTH,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO); // remainder of fifo is loaded into packet
 			outp.append(fifo + ZT_ADDRESS_LENGTH,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO); // remainder of fifo is loaded into packet
 			outp.append(bloom,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM);
 			outp.append(bloom,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM);
@@ -202,7 +202,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 			outp.append(bloomNonce);
 			outp.append(bloomNonce);
 			outp.append((unsigned char)nconf->multicastPrefixBits());
 			outp.append((unsigned char)nconf->multicastPrefixBits());
 			outp.append((unsigned char)prefix);
 			outp.append((unsigned char)prefix);
-			_r->identity.address().appendTo(outp); // lower 40 bits of MCID are my address
+			RR->identity.address().appendTo(outp); // lower 40 bits of MCID are my address
 			outp.append((unsigned char)((mcid >> 16) & 0xff));
 			outp.append((unsigned char)((mcid >> 16) & 0xff));
 			outp.append((unsigned char)((mcid >> 8) & 0xff));
 			outp.append((unsigned char)((mcid >> 8) & 0xff));
 			outp.append((unsigned char)(mcid & 0xff)); // upper 24 bits of MCID are from our counter
 			outp.append((unsigned char)(mcid & 0xff)); // upper 24 bits of MCID are from our counter
@@ -213,7 +213,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 			outp.append((uint16_t)data.size());
 			outp.append((uint16_t)data.size());
 			outp.append(data);
 			outp.append(data);
 
 
-			C25519::Signature sig(_r->identity.sign(outp.field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION,signedPartLen),signedPartLen));
+			C25519::Signature sig(RR->identity.sign(outp.field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION,signedPartLen),signedPartLen));
 			outp.append((uint16_t)sig.size());
 			outp.append((uint16_t)sig.size());
 			outp.append(sig.data,(unsigned int)sig.size());
 			outp.append(sig.data,(unsigned int)sig.size());
 
 
@@ -240,7 +240,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 
 
 			if (fromBridged) {
 			if (fromBridged) {
 				// Must use EXT_FRAME if source is not myself
 				// Must use EXT_FRAME if source is not myself
-				Packet outp(toZT,_r->identity.address(),Packet::VERB_EXT_FRAME);
+				Packet outp(toZT,RR->identity.address(),Packet::VERB_EXT_FRAME);
 				outp.append(network->id());
 				outp.append(network->id());
 				outp.append((unsigned char)0);
 				outp.append((unsigned char)0);
 				to.appendTo(outp);
 				to.appendTo(outp);
@@ -251,7 +251,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 				send(outp,true);
 				send(outp,true);
 			} else {
 			} else {
 				// VERB_FRAME is really just lighter weight EXT_FRAME, can use for direct-to-direct (before bridging this was the only unicast method)
 				// VERB_FRAME is really just lighter weight EXT_FRAME, can use for direct-to-direct (before bridging this was the only unicast method)
-				Packet outp(toZT,_r->identity.address(),Packet::VERB_FRAME);
+				Packet outp(toZT,RR->identity.address(),Packet::VERB_FRAME);
 				outp.append(network->id());
 				outp.append(network->id());
 				outp.append((uint16_t)etherType);
 				outp.append((uint16_t)etherType);
 				outp.append(data);
 				outp.append(data);
@@ -272,7 +272,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 		unsigned int numBridges = 0;
 		unsigned int numBridges = 0;
 
 
 		bridges[0] = network->findBridgeTo(to);
 		bridges[0] = network->findBridgeTo(to);
-		if ((bridges[0])&&(bridges[0] != _r->identity.address())&&(network->isAllowed(bridges[0]))&&(network->permitsBridging(bridges[0]))) {
+		if ((bridges[0])&&(bridges[0] != RR->identity.address())&&(network->isAllowed(bridges[0]))&&(network->permitsBridging(bridges[0]))) {
 			// We have a known bridge route for this MAC.
 			// We have a known bridge route for this MAC.
 			++numBridges;
 			++numBridges;
 		} else if (!nconf->activeBridges().empty()) {
 		} else if (!nconf->activeBridges().empty()) {
@@ -294,7 +294,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 				while (numBridges < ZT_MAX_BRIDGE_SPAM) {
 				while (numBridges < ZT_MAX_BRIDGE_SPAM) {
 					if (ab == nconf->activeBridges().end())
 					if (ab == nconf->activeBridges().end())
 						ab = nconf->activeBridges().begin();
 						ab = nconf->activeBridges().begin();
-					if (((unsigned long)_r->prng->next32() % (unsigned long)nconf->activeBridges().size()) == 0) {
+					if (((unsigned long)RR->prng->next32() % (unsigned long)nconf->activeBridges().size()) == 0) {
 						if (network->isAllowed(*ab)) // config sanity check
 						if (network->isAllowed(*ab)) // config sanity check
 							bridges[numBridges++] = *ab;
 							bridges[numBridges++] = *ab;
 						++ab;
 						++ab;
@@ -304,7 +304,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 		}
 		}
 
 
 		for(unsigned int b=0;b<numBridges;++b) {
 		for(unsigned int b=0;b<numBridges;++b) {
-			Packet outp(bridges[b],_r->identity.address(),Packet::VERB_EXT_FRAME);
+			Packet outp(bridges[b],RR->identity.address(),Packet::VERB_EXT_FRAME);
 			outp.append(network->id());
 			outp.append(network->id());
 			outp.append((unsigned char)0);
 			outp.append((unsigned char)0);
 			to.appendTo(outp);
 			to.appendTo(outp);
@@ -319,7 +319,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
 
 
 void Switch::send(const Packet &packet,bool encrypt)
 void Switch::send(const Packet &packet,bool encrypt)
 {
 {
-	if (packet.destination() == _r->identity.address()) {
+	if (packet.destination() == RR->identity.address()) {
 		TRACE("BUG: caught attempt to send() to self, ignored");
 		TRACE("BUG: caught attempt to send() to self, ignored");
 		return;
 		return;
 	}
 	}
@@ -332,55 +332,55 @@ void Switch::send(const Packet &packet,bool encrypt)
 
 
 void Switch::sendHELLO(const Address &dest)
 void Switch::sendHELLO(const Address &dest)
 {
 {
-	Packet outp(dest,_r->identity.address(),Packet::VERB_HELLO);
+	Packet outp(dest,RR->identity.address(),Packet::VERB_HELLO);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append(Utils::now());
 	outp.append(Utils::now());
-	_r->identity.serialize(outp,false);
+	RR->identity.serialize(outp,false);
 	send(outp,false);
 	send(outp,false);
 }
 }
 
 
 bool Switch::sendHELLO(const SharedPtr<Peer> &dest,const Path &path)
 bool Switch::sendHELLO(const SharedPtr<Peer> &dest,const Path &path)
 {
 {
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
-	Packet outp(dest->address(),_r->identity.address(),Packet::VERB_HELLO);
+	Packet outp(dest->address(),RR->identity.address(),Packet::VERB_HELLO);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append(now);
 	outp.append(now);
-	_r->identity.serialize(outp,false);
+	RR->identity.serialize(outp,false);
 	outp.armor(dest->key(),false);
 	outp.armor(dest->key(),false);
-	_r->antiRec->logOutgoingZT(outp.data(),outp.size());
-	return _r->sm->send(path.address(),path.tcp(),path.type() == Path::PATH_TYPE_TCP_OUT,outp.data(),outp.size());
+	RR->antiRec->logOutgoingZT(outp.data(),outp.size());
+	return RR->sm->send(path.address(),path.tcp(),path.type() == Path::PATH_TYPE_TCP_OUT,outp.data(),outp.size());
 }
 }
 
 
 bool Switch::sendHELLO(const SharedPtr<Peer> &dest,const InetAddress &destUdp)
 bool Switch::sendHELLO(const SharedPtr<Peer> &dest,const InetAddress &destUdp)
 {
 {
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
-	Packet outp(dest->address(),_r->identity.address(),Packet::VERB_HELLO);
+	Packet outp(dest->address(),RR->identity.address(),Packet::VERB_HELLO);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZT_PROTO_VERSION);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
 	outp.append(now);
 	outp.append(now);
-	_r->identity.serialize(outp,false);
+	RR->identity.serialize(outp,false);
 	outp.armor(dest->key(),false);
 	outp.armor(dest->key(),false);
-	_r->antiRec->logOutgoingZT(outp.data(),outp.size());
-	return _r->sm->send(destUdp,false,false,outp.data(),outp.size());
+	RR->antiRec->logOutgoingZT(outp.data(),outp.size());
+	return RR->sm->send(destUdp,false,false,outp.data(),outp.size());
 }
 }
 
 
 bool Switch::unite(const Address &p1,const Address &p2,bool force)
 bool Switch::unite(const Address &p1,const Address &p2,bool force)
 {
 {
-	if ((p1 == _r->identity.address())||(p2 == _r->identity.address()))
+	if ((p1 == RR->identity.address())||(p2 == RR->identity.address()))
 		return false;
 		return false;
 
 
-	SharedPtr<Peer> p1p = _r->topology->getPeer(p1);
+	SharedPtr<Peer> p1p = RR->topology->getPeer(p1);
 	if (!p1p)
 	if (!p1p)
 		return false;
 		return false;
-	SharedPtr<Peer> p2p = _r->topology->getPeer(p2);
+	SharedPtr<Peer> p2p = RR->topology->getPeer(p2);
 	if (!p2p)
 	if (!p2p)
 		return false;
 		return false;
 
 
@@ -420,12 +420,12 @@ bool Switch::unite(const Address &p1,const Address &p2,bool force)
 	 * the order we make each attempted NAT-t favor one or the other going
 	 * the order we make each attempted NAT-t favor one or the other going
 	 * first, meaning if it doesn't succeed the first time it might the second
 	 * first, meaning if it doesn't succeed the first time it might the second
 	 * and so forth. */
 	 * and so forth. */
-	unsigned int alt = _r->prng->next32() & 1;
+	unsigned int alt = RR->prng->next32() & 1;
 	unsigned int completed = alt + 2;
 	unsigned int completed = alt + 2;
 	while (alt != completed) {
 	while (alt != completed) {
 		if ((alt & 1) == 0) {
 		if ((alt & 1) == 0) {
 			// Tell p1 where to find p2.
 			// Tell p1 where to find p2.
-			Packet outp(p1,_r->identity.address(),Packet::VERB_RENDEZVOUS);
+			Packet outp(p1,RR->identity.address(),Packet::VERB_RENDEZVOUS);
 			outp.append((unsigned char)0);
 			outp.append((unsigned char)0);
 			p2.appendTo(outp);
 			p2.appendTo(outp);
 			outp.append((uint16_t)cg.first.port());
 			outp.append((uint16_t)cg.first.port());
@@ -437,10 +437,10 @@ bool Switch::unite(const Address &p1,const Address &p2,bool force)
 				outp.append(cg.first.rawIpData(),4);
 				outp.append(cg.first.rawIpData(),4);
 			}
 			}
 			outp.armor(p1p->key(),true);
 			outp.armor(p1p->key(),true);
-			p1p->send(_r,outp.data(),outp.size(),now);
+			p1p->send(RR,outp.data(),outp.size(),now);
 		} else {
 		} else {
 			// Tell p2 where to find p1.
 			// Tell p2 where to find p1.
-			Packet outp(p2,_r->identity.address(),Packet::VERB_RENDEZVOUS);
+			Packet outp(p2,RR->identity.address(),Packet::VERB_RENDEZVOUS);
 			outp.append((unsigned char)0);
 			outp.append((unsigned char)0);
 			p1.appendTo(outp);
 			p1.appendTo(outp);
 			outp.append((uint16_t)cg.second.port());
 			outp.append((uint16_t)cg.second.port());
@@ -452,7 +452,7 @@ bool Switch::unite(const Address &p1,const Address &p2,bool force)
 				outp.append(cg.second.rawIpData(),4);
 				outp.append(cg.second.rawIpData(),4);
 			}
 			}
 			outp.armor(p2p->key(),true);
 			outp.armor(p2p->key(),true);
-			p2p->send(_r,outp.data(),outp.size(),now);
+			p2p->send(RR,outp.data(),outp.size(),now);
 		}
 		}
 		++alt; // counts up and also flips LSB
 		++alt; // counts up and also flips LSB
 	}
 	}
@@ -474,13 +474,13 @@ void Switch::contact(const SharedPtr<Peer> &peer,const InetAddress &atAddr)
 
 
 	// Kick main loop out of wait so that it can pick up this
 	// Kick main loop out of wait so that it can pick up this
 	// change to our scheduled timer tasks.
 	// change to our scheduled timer tasks.
-	_r->sm->whack();
+	RR->sm->whack();
 }
 }
 
 
 void Switch::announceMulticastGroups(const std::map< SharedPtr<Network>,std::set<MulticastGroup> > &allMemberships)
 void Switch::announceMulticastGroups(const std::map< SharedPtr<Network>,std::set<MulticastGroup> > &allMemberships)
 {
 {
 	std::vector< SharedPtr<Peer> > directPeers;
 	std::vector< SharedPtr<Peer> > directPeers;
-	_r->topology->eachPeer(Topology::CollectPeersWithActiveDirectPath(directPeers,Utils::now()));
+	RR->topology->eachPeer(Topology::CollectPeersWithActiveDirectPath(directPeers,Utils::now()));
 
 
 #ifdef ZT_TRACE
 #ifdef ZT_TRACE
 	unsigned int totalMulticastGroups = 0;
 	unsigned int totalMulticastGroups = 0;
@@ -491,16 +491,16 @@ void Switch::announceMulticastGroups(const std::map< SharedPtr<Network>,std::set
 
 
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
 	for(std::vector< SharedPtr<Peer> >::iterator p(directPeers.begin());p!=directPeers.end();++p) {
 	for(std::vector< SharedPtr<Peer> >::iterator p(directPeers.begin());p!=directPeers.end();++p) {
-		Packet outp((*p)->address(),_r->identity.address(),Packet::VERB_MULTICAST_LIKE);
+		Packet outp((*p)->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE);
 
 
 		for(std::map< SharedPtr<Network>,std::set<MulticastGroup> >::const_iterator nwmgs(allMemberships.begin());nwmgs!=allMemberships.end();++nwmgs) {
 		for(std::map< SharedPtr<Network>,std::set<MulticastGroup> >::const_iterator nwmgs(allMemberships.begin());nwmgs!=allMemberships.end();++nwmgs) {
 			nwmgs->first->pushMembershipCertificate((*p)->address(),false,now);
 			nwmgs->first->pushMembershipCertificate((*p)->address(),false,now);
 
 
-			if ((_r->topology->isSupernode((*p)->address()))||(nwmgs->first->isAllowed((*p)->address()))) {
+			if ((RR->topology->isSupernode((*p)->address()))||(nwmgs->first->isAllowed((*p)->address()))) {
 				for(std::set<MulticastGroup>::iterator mg(nwmgs->second.begin());mg!=nwmgs->second.end();++mg) {
 				for(std::set<MulticastGroup>::iterator mg(nwmgs->second.begin());mg!=nwmgs->second.end();++mg) {
 					if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) {
 					if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) {
 						send(outp,true);
 						send(outp,true);
-						outp.reset((*p)->address(),_r->identity.address(),Packet::VERB_MULTICAST_LIKE);
+						outp.reset((*p)->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE);
 					}
 					}
 
 
 					// network ID, MAC, ADI
 					// network ID, MAC, ADI
@@ -518,18 +518,18 @@ void Switch::announceMulticastGroups(const std::map< SharedPtr<Network>,std::set
 
 
 void Switch::announceMulticastGroups(const SharedPtr<Peer> &peer)
 void Switch::announceMulticastGroups(const SharedPtr<Peer> &peer)
 {
 {
-	Packet outp(peer->address(),_r->identity.address(),Packet::VERB_MULTICAST_LIKE);
-	std::vector< SharedPtr<Network> > networks(_r->nc->networks());
+	Packet outp(peer->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE);
+	std::vector< SharedPtr<Network> > networks(RR->nc->networks());
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
 	for(std::vector< SharedPtr<Network> >::iterator n(networks.begin());n!=networks.end();++n) {
 	for(std::vector< SharedPtr<Network> >::iterator n(networks.begin());n!=networks.end();++n) {
-		if (((*n)->isAllowed(peer->address()))||(_r->topology->isSupernode(peer->address()))) {
+		if (((*n)->isAllowed(peer->address()))||(RR->topology->isSupernode(peer->address()))) {
 			(*n)->pushMembershipCertificate(peer->address(),false,now);
 			(*n)->pushMembershipCertificate(peer->address(),false,now);
 
 
 			std::set<MulticastGroup> mgs((*n)->multicastGroups());
 			std::set<MulticastGroup> mgs((*n)->multicastGroups());
 			for(std::set<MulticastGroup>::iterator mg(mgs.begin());mg!=mgs.end();++mg) {
 			for(std::set<MulticastGroup>::iterator mg(mgs.begin());mg!=mgs.end();++mg) {
 				if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) {
 				if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) {
 					send(outp,true);
 					send(outp,true);
-					outp.reset(peer->address(),_r->identity.address(),Packet::VERB_MULTICAST_LIKE);
+					outp.reset(peer->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE);
 				}
 				}
 
 
 				// network ID, MAC, ADI
 				// network ID, MAC, ADI
@@ -702,19 +702,19 @@ void Switch::_handleRemotePacketFragment(const SharedPtr<Socket> &fromSock,const
 	Packet::Fragment fragment(data);
 	Packet::Fragment fragment(data);
 	Address destination(fragment.destination());
 	Address destination(fragment.destination());
 
 
-	if (destination != _r->identity.address()) {
+	if (destination != RR->identity.address()) {
 		// Fragment is not for us, so try to relay it
 		// Fragment is not for us, so try to relay it
 		if (fragment.hops() < ZT_RELAY_MAX_HOPS) {
 		if (fragment.hops() < ZT_RELAY_MAX_HOPS) {
 			fragment.incrementHops();
 			fragment.incrementHops();
 
 
 			// Note: we don't bother initiating NAT-t for fragments, since heads will set that off.
 			// Note: we don't bother initiating NAT-t for fragments, since heads will set that off.
 			// It wouldn't hurt anything, just redundant and unnecessary.
 			// It wouldn't hurt anything, just redundant and unnecessary.
-			SharedPtr<Peer> relayTo = _r->topology->getPeer(destination);
-			if ((!relayTo)||(relayTo->send(_r,fragment.data(),fragment.size(),Utils::now()) == Path::PATH_TYPE_NULL)) {
+			SharedPtr<Peer> relayTo = RR->topology->getPeer(destination);
+			if ((!relayTo)||(relayTo->send(RR,fragment.data(),fragment.size(),Utils::now()) == Path::PATH_TYPE_NULL)) {
 				// Don't know peer or no direct path -- so relay via supernode
 				// Don't know peer or no direct path -- so relay via supernode
-				relayTo = _r->topology->getBestSupernode();
+				relayTo = RR->topology->getBestSupernode();
 				if (relayTo)
 				if (relayTo)
-					relayTo->send(_r,fragment.data(),fragment.size(),Utils::now());
+					relayTo->send(RR,fragment.data(),fragment.size(),Utils::now());
 			}
 			}
 		} else {
 		} else {
 			TRACE("dropped relay [fragment](%s) -> %s, max hops exceeded",fromAddr.toString().c_str(),destination.toString().c_str());
 			TRACE("dropped relay [fragment](%s) -> %s, max hops exceeded",fromAddr.toString().c_str(),destination.toString().c_str());
@@ -778,14 +778,14 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
 
 
 	//TRACE("<< %.16llx %s -> %s (size: %u)",(unsigned long long)packet->packetId(),source.toString().c_str(),destination.toString().c_str(),packet->size());
 	//TRACE("<< %.16llx %s -> %s (size: %u)",(unsigned long long)packet->packetId(),source.toString().c_str(),destination.toString().c_str(),packet->size());
 
 
-	if (destination != _r->identity.address()) {
+	if (destination != RR->identity.address()) {
 		// Packet is not for us, so try to relay it
 		// Packet is not for us, so try to relay it
 		if (packet->hops() < ZT_RELAY_MAX_HOPS) {
 		if (packet->hops() < ZT_RELAY_MAX_HOPS) {
 			packet->incrementHops();
 			packet->incrementHops();
 
 
-			SharedPtr<Peer> relayTo = _r->topology->getPeer(destination);
+			SharedPtr<Peer> relayTo = RR->topology->getPeer(destination);
 			Path::Type relayedVia;
 			Path::Type relayedVia;
-			if ((relayTo)&&((relayedVia = relayTo->send(_r,packet->data(),packet->size(),Utils::now())) != Path::PATH_TYPE_NULL)) {
+			if ((relayTo)&&((relayedVia = relayTo->send(RR,packet->data(),packet->size(),Utils::now())) != Path::PATH_TYPE_NULL)) {
 				/* If both paths are UDP, attempt to invoke UDP NAT-t between peers
 				/* If both paths are UDP, attempt to invoke UDP NAT-t between peers
 				 * by sending VERB_RENDEZVOUS. Do not do this for TCP due to GitHub
 				 * by sending VERB_RENDEZVOUS. Do not do this for TCP due to GitHub
 				 * issue #63. */
 				 * issue #63. */
@@ -793,9 +793,9 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
 					unite(source,destination,false);
 					unite(source,destination,false);
 			} else {
 			} else {
 				// Don't know peer or no direct path -- so relay via supernode
 				// Don't know peer or no direct path -- so relay via supernode
-				relayTo = _r->topology->getBestSupernode(&source,1,true);
+				relayTo = RR->topology->getBestSupernode(&source,1,true);
 				if (relayTo)
 				if (relayTo)
-					relayTo->send(_r,packet->data(),packet->size(),Utils::now());
+					relayTo->send(RR,packet->data(),packet->size(),Utils::now());
 			}
 			}
 		} else {
 		} else {
 			TRACE("dropped relay %s(%s) -> %s, max hops exceeded",packet->source().toString().c_str(),fromAddr.toString().c_str(),destination.toString().c_str());
 			TRACE("dropped relay %s(%s) -> %s, max hops exceeded",packet->source().toString().c_str(),fromAddr.toString().c_str(),destination.toString().c_str());
@@ -847,14 +847,14 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
 void Switch::_handleBeacon(const SharedPtr<Socket> &fromSock,const InetAddress &fromAddr,const Buffer<4096> &data)
 void Switch::_handleBeacon(const SharedPtr<Socket> &fromSock,const InetAddress &fromAddr,const Buffer<4096> &data)
 {
 {
 	Address beaconAddr(data.field(ZT_PROTO_BEACON_IDX_ADDRESS,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH);
 	Address beaconAddr(data.field(ZT_PROTO_BEACON_IDX_ADDRESS,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH);
-	if (beaconAddr == _r->identity.address())
+	if (beaconAddr == RR->identity.address())
 		return;
 		return;
-	SharedPtr<Peer> peer(_r->topology->getPeer(beaconAddr));
+	SharedPtr<Peer> peer(RR->topology->getPeer(beaconAddr));
 	if (peer) {
 	if (peer) {
 		uint64_t now = Utils::now();
 		uint64_t now = Utils::now();
 		if (peer->haveUdpPath(fromAddr)) {
 		if (peer->haveUdpPath(fromAddr)) {
 			if ((now - peer->lastDirectReceive()) >= ZT_PEER_DIRECT_PING_DELAY)
 			if ((now - peer->lastDirectReceive()) >= ZT_PEER_DIRECT_PING_DELAY)
-				peer->sendPing(_r,now);
+				peer->sendPing(RR,now);
 		} else {
 		} else {
 			if ((now - _lastBeacon) < ZT_MIN_BEACON_RESPONSE_INTERVAL)
 			if ((now - _lastBeacon) < ZT_MIN_BEACON_RESPONSE_INTERVAL)
 				return;
 				return;
@@ -866,13 +866,13 @@ void Switch::_handleBeacon(const SharedPtr<Socket> &fromSock,const InetAddress &
 
 
 Address Switch::_sendWhoisRequest(const Address &addr,const Address *peersAlreadyConsulted,unsigned int numPeersAlreadyConsulted)
 Address Switch::_sendWhoisRequest(const Address &addr,const Address *peersAlreadyConsulted,unsigned int numPeersAlreadyConsulted)
 {
 {
-	SharedPtr<Peer> supernode(_r->topology->getBestSupernode(peersAlreadyConsulted,numPeersAlreadyConsulted,false));
+	SharedPtr<Peer> supernode(RR->topology->getBestSupernode(peersAlreadyConsulted,numPeersAlreadyConsulted,false));
 	if (supernode) {
 	if (supernode) {
-		Packet outp(supernode->address(),_r->identity.address(),Packet::VERB_WHOIS);
+		Packet outp(supernode->address(),RR->identity.address(),Packet::VERB_WHOIS);
 		addr.appendTo(outp);
 		addr.appendTo(outp);
 		outp.armor(supernode->key(),true);
 		outp.armor(supernode->key(),true);
 		uint64_t now = Utils::now();
 		uint64_t now = Utils::now();
-		if (supernode->send(_r,outp.data(),outp.size(),now) != Path::PATH_TYPE_NULL)
+		if (supernode->send(RR,outp.data(),outp.size(),now) != Path::PATH_TYPE_NULL)
 			return supernode->address();
 			return supernode->address();
 	}
 	}
 	return Address();
 	return Address();
@@ -880,7 +880,7 @@ Address Switch::_sendWhoisRequest(const Address &addr,const Address *peersAlread
 
 
 bool Switch::_trySend(const Packet &packet,bool encrypt)
 bool Switch::_trySend(const Packet &packet,bool encrypt)
 {
 {
-	SharedPtr<Peer> peer(_r->topology->getPeer(packet.destination()));
+	SharedPtr<Peer> peer(RR->topology->getPeer(packet.destination()));
 
 
 	if (peer) {
 	if (peer) {
 		uint64_t now = Utils::now();
 		uint64_t now = Utils::now();
@@ -889,7 +889,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
 		if (peer->hasActiveDirectPath(now)) {
 		if (peer->hasActiveDirectPath(now)) {
 			via = peer;
 			via = peer;
 		} else {
 		} else {
-			via = _r->topology->getBestSupernode();
+			via = RR->topology->getBestSupernode();
 			if (!via)
 			if (!via)
 				return false;
 				return false;
 		}
 		}
@@ -901,7 +901,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
 
 
 		tmp.armor(peer->key(),encrypt);
 		tmp.armor(peer->key(),encrypt);
 
 
-		if (via->send(_r,tmp.data(),chunkSize,now) != Path::PATH_TYPE_NULL) {
+		if (via->send(RR,tmp.data(),chunkSize,now) != Path::PATH_TYPE_NULL) {
 			if (chunkSize < tmp.size()) {
 			if (chunkSize < tmp.size()) {
 				// Too big for one bite, fragment the rest
 				// Too big for one bite, fragment the rest
 				unsigned int fragStart = chunkSize;
 				unsigned int fragStart = chunkSize;
@@ -914,7 +914,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
 				for(unsigned int f=0;f<fragsRemaining;++f) {
 				for(unsigned int f=0;f<fragsRemaining;++f) {
 					chunkSize = std::min(remaining,(unsigned int)(ZT_UDP_DEFAULT_PAYLOAD_MTU - ZT_PROTO_MIN_FRAGMENT_LENGTH));
 					chunkSize = std::min(remaining,(unsigned int)(ZT_UDP_DEFAULT_PAYLOAD_MTU - ZT_PROTO_MIN_FRAGMENT_LENGTH));
 					Packet::Fragment frag(tmp,fragStart,chunkSize,f + 1,totalFragments);
 					Packet::Fragment frag(tmp,fragStart,chunkSize,f + 1,totalFragments);
-					via->send(_r,frag.data(),frag.size(),now);
+					via->send(RR,frag.data(),frag.size(),now);
 					fragStart += chunkSize;
 					fragStart += chunkSize;
 					remaining -= chunkSize;
 					remaining -= chunkSize;
 				}
 				}

+ 11 - 11
node/Topology.cpp

@@ -39,11 +39,11 @@
 namespace ZeroTier {
 namespace ZeroTier {
 
 
 Topology::Topology(const RuntimeEnvironment *renv,bool enablePermanentIdCaching) :
 Topology::Topology(const RuntimeEnvironment *renv,bool enablePermanentIdCaching) :
-	_r(renv),
+	RR(renv),
 	_amSupernode(false)
 	_amSupernode(false)
 {
 {
 	if (enablePermanentIdCaching)
 	if (enablePermanentIdCaching)
-		_idCacheBase = (_r->homePath + ZT_PATH_SEPARATOR_S + "iddb.d");
+		_idCacheBase = (RR->homePath + ZT_PATH_SEPARATOR_S + "iddb.d");
 	_loadPeers();
 	_loadPeers();
 }
 }
 
 
@@ -66,10 +66,10 @@ void Topology::setSupernodes(const std::map< Identity,std::vector< std::pair<Ine
 	uint64_t now = Utils::now();
 	uint64_t now = Utils::now();
 
 
 	for(std::map< Identity,std::vector< std::pair<InetAddress,bool> > >::const_iterator i(sn.begin());i!=sn.end();++i) {
 	for(std::map< Identity,std::vector< std::pair<InetAddress,bool> > >::const_iterator i(sn.begin());i!=sn.end();++i) {
-		if (i->first != _r->identity) {
+		if (i->first != RR->identity) {
 			SharedPtr<Peer> p(getPeer(i->first.address()));
 			SharedPtr<Peer> p(getPeer(i->first.address()));
 			if (!p)
 			if (!p)
-				p = addPeer(SharedPtr<Peer>(new Peer(_r->identity,i->first)));
+				p = addPeer(SharedPtr<Peer>(new Peer(RR->identity,i->first)));
 			for(std::vector< std::pair<InetAddress,bool> >::const_iterator j(i->second.begin());j!=i->second.end();++j)
 			for(std::vector< std::pair<InetAddress,bool> >::const_iterator j(i->second.begin());j!=i->second.end();++j)
 				p->addPath(Path(j->first,(j->second) ? Path::PATH_TYPE_TCP_OUT : Path::PATH_TYPE_UDP,true));
 				p->addPath(Path(j->first,(j->second) ? Path::PATH_TYPE_TCP_OUT : Path::PATH_TYPE_UDP,true));
 			p->use(now);
 			p->use(now);
@@ -78,7 +78,7 @@ void Topology::setSupernodes(const std::map< Identity,std::vector< std::pair<Ine
 		_supernodeAddresses.insert(i->first.address());
 		_supernodeAddresses.insert(i->first.address());
 	}
 	}
 
 
-	_amSupernode = (_supernodes.find(_r->identity) != _supernodes.end());
+	_amSupernode = (_supernodes.find(RR->identity) != _supernodes.end());
 }
 }
 
 
 void Topology::setSupernodes(const Dictionary &sn)
 void Topology::setSupernodes(const Dictionary &sn)
@@ -104,7 +104,7 @@ void Topology::setSupernodes(const Dictionary &sn)
 
 
 SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
 SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
 {
 {
-	if (peer->address() == _r->identity.address()) {
+	if (peer->address() == RR->identity.address()) {
 		TRACE("BUG: addNewPeer() caught and ignored attempt to add peer for self");
 		TRACE("BUG: addNewPeer() caught and ignored attempt to add peer for self");
 		throw std::logic_error("cannot add peer for self");
 		throw std::logic_error("cannot add peer for self");
 	}
 	}
@@ -118,7 +118,7 @@ SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
 
 
 SharedPtr<Peer> Topology::getPeer(const Address &zta) const
 SharedPtr<Peer> Topology::getPeer(const Address &zta) const
 {
 {
-	if (zta == _r->identity.address()) {
+	if (zta == RR->identity.address()) {
 		TRACE("BUG: ignored attempt to getPeer() for self, returned NULL");
 		TRACE("BUG: ignored attempt to getPeer() for self, returned NULL");
 		return SharedPtr<Peer>();
 		return SharedPtr<Peer>();
 	}
 	}
@@ -171,12 +171,12 @@ SharedPtr<Peer> Topology::getBestSupernode(const Address *avoid,unsigned int avo
 		 * circumnavigate the globe rather than bouncing between just two. */
 		 * circumnavigate the globe rather than bouncing between just two. */
 
 
 		if (_supernodeAddresses.size() > 1) { // gotta be one other than me for this to work
 		if (_supernodeAddresses.size() > 1) { // gotta be one other than me for this to work
-			std::set<Address>::const_iterator sna(_supernodeAddresses.find(_r->identity.address()));
+			std::set<Address>::const_iterator sna(_supernodeAddresses.find(RR->identity.address()));
 			if (sna != _supernodeAddresses.end()) { // sanity check -- _amSupernode should've been false in this case
 			if (sna != _supernodeAddresses.end()) { // sanity check -- _amSupernode should've been false in this case
 				for(;;) {
 				for(;;) {
 					if (++sna == _supernodeAddresses.end())
 					if (++sna == _supernodeAddresses.end())
 						sna = _supernodeAddresses.begin(); // wrap around at end
 						sna = _supernodeAddresses.begin(); // wrap around at end
-					if (*sna != _r->identity.address()) { // pick one other than us -- starting from me+1 in sorted set order
+					if (*sna != RR->identity.address()) { // pick one other than us -- starting from me+1 in sorted set order
 						SharedPtr<Peer> p(getPeer(*sna));
 						SharedPtr<Peer> p(getPeer(*sna));
 						if ((p)&&(p->hasActiveDirectPath(now))) {
 						if ((p)&&(p->hasActiveDirectPath(now))) {
 							bestSupernode = p;
 							bestSupernode = p;
@@ -292,7 +292,7 @@ bool Topology::authenticateRootTopology(const Dictionary &rt)
 void Topology::_dumpPeers()
 void Topology::_dumpPeers()
 {
 {
 	Buffer<ZT_PEER_WRITE_BUF_SIZE> buf;
 	Buffer<ZT_PEER_WRITE_BUF_SIZE> buf;
-	std::string pdpath(_r->homePath + ZT_PATH_SEPARATOR_S + "peers.persist");
+	std::string pdpath(RR->homePath + ZT_PATH_SEPARATOR_S + "peers.persist");
 	Mutex::Lock _l(_activePeers_m);
 	Mutex::Lock _l(_activePeers_m);
 
 
 	FILE *pd = fopen(pdpath.c_str(),"wb");
 	FILE *pd = fopen(pdpath.c_str(),"wb");
@@ -343,7 +343,7 @@ void Topology::_dumpPeers()
 void Topology::_loadPeers()
 void Topology::_loadPeers()
 {
 {
 	Buffer<ZT_PEER_WRITE_BUF_SIZE> buf;
 	Buffer<ZT_PEER_WRITE_BUF_SIZE> buf;
-	std::string pdpath(_r->homePath + ZT_PATH_SEPARATOR_S + "peers.persist");
+	std::string pdpath(RR->homePath + ZT_PATH_SEPARATOR_S + "peers.persist");
 	Mutex::Lock _l(_activePeers_m);
 	Mutex::Lock _l(_activePeers_m);
 
 
 	_activePeers.clear();
 	_activePeers.clear();

+ 13 - 13
node/Topology.hpp

@@ -237,7 +237,7 @@ public:
 		PingPeersThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) throw() :
 		PingPeersThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) throw() :
 			_now(now),
 			_now(now),
 			_supernodeAddresses(renv->topology->supernodeAddresses()),
 			_supernodeAddresses(renv->topology->supernodeAddresses()),
-			_r(renv) {}
+			RR(renv) {}
 
 
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		{
 		{
@@ -249,14 +249,14 @@ public:
 			if ( (!_supernodeAddresses.count(p->address())) &&
 			if ( (!_supernodeAddresses.count(p->address())) &&
 			     ((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT) &&
 			     ((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT) &&
 			     ((_now - p->lastDirectReceive()) >= ZT_PEER_DIRECT_PING_DELAY) ) {
 			     ((_now - p->lastDirectReceive()) >= ZT_PEER_DIRECT_PING_DELAY) ) {
-				p->sendPing(_r,_now);
+				p->sendPing(RR,_now);
 			}
 			}
 		}
 		}
 
 
 	private:
 	private:
 		uint64_t _now;
 		uint64_t _now;
 		std::set<Address> _supernodeAddresses;
 		std::set<Address> _supernodeAddresses;
-		const RuntimeEnvironment *_r;
+		const RuntimeEnvironment *RR;
 	};
 	};
 
 
 	/**
 	/**
@@ -273,7 +273,7 @@ public:
 	public:
 	public:
 		PingSupernodesThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) throw() :
 		PingSupernodesThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) throw() :
 			_now(now),
 			_now(now),
-			_r(renv) {}
+			RR(renv) {}
 
 
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		{
 		{
@@ -284,13 +284,13 @@ public:
 			uint64_t lp = 0;
 			uint64_t lp = 0;
 			uint64_t lr = 0;
 			uint64_t lr = 0;
 			p->lastPingAndDirectReceive(lp,lr);
 			p->lastPingAndDirectReceive(lp,lr);
-			if ( (lr < _r->timeOfLastResynchronize) || ((lr < lp)&&((lp - lr) >= ZT_PING_UNANSWERED_AFTER)) || ((_now - lr) >= ZT_PEER_DIRECT_PING_DELAY) )
-				p->sendPing(_r,_now);
+			if ( (lr < RR->timeOfLastResynchronize) || ((lr < lp)&&((lp - lr) >= ZT_PING_UNANSWERED_AFTER)) || ((_now - lr) >= ZT_PEER_DIRECT_PING_DELAY) )
+				p->sendPing(RR,_now);
 		}
 		}
 
 
 	private:
 	private:
 		uint64_t _now;
 		uint64_t _now;
-		const RuntimeEnvironment *_r;
+		const RuntimeEnvironment *RR;
 	};
 	};
 
 
 	/**
 	/**
@@ -315,23 +315,23 @@ public:
 			_now(now),
 			_now(now),
 			_supernode(renv->topology->getBestSupernode()),
 			_supernode(renv->topology->getBestSupernode()),
 			_supernodeAddresses(renv->topology->supernodeAddresses()),
 			_supernodeAddresses(renv->topology->supernodeAddresses()),
-			_r(renv) {}
+			RR(renv) {}
 
 
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		inline void operator()(Topology &t,const SharedPtr<Peer> &p)
 		{
 		{
 			p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes
 			p->clearPaths(false); // false means don't forget 'fixed' paths e.g. supernodes
 
 
-			Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP);
+			Packet outp(p->address(),RR->identity.address(),Packet::VERB_NOP);
 			outp.armor(p->key(),false); // no need to encrypt a NOP
 			outp.armor(p->key(),false); // no need to encrypt a NOP
 
 
 			if (_supernodeAddresses.count(p->address())) {
 			if (_supernodeAddresses.count(p->address())) {
 				// Send NOP directly to supernodes
 				// Send NOP directly to supernodes
-				p->send(_r,outp.data(),outp.size(),_now);
+				p->send(RR,outp.data(),outp.size(),_now);
 			} else {
 			} else {
 				// Send NOP indirectly to regular peers if still active, triggering a new RENDEZVOUS
 				// Send NOP indirectly to regular peers if still active, triggering a new RENDEZVOUS
 				if (((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT)&&(_supernode)) {
 				if (((_now - p->lastFrame()) < ZT_PEER_PATH_ACTIVITY_TIMEOUT)&&(_supernode)) {
 					TRACE("sending reset NOP to %s",p->address().toString().c_str());
 					TRACE("sending reset NOP to %s",p->address().toString().c_str());
-					_supernode->send(_r,outp.data(),outp.size(),_now);
+					_supernode->send(RR,outp.data(),outp.size(),_now);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -340,7 +340,7 @@ public:
 		uint64_t _now;
 		uint64_t _now;
 		SharedPtr<Peer> _supernode;
 		SharedPtr<Peer> _supernode;
 		std::set<Address> _supernodeAddresses;
 		std::set<Address> _supernodeAddresses;
-		const RuntimeEnvironment *_r;
+		const RuntimeEnvironment *RR;
 	};
 	};
 
 
 	/**
 	/**
@@ -373,7 +373,7 @@ public:
 	static bool authenticateRootTopology(const Dictionary &rt);
 	static bool authenticateRootTopology(const Dictionary &rt);
 
 
 private:
 private:
-	const RuntimeEnvironment *const _r;
+	const RuntimeEnvironment *RR;
 
 
 	void _dumpPeers();
 	void _dumpPeers();
 	void _loadPeers();
 	void _loadPeers();