From 45434738214e146671fbe5a23a03b52799469b09 Mon Sep 17 00:00:00 2001 From: /jedi/ Date: Thu, 21 Jan 2016 05:19:26 +0100 Subject: [PATCH] merging dev --- src/Program.cpp | 128 ------------------------------------------------ src/Switch.cpp | 50 ------------------- 2 files changed, 178 deletions(-) diff --git a/src/Program.cpp b/src/Program.cpp index f7d161a..636ed70 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -30,62 +30,6 @@ int printHeader(Packet p) { } int printPacket(Packet p) { -<<<<<<< HEAD - if (options.flags & FLAG_HEX) { - std::cout << "Received Payload:\n\t" << p.getBody() << "\n"; - } else { - for (dataset d : p.getPayload()) { - auto lookup = - (options.flags & FLAG_REVERSE) ? snd_lookup : rcv_lookup; - if (lookup.exists(d.type)) { - const table::set *s = lookup.get(d.type); - if (d.len > 0) { - switch (s->format) { - case table::STRING: - std::cout << "+\t" << s->name << " = " << &d.value[0] - << "\n"; - break; - case table::BOOL: - std::cout << "+\t" << s->name << " = " << (d.value[0]?"YES":"NO") - << "\n"; - break; - case table::HEX: - std::cout << "+\t" << s->name << " = " << d.value - << "\n"; - break; - case table::DEC: - std::cout << "+\t" << s->name << " = "; - if (d.value.size() > 0) - std::cout << std::dec << (unsigned) d.value[0]; - for (unsigned i = 1; i < d.value.size(); i++) - std::cout << std::dec << "." << (unsigned) d.value[i]; - std::cout << "\n"; - break; - case table::ACTION: - std::cout << "Error:" << s->name - << " is marked as 'action' but carries payload." - << d.value << "\n"; - break; - default: - std::cout << "+\t" << s->name << " = " << d.value - << "\n"; - break; - } - } else { //empty - std::cout << std::dec << ">\t" << s->name << "\n"; - } - } else { //unknown id - if (d.len > 0) { - std::cout << "##\t" << d.type << ":\n\t"; - std::cout << std::hex << d.value << std::dec << "\n"; - } else { //empty - std::cout << "#>\t" << d.type << "\n"; - } - } - } - } - return 0; -======= if (options.flags & FLAG_HEX) { std::cout << "Received Payload:\n\t" << p.getBody() << "\n"; } else { @@ -141,7 +85,6 @@ int printPacket(Packet p) { } } return 0; ->>>>>>> 3ef2da7b7a10c8b34f20c452acc0f8d0ffc17db5 } int Program::list() { @@ -214,71 +157,6 @@ int Program::setProperty() { } int Program::getProperty() { -<<<<<<< HEAD - std::cout << "List:\n"; - Packet p = Packet(Packet::DISCOVERY); - p.setHostMac(host.getMac()); - p.setPayload( { }); - bytes b = p.getBytes(); - p.encode(b); - auto s = sock; - try { - sock->setHostIp(host.getIp()); - sock->init(DST_PORT, SRC_PORT); - sock->callback = - [this](Packet a) { - auto s = sock; - datasets d =a.getPayload(); - Switch sw = Switch(); - sw.parse(d); - std::cout <<"Devices:\n\t"<callback = - [this](Packet a) { - auto s = sock; - datasets d =a.getPayload(); - Switch sw = Switch(); - sw.parse(d); - Packet p = Packet(Packet::SET); - p.setSwitchMac(a.getSwitchMac()); - p.setHostMac(host.getMac()); - datasets t = { - {snd_lookup["login_user"], (short)(options.user.length()), options.user}, - {snd_lookup["login_password"], (short)(options.password.length()), options.password} - }; - std::cout<callback = - [this](Packet a) { - std::cout << a.opCodeToString() << "\n"; - printHeader(a); - printPacket(a); - return 0; - }; - sock->send(c); - return 0; - }; - - sock->send(c); - return 0; - }; - sock->send(b); - io_service->run(); - } catch (std::exception& e) { - std::cerr << "Exception: " << e.what() << "\n"; - } - return 1; -======= std::cout << "List:\n"; Packet p = Packet(Packet::DISCOVERY); p.setHostMac(host.getMac()); @@ -348,7 +226,6 @@ int Program::getProperty() { std::cerr << "Exception: " << e.what() << "\n"; } return 1; ->>>>>>> 3ef2da7b7a10c8b34f20c452acc0f8d0ffc17db5 } int Program::save() { @@ -389,11 +266,6 @@ int Program::ping(std::function) { return 0; } -int Program::ping(std::function){ - - return 0; -} - void Program::init() { if (options.interface.compare("") == 0) options.interface = host.getIface(); diff --git a/src/Switch.cpp b/src/Switch.cpp index baf5c91..89419a8 100644 --- a/src/Switch.cpp +++ b/src/Switch.cpp @@ -8,11 +8,7 @@ #include #include "Types.h" #include "Switch.h" -<<<<<<< HEAD -#include "Lookup.h" -======= #include "lookup.h" ->>>>>>> 3ef2da7b7a10c8b34f20c452acc0f8d0ffc17db5 #include "Constant.h" #include "table.h" @@ -24,51 +20,6 @@ int Switch::parse(datasets arr) { } int Switch::parse(dataset d) { -<<<<<<< HEAD - auto lookup = (options.flags & FLAG_REVERSE) ? snd_lookup : rcv_lookup; - std::string id = lookup.exists(d.type)?lookup[d.type]:"unknown"; - if (d.type == lookup["type"]) { - device.type = d.value; - } - else if (id == "mac") { - device.mac = d.value; - } - else if (d.type == lookup["firmware_version"]) { - device.firmware_version = d.value; - } - else if (id == "hardware_version") { - device.hardware_version = d.value; - } - else if (id == "ports") { - device.ports = d.value[0]; - } - else if (id == "hostname") { - settings.hostname = d.value; - } - else if (id == "ip_addr") { - settings.ip_addr = d.value; - } - else if (id == "ip_mask") { - settings.ip_mask = d.value; - } - else if (id == "gateway") { - settings.gateway = d.value; - } - else if (id == "dhcp_enabled") { - settings.dhcp = d.value[0]; - } - else if (id == "loop_prevention") { - settings.loop_prevention = d.value[0]; - } - else if (id == "qos_basic_enabled") { - settings.qos_enabled = d.value[0]; - } - else if (id == "vlan_enabled") { - settings.vlan_enabled = d.value[0]; - } - return 0; -} -======= switch (d.type) { case RCV_TYPE: device.type = d.value; @@ -113,4 +64,3 @@ int Switch::parse(dataset d) { return 0; } ->>>>>>> 3ef2da7b7a10c8b34f20c452acc0f8d0ffc17db5