When the packet length is greater than the IP expected length, the padding data at the end of the frame will be trimmed.

This commit is contained in:
luwenpeng
2024-05-24 19:10:33 +08:00
parent 94fc1af6bd
commit 54385ed08b
6 changed files with 264 additions and 45 deletions

View File

@@ -670,7 +670,7 @@ TEST(IPV6_REASSEMBLE, NORMAL)
0, 0, 0, 0, 0, 0); // ip6: nospace, overlap, many frag, invalid length, dup first frag, dup last frag
// check packet
// packet_print(new_pkt);
// packet_print_str(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 40 /* IPv6 */ + 8 /* UDP */ + 5379 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);
@@ -841,7 +841,7 @@ TEST(IPV6_REASSEMBLE, DUP_FIRST_FRAG)
0, 0, 0, 0, 1, 0); // ip6: nospace, overlap, many frag, invalid length, dup first frag, dup last frag
// check packet
// packet_print(new_pkt);
// packet_print_str(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 40 /* IPv6 */ + 8 /* UDP */ + 5379 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);
@@ -961,7 +961,7 @@ TEST(IPV6_REASSEMBLE, DUP_LAST_FRAG)
0, 0, 0, 0, 0, 1); // ip6: nospace, overlap, many frag, invalid length, dup first frag, dup last frag
// check packet
// packet_print(new_pkt);
// packet_print_str(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 40 /* IPv6 */ + 8 /* UDP */ + 5379 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);