Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jedi
smrtlink
Commits
73df3e05
Commit
73df3e05
authored
Nov 02, 2015
by
jedi
Browse files
packet can contain multiple datasets of same type
parent
ed876483
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Lookup.h
View file @
73df3e05
...
...
@@ -16,12 +16,14 @@ static table rcv_lookup = { { 1, table::STRING, "type" }, //string
{
7
,
table
::
STRING
,
"firmware_version"
},
{
8
,
table
::
STRING
,
"hardware_version"
},
{
9
,
table
::
DEC
,
"dhcp"
},
//bool byte
{
1
9
,
table
::
DEC
,
"ports"
},
//byte, maybe number of ports
{
1
0
,
table
::
DEC
,
"ports
???
"
},
//byte, maybe number of ports
{
4352
,
table
::
HEX
,
"igmp_snooping"
},
//switching
{
4096
,
table
::
HEX
,
"port_settings"
},
//switching
{
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
{
12289
,
table
::
HEX
,
"QoS Basic 2"
},
//QoS
{
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
{
2
,
table
::
HEX
,
"system_info"
},
//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
{
513
,
table
::
STRING
,
"new_user"
},
//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
{
8449
,
table
::
HEX
,
"port_vlan1"
},
//???
{
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"
},
//???
{
8706
,
table
::
HEX
,
"802.1q vlan pvid"
},
//????
...
...
src/Packet.cpp
View file @
73df3e05
...
...
@@ -33,7 +33,7 @@ void Packet::printHeader() {
bytes
Packet
::
getBytes
()
{
int
i
=
0
;
for
(
auto
d
:
payload
)
push
(
body
,
i
,
d
.
second
);
push
(
body
,
i
,
d
);
push
(
body
,
i
,
(
int
)
PACKET_END
);
i
=
0
;
push
(
head
,
i
,
version
);
...
...
@@ -79,7 +79,7 @@ void Packet::parse(bytes data) {
pull
(
body
,
i
,
d
.
type
);
pull
(
body
,
i
,
d
.
len
);
pull
(
body
,
i
,
d
.
value
,
d
.
len
);
payload
=
d
;
payload
.
push_back
(
d
)
;
}
}
...
...
src/Program.cpp
View file @
73df3e05
...
...
@@ -32,8 +32,7 @@ int printPacket(Packet p) {
if
(
options
.
flags
&
FLAG_HEX
)
{
std
::
cout
<<
"Received Payload:
\n\t
"
<<
p
.
getBody
()
<<
"
\n
"
;
}
else
{
for
(
auto
a
:
p
.
getPayload
())
{
dataset
d
=
a
.
second
;
for
(
dataset
d
:
p
.
getPayload
())
{
auto
lookup
=
(
options
.
flags
&
FLAG_REVERSE
)
?
snd_lookup
:
rcv_lookup
;
if
(
lookup
.
exists
(
d
.
type
))
{
...
...
src/Switch.cpp
View file @
73df3e05
...
...
@@ -13,8 +13,8 @@
#include
"Options.h"
int
Switch
::
parse
(
datasets
arr
)
{
for
(
auto
a
:
arr
)
{
parse
(
a
.
second
);
for
(
dataset
a
:
arr
)
{
parse
(
a
);
}
return
0
;
}
...
...
src/datasets.h
View file @
73df3e05
...
...
@@ -17,13 +17,14 @@ struct dataset {
bytes
value
;
};
class
datasets
:
public
std
::
map
<
short
,
dataset
>
{
class
datasets
:
public
std
::
vector
<
dataset
>
{
public:
datasets
(){};
datasets
(
std
::
initializer_list
<
dataset
>
s
)
{
for
(
dataset
b
:
s
)
{
(
*
this
)[
b
.
type
]
=
b
;
//(*this)[b.type]=b;
push_back
(
b
);
}
}
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment