packet can contain multiple datasets of same type
This commit is contained in:
parent
ed87648312
commit
73df3e0528
5 changed files with 15 additions and 13 deletions
12
src/Lookup.h
12
src/Lookup.h
|
|
@ -16,12 +16,14 @@ static table rcv_lookup = { { 1, table::STRING, "type" }, //string
|
||||||
{ 7, table::STRING, "firmware_version" },
|
{ 7, table::STRING, "firmware_version" },
|
||||||
{ 8, table::STRING, "hardware_version" },
|
{ 8, table::STRING, "hardware_version" },
|
||||||
{ 9, table::DEC, "dhcp" }, //bool byte
|
{ 9, table::DEC, "dhcp" }, //bool byte
|
||||||
{ 19, table::DEC, "ports" }, //byte, maybe number of ports
|
{ 10, table::DEC, "ports???" }, //byte, maybe number of ports
|
||||||
{ 4352, table::HEX, "igmp_snooping" }, //switching
|
{ 4352, table::HEX, "igmp_snooping" }, //switching
|
||||||
{ 4096, table::HEX, "port_settings" }, //switching
|
{ 4096, table::HEX, "port_settings" }, //switching
|
||||||
{ 4608, table::HEX, "port_trunk" }, //byte[5] last byte bitmask??
|
{ 4608, table::HEX, "port_trunk" }, //byte[5] last byte bitmask??
|
||||||
{ 8704, table::HEX, "802.1q vlan" }, //???
|
{ 8192, table::HEX, "mtu_vlan" }, //byte[2] first byte bool,second byte port id
|
||||||
|
{ 8704, table::HEX, "802.1q vlan enabled" }, //bool byte
|
||||||
|
{ 8705, table::HEX, "802.1q vlan" }, //one set per vlan
|
||||||
|
{ 8706, table::HEX, "802.1q vlan pvid" }, //????
|
||||||
{ 12288, table::HEX, "QoS Basic 1" }, //bool = QoS Mod
|
{ 12288, table::HEX, "QoS Basic 1" }, //bool = QoS Mod
|
||||||
{ 12289, table::HEX, "QoS Basic 2" }, //QoS
|
{ 12289, table::HEX, "QoS Basic 2" }, //QoS
|
||||||
{ 16640, table::HEX, "port_mirror" }, //byte[10] second byte port id??
|
{ 16640, table::HEX, "port_mirror" }, //byte[10] second byte port id??
|
||||||
|
|
@ -35,7 +37,7 @@ static table snd_lookup = {
|
||||||
// TODO find out if id is unique in response
|
// TODO find out if id is unique in response
|
||||||
{ 2, table::HEX, "system_info" }, //page sysinfo
|
{ 2, table::HEX, "system_info" }, //page sysinfo
|
||||||
{ 9, table::HEX, "ip_config" }, //page sysinfo
|
{ 9, table::HEX, "ip_config" }, //page sysinfo
|
||||||
{ 10, table::HEX, "??? - 10" }, //after login
|
{ 10, table::HEX, "ports???" }, //after login
|
||||||
{ 512, table::STRING, "login_user" }, //string
|
{ 512, table::STRING, "login_user" }, //string
|
||||||
{ 513, table::STRING, "new_user" }, //string
|
{ 513, table::STRING, "new_user" }, //string
|
||||||
{ 514, table::STRING, "login_password" }, //string
|
{ 514, table::STRING, "login_password" }, //string
|
||||||
|
|
@ -50,7 +52,7 @@ static table snd_lookup = {
|
||||||
{ 8192, table::HEX, "mtu_vlan" }, //byte[2] first byte bool, second byte port id
|
{ 8192, table::HEX, "mtu_vlan" }, //byte[2] first byte bool, second byte port id
|
||||||
{ 8449, table::HEX, "port_vlan1" }, //???
|
{ 8449, table::HEX, "port_vlan1" }, //???
|
||||||
{ 8448, table::HEX, "port_vlan2" }, //open page
|
{ 8448, table::HEX, "port_vlan2" }, //open page
|
||||||
{ 8704, table::HEX, "802.1q vlan" }, //??? get vlan / set status
|
{ 8704, table::HEX, "802.1q vlan enabled" }, //??? get vlan / set status
|
||||||
{ 8705, table::HEX, "802.1q vlan" }, //???
|
{ 8705, table::HEX, "802.1q vlan" }, //???
|
||||||
{ 8706, table::HEX, "802.1q vlan pvid" }, //????
|
{ 8706, table::HEX, "802.1q vlan pvid" }, //????
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void Packet::printHeader() {
|
||||||
bytes Packet::getBytes() {
|
bytes Packet::getBytes() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto d : payload)
|
for (auto d : payload)
|
||||||
push(body, i, d.second);
|
push(body, i, d);
|
||||||
push(body, i, (int) PACKET_END);
|
push(body, i, (int) PACKET_END);
|
||||||
i = 0;
|
i = 0;
|
||||||
push(head, i, version);
|
push(head, i, version);
|
||||||
|
|
@ -79,7 +79,7 @@ void Packet::parse(bytes data) {
|
||||||
pull(body, i, d.type);
|
pull(body, i, d.type);
|
||||||
pull(body, i, d.len);
|
pull(body, i, d.len);
|
||||||
pull(body, i, d.value, d.len);
|
pull(body, i, d.value, d.len);
|
||||||
payload = d;
|
payload.push_back(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ int printPacket(Packet p) {
|
||||||
if (options.flags & FLAG_HEX) {
|
if (options.flags & FLAG_HEX) {
|
||||||
std::cout << "Received Payload:\n\t" << p.getBody() << "\n";
|
std::cout << "Received Payload:\n\t" << p.getBody() << "\n";
|
||||||
} else {
|
} else {
|
||||||
for (auto a : p.getPayload()) {
|
for (dataset d : p.getPayload()) {
|
||||||
dataset d = a.second;
|
|
||||||
auto lookup =
|
auto lookup =
|
||||||
(options.flags & FLAG_REVERSE) ? snd_lookup : rcv_lookup;
|
(options.flags & FLAG_REVERSE) ? snd_lookup : rcv_lookup;
|
||||||
if (lookup.exists(d.type)) {
|
if (lookup.exists(d.type)) {
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
int Switch::parse(datasets arr) {
|
int Switch::parse(datasets arr) {
|
||||||
for (auto a : arr) {
|
for (dataset a : arr) {
|
||||||
parse(a.second);
|
parse(a);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,14 @@ struct dataset {
|
||||||
bytes value;
|
bytes value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class datasets : public std::map<short, dataset> {
|
class datasets : public std::vector<dataset> {
|
||||||
public:
|
public:
|
||||||
datasets(){};
|
datasets(){};
|
||||||
datasets(std::initializer_list<dataset> s)
|
datasets(std::initializer_list<dataset> s)
|
||||||
{
|
{
|
||||||
for (dataset b : s) {
|
for (dataset b : s) {
|
||||||
(*this)[b.type]=b;
|
//(*this)[b.type]=b;
|
||||||
|
push_back(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue