1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Set payload type to 0 if no inner_pdu on Dot1Q

This commit is contained in:
Matias Fontanini
2016-09-29 07:27:27 -07:00
parent 8dcfd6aae0
commit 54ce11629c
2 changed files with 13 additions and 0 deletions

View File

@@ -121,6 +121,9 @@ void Dot1Q::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU *)
payload_type(static_cast<uint16_t>(flag));
}
}
else {
payload_type(0);
}
stream.write(header_);
// Skip inner PDU size

View File

@@ -93,3 +93,13 @@ TEST_F(Dot1QTest, QinQ) {
EXPECT_EQ(10, q1.id());
EXPECT_EQ(42, q2.id());
}
TEST_F(Dot1QTest, SerializeAfterInnerPduRemoved) {
EthernetII eth1 = EthernetII() / Dot1Q() / IP();
eth1.serialize();
eth1.rfind_pdu<Dot1Q>().inner_pdu(0);
PDU::serialization_type buffer = eth1.serialize();
EthernetII eth2(&buffer[0], buffer.size());
EXPECT_EQ(eth1.size(), eth2.size());
}