diff --git a/src/dot1q.cpp b/src/dot1q.cpp index 1b7a2b8..574521d 100644 --- a/src/dot1q.cpp +++ b/src/dot1q.cpp @@ -121,6 +121,9 @@ void Dot1Q::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU *) payload_type(static_cast(flag)); } } + else { + payload_type(0); + } stream.write(header_); // Skip inner PDU size diff --git a/tests/src/dot1q.cpp b/tests/src/dot1q.cpp index e6ac20c..ae8e519 100644 --- a/tests/src/dot1q.cpp +++ b/tests/src/dot1q.cpp @@ -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().inner_pdu(0); + + PDU::serialization_type buffer = eth1.serialize(); + EthernetII eth2(&buffer[0], buffer.size()); + EXPECT_EQ(eth1.size(), eth2.size()); +}