From d73607430131dd352cf9248f37e76c2618dd39e5 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 22 Apr 2016 15:40:53 -0700 Subject: Refactor rules table in-memory structure in new NetworkConfig to permit far more rules with better space efficiency. --- node/NetworkConfig.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'node/NetworkConfig.hpp') diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index c3cc9cd4..0ed7b6a2 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -133,8 +133,12 @@ public: inline bool permitsEtherType(unsigned int etherType) const { for(unsigned int i=0;i<_ruleCount;++i) { - if ((_rules[i].etherType < 0)||((unsigned int)_rules[i].etherType == etherType)) - return (_rules[i].action == ZT_NETWORK_RULE_ACTION_ACCEPT); + if ((ZT_VirtualNetworkRuleMatches)_rules[i].matches == ZT_NETWORK_RULE_MATCHES_ETHERTYPE) { + if (_rules[i].datum.etherType == etherType) + return ((ZT_VirtualNetworkRuleAction)_rules[i].action == ZT_NETWORK_RULE_ACTION_ACCEPT); + } else if ((ZT_VirtualNetworkRuleMatches)_rules[i].matches == ZT_NETWORK_RULE_MATCHES_ALL) { + return ((ZT_VirtualNetworkRuleAction)_rules[i].action == ZT_NETWORK_RULE_ACTION_ACCEPT); + } } return false; } -- cgit v1.2.3