From 797bba04dd738f69aa0554800ab064f35b69e5b3 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 17 Oct 2013 13:07:53 -0400 Subject: [PATCH] Get rid of not used and maybe never to be used Filter code. --- {node => attic}/Filter.cpp | 0 {node => attic}/Filter.hpp | 0 node/PacketDecoder.cpp | 1 - node/Switch.cpp | 25 ++++++++++++++++++++----- node/Switch.hpp | 17 +++++++++++++++++ objects.mk | 1 - 6 files changed, 37 insertions(+), 7 deletions(-) rename {node => attic}/Filter.cpp (100%) rename {node => attic}/Filter.hpp (100%) diff --git a/node/Filter.cpp b/attic/Filter.cpp similarity index 100% rename from node/Filter.cpp rename to attic/Filter.cpp diff --git a/node/Filter.hpp b/attic/Filter.hpp similarity index 100% rename from node/Filter.hpp rename to attic/Filter.hpp diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp index f41000296..0e9bde17f 100644 --- a/node/PacketDecoder.cpp +++ b/node/PacketDecoder.cpp @@ -39,7 +39,6 @@ #include "Switch.hpp" #include "Peer.hpp" #include "NodeConfig.hpp" -#include "Filter.hpp" #include "Service.hpp" #include "Demarc.hpp" diff --git a/node/Switch.cpp b/node/Switch.cpp index c6cd7987e..371840766 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -48,7 +48,6 @@ #include "Peer.hpp" #include "NodeConfig.hpp" #include "Demarc.hpp" -#include "Filter.hpp" #include "CMWC4096.hpp" #include "../version.h" @@ -89,12 +88,12 @@ void Switch::onLocalEthernet(const SharedPtr &network,const MAC &from,c } if (from != network->tap().mac()) { - LOG("ignored tap: %s -> %s %s (bridging not supported)",from.toString().c_str(),to.toString().c_str(),Filter::etherTypeName(etherType)); + LOG("ignored tap: %s -> %s %s (bridging not supported)",from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType)); return; } if (!network->permitsEtherType(etherType)) { - LOG("ignored tap: %s -> %s: ethertype %s not allowed on network %.16llx",from.toString().c_str(),to.toString().c_str(),Filter::etherTypeName(etherType),(unsigned long long)network->id()); + LOG("ignored tap: %s -> %s: ethertype %s not allowed on network %.16llx",from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),(unsigned long long)network->id()); return; } @@ -177,10 +176,10 @@ void Switch::onLocalEthernet(const SharedPtr &network,const MAC &from,c outp.compress(); send(outp,true); } else { - TRACE("UNICAST: %s -> %s %s (dropped, destination not a member of closed network %llu)",from.toString().c_str(),to.toString().c_str(),Filter::etherTypeName(etherType),network->id()); + TRACE("UNICAST: %s -> %s %s (dropped, destination not a member of closed network %llu)",from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType),network->id()); } } else { - TRACE("UNICAST: %s -> %s %s (dropped, destination MAC not ZeroTier)",from.toString().c_str(),to.toString().c_str(),Filter::etherTypeName(etherType)); + TRACE("UNICAST: %s -> %s %s (dropped, destination MAC not ZeroTier)",from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType)); } } @@ -501,6 +500,22 @@ void Switch::doAnythingWaitingForPeer(const SharedPtr &peer) } } +const char *Switch::etherTypeName(const unsigned int etherType) + throw() +{ + switch(etherType) { + case ZT_ETHERTYPE_IPV4: return "IPV4"; + case ZT_ETHERTYPE_ARP: return "ARP"; + case ZT_ETHERTYPE_RARP: return "RARP"; + case ZT_ETHERTYPE_ATALK: return "ATALK"; + case ZT_ETHERTYPE_AARP: return "AARP"; + case ZT_ETHERTYPE_IPX_A: return "IPX_A"; + case ZT_ETHERTYPE_IPX_B: return "IPX_B"; + case ZT_ETHERTYPE_IPV6: return "IPV6"; + } + return "UNKNOWN"; +} + void Switch::_handleRemotePacketFragment(Demarc::Port localPort,const InetAddress &fromAddr,const Buffer<4096> &data) { Packet::Fragment fragment(data); diff --git a/node/Switch.hpp b/node/Switch.hpp index 3cc6887c8..68e3c6c40 100644 --- a/node/Switch.hpp +++ b/node/Switch.hpp @@ -48,6 +48,16 @@ #include "Multicaster.hpp" #include "PacketDecoder.hpp" +/* Ethernet frame types that might be relevant to us */ +#define ZT_ETHERTYPE_IPV4 0x0800 +#define ZT_ETHERTYPE_ARP 0x0806 +#define ZT_ETHERTYPE_RARP 0x8035 +#define ZT_ETHERTYPE_ATALK 0x809b +#define ZT_ETHERTYPE_AARP 0x80f3 +#define ZT_ETHERTYPE_IPX_A 0x8137 +#define ZT_ETHERTYPE_IPX_B 0x8138 +#define ZT_ETHERTYPE_IPV6 0x86dd + namespace ZeroTier { class RuntimeEnvironment; @@ -195,6 +205,13 @@ public: */ void doAnythingWaitingForPeer(const SharedPtr &peer); + /** + * @param etherType Ethernet type ID + * @return Human-readable name + */ + static const char *etherTypeName(const unsigned int etherType) + throw(); + private: void _handleRemotePacketFragment( Demarc::Port localPort, diff --git a/objects.mk b/objects.mk index cd8f6e46b..41e1d83cb 100644 --- a/objects.mk +++ b/objects.mk @@ -7,7 +7,6 @@ OBJS=\ node/Defaults.o \ node/Demarc.o \ node/EthernetTap.o \ - node/Filter.o \ node/Identity.o \ node/InetAddress.o \ node/Logger.o \