refactor: packet dump utils

This commit is contained in:
luwenpeng
2024-08-13 10:24:26 +08:00
parent ff8630e436
commit 03468d55be
13 changed files with 200 additions and 186 deletions

View File

@@ -239,7 +239,7 @@ TEST(IPV4_REASSEMBLE, PADDING_ORDER)
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_dump_stdio(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 20 /* IPv4 */ + 20 /* TCP */ + 28 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);
@@ -334,7 +334,7 @@ TEST(IPV4_REASSEMBLE, PADDING_UNORDER)
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_dump_stdio(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 20 /* IPv4 */ + 20 /* TCP */ + 28 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);
@@ -494,7 +494,7 @@ TEST(IPV4_REASSEMBLE, DUP_FIRST_FRAG)
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_dump_stdio(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 20 /* IPv4 */ + 20 /* TCP */ + 28 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);
@@ -601,7 +601,7 @@ TEST(IPV4_REASSEMBLE, DUP_LAST_FRAG)
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_dump_stdio(new_pkt);
EXPECT_TRUE(new_pkt->data_len == 14 /* ETH */ + 20 /* IPv4 */ + 20 /* TCP */ + 28 /* DATA */);
EXPECT_TRUE(new_pkt->data_len == sizeof(expect));
EXPECT_TRUE(memcmp(new_pkt->data_ptr, expect, new_pkt->data_len) == 0);

View File

@@ -674,7 +674,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_dump_stdio(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);
@@ -852,7 +852,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_dump_stdio(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);
@@ -977,7 +977,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_dump_stdio(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);

View File

@@ -13,6 +13,7 @@ extern "C"
#include "ip6_utils.h"
#include "ip_reassembly.h"
#include "packet_def.h"
#include "packet_dump.h"
#include "packet_utils.h"
#include "packet_parse.h"
#include "packet_layer.h"