From 86437239e49a58a9ab661b127709af482aa981e4 Mon Sep 17 00:00:00 2001 From: /jedi/ Date: Thu, 25 Feb 2016 19:56:00 +0100 Subject: [PATCH] 1.2 --- src/Filter.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++ src/Filter.h | 30 +++++++++++++++++++++++++ src/Switch-Cmd.cpp | 31 ++++++++++++++++++++++++++ src/lookup/input.lst | 38 +++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 src/Filter.cpp create mode 100644 src/Filter.h create mode 100644 src/Switch-Cmd.cpp create mode 100644 src/lookup/input.lst diff --git a/src/Filter.cpp b/src/Filter.cpp new file mode 100644 index 0000000..cb5f87d --- /dev/null +++ b/src/Filter.cpp @@ -0,0 +1,53 @@ +/* + * Filter.cpp + * + * Created on: 23.02.2016 + * Author: jedi + */ + +#include "Filter.h" + +Filter::Filter() { +} +Filter::Filter(macAddr a) { + switchMac = a; +} +Filter::Filter(Packet::OpCode o) { + oc = o; +} + +Filter Filter::opcode(Packet::OpCode o) { + oc = o; + return *this; +} +Filter Filter::mac(macAddr a) { + switchMac = a; + return *this; +} +Filter Filter::tokenid(short i) { + tokenId = i; + return *this; +} + +bool Filter::pass(const Packet p) const { + macAddr none { 0, 0, 0, 0, 0, 0 }; + if (this->oc != Packet::NONE && this->oc != p.getOpCode()) + return false; + if (this->switchMac != none && this->switchMac != p.getSwitchMac()) + return false; + if (this->tokenId != -1 && this->tokenId != p.getTokenId()) + return false; + /* if (fragmentOffset != p.getF && fragmentOffset != -1) + return false;*/ + return true; +} + +bool Filter::operator<(const Filter f) const { + if (this->oc != f.oc) + return this->oc > f.oc; + if (this->switchMac != f.switchMac) + return this->switchMac > f.switchMac; + if (this->tokenId != f.tokenId) + return this->tokenId > f.tokenId; + return false; +} diff --git a/src/Filter.h b/src/Filter.h new file mode 100644 index 0000000..a9d9213 --- /dev/null +++ b/src/Filter.h @@ -0,0 +1,30 @@ +/* + * Filter.h + * + * Created on: 23.02.2016 + * Author: jedi + */ + +#ifndef FILTER_H_ +#define FILTER_H_ + +#include "Packet.h" + +class Filter { +public: + Filter(); + Filter(Packet::OpCode); + Filter(macAddr); + Filter opcode(Packet::OpCode); + Filter mac(macAddr); + Filter tokenid(short); + bool pass(const Packet) const; + bool operator<(const Filter) const; +private: + Packet::OpCode oc = Packet::NONE; + macAddr switchMac = { 0, 0, 0, 0, 0, 0 }; + short tokenId = -1; + short fragmentOffset = -1; +}; + +#endif /* FILTER_H_ */ diff --git a/src/Switch-Cmd.cpp b/src/Switch-Cmd.cpp new file mode 100644 index 0000000..916b69e --- /dev/null +++ b/src/Switch-Cmd.cpp @@ -0,0 +1,31 @@ +/* + * Switch.cpp + * + * Created on: 29.09.2015 + * Author: jdi + */ + +#include +#include "Types.h" +#include "Switch.h" +#include "Constant.h" +#include "table.h" + +using namespace smrtlink; +using namespace std; + +int Switch::set(pair str) { + + return 0; +} + +std::string Switch::get(std::string str) { + std::string ret; + switch (caseArg(str.c_str())) { + case caseArg("ip"): + ret = "0.0.0.0"; + break; + } + return ret; +} + diff --git a/src/lookup/input.lst b/src/lookup/input.lst new file mode 100644 index 0000000..5c48cff --- /dev/null +++ b/src/lookup/input.lst @@ -0,0 +1,38 @@ +LOOKUP_SET(type, TYPE, STRING) //+string +LOOKUP_SET(mac, MAC, HEX) //+byte[6] +LOOKUP_SET(firmware,FIRMWARE_VERSION, STRING) +LOOKUP_SET(hardware,HARDWARE_VERSION, STRING) + + +LOOKUP_SET(HOSTNAME,host, 2, STRING) //+string +LOOKUP_SET(IP_ADDR,ip, 4, DEC) //+byte[4] +LOOKUP_SET(IP_MASK,mask, 5, DEC) //+byte[4] +LOOKUP_SET(GATEWAY,gateway, 6, DEC) //+byte[4] +LOOKUP_SET(DHCP_ENABLED,dhcp, 9, BOOL) //+bool byte + +LOOKUP_SET(PORT_VLAN_FOOOOO, 2101,2101, HEX) + +LOOKUP_SET(PORTS, ports, 10, DEC) //+byte, maybe number of ports + +LOOKUP_SET(IGMP_SNOOPING, igmp, 4352, HEX) //??? +LOOKUP_SET(PORTS_SETTINGS, psetings, 4096, HEX) //+per port +LOOKUP_SET(PORT_TRUNK, trunk, 4608, HEX) //byte[5] last byte bitmask?? + +LOOKUP_SET(MTU_VLAN, 8192,8192, HEX) //byte[2] first byte bool,second byte port id +LOOKUP_SET(PORT_VLAN_ENABLED, 8448,8448, BOOL) //open page +LOOKUP_SET(PORT_VLAN, 8449,8449, HEX) +LOOKUP_SET(PORT_VLAN_MAX, 8450,8450, DEC) +LOOKUP_SET(VLAN_ENABLED, 8704, 8704, BOOL) //+bool byte +LOOKUP_SET(VLAN, 8705,8705, HEX) //+one set per vlan +LOOKUP_SET(VLAN_PVID, 8706,8706, HEX) //+per port +LOOKUP_SET(VLAN_FOOOO, 8707,8707, DEC) //???? + +LOOKUP_SET(QOS_BASIC_ENABLED, 12288,12288, BOOL) //+bool = QoS Mod +LOOKUP_SET(QOS_BASIC, 12289,12289, HEX) //+per port ??? +LOOKUP_SET(BW_CONTROL_INGRESS, 12544,12544, HEX) //+per port ??? +LOOKUP_SET(BW_CONTROL_EGRESS, 12545,12545, HEX) //+per port ??? +LOOKUP_SET(STORM_CONTROL, 12800,12800, HEX) //+per port ??? +LOOKUP_SET(PORT_MIRROR, 16640,16640, HEX) //byte[10] second byte port id??? +LOOKUP_SET(PORT_STATISTICS, 16384,16384, HEX) //+per port ??? +LOOKUP_SET(CABLE_TEST, 16896,16896, HEX) //+per port ??? +LOOKUP_SET(LOOP_PREVENTION, 17152,17152, BOOL) //+bool byte \ No newline at end of file