Bridging #68 should work now!

This commit is contained in:
Adam Ierymenko 2014-06-21 11:59:08 -04:00
parent 35aa0921ee
commit 0b0d5fabac

View File

@ -219,24 +219,37 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
return; return;
} }
// Unicast from local peer to another non-bridged ZeroTier node // Destination is another ZeroTier node
if ((!fromBridged)&&(to[0] == MAC::firstOctetForNetwork(network->id()))) { if (to[0] == MAC::firstOctetForNetwork(network->id())) {
Address toZT(to.toAddress(network->id())); Address toZT(to.toAddress(network->id()));
if (network->isAllowed(toZT)) { if (network->isAllowed(toZT)) {
network->pushMembershipCertificate(toZT,false,Utils::now()); network->pushMembershipCertificate(toZT,false,Utils::now());
if (fromBridged) {
Packet outp(toZT,_r->identity.address(),Packet::VERB_FRAME); // Must use EXT_FRAME if source is not myself
outp.append(network->id()); Packet outp(toZT,_r->identity.address(),Packet::VERB_EXT_FRAME);
outp.append((uint16_t)etherType); outp.append(network->id());
outp.append(data); outp.append((unsigned char)0);
outp.compress(); to.appendTo(outp);
send(outp,true); from.appendTo(outp);
outp.append((uint16_t)etherType);
outp.append(data);
outp.compress();
send(outp,true);
} else {
// 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);
outp.append(network->id());
outp.append((uint16_t)etherType);
outp.append(data);
outp.compress();
send(outp,true);
}
} else { } else {
TRACE("%s: UNICAST: %s -> %s %s dropped, destination not a member of closed network %.16llx",network->tapDeviceName().c_str(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),network->id()); TRACE("%s: UNICAST: %s -> %s %s dropped, destination not a member of closed network %.16llx",network->tapDeviceName().c_str(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),network->id());
} }
} }
// Unicast to another node behind another bridge, whether from us or not // Destination is behind another bridge
Address bridges[ZT_MAX_BRIDGE_SPAM]; Address bridges[ZT_MAX_BRIDGE_SPAM];
unsigned int numBridges = 0; unsigned int numBridges = 0;
@ -266,15 +279,17 @@ 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); if (network->isAllowed(bridges[b])) {
outp.append(network->id()); Packet outp(bridges[b],_r->identity.address(),Packet::VERB_EXT_FRAME);
outp.append((unsigned char)0); outp.append(network->id());
to.appendTo(outp); outp.append((unsigned char)0);
from.appendTo(outp); to.appendTo(outp);
outp.append((uint16_t)etherType); from.appendTo(outp);
outp.append(data); outp.append((uint16_t)etherType);
outp.compress(); outp.append(data);
send(outp,true); outp.compress();
send(outp,true);
}
} }
} }