summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-03-25 21:38:54 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-03-25 21:38:54 -0700
commitab5a4601775bfb9988f6c7c93f5666d5e96d34cc (patch)
tree12172fc1848bf5d7d7203bc71c2f37e8f74eb64b /node/Switch.cpp
parent67a85221d5bac4b363d3f8d0263a9b8848ba0adb (diff)
downloadinfinitytier-ab5a4601775bfb9988f6c7c93f5666d5e96d34cc.tar.gz
infinitytier-ab5a4601775bfb9988f6c7c93f5666d5e96d34cc.zip
Apply multicast rate limits on a network to ourselves and do not send multicasts that would exceed limits, for GitHub issue #55
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 351034b2..2e021a5f 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -108,6 +108,11 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
mg = MulticastGroup::deriveMulticastGroupForAddressResolution(InetAddress(data.field(24,4),4,0));
}
+ if (!network->updateAndCheckMulticastBalance(_r->identity.address(),mg,data.size())) {
+ TRACE("%s: didn't multicast %d bytes, quota exceeded for multicast group %s",network->tapDeviceName().c_str(),(int)data.size(),mg.toString().c_str());
+ return;
+ }
+
const unsigned int mcid = ++_multicastIdCounter & 0xffffff;
const uint16_t bloomNonce = (uint16_t)(_r->prng->next32() & 0xffff); // doesn't need to be cryptographically strong
unsigned char bloom[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM];