summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-13 14:27:18 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-13 14:27:18 -0700
commit5b6d27e65919cf0429feb2d8a9ce0b6164153efd (patch)
treec39d4abc138eb2cfe1b46df7154c298156ba020b /node/Switch.cpp
parentced8dfc639f73939aacd2bae3002daa11661a14f (diff)
downloadinfinitytier-5b6d27e65919cf0429feb2d8a9ce0b6164153efd.tar.gz
infinitytier-5b6d27e65919cf0429feb2d8a9ce0b6164153efd.zip
Implement relay policy, and setting multicast limit to 0 now disables multicast on the network as would be expected.
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index ea92c99a..beb36b6c 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -105,7 +105,18 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
const Address destination(fragment.destination());
if (destination != RR->identity.address()) {
- // Fragment is not for us, so try to relay it
+ switch(RR->node->relayPolicy()) {
+ case ZT_RELAY_POLICY_ALWAYS:
+ break;
+ case ZT_RELAY_POLICY_TRUSTED:
+ if (!path->trustEstablished(now))
+ return;
+ break;
+ // case ZT_RELAY_POLICY_NEVER:
+ default:
+ return;
+ }
+
if (fragment.hops() < ZT_RELAY_MAX_HOPS) {
fragment.incrementHops();
@@ -203,9 +214,20 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
//TRACE("<< %.16llx %s -> %s (size: %u)",(unsigned long long)packet->packetId(),source.toString().c_str(),destination.toString().c_str(),packet->size());
if (destination != RR->identity.address()) {
+ switch(RR->node->relayPolicy()) {
+ case ZT_RELAY_POLICY_ALWAYS:
+ break;
+ case ZT_RELAY_POLICY_TRUSTED:
+ if (!path->trustEstablished(now))
+ return;
+ break;
+ // case ZT_RELAY_POLICY_NEVER:
+ default:
+ return;
+ }
+
Packet packet(data,len);
- // Packet is not for us, so try to relay it
if (packet.hops() < ZT_RELAY_MAX_HOPS) {
packet.incrementHops();
@@ -327,6 +349,11 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
}
if (to.isMulticast()) {
+ if (network->config().multicastLimit == 0) {
+ TRACE("%.16llx: dropped multicast: not allowed on network",network->id());
+ return;
+ }
+
// Destination is a multicast address (including broadcast)
MulticastGroup mg(to,0);