1.2
This commit is contained in:
parent
0f01d375db
commit
86437239e4
4 changed files with 152 additions and 0 deletions
53
src/Filter.cpp
Normal file
53
src/Filter.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
30
src/Filter.h
Normal file
30
src/Filter.h
Normal file
|
@ -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_ */
|
31
src/Switch-Cmd.cpp
Normal file
31
src/Switch-Cmd.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Switch.cpp
|
||||||
|
*
|
||||||
|
* Created on: 29.09.2015
|
||||||
|
* Author: jdi
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "Types.h"
|
||||||
|
#include "Switch.h"
|
||||||
|
#include "Constant.h"
|
||||||
|
#include "table.h"
|
||||||
|
|
||||||
|
using namespace smrtlink;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int Switch::set(pair<string, string> 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;
|
||||||
|
}
|
||||||
|
|
38
src/lookup/input.lst
Normal file
38
src/lookup/input.lst
Normal file
|
@ -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
|
Loading…
Reference in a new issue