diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-25 17:41:49 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-25 17:41:49 -0400 |
commit | 24bad9f3d1119c4bf80e28f33d4241c7e6221877 (patch) | |
tree | f570e235f547628d5498a4bbc54f653325848cf0 /node/Network.hpp | |
parent | f3128a18fee6745317cdf1918fe3c3901958b1de (diff) | |
download | infinitytier-24bad9f3d1119c4bf80e28f33d4241c7e6221877.tar.gz infinitytier-24bad9f3d1119c4bf80e28f33d4241c7e6221877.zip |
More work in progress in new multicast propagation...
Diffstat (limited to 'node/Network.hpp')
-rw-r--r-- | node/Network.hpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/node/Network.hpp b/node/Network.hpp index d5c75cef..993ee6a6 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -52,6 +52,8 @@ #include "InetAddress.hpp" #include "BandwidthAccount.hpp" +#define ZT_NETWORK_MULTICAST_DEDUP_HISTORY_LENGTH 256 + namespace ZeroTier { class RuntimeEnvironment; @@ -583,12 +585,46 @@ public: //return tmp; } + /** + * Multicast deduplicator + * + * This checks to see if a multicast GUID has been seen before. If not, it + * adds it to the history and returns false. + * + * @param mcGuid Multicast GUID (sender address + sender unique ID) + * @return True if multicast IS a duplicate, false otherwise + */ + inline bool multicastDeduplicate(uint64_t mcGuid) + throw() + { + Mutex::Lock _l(_lock); + for(unsigned int i=0;i<ZT_NETWORK_MULTICAST_DEDUP_HISTORY_LENGTH;++i) { + if (_multicastHistory[i] == mcGuid) + return true; + } + _multicastHistory[_multicastHistoryPtr++ % ZT_NETWORK_MULTICAST_DEDUP_HISTORY_LENGTH] = mcGuid; + return false; + } + + /** + * @return True if this network allows bridging + */ + inline bool permitsBridging() const + throw() + { + return false; // TODO: bridging not implemented yet + } + private: static void _CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned int etherType,const Buffer<4096> &data); void _restoreState(); const RuntimeEnvironment *_r; + // Ring buffer of most recently injected multicast packet GUIDs + uint64_t _multicastHistory[ZT_NETWORK_MULTICAST_DEDUP_HISTORY_LENGTH]; + unsigned int _multicastHistoryPtr; + // Multicast bandwidth accounting for peers on this network std::map< std::pair<Address,MulticastGroup>,BandwidthAccount > _multicastRateAccounts; |