diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-01 17:19:36 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-01 17:19:36 -0400 |
commit | 929ed5d8b8bf9b9e86c64615bb706d2d52f09246 (patch) | |
tree | 749d61f10565f7975b10d372916cc8a9a811d863 /node | |
parent | 676f391ccf5c1112d1725992dd444ac4084b570a (diff) | |
parent | 4b6ec872c7680a2529e8c12a3ef9a4a349c1aff8 (diff) | |
download | infinitytier-929ed5d8b8bf9b9e86c64615bb706d2d52f09246.tar.gz infinitytier-929ed5d8b8bf9b9e86c64615bb706d2d52f09246.zip |
Merge branch 'adamierymenko-dev' of /Users/api/Code/local-ZeroTierOne into adamierymenko-dev
Diffstat (limited to 'node')
-rw-r--r-- | node/Multicaster.hpp | 16 | ||||
-rw-r--r-- | node/PacketDecoder.cpp | 2 |
2 files changed, 8 insertions, 10 deletions
diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index 46ab08ea..861fc65e 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -156,11 +156,11 @@ public: throw() : _origin(origin), _bloomNonce((uint64_t)bloomNonce), + _prefixMask(0xffffffffffffffffULL >> (64 - prefixBits)), + _prefix((uint64_t)prefix & _prefixMask), _ptr(ptr), _end(end), - _bloom(bloom), - _prefix(prefix), - _prefixBits(std::min(prefixBits,(unsigned int)16)) {} + _bloom(bloom) {} inline bool operator()(const Address &a) throw() @@ -169,10 +169,8 @@ public: if (a == _origin) return true; - // Prefixes match if N least significant bits in address are equal to the - // prefix. (e.g. 0 bits and 0 prefix would match all, 1 bit and 0 prefix - // would match addresses with LSB == 0) - if (((unsigned int)a.toInt() & (0xffff >> (16 - _prefixBits))) != _prefix) + // Exclude addresses not in this prefix domain + if ((a.toInt() & _prefixMask) != _prefix) return true; // Exclude addresses remembered in bloom filter -- or else remember them @@ -191,11 +189,11 @@ public: private: const Address _origin; const uint64_t _bloomNonce; + const uint64_t _prefixMask; + const uint64_t _prefix; unsigned char **const _ptr; unsigned char *const _end; unsigned char *const _bloom; - const unsigned int _prefix; - const unsigned int _prefixBits; }; private: diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp index 1560ec1e..0533ebda 100644 --- a/node/PacketDecoder.cpp +++ b/node/PacketDecoder.cpp @@ -564,7 +564,7 @@ bool PacketDecoder::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Shared // New FIFO with room for one extra, since head will be next hop unsigned char newFifo[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO + ZT_ADDRESS_LENGTH]; unsigned char *newFifoPtr = newFifo; - unsigned char *newFifoEnd = newFifoPtr + sizeof(newFifo); + unsigned char *const newFifoEnd = newFifoPtr + sizeof(newFifo); for(unsigned int i=0;i<ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_FIFO;) { unsigned int j = i; i += ZT_ADDRESS_LENGTH; |