diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-06-10 15:47:20 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-06-10 15:47:20 -0700 |
| commit | 4e1f49258bd5ff2b87c313f7452775ad78ce53db (patch) | |
| tree | 1a8ffea4590bfa2efc728ef5a4dce186ba82bdf2 /node/NetworkConfig.hpp | |
| parent | fb31f93c5295752b5a07d742dae397654c6c8f67 (diff) | |
| download | infinitytier-4e1f49258bd5ff2b87c313f7452775ad78ce53db.tar.gz infinitytier-4e1f49258bd5ff2b87c313f7452775ad78ce53db.zip | |
Bridging in NetworkConfig - GitHub Issue #68
Diffstat (limited to 'node/NetworkConfig.hpp')
| -rw-r--r-- | node/NetworkConfig.hpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index a53841de..05c395c0 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -62,13 +62,13 @@ namespace ZeroTier { #define ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC "v6s" #define ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP "com" #define ZT_NETWORKCONFIG_DICT_KEY_ENABLE_BROADCAST "eb" +#define ZT_NETWORKCONFIG_DICT_KEY_BRIDGING_MODE "br" +#define ZT_NETWORKCONFIG_DICT_KEY_ACTIVE_BRIDGES "ab" /** * Network configuration received from netconf master nodes * - * This is designed to work as an immutable value object held in a shared - * pointer so that it can be both updated and used without too much mutex - * boogie. + * This is an immutable value object created from a dictionary received from netconf master. */ class NetworkConfig { @@ -76,6 +76,16 @@ public: friend class SharedPtr<NetworkConfig>; /** + * Network bridging mode + */ + enum BridgingMode + { + BRIDGING_DISABLED = 0, // no bridging + BRIDGING_ACTIVE_ONLY = 1, // only active bridges may bridge + BRIDGING_PERMISSIVE = 2 // allow passive bridging by any peer + }; + + /** * Tuple of multicast rate parameters */ struct MulticastRate @@ -102,7 +112,7 @@ public: * @param etherType Ethernet frame type to check * @return True if allowed on this network */ - inline bool permitsEtherType(unsigned int etherType) + inline bool permitsEtherType(unsigned int etherType) const throw() { if ((!etherType)||(etherType > 0xffff)) // sanity checks @@ -124,6 +134,7 @@ public: inline const std::string &name() const throw() { return _name; } inline const std::string &description() const throw() { return _description; } inline const std::set<InetAddress> &staticIps() const throw() { return _staticIps; } + inline const std::set<Address> &activeBridges() const throw() { return _activeBridges; } inline const CertificateOfMembership &com() const throw() { return _com; } inline bool enableBroadcast() const throw() { return _enableBroadcast; } @@ -134,7 +145,15 @@ public: inline bool permitsBridging(const Address &fromPeer) const throw() { - return false; // TODO: bridging not implemented yet + switch(_bridgingMode) { + case BRIDGING_ACTIVE_ONLY: + return (_activeBridges.count(fromPeer) > 0); + case BRIDGING_PERMISSIVE: + return true; + //case BRIDGING_DISABLED: + default: + return false; + } } /** @@ -156,11 +175,13 @@ private: Address _issuedTo; unsigned int _multicastPrefixBits; unsigned int _multicastDepth; + BridgingMode _bridgingMode; bool _private; bool _enableBroadcast; std::string _name; std::string _description; std::set<InetAddress> _staticIps; + std::set<Address> _activeBridges; std::map<MulticastGroup,MulticastRate> _multicastRates; CertificateOfMembership _com; |
