some minor fixes
This commit is contained in:
parent
5b61676236
commit
06351d87d1
8 changed files with 47 additions and 53 deletions
6
Makefile
6
Makefile
|
@ -15,12 +15,14 @@ $(BUILDDIR):
|
|||
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $^ -o $@ -lboost_filesystem -lboost_system
|
||||
$(CC) $^ -o $(BUILDDIR)/$@ -lboost_filesystem -lboost_system
|
||||
|
||||
|
||||
$(OBJECTS): $(BUILDDIR)/%.o : $(SOURCEDIR)/%.cpp
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
install: bin/$(TARGET)
|
||||
install -m 0755 bin/$(TARGET) $(prefix)/bin
|
||||
|
||||
clean:
|
||||
rm -f $(BUILDDIR)/*o $(TARGET)
|
||||
rm -f $(BUILDDIR)/*
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "table.h"
|
||||
|
||||
const static table rcv_lookup = { //
|
||||
static table rcv_lookup = { //
|
||||
{ 1, table::STRING, "type" }, //+string
|
||||
{ 2, table::STRING, "hostname" }, //+string
|
||||
{ 3, table::HEX, "mac" }, //+byte[6]
|
||||
|
@ -44,7 +44,7 @@ const static table rcv_lookup = { //
|
|||
//{0000," "},
|
||||
};
|
||||
|
||||
const static table snd_lookup = {
|
||||
static table snd_lookup = {
|
||||
|
||||
// TODO find out if id is unique in response
|
||||
{ 2, table::HEX, "system_info" }, //page sysinfo
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "Switch.h"
|
||||
#include "Packet.h"
|
||||
#include "Lookup.h"
|
||||
#include "table.h"
|
||||
|
||||
int printHeader(Packet p) {
|
||||
if (options.flags & FLAG_HEADER) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "Lookup.h"
|
||||
#include "jsonNode.h"
|
||||
#include "Options.h"
|
||||
#include "table.h"
|
||||
|
||||
int Switch::parse(datasets arr) {
|
||||
for (dataset a : arr) {
|
||||
|
@ -21,55 +22,44 @@ int Switch::parse(datasets arr) {
|
|||
|
||||
int Switch::parse(dataset d) {
|
||||
auto lookup = (options.flags & FLAG_REVERSE) ? snd_lookup : rcv_lookup;
|
||||
switch (d.type) {
|
||||
case lookup["type"]:
|
||||
if (d.type == lookup["type"]) {
|
||||
device.type = d.value;
|
||||
return 0;
|
||||
case lookup["mac"]:
|
||||
}
|
||||
if (d.type == lookup["mac"]) {
|
||||
device.mac = d.value;
|
||||
return 0;
|
||||
case lookup["ip_addr"]:
|
||||
}
|
||||
if (d.type == lookup["firmware_version"]) {
|
||||
device.firmware_version = d.value;
|
||||
return 0;
|
||||
case lookup["ip_mask"]:
|
||||
device.firmware_version = d.value;
|
||||
return 0;
|
||||
case lookup["gateway"]:
|
||||
device.firmware_version = d.value;
|
||||
return 0;
|
||||
case lookup["firmware_version"]:
|
||||
device.firmware_version = d.value;
|
||||
return 0;
|
||||
case lookup["hardware_version"]:
|
||||
}
|
||||
if (d.type == lookup["hardware_version"]) {
|
||||
device.hardware_version = d.value;
|
||||
return 0;
|
||||
case lookup["ports"]:
|
||||
}
|
||||
if (d.type == lookup["ports"]) {
|
||||
device.ports = d.value[0];
|
||||
return 0;
|
||||
case lookup["hostname"]:
|
||||
}
|
||||
if (d.type == lookup["hostname"]) {
|
||||
settings.hostname = d.value;
|
||||
return 0;
|
||||
case lookup["ip_addr"]:
|
||||
}
|
||||
if (d.type == lookup["ip_addr"]) {
|
||||
settings.ip_addr = d.value;
|
||||
return 0;
|
||||
case lookup["ip_mask"]:
|
||||
}
|
||||
if (d.type == lookup["ip_mask"]) {
|
||||
settings.ip_mask = d.value;
|
||||
return 0;
|
||||
case lookup["gateway"]:
|
||||
}
|
||||
if (d.type == lookup["gateway"]) {
|
||||
settings.gateway = d.value;
|
||||
return 0;
|
||||
case lookup["dhcp"]:
|
||||
}
|
||||
if (d.type == lookup["dhcp"]) {
|
||||
settings.dhcp = d.value[0];
|
||||
return 0;
|
||||
case lookup["loop_prevention"]:
|
||||
}
|
||||
if (d.type == lookup["loop_prevention"]) {
|
||||
settings.loop_prevention = d.value[0];
|
||||
return 0;
|
||||
case lookup["qos_basic_enabled"]:
|
||||
}
|
||||
if (d.type == lookup["qos_basic_enabled"]) {
|
||||
settings.qos_enabled = d.value[0];
|
||||
return 0;
|
||||
case lookup["vlan_enabled"]:
|
||||
}
|
||||
if (d.type == lookup["vlan_enabled"]) {
|
||||
settings.vlan_enabled = d.value[0];
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ struct vlan {
|
|||
struct port {
|
||||
byte id;
|
||||
byte status;
|
||||
int vlan_pvid;
|
||||
int pvid;
|
||||
//port_settings
|
||||
//qos_basic
|
||||
//bandwidth_control_1
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "bytes.h"
|
||||
#include "datasets.h"
|
||||
#include "table.h"
|
||||
|
||||
class macAddr: public std::array<byte, 6> {
|
||||
public:
|
||||
|
|
|
@ -18,10 +18,10 @@ table::table(std::initializer_list<set> l) {
|
|||
i++;
|
||||
}
|
||||
}
|
||||
constexpr const short& table::operator[](std::string s) {
|
||||
short table::operator[](std::string s){
|
||||
return this->right[s]->type;
|
||||
}
|
||||
constexpr const std::string& table::operator[](short n) {
|
||||
std::string table::operator[](short n){
|
||||
return this->left[n]->name;
|
||||
}
|
||||
bool table::exists(std::string s){
|
||||
|
|
12
src/table.h
12
src/table.h
|
@ -20,16 +20,16 @@ public:
|
|||
std::string name;
|
||||
};
|
||||
table(std::initializer_list<set> l);
|
||||
const short& operator[](std::string);
|
||||
const std::string& operator[](short);
|
||||
const set* get(std::string);
|
||||
const set* get(short);
|
||||
short operator[](std::string);
|
||||
std::string operator[](short);
|
||||
bool exists(std::string);
|
||||
bool exists(short);
|
||||
const set* get(std::string);
|
||||
const set* get(short);
|
||||
private:
|
||||
std::vector<set> data;
|
||||
const std::map<short, set*> left;
|
||||
const std::map<std::string, set*> right;
|
||||
std::map<short, set*> left;
|
||||
std::map<std::string, set*> right;
|
||||
};
|
||||
|
||||
#endif /* LOOKUPTABLE_H_ */
|
||||
|
|
Loading…
Reference in a new issue