srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_summarize.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_summarize.cpp')
-rw-r--r--tests/test_summarize.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/test_summarize.cpp b/tests/test_summarize.cpp
index baf4ed4..0cb0f98 100644
--- a/tests/test_summarize.cpp
+++ b/tests/test_summarize.cpp
@@ -166,10 +166,30 @@ TEST_CASE("summarize_packet reports a truncated Ethernet frame without decoding
TEST_CASE("summarize_packet stops after the Ethernet line for an unhandled ethertype") {
std::vector<unsigned char> bytes = {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
- 0x88, 0xCC, // LLDP, not IPv4/IPv6/ARP
+ 0x80, 0x35, // RARP - real ethertype, just not one this project decodes
};
auto line = packeteer::summarize_packet(bytes, DLT_EN10MB);
- CHECK(line == "ETH aa:bb:cc:dd:ee:ff -> 11:22:33:44:55:66 ethertype=0x88cc");
+ CHECK(line == "ETH aa:bb:cc:dd:ee:ff -> 11:22:33:44:55:66 ethertype=0x8035");
+}
+
+TEST_CASE("summarize_packet decodes an LLDP frame end to end") {
+ std::vector<unsigned char> bytes = {
+ 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E, // dst: LLDP multicast
+ 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, // src mac
+ 0x88, 0xCC, // ethertype: LLDP
+ // Chassis ID TLV: subtype=4 (MAC), value=aa:bb:cc:dd:ee:ff
+ 0x02, 0x07, 4, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
+ // Port ID TLV: subtype=7 (locally assigned), value="eth0"
+ 0x04, 0x05, 7, 'e', 't', 'h', '0',
+ // TTL TLV: 120 seconds
+ 0x06, 0x02, 0x00, 0x78,
+ // End of LLDPDU
+ 0x00, 0x00,
+ };
+ auto line = packeteer::summarize_packet(bytes, DLT_EN10MB);
+ CHECK(line ==
+ "ETH aa:bb:cc:dd:ee:ff -> 01:80:c2:00:00:0e ethertype=0x88cc | "
+ "LLDP chassis=aa:bb:cc:dd:ee:ff port=eth0 ttl=120");
}
TEST_CASE("summarize_packet decodes an ARP request end to end") {