diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-02 13:50:42 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-02 13:50:42 -0400 |
commit | 2cfa76fa8b5d93ba2a92dc4df556c6a7fab52920 (patch) | |
tree | 9a8fe04165228476f69b6c704d0ffe1b16278bf4 /node/Switch.cpp | |
parent | 929ed5d8b8bf9b9e86c64615bb706d2d52f09246 (diff) | |
download | infinitytier-2cfa76fa8b5d93ba2a92dc4df556c6a7fab52920.tar.gz infinitytier-2cfa76fa8b5d93ba2a92dc4df556c6a7fab52920.zip |
Multicast propagation is now working from non-supernodes, and working quite well. Time for some more simulation before 0.5.0!
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r-- | node/Switch.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 896c6435..b1e5f624 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -107,27 +107,27 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c mg = MulticastGroup::deriveMulticastGroupForAddressResolution(InetAddress(data.field(24,4),4,0)); } - unsigned int mcid = ++_multicastIdCounter & 0xffffff; - uint16_t bloomNonce = (uint16_t)_r->prng->next32(); // doesn't need to be cryptographically strong + const unsigned int mcid = ++_multicastIdCounter & 0xffffff; + const uint16_t bloomNonce = (uint16_t)(_r->prng->next32() & 0xffff); // doesn't need to be cryptographically strong 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]; + 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 SharedPtr<Peer> supernode(_r->topology->getBestSupernode()); for(unsigned int prefix=0,np=((unsigned int)2 << (network->multicastPrefixBits() - 1));prefix<np;++prefix) { memset(bloom,0,sizeof(bloom)); unsigned char *fifoPtr = fifo; - unsigned char *fifoEnd = fifo + sizeof(fifo); - _r->mc->getNextHops(network->id(),mg,Multicaster::AddToPropagationQueue(&fifoPtr,fifoEnd,bloom,bloomNonce,_r->identity.address(),network->multicastPrefixBits(),prefix)); while (fifoPtr != fifoEnd) *(fifoPtr++) = (unsigned char)0; Address firstHop(fifo,ZT_ADDRESS_LENGTH); // fifo is +1 in size, with first element being used here if (!firstHop) { - SharedPtr<Peer> sn(_r->topology->getBestSupernode()); - if (sn) - firstHop = sn->address(); - else break; + if (supernode) + firstHop = supernode->address(); + else continue; } Packet outp(firstHop,_r->identity.address(),Packet::VERB_MULTICAST_FRAME); @@ -150,7 +150,6 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c outp.append((uint16_t)data.size()); outp.append(data); - unsigned int signedPartLen = (ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME - ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION) + data.size(); C25519::Signature sig(_r->identity.sign(outp.field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION,signedPartLen),signedPartLen)); outp.append((uint16_t)sig.size()); outp.append(sig.data,sig.size()); |