diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-30 13:51:56 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-30 13:51:56 -0400 |
| commit | 9db7939d383f2d048d48a4d78e4834fc5d2dbafe (patch) | |
| tree | ba02e4b773704cd095da0bb47727ccdb7301c901 /node/Network.hpp | |
| parent | 4ecb9369b56c7aa507c9c0c9fa8381ec6772a0ea (diff) | |
| download | infinitytier-9db7939d383f2d048d48a4d78e4834fc5d2dbafe.tar.gz infinitytier-9db7939d383f2d048d48a4d78e4834fc5d2dbafe.zip | |
Make new multicast depth and prefix bits parameters configurable.
Diffstat (limited to 'node/Network.hpp')
| -rw-r--r-- | node/Network.hpp | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/node/Network.hpp b/node/Network.hpp index 2ed70504..cccae17e 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -266,12 +266,20 @@ public: * nwid=<hex network ID> (required) * name=short name * desc=long(er) description - * com=Certificate (serialized dictionary) + * com=Serialized certificate of membership * mr=MulticastRates (serialized dictionary) + * md=multicast propagation depth + * mpb=multicast propagation prefix bits (2^mpb packets are sent by origin) * o=open network? (1 or 0, default false if missing) * et=ethertype whitelist (comma-delimited list of ethertypes in decimal) * v4s=IPv4 static assignments / netmasks (comma-delimited) * v6s=IPv6 static assignments / netmasks (comma-delimited) + * + * Notes: + * + * If zero appears in the 'et' list, the sense is inverted. It becomes an + * ethertype blacklist instead of a whitelist and anything not blacklisted + * is permitted. */ class Config : private Dictionary { @@ -340,6 +348,34 @@ public: } /** + * @return Number of bits in propagation prefix for this network + */ + inline unsigned int multicastPrefixBits() const + { + const_iterator mpb(find("mpb")); + if (mpb == end()) + return ZT_DEFAULT_MULTICAST_PREFIX_BITS; + unsigned int tmp = Utils::hexStrToUInt(mpb->second.c_str()); + if (tmp) + return tmp; + else return ZT_DEFAULT_MULTICAST_PREFIX_BITS; + } + + /** + * @return Maximum multicast propagation depth for this network + */ + inline unsigned int multicastDepth() const + { + const_iterator md(find("md")); + if (md == end()) + return ZT_DEFAULT_MULTICAST_DEPTH; + unsigned int tmp = Utils::hexStrToUInt(md->second.c_str()); + if (tmp) + return tmp; + else return ZT_DEFAULT_MULTICAST_DEPTH; + } + + /** * @return True if this is an open non-access-controlled network */ inline bool isOpen() const @@ -557,7 +593,9 @@ public: return false; else if (etherType > 65535) return false; - else return ((_etWhitelist[etherType / 8] & (unsigned char)(1 << (etherType % 8))) != 0); + else if ((_etWhitelist[0] & 1)) // if type 0 is in the whitelist, sense is inverted from whitelist to blacklist + return ((_etWhitelist[etherType / 8] & (unsigned char)(1 << (etherType & 7))) == 0); + else return ((_etWhitelist[etherType / 8] & (unsigned char)(1 << (etherType & 7))) != 0); } /** @@ -592,6 +630,24 @@ public: return false; // TODO: bridging not implemented yet } + /** + * @return Bits in multicast restriciton prefix + */ + inline unsigned int multicastPrefixBits() const + throw() + { + return _multicastPrefixBits; + } + + /** + * @return Max depth (TTL) for a multicast frame + */ + inline unsigned int multicastDepth() const + throw() + { + return _multicastDepth; + } + private: static void _CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned int etherType,const Buffer<4096> &data); void _restoreState(); @@ -614,6 +670,8 @@ private: MulticastRates _mcRates; // memoized from _configuration std::set<InetAddress> _staticAddresses; // memoized from _configuration bool _isOpen; // memoized from _configuration + unsigned int _multicastPrefixBits; // memoized from _configuration + unsigned int _multicastDepth; // memoized from _configuration // Ethertype whitelist bit field, set from config, for really fast lookup unsigned char _etWhitelist[65536 / 8]; |
