refactor: rename the directory infra/packet_parser to infra/paket_manager
This commit is contained in:
77
infra/packet_manager/test/CMakeLists.txt
Normal file
77
infra/packet_manager/test/CMakeLists.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
add_executable(gtest_tunnel gtest_tunnel.cpp)
|
||||
target_link_libraries(gtest_tunnel packet_manager gtest)
|
||||
|
||||
add_executable(gtest_udp_utils gtest_udp_utils.cpp)
|
||||
target_link_libraries(gtest_udp_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_tcp_utils gtest_tcp_utils.cpp)
|
||||
target_link_libraries(gtest_tcp_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_ip4_utils gtest_ip4_utils.cpp)
|
||||
target_link_libraries(gtest_ip4_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_ip6_utils gtest_ip6_utils.cpp)
|
||||
target_link_libraries(gtest_ip6_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_mpls_utils gtest_mpls_utils.cpp)
|
||||
target_link_libraries(gtest_mpls_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_eth_utils gtest_eth_utils.cpp)
|
||||
target_link_libraries(gtest_eth_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_vlan_utils gtest_vlan_utils.cpp)
|
||||
target_link_libraries(gtest_vlan_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_vxlan_utils gtest_vxlan_utils.cpp)
|
||||
target_link_libraries(gtest_vxlan_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_gre0_utils gtest_gre0_utils.cpp)
|
||||
target_link_libraries(gtest_gre0_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_gre1_utils gtest_gre1_utils.cpp)
|
||||
target_link_libraries(gtest_gre1_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_l2tp_utils gtest_l2tp_utils.cpp)
|
||||
target_link_libraries(gtest_l2tp_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_gtp1_utils gtest_gtp1_utils.cpp)
|
||||
target_link_libraries(gtest_gtp1_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_gtp2_utils gtest_gtp2_utils.cpp)
|
||||
target_link_libraries(gtest_gtp2_utils packet_manager gtest)
|
||||
|
||||
add_executable(gtest_packet_frag gtest_packet_frag.cpp)
|
||||
target_link_libraries(gtest_packet_frag packet_manager gtest)
|
||||
|
||||
add_executable(gtest_packet_parser gtest_packet_parser.cpp)
|
||||
target_link_libraries(gtest_packet_parser packet_manager gtest)
|
||||
|
||||
add_executable(gtest_packet_builder gtest_packet_builder.cpp)
|
||||
target_link_libraries(gtest_packet_builder packet_manager gtest)
|
||||
|
||||
add_executable(gtest_packet_filter gtest_packet_filter.cpp)
|
||||
target_link_libraries(gtest_packet_filter packet_manager gtest)
|
||||
|
||||
add_executable(gtest_packet_ldbc gtest_packet_ldbc.cpp)
|
||||
target_link_libraries(gtest_packet_ldbc packet_manager gtest)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(gtest_tunnel)
|
||||
gtest_discover_tests(gtest_udp_utils)
|
||||
gtest_discover_tests(gtest_tcp_utils)
|
||||
gtest_discover_tests(gtest_ip4_utils)
|
||||
gtest_discover_tests(gtest_ip6_utils)
|
||||
gtest_discover_tests(gtest_mpls_utils)
|
||||
gtest_discover_tests(gtest_eth_utils)
|
||||
gtest_discover_tests(gtest_vlan_utils)
|
||||
gtest_discover_tests(gtest_vxlan_utils)
|
||||
gtest_discover_tests(gtest_gre0_utils)
|
||||
gtest_discover_tests(gtest_gre1_utils)
|
||||
gtest_discover_tests(gtest_l2tp_utils)
|
||||
gtest_discover_tests(gtest_gtp1_utils)
|
||||
gtest_discover_tests(gtest_gtp2_utils)
|
||||
gtest_discover_tests(gtest_packet_frag)
|
||||
gtest_discover_tests(gtest_packet_parser)
|
||||
gtest_discover_tests(gtest_packet_builder)
|
||||
gtest_discover_tests(gtest_packet_filter)
|
||||
gtest_discover_tests(gtest_packet_ldbc)
|
||||
49
infra/packet_manager/test/gtest_eth_utils.cpp
Normal file
49
infra/packet_manager/test/gtest_eth_utils.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Ethernet II, Src: 00:00:00_00:04:36 (00:00:00:00:04:36), Dst: 18:10:04:00:03:1f (18:10:04:00:03:1f)
|
||||
* Destination: 18:10:04:00:03:1f (18:10:04:00:03:1f)
|
||||
* Address: 18:10:04:00:03:1f (18:10:04:00:03:1f)
|
||||
* .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
|
||||
* .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
|
||||
* Source: 00:00:00_00:04:36 (00:00:00:00:04:36)
|
||||
* Address: 00:00:00_00:04:36 (00:00:00:00:04:36)
|
||||
* .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
|
||||
* .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
|
||||
* Type: MPLS label switched packet (0x8847)
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0x18, 0x10, 0x04, 0x00, 0x03, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x04, 0x36, 0x88, 0x47};
|
||||
|
||||
TEST(ETH_UTILS, GET)
|
||||
{
|
||||
const struct ethhdr *hdr = (struct ethhdr *)data;
|
||||
|
||||
char dest[18] = {0};
|
||||
char source[18] = {0};
|
||||
EXPECT_TRUE(eth_hdr_get_dest(hdr, dest, sizeof(dest)) == 17);
|
||||
EXPECT_TRUE(eth_hdr_get_source(hdr, source, sizeof(source)) == 17);
|
||||
EXPECT_TRUE(memcmp(dest, "18:10:04:00:03:1f", 17) == 0);
|
||||
EXPECT_TRUE(memcmp(source, "00:00:00:00:04:36", 17) == 0);
|
||||
EXPECT_TRUE(eth_hdr_get_proto(hdr) == ETH_P_MPLS_UC);
|
||||
}
|
||||
|
||||
TEST(ETH_UTILS, SET)
|
||||
{
|
||||
char buff[14] = {0};
|
||||
struct ethhdr *hdr = (struct ethhdr *)buff;
|
||||
|
||||
eth_hdr_set_dest(hdr, "18:10:04:00:03:1f");
|
||||
eth_hdr_set_source(hdr, "00:00:00:00:04:36");
|
||||
eth_hdr_set_proto(hdr, ETH_P_MPLS_UC);
|
||||
EXPECT_TRUE(memcmp(buff, data, 14) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
210
infra/packet_manager/test/gtest_gre0_utils.cpp
Normal file
210
infra/packet_manager/test/gtest_gre0_utils.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Generic Routing Encapsulation (IP)
|
||||
* Flags and Version: 0x0000
|
||||
* 0... .... .... .... = Checksum Bit: No
|
||||
* .0.. .... .... .... = Routing Bit: No
|
||||
* ..0. .... .... .... = Key Bit: No
|
||||
* ...0 .... .... .... = Sequence Number Bit: No
|
||||
* .... 0... .... .... = Strict Source Route Bit: No
|
||||
* .... .000 .... .... = Recursion control: 0
|
||||
* .... .... 0000 0... = Flags (Reserved): 0
|
||||
* .... .... .... .000 = Version: GRE (0)
|
||||
* Protocol Type: IP (0x0800)
|
||||
*/
|
||||
|
||||
unsigned char gre0_no_opt[] = {
|
||||
0x00, 0x00, 0x08, 0x00};
|
||||
|
||||
TEST(GRE0_UTILS, GET_1)
|
||||
{
|
||||
const struct gre0_hdr *hdr = (struct gre0_hdr *)gre0_no_opt;
|
||||
|
||||
EXPECT_TRUE(gre0_hdr_get_flags(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_key_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_strict_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_version(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_proto(hdr) == 0x0800);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_offset(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_key(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_data(hdr) == NULL);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_len(hdr) == 0);
|
||||
|
||||
EXPECT_TRUE(calc_gre0_hdr_len((const char *)gre0_no_opt, sizeof(gre0_no_opt)) == 4);
|
||||
}
|
||||
|
||||
TEST(GRE0_UTILS, SET_1)
|
||||
{
|
||||
char buff[4] = {0};
|
||||
|
||||
struct gre0_hdr *hdr = (struct gre0_hdr *)buff;
|
||||
gre0_hdr_set_flags(hdr, 0);
|
||||
gre0_hdr_set_checksum_flag(hdr, 0);
|
||||
gre0_hdr_set_routing_flag(hdr, 0);
|
||||
gre0_hdr_set_key_flag(hdr, 0);
|
||||
gre0_hdr_set_seq_flag(hdr, 0);
|
||||
gre0_hdr_set_strict_flag(hdr, 0);
|
||||
gre0_hdr_set_version(hdr, 0);
|
||||
gre0_hdr_set_proto(hdr, 0x0800);
|
||||
gre0_hdr_set_checksum(hdr, 0);
|
||||
gre0_hdr_set_offset(hdr, 0);
|
||||
gre0_hdr_set_key(hdr, 0);
|
||||
gre0_hdr_set_seq(hdr, 0);
|
||||
gre0_hdr_set_routing_data(hdr, NULL, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gre0_no_opt, 4) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic Routing Encapsulation (IP)
|
||||
* Flags and Version: 0x2000
|
||||
* 0... .... .... .... = Checksum Bit: No
|
||||
* .0.. .... .... .... = Routing Bit: No
|
||||
* ..1. .... .... .... = Key Bit: Yes
|
||||
* ...0 .... .... .... = Sequence Number Bit: No
|
||||
* .... 0... .... .... = Strict Source Route Bit: No
|
||||
* .... .000 .... .... = Recursion control: 0
|
||||
* .... .... 0000 0... = Flags (Reserved): 0
|
||||
* .... .... .... .000 = Version: GRE (0)
|
||||
* Protocol Type: IP (0x0800)
|
||||
* Key: 0x00000384
|
||||
*/
|
||||
|
||||
unsigned char gre0_opt_key[] = {0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x84};
|
||||
|
||||
TEST(GRE0_UTILS, GET_2)
|
||||
{
|
||||
const struct gre0_hdr *hdr = (struct gre0_hdr *)gre0_opt_key;
|
||||
|
||||
EXPECT_TRUE(gre0_hdr_get_flags(hdr) == 0x2000);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_key_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_strict_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_version(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_proto(hdr) == 0x0800);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_offset(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_key(hdr) == 0x00000384);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_data(hdr) == NULL);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_len(hdr) == 0);
|
||||
|
||||
EXPECT_TRUE(calc_gre0_hdr_len((const char *)gre0_opt_key, sizeof(gre0_opt_key)) == 8);
|
||||
}
|
||||
|
||||
TEST(GRE0_UTILS, SET_2)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
|
||||
struct gre0_hdr *hdr = (struct gre0_hdr *)buff;
|
||||
gre0_hdr_set_flags(hdr, 0x2000);
|
||||
gre0_hdr_set_checksum_flag(hdr, 0);
|
||||
gre0_hdr_set_routing_flag(hdr, 0);
|
||||
gre0_hdr_set_key_flag(hdr, 1);
|
||||
gre0_hdr_set_seq_flag(hdr, 0);
|
||||
gre0_hdr_set_strict_flag(hdr, 0);
|
||||
gre0_hdr_set_version(hdr, 0);
|
||||
gre0_hdr_set_proto(hdr, 0x0800);
|
||||
gre0_hdr_set_checksum(hdr, 0);
|
||||
gre0_hdr_set_offset(hdr, 0);
|
||||
gre0_hdr_set_key(hdr, 0x00000384);
|
||||
gre0_hdr_set_seq(hdr, 0);
|
||||
gre0_hdr_set_routing_data(hdr, NULL, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gre0_opt_key, 8) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic Routing Encapsulation (IP)
|
||||
* Flags and Version: 0xc000
|
||||
* 1... .... .... .... = Checksum Bit: Yes
|
||||
* .1.. .... .... .... = Routing Bit: Yes
|
||||
* ..0. .... .... .... = Key Bit: No
|
||||
* ...0 .... .... .... = Sequence Number Bit: No
|
||||
* .... 0... .... .... = Strict Source Route Bit: No
|
||||
* .... .000 .... .... = Recursion control: 0
|
||||
* .... .... 0000 0... = Flags (Reserved): 0
|
||||
* .... .... .... .000 = Version: GRE (0)
|
||||
* Protocol Type: IP (0x0800)
|
||||
* Checksum: 0x0000 incorrect, should be 0xea95
|
||||
* [Expert Info (Warning/Protocol): Incorrect GRE Checksum [should be 0xea95]]
|
||||
* [Incorrect GRE Checksum [should be 0xea95]]
|
||||
* [Severity level: Warning]
|
||||
* [Group: Protocol]
|
||||
* [Checksum Status: Bad]
|
||||
* Offset: 44
|
||||
* Routing
|
||||
* Address Family: 2
|
||||
* SRE Offset: 0
|
||||
* SRE Length: 44
|
||||
* Routing Information: 6c696e6b5f696e666f206c696e6b5f696e666f206c696e6b5f696e666f206c696e6b5f696e666f2000000000
|
||||
* Routing
|
||||
* Address Family: 0
|
||||
* SRE Offset: 0
|
||||
* SRE Length: 0
|
||||
*/
|
||||
|
||||
unsigned char gre0_opt_chek_rout[] = {
|
||||
0xc0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x02, 0x00, 0x2c, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x20, 0x6c, 0x69, 0x6e, 0x6b,
|
||||
0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x20,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
TEST(GRE0_UTILS, GET_3)
|
||||
{
|
||||
const struct gre0_hdr *hdr = (struct gre0_hdr *)gre0_opt_chek_rout;
|
||||
|
||||
EXPECT_TRUE(gre0_hdr_get_flags(hdr) == 0xc000);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gre0_hdr_get_key_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_strict_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_version(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_proto(hdr) == 0x0800);
|
||||
EXPECT_TRUE(gre0_hdr_get_checksum(hdr) == 0x0000);
|
||||
EXPECT_TRUE(gre0_hdr_get_offset(hdr) == 44);
|
||||
EXPECT_TRUE(gre0_hdr_get_key(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_data(hdr) == (const char *)gre0_opt_chek_rout + 8);
|
||||
EXPECT_TRUE(gre0_hdr_get_routing_len(hdr) == 52);
|
||||
|
||||
EXPECT_TRUE(calc_gre0_hdr_len((const char *)gre0_opt_chek_rout, sizeof(gre0_opt_chek_rout)) == 60);
|
||||
}
|
||||
|
||||
TEST(GRE0_UTILS, SET_3)
|
||||
{
|
||||
char buff[60] = {0};
|
||||
|
||||
struct gre0_hdr *hdr = (struct gre0_hdr *)buff;
|
||||
gre0_hdr_set_flags(hdr, 0xc000);
|
||||
gre0_hdr_set_checksum_flag(hdr, 1);
|
||||
gre0_hdr_set_routing_flag(hdr, 1);
|
||||
gre0_hdr_set_key_flag(hdr, 0);
|
||||
gre0_hdr_set_seq_flag(hdr, 0);
|
||||
gre0_hdr_set_strict_flag(hdr, 0);
|
||||
gre0_hdr_set_version(hdr, 0);
|
||||
gre0_hdr_set_proto(hdr, 0x0800);
|
||||
gre0_hdr_set_checksum(hdr, 0x0000);
|
||||
gre0_hdr_set_offset(hdr, 44);
|
||||
gre0_hdr_set_key(hdr, 0);
|
||||
gre0_hdr_set_seq(hdr, 0);
|
||||
gre0_hdr_set_routing_data(hdr, (const char *)gre0_opt_chek_rout + 8, 52);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gre0_opt_chek_rout, 60) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
66
infra/packet_manager/test/gtest_gre1_utils.cpp
Normal file
66
infra/packet_manager/test/gtest_gre1_utils.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Generic Routing Encapsulation (PPP)
|
||||
* Flags and Version: 0x3081
|
||||
* 0... .... .... .... = Checksum Bit: No
|
||||
* .0.. .... .... .... = Routing Bit: No
|
||||
* ..1. .... .... .... = Key Bit: Yes
|
||||
* ...1 .... .... .... = Sequence Number Bit: Yes
|
||||
* .... 0... .... .... = Strict Source Route Bit: No
|
||||
* .... .000 .... .... = Recursion control: 0
|
||||
* .... .... 1... .... = Acknowledgment: Yes
|
||||
* .... .... .000 0... = Flags (Reserved): 0
|
||||
* .... .... .... .001 = Version: Enhanced GRE (1)
|
||||
* Protocol Type: PPP (0x880b)
|
||||
* Payload Length: 103
|
||||
* Call ID: 6016
|
||||
* Sequence Number: 430001
|
||||
* Acknowledgment Number: 539254
|
||||
*/
|
||||
|
||||
unsigned char gre1_opt_seq_ack[] = {
|
||||
0x30, 0x81, 0x88, 0x0b, 0x00, 0x67, 0x17, 0x80, 0x00, 0x06, 0x8f, 0xb1, 0x00, 0x08, 0x3a, 0x76};
|
||||
|
||||
TEST(GRE1_UTILS, GET_1)
|
||||
{
|
||||
const struct gre1_hdr *hdr = (struct gre1_hdr *)gre1_opt_seq_ack;
|
||||
|
||||
EXPECT_TRUE(gre1_hdr_get_flags(hdr) == 0x3081);
|
||||
EXPECT_TRUE(gre1_hdr_get_seq_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gre1_hdr_get_ack_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gre1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gre1_hdr_get_proto(hdr) == 0x880b);
|
||||
EXPECT_TRUE(gre1_hdr_get_payload_length(hdr) == 103);
|
||||
EXPECT_TRUE(gre1_hdr_get_call_id(hdr) == 6016);
|
||||
EXPECT_TRUE(gre1_hdr_get_seq(hdr) == 430001);
|
||||
EXPECT_TRUE(gre1_hdr_get_ack(hdr) == 539254);
|
||||
|
||||
EXPECT_TRUE(calc_gre1_hdr_len((const char *)gre1_opt_seq_ack, sizeof(gre1_opt_seq_ack)) == 16);
|
||||
}
|
||||
|
||||
TEST(GRE1_UTILS, SET_1)
|
||||
{
|
||||
char buff[16] = {0};
|
||||
|
||||
struct gre1_hdr *hdr = (struct gre1_hdr *)buff;
|
||||
gre1_hdr_set_flags(hdr, 0x3081);
|
||||
gre1_hdr_set_seq_flag(hdr, 1);
|
||||
gre1_hdr_set_ack_flag(hdr, 1);
|
||||
gre1_hdr_set_version(hdr, 1);
|
||||
gre1_hdr_set_proto(hdr, 0x880b);
|
||||
gre1_hdr_set_payload_length(hdr, 103);
|
||||
gre1_hdr_set_call_id(hdr, 6016);
|
||||
gre1_hdr_set_seq(hdr, 430001);
|
||||
gre1_hdr_set_ack(hdr, 539254);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gre1_opt_seq_ack, 16) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
318
infra/packet_manager/test/gtest_gtp1_utils.cpp
Normal file
318
infra/packet_manager/test/gtest_gtp1_utils.cpp
Normal file
@@ -0,0 +1,318 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2123, Dst Port: 2123
|
||||
* GPRS Tunneling Protocol
|
||||
* Flags: 0x32
|
||||
* 001. .... = Version: GTP release 99 version (1)
|
||||
* ...1 .... = Protocol type: GTP (1)
|
||||
* .... 0... = Reserved: 0
|
||||
* .... .0.. = Is Next Extension Header present?: No
|
||||
* .... ..1. = Is Sequence Number present?: Yes
|
||||
* .... ...0 = Is N-PDU number present?: No
|
||||
* Message Type: Create PDP context request (0x10)
|
||||
* Length: 151
|
||||
* TEID: 0x00000000 (0)
|
||||
* Sequence number: 0x00fe (254)
|
||||
* IMSI: 27203
|
||||
* [Association IMSI: 27203]
|
||||
* Mobile Country Code (MCC): Ireland (272)
|
||||
* Mobile Network Code (MNC): Eircom Ltd (03)
|
||||
* Routing Area Identity
|
||||
* Mobile Country Code (MCC): Ireland (272)
|
||||
* Mobile Network Code (MNC): Eircom Ltd (03)
|
||||
* Location Area Code (LAC): 65534
|
||||
* Routing Area Code (RAC): 255
|
||||
* Recovery: 93
|
||||
* Selection mode: MS or network provided APN, subscribed verified
|
||||
* .... ..00 = Selection mode: MS or network provided APN, subscribed verified (0)
|
||||
* TEID Data I: 0x372f0000 (925827072)
|
||||
* TEID Control Plane: 0x372f0000 (925827072)
|
||||
* NSAPI: 5
|
||||
* .... 0101 = NSAPI: 5
|
||||
* End user address (IETF/IPv4)
|
||||
* Length: 2
|
||||
* PDP type organization: IETF (1)
|
||||
* PDP type number: IPv4 (0x21)
|
||||
* Access Point Name: mms.mymeteor.ie
|
||||
* APN length: 16
|
||||
* APN: mms.mymeteor.ie
|
||||
* Protocol configuration options
|
||||
* Length: 34
|
||||
* [Link direction: MS to network (0)]
|
||||
* 1... .... = Extension: True
|
||||
* .... .000 = Configuration Protocol: PPP for use with IP PDP type or IP PDN type (0)
|
||||
* Protocol or Container ID: Password Authentication Protocol (0xc023)
|
||||
* Length: 0x0b (11)
|
||||
* PPP Password Authentication Protocol
|
||||
* Code: Authenticate-Request (1)
|
||||
* Identifier: 0
|
||||
* Length: 11
|
||||
* Data
|
||||
* Peer-ID-Length: 2
|
||||
* Peer-ID: my
|
||||
* Password-Length: 3
|
||||
* Password: wap
|
||||
* Protocol or Container ID: Internet Protocol Control Protocol (0x8021)
|
||||
* Length: 0x10 (16)
|
||||
* PPP IP Control Protocol
|
||||
* Code: Configuration Request (1)
|
||||
* Identifier: 0 (0x00)
|
||||
* Length: 16
|
||||
* Options: (12 bytes), Primary DNS Server IP Address, Secondary DNS Server IP Address
|
||||
* Primary DNS Server IP Address
|
||||
* Type: Primary DNS Server IP Address (129)
|
||||
* Length: 6
|
||||
* Primary DNS Address: 0.0.0.0
|
||||
* Secondary DNS Server IP Address
|
||||
* Type: Secondary DNS Server IP Address (131)
|
||||
* Length: 6
|
||||
* Secondary DNS Address: 0.0.0.0
|
||||
* GSN address : 212.129.65.13
|
||||
* GSN address length: 4
|
||||
* GSN address IPv4: 212.129.65.13
|
||||
* GSN address : 212.129.65.23
|
||||
* GSN address length: 4
|
||||
* GSN address IPv4: 212.129.65.23
|
||||
* MS international PSTN/ISDN number
|
||||
* Length: 7
|
||||
* 1... .... = Extension: No Extension
|
||||
* .001 .... = Nature of number: International Number (0x1)
|
||||
* .... 0001 = Number plan: ISDN/Telephony Numbering (Rec ITU-T E.164) (0x1)
|
||||
* E.164 number (MSISDN): 353800000000
|
||||
* Country Code: Ireland (353)
|
||||
* Quality of Service
|
||||
* Length: 12
|
||||
* Allocation/Retention priority: 2
|
||||
* 00.. .... = Spare: 0
|
||||
* ..10 0... = QoS delay: Delay class 4 (best effort) (4)
|
||||
* .... .011 = QoS reliability: Unacknowledged GTP/LLC, Ack RLC, Protected data (3)
|
||||
* 0110 .... = QoS peak: Up to 32 000 oct/s (6)
|
||||
* .... 0... = Spare: 0
|
||||
* .... .010 = QoS precedence: Normal priority (2)
|
||||
* 000. .... = Spare: 0
|
||||
* ...1 1111 = QoS mean: Best effort (31)
|
||||
* 100. .... = Traffic class: Background class (4)
|
||||
* ...1 0... = Delivery order: Without delivery order ('no') (2)
|
||||
* .... .011 = Delivery of erroneous SDU: Erroneous SDUs are not delivered ('no') (3)
|
||||
* Maximum SDU size: 1500 octets
|
||||
* Maximum bit rate for uplink: 256 kbps
|
||||
* Maximum bit rate for downlink: 256 kbps
|
||||
* 0111 .... = Residual BER: 1/100 000 = 1x10^-5 (7)
|
||||
* .... 0100 = SDU Error ratio: 1/10 000 = 1x10^-4 (4)
|
||||
* 1111 10.. = Transfer delay: 4000 ms (62)
|
||||
* .... ..11 = Traffic handling priority: Priority level 3 (3)
|
||||
* Guaranteed bit rate for uplink: 0 kbps (255)
|
||||
* Guaranteed bit rate for downlink: 0 kbps (255)
|
||||
* RAT Type: GERAN
|
||||
* Length: 1
|
||||
* RAT Type: GERAN (2)
|
||||
* IMEI(SV): 3598100185893512
|
||||
* Length: 8
|
||||
* IMEI(SV): 3598100185893512
|
||||
* [Response In: 2]
|
||||
*/
|
||||
|
||||
unsigned char gtp1_c[] = {
|
||||
0x32, 0x10, 0x00, 0x97, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x02, 0x72, 0x02, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x72, 0xf2, 0x30, 0xff,
|
||||
0xfe, 0xff, 0x0e, 0x5d, 0x0f, 0xfc, 0x10, 0x37, 0x2f, 0x00, 0x00, 0x11, 0x37, 0x2f, 0x00, 0x00, 0x14, 0x05, 0x80, 0x00, 0x02, 0xf1, 0x21, 0x83, 0x00, 0x10,
|
||||
0x03, 0x6d, 0x6d, 0x73, 0x08, 0x6d, 0x79, 0x6d, 0x65, 0x74, 0x65, 0x6f, 0x72, 0x02, 0x69, 0x65, 0x84, 0x00, 0x22, 0x80, 0xc0, 0x23, 0x0b, 0x01, 0x00, 0x00,
|
||||
0x0b, 0x02, 0x6d, 0x79, 0x03, 0x77, 0x61, 0x70, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, 0x00,
|
||||
0x00, 0x85, 0x00, 0x04, 0xd4, 0x81, 0x41, 0x0d, 0x85, 0x00, 0x04, 0xd4, 0x81, 0x41, 0x17, 0x86, 0x00, 0x07, 0x91, 0x53, 0x83, 0x00, 0x00, 0x00, 0x00, 0x87,
|
||||
0x00, 0x0c, 0x02, 0x23, 0x62, 0x1f, 0x93, 0x96, 0x58, 0x58, 0x74, 0xfb, 0xff, 0xff, 0x97, 0x00, 0x01, 0x02, 0x9a, 0x00, 0x08, 0x53, 0x89, 0x01, 0x10, 0x58,
|
||||
0x98, 0x53, 0x21};
|
||||
|
||||
TEST(GTP1_UTILS, C_GET)
|
||||
{
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_c;
|
||||
|
||||
// GTP Fixed Header Length + GTPv1-C Optional Headers + GTPv1-C Extension Headers
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_c, sizeof(gtp1_c)) == 12);
|
||||
EXPECT_TRUE(gtp1_hdr_get_flags(hdr) == 0x32);
|
||||
EXPECT_TRUE(gtp1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_proto(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_reserved(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_ext_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_type(hdr) == 0x10);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_len(hdr) == 151);
|
||||
EXPECT_TRUE(gtp1_hdr_get_teid(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq(hdr) == 254);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_next_ext_type(hdr) == 0);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp1_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP1_UTILS, C_SET)
|
||||
{
|
||||
char buff[12] = {0};
|
||||
|
||||
struct gtp1_hdr *hdr = (struct gtp1_hdr *)buff;
|
||||
gtp1_hdr_set_flags(hdr, 0x32);
|
||||
gtp1_hdr_set_version(hdr, 1);
|
||||
gtp1_hdr_set_proto(hdr, 1);
|
||||
gtp1_hdr_set_reserved(hdr, 0);
|
||||
gtp1_hdr_set_ext_flag(hdr, 0);
|
||||
gtp1_hdr_set_seq_flag(hdr, 1);
|
||||
gtp1_hdr_set_npdu_flag(hdr, 0);
|
||||
gtp1_hdr_set_msg_type(hdr, 0x10);
|
||||
gtp1_hdr_set_msg_len(hdr, 151);
|
||||
gtp1_hdr_set_teid(hdr, 0);
|
||||
gtp1_hdr_set_seq(hdr, 254);
|
||||
gtp1_hdr_set_npdu(hdr, 0);
|
||||
gtp1_hdr_set_next_ext_type(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_c, 12) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2152, Dst Port: 2152
|
||||
* GPRS Tunneling Protocol
|
||||
* Flags: 0x30
|
||||
* 001. .... = Version: GTP release 99 version (1)
|
||||
* ...1 .... = Protocol type: GTP (1)
|
||||
* .... 0... = Reserved: 0
|
||||
* .... .0.. = Is Next Extension Header present?: No
|
||||
* .... ..0. = Is Sequence Number present?: No
|
||||
* .... ...0 = Is N-PDU number present?: No
|
||||
* Message Type: T-PDU (0xff)
|
||||
* Length: 40
|
||||
* TEID: 0x001e849a (2000026)
|
||||
*/
|
||||
|
||||
unsigned char gtp1_u1[] = {
|
||||
0x30, 0xff, 0x00, 0x28, 0x00, 0x1e, 0x84, 0x9a};
|
||||
|
||||
TEST(GTP1_UTILS, U1_GET)
|
||||
{
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_u1;
|
||||
|
||||
// GTP Fixed Header Length + GTPv1-U Optional Headers + GTPv1-U Extension Headers
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_u1, sizeof(gtp1_u1)) == 8);
|
||||
EXPECT_TRUE(gtp1_hdr_get_flags(hdr) == 0x30);
|
||||
EXPECT_TRUE(gtp1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_proto(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_reserved(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_ext_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_type(hdr) == 0xff);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_len(hdr) == 40);
|
||||
EXPECT_TRUE(gtp1_hdr_get_teid(hdr) == 2000026);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_next_ext_type(hdr) == 0);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp1_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP1_UTILS, U1_SET)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
|
||||
struct gtp1_hdr *hdr = (struct gtp1_hdr *)buff;
|
||||
gtp1_hdr_set_flags(hdr, 0x30);
|
||||
gtp1_hdr_set_version(hdr, 1);
|
||||
gtp1_hdr_set_proto(hdr, 1);
|
||||
gtp1_hdr_set_reserved(hdr, 0);
|
||||
gtp1_hdr_set_ext_flag(hdr, 0);
|
||||
gtp1_hdr_set_seq_flag(hdr, 0);
|
||||
gtp1_hdr_set_npdu_flag(hdr, 0);
|
||||
gtp1_hdr_set_msg_type(hdr, 0xff);
|
||||
gtp1_hdr_set_msg_len(hdr, 40);
|
||||
gtp1_hdr_set_teid(hdr, 2000026);
|
||||
gtp1_hdr_set_seq(hdr, 0);
|
||||
gtp1_hdr_set_npdu(hdr, 0);
|
||||
gtp1_hdr_set_next_ext_type(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_u1, 8) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2152, Dst Port: 2152
|
||||
* GPRS Tunneling Protocol
|
||||
* Flags: 0x34
|
||||
* 001. .... = Version: GTP release 99 version (1)
|
||||
* ...1 .... = Protocol type: GTP (1)
|
||||
* .... 0... = Reserved: 0
|
||||
* .... .1.. = Is Next Extension Header present?: Yes
|
||||
* .... ..0. = Is Sequence Number present?: No
|
||||
* .... ...0 = Is N-PDU number present?: No
|
||||
* Message Type: T-PDU (0xff)
|
||||
* Length: 445
|
||||
* TEID: 0x01447453 (21263443)
|
||||
* Next extension header type: PDU Session container (0x85)
|
||||
* Extension header (PDU Session container)
|
||||
* Extension Header Length: 1
|
||||
* PDU Session Container
|
||||
* 0001 .... = PDU Type: UL PDU SESSION INFORMATION (1)
|
||||
* .... 0000 = Spare: 0x0
|
||||
* 00.. .... = Spare: 0x0
|
||||
* ..00 0001 = QoS Flow Identifier (QFI): 1
|
||||
* Next extension header type: No more extension headers (0x00)
|
||||
*/
|
||||
|
||||
unsigned char gtp1_u2[] = {
|
||||
0x34, 0xff, 0x01, 0xbd, 0x01, 0x44, 0x74, 0x53, 0x00, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x00};
|
||||
|
||||
TEST(GTP1_UTILS, U2_GET)
|
||||
{
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_u2;
|
||||
|
||||
// GTP Fixed Header Length + GTPv1-U Optional Headers + GTPv1-U Extension Headers
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_u2, sizeof(gtp1_u2)) == 16);
|
||||
EXPECT_TRUE(gtp1_hdr_get_flags(hdr) == 0x34);
|
||||
EXPECT_TRUE(gtp1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_proto(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_reserved(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_ext_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_type(hdr) == 0xff);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_len(hdr) == 445);
|
||||
EXPECT_TRUE(gtp1_hdr_get_teid(hdr) == 21263443);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_next_ext_type(hdr) == 0x85);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp1_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP1_UTILS, U2_SET)
|
||||
{
|
||||
char buff[16] = {0};
|
||||
|
||||
struct gtp1_hdr *hdr = (struct gtp1_hdr *)buff;
|
||||
gtp1_hdr_set_flags(hdr, 0x34);
|
||||
gtp1_hdr_set_version(hdr, 1);
|
||||
gtp1_hdr_set_proto(hdr, 1);
|
||||
gtp1_hdr_set_reserved(hdr, 0);
|
||||
gtp1_hdr_set_ext_flag(hdr, 1);
|
||||
gtp1_hdr_set_seq_flag(hdr, 0);
|
||||
gtp1_hdr_set_npdu_flag(hdr, 0);
|
||||
gtp1_hdr_set_msg_type(hdr, 0xff);
|
||||
gtp1_hdr_set_msg_len(hdr, 445);
|
||||
gtp1_hdr_set_teid(hdr, 21263443);
|
||||
gtp1_hdr_set_seq(hdr, 0);
|
||||
gtp1_hdr_set_npdu(hdr, 0);
|
||||
gtp1_hdr_set_next_ext_type(hdr, 0x85);
|
||||
|
||||
// not compare the extension header
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_u2, 12) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
150
infra/packet_manager/test/gtest_gtp2_utils.cpp
Normal file
150
infra/packet_manager/test/gtest_gtp2_utils.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2123, Dst Port: 12491
|
||||
* GPRS Tunneling Protocol V2
|
||||
* Flags: 0x48
|
||||
* 010. .... = Version: 2
|
||||
* ...0 .... = Piggybacking flag (P): 0
|
||||
* .... 1... = TEID flag (T): 1
|
||||
* .... .0.. = Message Priority(MP): 0
|
||||
* Message Type: Delete Session Response (37)
|
||||
* Message Length: 19
|
||||
* Tunnel Endpoint Identifier: 0x0e05cd4d (235261261)
|
||||
* Sequence Number: 0x000ce7 (3303)
|
||||
* Spare: 0
|
||||
* Cause : Request accepted (16)
|
||||
* IE Type: Cause (2)
|
||||
* IE Length: 2
|
||||
* 0000 .... = CR flag: 0
|
||||
* .... 0000 = Instance: 0
|
||||
* Cause: Request accepted (16)
|
||||
* 0000 0... = Spare bit(s): 0
|
||||
* .... .0.. = PCE (PDN Connection IE Error): False
|
||||
* .... ..0. = BCE (Bearer Context IE Error): False
|
||||
* .... ...0 = CS (Cause Source): Originated by node sending the message
|
||||
* Recovery (Restart Counter) : 13
|
||||
* IE Type: Recovery (Restart Counter) (3)
|
||||
* IE Length: 1
|
||||
* 0000 .... = CR flag: 0
|
||||
* .... 0000 = Instance: 0
|
||||
* Restart Counter: 13
|
||||
*/
|
||||
|
||||
unsigned char gtp2_c_pkt1[] = {
|
||||
0x48, 0x25, 0x00, 0x13, 0x0e, 0x05, 0xcd, 0x4d, 0x00, 0x0c, 0xe7, 0x00, 0x02, 0x00, 0x02, 0x00, 0x10, 0x00, 0x03, 0x00, 0x01, 0x00, 0x0d};
|
||||
|
||||
// have teid
|
||||
|
||||
TEST(GTP2_UTILS, C_GET1)
|
||||
{
|
||||
const struct gtp2_hdr *hdr = (struct gtp2_hdr *)gtp2_c_pkt1;
|
||||
|
||||
EXPECT_TRUE(calc_gtp2_hdr_len((const char *)gtp2_c_pkt1, sizeof(gtp2_c_pkt1)) == 12);
|
||||
EXPECT_TRUE(gtp2_hdr_get_flags(hdr) == 0x48);
|
||||
EXPECT_TRUE(gtp2_hdr_get_version(hdr) == 2);
|
||||
EXPECT_TRUE(gtp2_hdr_get_piggyback_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_teid_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gtp2_hdr_get_spare_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_msg_type(hdr) == 37);
|
||||
EXPECT_TRUE(gtp2_hdr_get_msg_len(hdr) == 19);
|
||||
EXPECT_TRUE(gtp2_hdr_get_teid(hdr) == 0x0e05cd4d);
|
||||
EXPECT_TRUE(gtp2_hdr_get_seq(hdr) == 0x000ce7);
|
||||
EXPECT_TRUE(gtp2_hdr_get_spare(hdr) == 0);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp2_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP2_UTILS, C_SET1)
|
||||
{
|
||||
char buff[12] = {0};
|
||||
|
||||
struct gtp2_hdr *hdr = (struct gtp2_hdr *)buff;
|
||||
gtp2_hdr_set_flags(hdr, 0x48);
|
||||
gtp2_hdr_set_version(hdr, 2);
|
||||
gtp2_hdr_set_piggyback_flag(hdr, 0);
|
||||
gtp2_hdr_set_teid_flag(hdr, 1);
|
||||
gtp2_hdr_set_spare_flag(hdr, 0);
|
||||
gtp2_hdr_set_msg_type(hdr, 37);
|
||||
gtp2_hdr_set_msg_len(hdr, 19);
|
||||
gtp2_hdr_set_teid(hdr, 0x0e05cd4d);
|
||||
gtp2_hdr_set_seq(hdr, 0x000ce7);
|
||||
gtp2_hdr_set_spare(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gtp2_c_pkt1, 12) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2123, Dst Port: 2123
|
||||
* GPRS Tunneling Protocol V2
|
||||
* Flags: 0x40
|
||||
* 010. .... = Version: 2
|
||||
* ...0 .... = Piggybacking flag (P): 0
|
||||
* .... 0... = TEID flag (T): 0
|
||||
* .... .0.. = Message Priority(MP): 0
|
||||
* Message Type: Echo Request (1)
|
||||
* Message Length: 9
|
||||
* Sequence Number: 0x0041d4 (16852)
|
||||
* Spare: 0
|
||||
* Recovery (Restart Counter) : 5
|
||||
* IE Type: Recovery (Restart Counter) (3)
|
||||
* IE Length: 1
|
||||
* 0000 .... = CR flag: 0
|
||||
* .... 0000 = Instance: 0
|
||||
* Restart Counter: 5
|
||||
*/
|
||||
|
||||
unsigned char gtp2_c_pkt2[] = {
|
||||
0x40, 0x01, 0x00, 0x09, 0x00, 0x41, 0xd4, 0x00, 0x03, 0x00, 0x01, 0x00, 0x05};
|
||||
|
||||
// no teid
|
||||
|
||||
TEST(GTP2_UTILS, C_GET2)
|
||||
{
|
||||
const struct gtp2_hdr *hdr = (struct gtp2_hdr *)gtp2_c_pkt2;
|
||||
|
||||
EXPECT_TRUE(calc_gtp2_hdr_len((const char *)gtp2_c_pkt2, sizeof(gtp2_c_pkt2)) == 8);
|
||||
EXPECT_TRUE(gtp2_hdr_get_flags(hdr) == 0x40);
|
||||
EXPECT_TRUE(gtp2_hdr_get_version(hdr) == 2);
|
||||
EXPECT_TRUE(gtp2_hdr_get_piggyback_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_teid_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_spare_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_msg_type(hdr) == 1);
|
||||
EXPECT_TRUE(gtp2_hdr_get_msg_len(hdr) == 9);
|
||||
EXPECT_TRUE(gtp2_hdr_get_teid(hdr) == 0);
|
||||
EXPECT_TRUE(gtp2_hdr_get_seq(hdr) == 0x0041d4);
|
||||
EXPECT_TRUE(gtp2_hdr_get_spare(hdr) == 0);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp2_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP2_UTILS, C_SET2)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
|
||||
struct gtp2_hdr *hdr = (struct gtp2_hdr *)buff;
|
||||
gtp2_hdr_set_flags(hdr, 0x40);
|
||||
gtp2_hdr_set_version(hdr, 2);
|
||||
gtp2_hdr_set_piggyback_flag(hdr, 0);
|
||||
gtp2_hdr_set_teid_flag(hdr, 0);
|
||||
gtp2_hdr_set_spare_flag(hdr, 0);
|
||||
gtp2_hdr_set_msg_type(hdr, 1);
|
||||
gtp2_hdr_set_msg_len(hdr, 9);
|
||||
gtp2_hdr_set_teid(hdr, 0);
|
||||
gtp2_hdr_set_seq(hdr, 0x0041d4);
|
||||
gtp2_hdr_set_spare(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gtp2_c_pkt2, 8) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
274
infra/packet_manager/test/gtest_ip4_utils.cpp
Normal file
274
infra/packet_manager/test/gtest_ip4_utils.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/******************************************************************************
|
||||
* more fragment
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Internet Protocol Version 4, Src: 192.168.36.103, Dst: 192.168.40.137
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 44
|
||||
* Identification: 0xffff (65535)
|
||||
* 001. .... = Flags: 0x1, More fragments
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..1. .... = More fragments: Set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 127
|
||||
* Protocol: TCP (6)
|
||||
* Header Checksum: 0x4d8b [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0x4d8b]
|
||||
* Source Address: 192.168.36.103
|
||||
* Destination Address: 192.168.40.137
|
||||
* [Reassembled IPv4 in frame: 5]
|
||||
* Data (24 bytes)
|
||||
*/
|
||||
|
||||
unsigned char data1[] = {0x45, 0x00, 0x00, 0x2c, 0xff, 0xff, 0x20, 0x00, 0x7f, 0x06, 0x4d, 0x8b, 0xc0, 0xa8, 0x24, 0x67, 0xc0, 0xa8, 0x28, 0x89};
|
||||
|
||||
TEST(IPV4_UTILS, GET1)
|
||||
{
|
||||
const struct ip *hdr = (struct ip *)data1;
|
||||
EXPECT_TRUE(ip4_hdr_get_version(hdr) == 4);
|
||||
EXPECT_TRUE(ip4_hdr_get_hdr_len(hdr) == 20);
|
||||
EXPECT_TRUE(ip4_hdr_get_tos(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_total_len(hdr) == 44);
|
||||
EXPECT_TRUE(ip4_hdr_get_ipid(hdr) == 65535);
|
||||
EXPECT_TRUE(ip4_hdr_get_flags(hdr) == 1);
|
||||
EXPECT_TRUE(ip4_hdr_get_rf_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_df_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_mf_flag(hdr) == true);
|
||||
EXPECT_TRUE(ip4_hdr_get_frag_offset(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_ttl(hdr) == 127);
|
||||
EXPECT_TRUE(ip4_hdr_get_proto(hdr) == 6);
|
||||
EXPECT_TRUE(ip4_hdr_get_checksum(hdr) == 0x4d8b);
|
||||
EXPECT_TRUE(ip4_hdr_get_src_addr(hdr) == 0xc0a82467);
|
||||
EXPECT_TRUE(ip4_hdr_get_dst_addr(hdr) == 0xc0a82889);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_len(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_data(hdr) == NULL);
|
||||
}
|
||||
|
||||
TEST(IPV4_UTILS, SET1)
|
||||
{
|
||||
char buff[20] = {0};
|
||||
|
||||
struct ip *hdr = (struct ip *)buff;
|
||||
ip4_hdr_set_version(hdr, 4);
|
||||
ip4_hdr_set_hdr_len(hdr, 20);
|
||||
ip4_hdr_set_tos(hdr, 0);
|
||||
ip4_hdr_set_total_len(hdr, 44);
|
||||
ip4_hdr_set_ipid(hdr, 65535);
|
||||
ip4_hdr_set_frag_offset(hdr, 0);
|
||||
ip4_hdr_set_ttl(hdr, 127);
|
||||
ip4_hdr_set_protocol(hdr, 6);
|
||||
ip4_hdr_set_checksum(hdr, 0x4d8b);
|
||||
ip4_hdr_set_src_addr(hdr, 0xc0a82467);
|
||||
ip4_hdr_set_dst_addr(hdr, 0xc0a82889);
|
||||
ip4_hdr_set_opt_len(hdr, 0);
|
||||
ip4_hdr_set_opt_data(hdr, NULL);
|
||||
|
||||
ip4_hdr_set_flags(hdr, 1);
|
||||
EXPECT_TRUE(memcmp(buff, data1, 20) == 0);
|
||||
|
||||
ip4_hdr_set_rf_flag(hdr, false);
|
||||
ip4_hdr_set_df_flag(hdr, false);
|
||||
ip4_hdr_set_mf_flag(hdr, true);
|
||||
EXPECT_TRUE(memcmp(buff, data1, 20) == 0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* fragment offset
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Frame 5: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
|
||||
* Ethernet II, Src: Fortinet_cc:87:22 (e8:1c:ba:cc:87:22), Dst: EvocInte_2f:35:b8 (00:22:46:2f:35:b8)
|
||||
* Internet Protocol Version 4, Src: 192.168.36.103, Dst: 192.168.40.137
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 44
|
||||
* Identification: 0xffff (65535)
|
||||
* 000. .... = Flags: 0x0
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..0. .... = More fragments: Not set
|
||||
* ...0 0000 0000 0011 = Fragment Offset: 24
|
||||
* Time to Live: 127
|
||||
* Protocol: TCP (6)
|
||||
* Header Checksum: 0x6d88 [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0x6d88]
|
||||
* Source Address: 192.168.36.103
|
||||
* Destination Address: 192.168.40.137
|
||||
* [2 IPv4 Fragments (48 bytes): #4(24), #5(24)]
|
||||
* [Frame: 4, payload: 0-23 (24 bytes)]
|
||||
* [Frame: 5, payload: 24-47 (24 bytes)]
|
||||
* [Fragment count: 2]
|
||||
* [Reassembled IPv4 length: 48]
|
||||
* [Reassembled IPv4 data: f4a5270f9107248703d518e75018ff005e9200003132330af4a5270f9107248b03d518e7…]
|
||||
* Transmission Control Protocol, Src Port: 62629, Dst Port: 9999, Seq: 1, Ack: 1, Len: 28
|
||||
* Data (28 bytes)
|
||||
* Data: 3132330af4a5270f9107248b03d518e75018ff00301600006162630a
|
||||
* [Length: 28]
|
||||
*/
|
||||
|
||||
unsigned char data2[] = {0x45, 0x00, 0x00, 0x2c, 0xff, 0xff, 0x00, 0x03, 0x7f, 0x06, 0x6d, 0x88, 0xc0, 0xa8, 0x24, 0x67, 0xc0, 0xa8, 0x28, 0x89};
|
||||
|
||||
TEST(IPV4_UTILS, GET2)
|
||||
{
|
||||
const struct ip *hdr = (struct ip *)data2;
|
||||
EXPECT_TRUE(ip4_hdr_get_version(hdr) == 4);
|
||||
EXPECT_TRUE(ip4_hdr_get_hdr_len(hdr) == 20);
|
||||
EXPECT_TRUE(ip4_hdr_get_tos(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_total_len(hdr) == 44);
|
||||
EXPECT_TRUE(ip4_hdr_get_ipid(hdr) == 65535);
|
||||
EXPECT_TRUE(ip4_hdr_get_flags(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_rf_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_df_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_mf_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_frag_offset(hdr) == 24);
|
||||
EXPECT_TRUE(ip4_hdr_get_ttl(hdr) == 127);
|
||||
EXPECT_TRUE(ip4_hdr_get_proto(hdr) == 6);
|
||||
EXPECT_TRUE(ip4_hdr_get_checksum(hdr) == 0x6d88);
|
||||
EXPECT_TRUE(ip4_hdr_get_src_addr(hdr) == 0xc0a82467);
|
||||
EXPECT_TRUE(ip4_hdr_get_dst_addr(hdr) == 0xc0a82889);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_len(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_data(hdr) == NULL);
|
||||
}
|
||||
|
||||
TEST(IPV4_UTILS, SET2)
|
||||
{
|
||||
char buff[20] = {0};
|
||||
|
||||
struct ip *hdr = (struct ip *)buff;
|
||||
ip4_hdr_set_version(hdr, 4);
|
||||
ip4_hdr_set_hdr_len(hdr, 20);
|
||||
ip4_hdr_set_tos(hdr, 0);
|
||||
ip4_hdr_set_total_len(hdr, 44);
|
||||
ip4_hdr_set_ipid(hdr, 65535);
|
||||
ip4_hdr_set_frag_offset(hdr, 24);
|
||||
ip4_hdr_set_ttl(hdr, 127);
|
||||
ip4_hdr_set_protocol(hdr, 6);
|
||||
ip4_hdr_set_checksum(hdr, 0x6d88);
|
||||
ip4_hdr_set_src_addr(hdr, 0xc0a82467);
|
||||
ip4_hdr_set_dst_addr(hdr, 0xc0a82889);
|
||||
ip4_hdr_set_opt_len(hdr, 0);
|
||||
ip4_hdr_set_opt_data(hdr, NULL);
|
||||
|
||||
ip4_hdr_set_flags(hdr, 0);
|
||||
EXPECT_TRUE(memcmp(buff, data2, 20) == 0);
|
||||
|
||||
ip4_hdr_set_rf_flag(hdr, false);
|
||||
ip4_hdr_set_df_flag(hdr, false);
|
||||
ip4_hdr_set_mf_flag(hdr, false);
|
||||
EXPECT_TRUE(memcmp(buff, data2, 20) == 0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* options
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
|
||||
* 0100 .... = Version: 4
|
||||
* .... 1111 = Header Length: 60 bytes (15)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 124
|
||||
* Identification: 0x0000 (0)
|
||||
* 010. .... = Flags: 0x2, Don't fragment
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .1.. .... = Don't fragment: Set
|
||||
* ..0. .... = More fragments: Not set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 64
|
||||
* Protocol: ICMP (1)
|
||||
* Header Checksum: 0xfd30 [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0xfd30]
|
||||
* Source Address: 127.0.0.1
|
||||
* Destination Address: 127.0.0.1
|
||||
* Options: (40 bytes), Commercial Security
|
||||
* IP Option - Commercial Security (40 bytes)
|
||||
* Type: 134
|
||||
* 1... .... = Copy on fragmentation: Yes
|
||||
* .00. .... = Class: Control (0)
|
||||
* ...0 0110 = Number: Commercial IP security option (6)
|
||||
* Length: 40
|
||||
* DOI: 1
|
||||
* Tag Type: Restrictive Category Bitmap (1)
|
||||
* Sensitivity Level: 1
|
||||
* Categories: 0,2,4,5,6,239
|
||||
*/
|
||||
|
||||
unsigned char data3[] = {
|
||||
0x4f, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0xfd, 0x30, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01, 0x86, 0x28, 0x00, 0x00, 0x00, 0x01,
|
||||
0x01, 0x22, 0x00, 0x01, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
TEST(IPV4_UTILS, GET3)
|
||||
{
|
||||
const struct ip *hdr = (struct ip *)data3;
|
||||
EXPECT_TRUE(ip4_hdr_get_version(hdr) == 4);
|
||||
EXPECT_TRUE(ip4_hdr_get_hdr_len(hdr) == 60);
|
||||
EXPECT_TRUE(ip4_hdr_get_tos(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_total_len(hdr) == 124);
|
||||
EXPECT_TRUE(ip4_hdr_get_ipid(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_flags(hdr) == 2);
|
||||
EXPECT_TRUE(ip4_hdr_get_rf_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_df_flag(hdr) == true);
|
||||
EXPECT_TRUE(ip4_hdr_get_mf_flag(hdr) == false);
|
||||
EXPECT_TRUE(ip4_hdr_get_frag_offset(hdr) == 0);
|
||||
EXPECT_TRUE(ip4_hdr_get_ttl(hdr) == 64);
|
||||
EXPECT_TRUE(ip4_hdr_get_proto(hdr) == 1);
|
||||
EXPECT_TRUE(ip4_hdr_get_checksum(hdr) == 0xfd30);
|
||||
EXPECT_TRUE(ip4_hdr_get_src_addr(hdr) == 0x7f000001);
|
||||
EXPECT_TRUE(ip4_hdr_get_dst_addr(hdr) == 0x7f000001);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_len(hdr) == 40);
|
||||
EXPECT_TRUE(ip4_hdr_get_opt_data(hdr) == (const char *)(data3 + 20));
|
||||
}
|
||||
|
||||
TEST(IPV4_UTILS, SET3)
|
||||
{
|
||||
char buff[60] = {0};
|
||||
|
||||
struct ip *hdr = (struct ip *)buff;
|
||||
ip4_hdr_set_version(hdr, 4);
|
||||
ip4_hdr_set_hdr_len(hdr, 60);
|
||||
ip4_hdr_set_tos(hdr, 0);
|
||||
ip4_hdr_set_total_len(hdr, 124);
|
||||
ip4_hdr_set_ipid(hdr, 0);
|
||||
ip4_hdr_set_frag_offset(hdr, 0);
|
||||
ip4_hdr_set_ttl(hdr, 64);
|
||||
ip4_hdr_set_protocol(hdr, 1);
|
||||
ip4_hdr_set_checksum(hdr, 0xfd30);
|
||||
ip4_hdr_set_src_addr(hdr, 0x7f000001);
|
||||
ip4_hdr_set_dst_addr(hdr, 0x7f000001);
|
||||
ip4_hdr_set_opt_len(hdr, 40);
|
||||
ip4_hdr_set_opt_data(hdr, (const char *)(data3 + 20));
|
||||
|
||||
ip4_hdr_set_flags(hdr, 2);
|
||||
EXPECT_TRUE(memcmp(buff, data3, 60) == 0);
|
||||
|
||||
ip4_hdr_set_rf_flag(hdr, false);
|
||||
ip4_hdr_set_df_flag(hdr, true);
|
||||
ip4_hdr_set_mf_flag(hdr, false);
|
||||
EXPECT_TRUE(memcmp(buff, data3, 60) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
104
infra/packet_manager/test/gtest_ip6_utils.cpp
Normal file
104
infra/packet_manager/test/gtest_ip6_utils.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Internet Protocol Version 6, Src: fe80::250:56ff:fe69:dc00, Dst: ff02::1:2
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
|
||||
* .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 60
|
||||
* Next Header: UDP (17)
|
||||
* Hop Limit: 1
|
||||
* Source Address: fe80::250:56ff:fe69:dc00
|
||||
* Destination Address: ff02::1:2
|
||||
* [Source SLAAC MAC: VMware_69:dc:00 (00:50:56:69:dc:00)]
|
||||
* */
|
||||
|
||||
unsigned char data[] = {
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x11, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50, 0x56, 0xff, 0xfe, 0x69, 0xdc, 0x00, 0xff, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02};
|
||||
|
||||
TEST(IPV6_UTILS, GET)
|
||||
{
|
||||
char src_str[INET6_ADDRSTRLEN];
|
||||
char dst_str[INET6_ADDRSTRLEN];
|
||||
const struct ip6_hdr *hdr = (struct ip6_hdr *)data;
|
||||
EXPECT_TRUE(ip6_hdr_get_version(hdr) == 6);
|
||||
EXPECT_TRUE(ip6_hdr_get_traffic_class(hdr) == 0);
|
||||
EXPECT_TRUE(ip6_hdr_get_flow_label(hdr) == 0);
|
||||
EXPECT_TRUE(ip6_hdr_get_payload_len(hdr) == 60);
|
||||
EXPECT_TRUE(ip6_hdr_get_next_header(hdr) == 17);
|
||||
EXPECT_TRUE(ip6_hdr_get_hop_limit(hdr) == 1);
|
||||
struct in6_addr src_addr = ip6_hdr_get_src_in6_addr(hdr);
|
||||
struct in6_addr dst_addr = ip6_hdr_get_dst_in6_addr(hdr);
|
||||
|
||||
inet_ntop(AF_INET6, &src_addr, src_str, INET6_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET6, &dst_addr, dst_str, INET6_ADDRSTRLEN);
|
||||
EXPECT_TRUE(strcmp(src_str, "fe80::250:56ff:fe69:dc00") == 0);
|
||||
EXPECT_TRUE(strcmp(dst_str, "ff02::1:2") == 0);
|
||||
}
|
||||
|
||||
TEST(IPV6_UTILS, SET)
|
||||
{
|
||||
char buff[40] = {0};
|
||||
struct in6_addr src_addr;
|
||||
struct in6_addr dst_addr;
|
||||
struct ip6_hdr *hdr = (struct ip6_hdr *)buff;
|
||||
|
||||
inet_pton(AF_INET6, "fe80::250:56ff:fe69:dc00", &src_addr);
|
||||
inet_pton(AF_INET6, "ff02::1:2", &dst_addr);
|
||||
ip6_hdr_set_version(hdr, 6);
|
||||
ip6_hdr_set_traffic_class(hdr, 0);
|
||||
ip6_hdr_set_flow_label(hdr, 0);
|
||||
ip6_hdr_set_payload_len(hdr, 60);
|
||||
ip6_hdr_set_next_header(hdr, 17);
|
||||
ip6_hdr_set_hop_limit(hdr, 1);
|
||||
ip6_hdr_set_src_in6_addr(hdr, src_addr);
|
||||
ip6_hdr_set_dst_in6_addr(hdr, dst_addr);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, data, 40) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fragment Header for IPv6
|
||||
* Next header: UDP (17)
|
||||
* Reserved octet: 0x00
|
||||
* 0000 0101 1010 1... = Offset: 181 (1448 bytes)
|
||||
* .... .... .... .00. = Reserved bits: 0
|
||||
* .... .... .... ...1 = More Fragments: Yes
|
||||
* Identification: 0xf88eb466
|
||||
*/
|
||||
|
||||
unsigned char frag[] = {
|
||||
0x11, 0x00, 0x05, 0xa9, 0xf8, 0x8e, 0xb4, 0x66};
|
||||
|
||||
TEST(IPV6_FRAG_HDR, GET)
|
||||
{
|
||||
const struct ip6_frag *hdr = (struct ip6_frag *)frag;
|
||||
EXPECT_TRUE(ipv6_frag_get_next_header(hdr) == 17);
|
||||
EXPECT_TRUE(ipv6_frag_get_offset(hdr) == 1448);
|
||||
EXPECT_TRUE(ipv6_frag_get_more(hdr) == 1);
|
||||
EXPECT_TRUE(ipv6_frag_get_ident(hdr) == 0xf88eb466);
|
||||
}
|
||||
|
||||
TEST(IPV6_FRAG_HDR, SET)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
|
||||
struct ip6_frag *hdr = (struct ip6_frag *)buff;
|
||||
ipv6_frag_set_next_header(hdr, 17);
|
||||
ipv6_frag_set_offset(hdr, 1448);
|
||||
ipv6_frag_set_more(hdr, 1);
|
||||
ipv6_frag_set_ident(hdr, 0xf88eb466);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, frag, 8) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
196
infra/packet_manager/test/gtest_l2tp_utils.cpp
Normal file
196
infra/packet_manager/test/gtest_l2tp_utils.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Layer 2 Tunneling Protocol
|
||||
* Flags: 0xc802, Type: Control Message, Length Bit, Sequence Bit
|
||||
* 1... .... .... .... = Type: Control Message (1)
|
||||
* .1.. .... .... .... = Length Bit: Length field is present
|
||||
* .... 1... .... .... = Sequence Bit: Ns and Nr fields are present
|
||||
* .... ..0. .... .... = Offset bit: Offset size field is not present
|
||||
* .... ...0 .... .... = Priority: No priority
|
||||
* .... .... .... 0010 = Version: 2
|
||||
* Length: 105
|
||||
* Tunnel ID: 0
|
||||
* Session ID: 0
|
||||
* Ns: 0
|
||||
* Nr: 0
|
||||
* Control Message AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1000 = Length: 8
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Control Message (0)
|
||||
* Message Type: Start_Control_Request (1)
|
||||
* Protocol Version AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1000 = Length: 8
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Protocol Version (2)
|
||||
* Version: 1
|
||||
* Revision: 0
|
||||
* Framing Capabilities AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1010 = Length: 10
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Framing Capabilities (3)
|
||||
* .... .... .... .... .... .... .... ..0. = Async Framing Supported: False
|
||||
* .... .... .... .... .... .... .... ...1 = Sync Framing Supported: True
|
||||
* Bearer Capabilities AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1010 = Length: 10
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Bearer Capabilities (4)
|
||||
* .... .... .... .... .... .... .... ..0. = Analog Access Supported: False
|
||||
* .... .... .... .... .... .... .... ...0 = Digital Access Supported: False
|
||||
* Firmware Revision AVP
|
||||
* 0... .... .... .... = Mandatory: False
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1000 = Length: 8
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Firmware Revision (6)
|
||||
* Firmware Revision: 1537 (0x0601)
|
||||
* Host Name AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0001 0010 = Length: 18
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Host Name (7)
|
||||
* Host Name: IIE-SM-THINK
|
||||
* Vendor Name AVP
|
||||
* 0... .... .... .... = Mandatory: False
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1111 = Length: 15
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Vendor Name (8)
|
||||
* Vendor Name: Microsoft
|
||||
* Assigned Tunnel ID AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1000 = Length: 8
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Assigned Tunnel ID (9)
|
||||
* Assigned Tunnel ID: 1
|
||||
* Receive Window Size AVP
|
||||
* 1... .... .... .... = Mandatory: True
|
||||
* .0.. .... .... .... = Hidden: False
|
||||
* .... ..00 0000 1000 = Length: 8
|
||||
* Vendor ID: Reserved (0)
|
||||
* AVP Type: Receive Window Size (10)
|
||||
* Receive Window Size: 8
|
||||
*/
|
||||
|
||||
unsigned char v2_over_udp_ctrl_msg[] = {
|
||||
0xc8, 0x02, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
|
||||
0x01, 0x00, 0x80, 0x0a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
|
||||
0x00, 0x06, 0x06, 0x01, 0x80, 0x12, 0x00, 0x00, 0x00, 0x07, 0x49, 0x49, 0x45, 0x2d, 0x53, 0x4d, 0x2d, 0x54, 0x48, 0x49, 0x4e, 0x4b, 0x00, 0x0f, 0x00, 0x00,
|
||||
0x00, 0x08, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x80, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x01, 0x80, 0x08, 0x00, 0x00, 0x00, 0x0a, 0x00,
|
||||
0x08};
|
||||
|
||||
TEST(L2TPV2_OVER_UDP_UTILS, CRTL_MSG)
|
||||
{
|
||||
const struct l2tp_hdr *hdr = (struct l2tp_hdr *)v2_over_udp_ctrl_msg;
|
||||
|
||||
EXPECT_TRUE(l2tp_hdr_get_ver(hdr) == 2);
|
||||
EXPECT_TRUE(l2tp_hdr_get_type(hdr) == 1);
|
||||
EXPECT_TRUE(calc_udp_l2tpv2_hdr_len((const char *)v2_over_udp_ctrl_msg, sizeof(v2_over_udp_ctrl_msg)) == 105);
|
||||
}
|
||||
|
||||
/*
|
||||
* Layer 2 Tunneling Protocol
|
||||
* Flags: 0x4002, Type: Data Message, Length Bit
|
||||
* 0... .... .... .... = Type: Data Message (0)
|
||||
* .1.. .... .... .... = Length Bit: Length field is present
|
||||
* .... 0... .... .... = Sequence Bit: Ns and Nr fields are not present
|
||||
* .... ..0. .... .... = Offset bit: Offset size field is not present
|
||||
* .... ...0 .... .... = Priority: No priority
|
||||
* .... .... .... 0010 = Version: 2
|
||||
* Length: 78
|
||||
* Tunnel ID: 28998
|
||||
* Session ID: 2
|
||||
*/
|
||||
|
||||
unsigned char v2_over_udp_data_msg[] = {
|
||||
0x40, 0x02, 0x00, 0x4e, 0x71, 0x46, 0x00, 0x02};
|
||||
|
||||
TEST(L2TPV2_OVER_UDP_UTILS, DATA_MSG)
|
||||
{
|
||||
const struct l2tp_hdr *hdr = (struct l2tp_hdr *)v2_over_udp_data_msg;
|
||||
|
||||
EXPECT_TRUE(l2tp_hdr_get_ver(hdr) == 2);
|
||||
EXPECT_TRUE(l2tp_hdr_get_type(hdr) == 0);
|
||||
EXPECT_TRUE(calc_udp_l2tpv2_hdr_len((const char *)v2_over_udp_data_msg, sizeof(v2_over_udp_data_msg)) == 8);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
|
||||
unsigned char v3_over_udp_ctrl_msg[] = {};
|
||||
|
||||
TEST(L2TPV3_OVER_UDP_UTILS, CRTL_MSG)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/*
|
||||
* Layer 2 Tunneling Protocol version 3
|
||||
* Flags: 0x0003, Type: Data Message
|
||||
* 0... .... .... .... = Type: Data Message (0)
|
||||
* .0.. .... .... .... = Length Bit: Length field is not present
|
||||
* .... 0... .... .... = Sequence Bit: Ns and Nr fields are not present
|
||||
* .... .... .... 0011 = Version: 3
|
||||
* Reserved: 0x0000
|
||||
* Session ID: 0x00000fa0
|
||||
* [Pseudowire Type: Unknown (0)]
|
||||
* Cookie: 00000000
|
||||
*/
|
||||
|
||||
unsigned char v3_over_udp_data_msg[] = {
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
TEST(L2TPV3_OVER_UDP_UTILS, DATA_MSG)
|
||||
{
|
||||
const struct l2tp_hdr *hdr = (struct l2tp_hdr *)v3_over_udp_data_msg;
|
||||
|
||||
EXPECT_TRUE(l2tp_hdr_get_ver(hdr) == 3);
|
||||
EXPECT_TRUE(l2tp_hdr_get_type(hdr) == 0);
|
||||
EXPECT_TRUE(calc_udp_l2tpv3_hdr_len((const char *)v3_over_udp_data_msg, sizeof(v3_over_udp_data_msg)) == 12);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO
|
||||
*/
|
||||
|
||||
unsigned char v3_over_ip_ctrl_msg[] = {};
|
||||
|
||||
TEST(L2TPV3_OVER_IP_UTILS, CRTL_MSG)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/*
|
||||
* Layer 2 Tunneling Protocol version 3
|
||||
* Session ID: 0x00009652
|
||||
* [Pseudowire Type: Unknown (0)]
|
||||
* Cookie: ca031078
|
||||
*/
|
||||
|
||||
unsigned char v3_over_ip_data_msg[] = {
|
||||
0x00, 0x00, 0x96, 0x52, 0xca, 0x03, 0x10, 0x78};
|
||||
|
||||
TEST(L2TPV3_OVER_IP_UTILS, DATA_MSG)
|
||||
{
|
||||
EXPECT_TRUE(ntohl(*((uint32_t *)v3_over_ip_data_msg)) != 0); // data message
|
||||
EXPECT_TRUE(calc_ip_l2tpv3_hdr_len((const char *)v3_over_ip_data_msg, sizeof(v3_over_ip_data_msg)) == 8);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
42
infra/packet_manager/test/gtest_mpls_utils.cpp
Normal file
42
infra/packet_manager/test/gtest_mpls_utils.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* MultiProtocol Label Switching Header, Label: 779408, Exp: 0, S: 0, TTL: 255
|
||||
* 1011 1110 0100 1001 0000 .... .... .... = MPLS Label: 779408 (0xbe490)
|
||||
* .... .... .... .... .... 000. .... .... = MPLS Experimental Bits: 0
|
||||
* .... .... .... .... .... ...0 .... .... = MPLS Bottom Of Label Stack: 0
|
||||
* .... .... .... .... .... .... 1111 1111 = MPLS TTL: 255
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0xbe, 0x49, 0x00, 0xff};
|
||||
|
||||
TEST(MPLS_UTILS, GET)
|
||||
{
|
||||
const struct mpls_label *hdr = (struct mpls_label *)data;
|
||||
|
||||
EXPECT_TRUE(mpls_label_get_label(hdr) == 0xbe490);
|
||||
EXPECT_TRUE(mpls_label_get_tc(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_label_get_bos(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_label_get_ttl(hdr) == 255);
|
||||
}
|
||||
|
||||
TEST(MPLS_UTILS, SET)
|
||||
{
|
||||
char buff[4] = {0};
|
||||
struct mpls_label *hdr = (struct mpls_label *)buff;
|
||||
|
||||
mpls_label_set_label(hdr, 0xbe490);
|
||||
mpls_label_set_tc(hdr, 0);
|
||||
mpls_label_set_bos(hdr, 0);
|
||||
mpls_label_set_ttl(hdr, 255);
|
||||
EXPECT_TRUE(memcmp(buff, data, 4) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
1230
infra/packet_manager/test/gtest_packet_builder.cpp
Normal file
1230
infra/packet_manager/test/gtest_packet_builder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
97
infra/packet_manager/test/gtest_packet_filter.cpp
Normal file
97
infra/packet_manager/test/gtest_packet_filter.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "packet_filter.h"
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
||||
* Ethernet II, Src: JuniperN_45:88:29 (2c:6b:f5:45:88:29), Dst: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Destination: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Source: JuniperN_45:88:29 (2c:6b:f5:45:88:29)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 210.77.88.163, Dst: 59.66.4.50
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 92
|
||||
* Identification: 0x0b4d (2893)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 59
|
||||
* Protocol: IPv6 (41)
|
||||
* Header Checksum: 0x09c8 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 210.77.88.163
|
||||
* Destination Address: 59.66.4.50
|
||||
* Internet Protocol Version 6, Src: 2001:da8:200:900e:200:5efe:d24d:58a3, Dst: 2600:140e:6::1702:1058
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 32
|
||||
* Next Header: TCP (6)
|
||||
* Hop Limit: 64
|
||||
* Source Address: 2001:da8:200:900e:200:5efe:d24d:58a3
|
||||
* Destination Address: 2600:140e:6::1702:1058
|
||||
* [Source ISATAP IPv4: 210.77.88.163]
|
||||
* Transmission Control Protocol, Src Port: 52556, Dst Port: 80, Seq: 0, Len: 0
|
||||
* Source Port: 52556
|
||||
* Destination Port: 80
|
||||
* [Stream index: 0]
|
||||
* [Conversation completeness: Complete, WITH_DATA (31)]
|
||||
* [TCP Segment Len: 0]
|
||||
* Sequence Number: 0 (relative sequence number)
|
||||
* Sequence Number (raw): 2172673142
|
||||
* [Next Sequence Number: 1 (relative sequence number)]
|
||||
* Acknowledgment Number: 0
|
||||
* Acknowledgment number (raw): 0
|
||||
* 1000 .... = Header Length: 32 bytes (8)
|
||||
* Flags: 0x002 (SYN)
|
||||
* Window: 8192
|
||||
* [Calculated window size: 8192]
|
||||
* Checksum: 0xf757 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* Urgent Pointer: 0
|
||||
* Options: (12 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), SACK permitted
|
||||
* [Timestamps]
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0x5c, 0x5e, 0xab, 0x2a, 0xa2, 0x00, 0x2c, 0x6b, 0xf5, 0x45, 0x88, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x5c, 0x0b, 0x4d, 0x00, 0x00, 0x3b, 0x29, 0x09, 0xc8,
|
||||
0xd2, 0x4d, 0x58, 0xa3, 0x3b, 0x42, 0x04, 0x32, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40, 0x20, 0x01, 0x0d, 0xa8, 0x02, 0x00, 0x90, 0x0e, 0x02, 0x00,
|
||||
0x5e, 0xfe, 0xd2, 0x4d, 0x58, 0xa3, 0x26, 0x00, 0x14, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x02, 0x10, 0x58, 0xcd, 0x4c, 0x00, 0x50,
|
||||
0x81, 0x80, 0x5c, 0x76, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, 0x00, 0xf7, 0x57, 0x00, 0x00, 0x02, 0x04, 0x04, 0xc4, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
|
||||
0x04, 0x02};
|
||||
|
||||
TEST(DUPLICATED_PACKET_FILTER, TEST)
|
||||
{
|
||||
struct packet pkt;
|
||||
uint32_t capacity = 1000000;
|
||||
uint32_t timeout = 2;
|
||||
double error_rate = 0.00001;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data, sizeof(data));
|
||||
|
||||
struct packet_filter *filter = packet_filter_new(capacity, timeout, error_rate, 1);
|
||||
EXPECT_TRUE(filter != nullptr);
|
||||
|
||||
EXPECT_TRUE(packet_filter_lookup(filter, &pkt, 1) == 0); // no found
|
||||
packet_filter_add(filter, &pkt, 1); // add
|
||||
EXPECT_TRUE(packet_filter_lookup(filter, &pkt, 1) == 1); // found
|
||||
EXPECT_TRUE(packet_filter_lookup(filter, &pkt, 2) == 1); // found
|
||||
EXPECT_TRUE(packet_filter_lookup(filter, &pkt, 3) == 0); // not found
|
||||
EXPECT_TRUE(packet_filter_lookup(filter, &pkt, 4) == 0); // not found
|
||||
|
||||
packet_filter_free(filter);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
315
infra/packet_manager/test/gtest_packet_frag.cpp
Normal file
315
infra/packet_manager/test/gtest_packet_frag.cpp
Normal file
@@ -0,0 +1,315 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:data]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 4: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
|
||||
* Ethernet II, Src: Fortinet_cc:87:22 (e8:1c:ba:cc:87:22), Dst: EvocInte_2f:35:b8 (00:22:46:2f:35:b8)
|
||||
* Destination: EvocInte_2f:35:b8 (00:22:46:2f:35:b8)
|
||||
* Source: Fortinet_cc:87:22 (e8:1c:ba:cc:87:22)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Padding: 0000
|
||||
* Internet Protocol Version 4, Src: 192.168.36.103, Dst: 192.168.40.137
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 44
|
||||
* Identification: 0xffff (65535)
|
||||
* 001. .... = Flags: 0x1, More fragments
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..1. .... = More fragments: Set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 127
|
||||
* Protocol: TCP (6)
|
||||
* Header Checksum: 0x4d8b [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0x4d8b]
|
||||
* Source Address: 192.168.36.103
|
||||
* Destination Address: 192.168.40.137
|
||||
* [Reassembled IPv4 in frame: 5]
|
||||
* Data (24 bytes)
|
||||
* Data: f4a5270f9107248703d518e75018ff005e9200003132330a
|
||||
* [Length: 24]
|
||||
*/
|
||||
|
||||
unsigned char data1[] = {
|
||||
0x00, 0x22, 0x46, 0x2f, 0x35, 0xb8, 0xe8, 0x1c, 0xba, 0xcc, 0x87, 0x22, 0x08, 0x00, 0x45, 0x00, 0x00, 0x2c, 0xff, 0xff, 0x20, 0x00, 0x7f, 0x06, 0x4d, 0x8b,
|
||||
0xc0, 0xa8, 0x24, 0x67, 0xc0, 0xa8, 0x28, 0x89, 0xf4, 0xa5, 0x27, 0x0f, 0x91, 0x07, 0x24, 0x87, 0x03, 0xd5, 0x18, 0xe7, 0x50, 0x18, 0xff, 0x00, 0x5e, 0x92,
|
||||
0x00, 0x00, 0x31, 0x32, 0x33, 0x0a, 0x00, 0x00};
|
||||
|
||||
#if 1
|
||||
TEST(PACKET_FRAG, IPV4_FRAGMENT)
|
||||
{
|
||||
struct packet handler;
|
||||
memset(&handler, 0, sizeof(handler));
|
||||
packet_parse(&handler, (const char *)data1, sizeof(data1));
|
||||
EXPECT_TRUE(packet_is_fragment(&handler) == true);
|
||||
|
||||
struct packet *dup = packet_dup(&handler);
|
||||
EXPECT_TRUE(dup != NULL);
|
||||
EXPECT_TRUE(packet_is_fragment(dup) == true);
|
||||
packet_free(dup);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ipv6:ipv6.fraghdr:data]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 5: 1510 bytes on wire (12080 bits), 1510 bytes captured (12080 bits)
|
||||
* Ethernet II, Src: Apple_c0:61:b6 (68:5b:35:c0:61:b6), Dst: Dell_94:65:38 (00:1d:09:94:65:38)
|
||||
* Destination: Dell_94:65:38 (00:1d:09:94:65:38)
|
||||
* Source: Apple_c0:61:b6 (68:5b:35:c0:61:b6)
|
||||
* Type: IPv6 (0x86dd)
|
||||
* Internet Protocol Version 6, Src: 2607:f010:3f9::1001, Dst: 2607:f010:3f9::11:0
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
|
||||
* .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* .... 0010 0001 0010 1000 1001 = Flow Label: 0x21289
|
||||
* Payload Length: 1456
|
||||
* Next Header: Fragment Header for IPv6 (44)
|
||||
* Hop Limit: 64
|
||||
* Source Address: 2607:f010:3f9::1001
|
||||
* Destination Address: 2607:f010:3f9::11:0
|
||||
* Fragment Header for IPv6
|
||||
* Next header: UDP (17)
|
||||
* Reserved octet: 0x00
|
||||
* 0000 1011 0101 0... = Offset: 362 (2896 bytes)
|
||||
* .... .... .... .00. = Reserved bits: 0
|
||||
* .... .... .... ...1 = More Fragments: Yes
|
||||
* Identification: 0xf88eb466
|
||||
* [Reassembled IPv6 in frame: 6]
|
||||
* Data (1448 bytes)
|
||||
* Data: 686868686868686868686868686868686868686868686868686868686868686868686868…
|
||||
* [Length: 1448]
|
||||
*/
|
||||
|
||||
unsigned char data2[] = {
|
||||
0x00, 0x1d, 0x09, 0x94, 0x65, 0x38, 0x68, 0x5b, 0x35, 0xc0, 0x61, 0xb6, 0x86, 0xdd, 0x60, 0x02, 0x12, 0x89, 0x05, 0xb0, 0x2c, 0x40, 0x26, 0x07, 0xf0, 0x10,
|
||||
0x03, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x26, 0x07, 0xf0, 0x10, 0x03, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
|
||||
0x00, 0x00, 0x11, 0x00, 0x0b, 0x51, 0xf8, 0x8e, 0xb4, 0x66, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
|
||||
0x68, 0x68};
|
||||
|
||||
#if 1
|
||||
TEST(PACKET_FRAG, IPV6_FRAGMENT)
|
||||
{
|
||||
struct packet handler;
|
||||
memset(&handler, 0, sizeof(handler));
|
||||
packet_parse(&handler, (const char *)data2, sizeof(data2));
|
||||
EXPECT_TRUE(packet_is_fragment(&handler) == true);
|
||||
|
||||
struct packet *dup = packet_dup(&handler);
|
||||
EXPECT_TRUE(dup != NULL);
|
||||
EXPECT_TRUE(packet_is_fragment(dup) == true);
|
||||
packet_free(dup);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
||||
* Ethernet II, Src: JuniperN_45:88:29 (2c:6b:f5:45:88:29), Dst: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Destination: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Source: JuniperN_45:88:29 (2c:6b:f5:45:88:29)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 210.77.88.163, Dst: 59.66.4.50
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 92
|
||||
* Identification: 0x0b4d (2893)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 59
|
||||
* Protocol: IPv6 (41)
|
||||
* Header Checksum: 0x09c8 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 210.77.88.163
|
||||
* Destination Address: 59.66.4.50
|
||||
* Internet Protocol Version 6, Src: 2001:da8:200:900e:200:5efe:d24d:58a3, Dst: 2600:140e:6::1702:1058
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 32
|
||||
* Next Header: TCP (6)
|
||||
* Hop Limit: 64
|
||||
* Source Address: 2001:da8:200:900e:200:5efe:d24d:58a3
|
||||
* Destination Address: 2600:140e:6::1702:1058
|
||||
* [Source ISATAP IPv4: 210.77.88.163]
|
||||
* Transmission Control Protocol, Src Port: 52556, Dst Port: 80, Seq: 0, Len: 0
|
||||
* Source Port: 52556
|
||||
* Destination Port: 80
|
||||
* [Stream index: 0]
|
||||
* [Conversation completeness: Complete, WITH_DATA (31)]
|
||||
* [TCP Segment Len: 0]
|
||||
* Sequence Number: 0 (relative sequence number)
|
||||
* Sequence Number (raw): 2172673142
|
||||
* [Next Sequence Number: 1 (relative sequence number)]
|
||||
* Acknowledgment Number: 0
|
||||
* Acknowledgment number (raw): 0
|
||||
* 1000 .... = Header Length: 32 bytes (8)
|
||||
* Flags: 0x002 (SYN)
|
||||
* Window: 8192
|
||||
* [Calculated window size: 8192]
|
||||
* Checksum: 0xf757 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* Urgent Pointer: 0
|
||||
* Options: (12 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), SACK permitted
|
||||
* [Timestamps]
|
||||
*/
|
||||
|
||||
unsigned char data3[] = {
|
||||
0x5c, 0x5e, 0xab, 0x2a, 0xa2, 0x00, 0x2c, 0x6b, 0xf5, 0x45, 0x88, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x5c, 0x0b, 0x4d, 0x00, 0x00, 0x3b, 0x29, 0x09, 0xc8,
|
||||
0xd2, 0x4d, 0x58, 0xa3, 0x3b, 0x42, 0x04, 0x32, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40, 0x20, 0x01, 0x0d, 0xa8, 0x02, 0x00, 0x90, 0x0e, 0x02, 0x00,
|
||||
0x5e, 0xfe, 0xd2, 0x4d, 0x58, 0xa3, 0x26, 0x00, 0x14, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x02, 0x10, 0x58, 0xcd, 0x4c, 0x00, 0x50,
|
||||
0x81, 0x80, 0x5c, 0x76, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, 0x00, 0xf7, 0x57, 0x00, 0x00, 0x02, 0x04, 0x04, 0xc4, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
|
||||
0x04, 0x02};
|
||||
|
||||
#if 1
|
||||
TEST(PACKET_FRAG, IPV4_IPV6_NOT_FRAGMENT)
|
||||
{
|
||||
struct packet handler;
|
||||
memset(&handler, 0, sizeof(handler));
|
||||
packet_parse(&handler, (const char *)data3, sizeof(data3));
|
||||
EXPECT_TRUE(packet_is_fragment(&handler) == false);
|
||||
|
||||
struct packet *dup = packet_dup(&handler);
|
||||
EXPECT_TRUE(dup != NULL);
|
||||
EXPECT_TRUE(packet_is_fragment(dup) == false);
|
||||
packet_free(dup);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ipv6:ipv6:udp:data]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
||||
* Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
|
||||
* Destination: Broadcast (ff:ff:ff:ff:ff:ff)
|
||||
* Source: 00:00:00_00:00:00 (00:00:00:00:00:00)
|
||||
* Type: IPv6 (0x86dd)
|
||||
* Internet Protocol Version 6, Src: 2001:4f8:4:7:2e0:81ff:fe52:ffff, Dst: 2001:4f8:4:7:2e0:81ff:fe52:9a6b
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 52
|
||||
* Next Header: IPv6 (41)
|
||||
* Hop Limit: 64
|
||||
* Source Address: 2001:4f8:4:7:2e0:81ff:fe52:ffff
|
||||
* Destination Address: 2001:4f8:4:7:2e0:81ff:fe52:9a6b
|
||||
* [Source SLAAC MAC: TyanComp_52:ff:ff (00:e0:81:52:ff:ff)]
|
||||
* [Destination SLAAC MAC: TyanComp_52:9a:6b (00:e0:81:52:9a:6b)]
|
||||
* Internet Protocol Version 6, Src: dead::beef, Dst: cafe::babe
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 12
|
||||
* Next Header: UDP (17)
|
||||
* Hop Limit: 64
|
||||
* Source Address: dead::beef
|
||||
* Destination Address: cafe::babe
|
||||
* User Datagram Protocol, Src Port: 30000, Dst Port: 13000
|
||||
* Source Port: 30000
|
||||
* Destination Port: 13000
|
||||
* Length: 12
|
||||
* Checksum: 0x83d2 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* UDP payload (4 bytes)
|
||||
* Data (4 bytes)
|
||||
*/
|
||||
|
||||
unsigned char data4[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x34, 0x29, 0x40, 0x20, 0x01, 0x04, 0xf8,
|
||||
0x00, 0x04, 0x00, 0x07, 0x02, 0xe0, 0x81, 0xff, 0xfe, 0x52, 0xff, 0xff, 0x20, 0x01, 0x04, 0xf8, 0x00, 0x04, 0x00, 0x07, 0x02, 0xe0, 0x81, 0xff, 0xfe, 0x52,
|
||||
0x9a, 0x6b, 0x60, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x11, 0x40, 0xde, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0xef,
|
||||
0xca, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0xbe, 0x75, 0x30, 0x32, 0xc8, 0x00, 0x0c, 0x83, 0xd2, 0x58, 0x58,
|
||||
0x58, 0x58};
|
||||
|
||||
#if 1
|
||||
TEST(PACKET_FRAG, IPV6_IPV6_NOT_FRAGMENT)
|
||||
{
|
||||
struct packet handler;
|
||||
memset(&handler, 0, sizeof(handler));
|
||||
packet_parse(&handler, (const char *)data4, sizeof(data4));
|
||||
EXPECT_TRUE(packet_is_fragment(&handler) == false);
|
||||
|
||||
struct packet *dup = packet_dup(&handler);
|
||||
EXPECT_TRUE(dup != NULL);
|
||||
EXPECT_TRUE(packet_is_fragment(dup) == false);
|
||||
packet_free(dup);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
96
infra/packet_manager/test/gtest_packet_ldbc.cpp
Normal file
96
infra/packet_manager/test/gtest_packet_ldbc.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "packet_dump.h"
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 106 bytes on wire (848 bits), 106 bytes captured (848 bits)
|
||||
* Ethernet II, Src: JuniperN_45:88:29 (2c:6b:f5:45:88:29), Dst: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Destination: JuniperN_2a:a2:00 (5c:5e:ab:2a:a2:00)
|
||||
* Source: JuniperN_45:88:29 (2c:6b:f5:45:88:29)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 210.77.88.163, Dst: 59.66.4.50
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 92
|
||||
* Identification: 0x0b4d (2893)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 59
|
||||
* Protocol: IPv6 (41)
|
||||
* Header Checksum: 0x09c8 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 210.77.88.163
|
||||
* Destination Address: 59.66.4.50
|
||||
* Internet Protocol Version 6, Src: 2001:da8:200:900e:200:5efe:d24d:58a3, Dst: 2600:140e:6::1702:1058
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 32
|
||||
* Next Header: TCP (6)
|
||||
* Hop Limit: 64
|
||||
* Source Address: 2001:da8:200:900e:200:5efe:d24d:58a3
|
||||
* Destination Address: 2600:140e:6::1702:1058
|
||||
* [Source ISATAP IPv4: 210.77.88.163]
|
||||
* Transmission Control Protocol, Src Port: 52556, Dst Port: 80, Seq: 0, Len: 0
|
||||
* Source Port: 52556
|
||||
* Destination Port: 80
|
||||
* [Stream index: 0]
|
||||
* [Conversation completeness: Complete, WITH_DATA (31)]
|
||||
* [TCP Segment Len: 0]
|
||||
* Sequence Number: 0 (relative sequence number)
|
||||
* Sequence Number (raw): 2172673142
|
||||
* [Next Sequence Number: 1 (relative sequence number)]
|
||||
* Acknowledgment Number: 0
|
||||
* Acknowledgment number (raw): 0
|
||||
* 1000 .... = Header Length: 32 bytes (8)
|
||||
* Flags: 0x002 (SYN)
|
||||
* Window: 8192
|
||||
* [Calculated window size: 8192]
|
||||
* Checksum: 0xf757 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* Urgent Pointer: 0
|
||||
* Options: (12 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), SACK permitted
|
||||
* [Timestamps]
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0x5c, 0x5e, 0xab, 0x2a, 0xa2, 0x00, 0x2c, 0x6b, 0xf5, 0x45, 0x88, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x5c, 0x0b, 0x4d, 0x00, 0x00, 0x3b, 0x29, 0x09, 0xc8,
|
||||
0xd2, 0x4d, 0x58, 0xa3, 0x3b, 0x42, 0x04, 0x32, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x06, 0x40, 0x20, 0x01, 0x0d, 0xa8, 0x02, 0x00, 0x90, 0x0e, 0x02, 0x00,
|
||||
0x5e, 0xfe, 0xd2, 0x4d, 0x58, 0xa3, 0x26, 0x00, 0x14, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x02, 0x10, 0x58, 0xcd, 0x4c, 0x00, 0x50,
|
||||
0x81, 0x80, 0x5c, 0x76, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, 0x00, 0xf7, 0x57, 0x00, 0x00, 0x02, 0x04, 0x04, 0xc4, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
|
||||
0x04, 0x02};
|
||||
|
||||
#if 1
|
||||
TEST(PACKET_LDBC, HASH_VALUE)
|
||||
{
|
||||
struct packet handler;
|
||||
|
||||
memset(&handler, 0, sizeof(handler));
|
||||
const char *payload = packet_parse(&handler, (const char *)data, sizeof(data));
|
||||
EXPECT_TRUE(payload != nullptr);
|
||||
EXPECT_TRUE((char *)payload - (char *)&data == 106);
|
||||
packet_print(&handler);
|
||||
|
||||
// buffer: "2001:da8:200:900e:200:5efe:d24d:58a3 0 2600:140e:6::1702:1058 0"
|
||||
// buffer: "210.77.88.163 0 59.66.4.50 0"
|
||||
|
||||
EXPECT_TRUE(packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_INT_IP, PACKET_DIRECTION_INCOMING) == packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_EXT_IP, PACKET_DIRECTION_OUTGOING));
|
||||
EXPECT_TRUE(packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_EXT_IP, PACKET_DIRECTION_INCOMING) == packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_INT_IP, PACKET_DIRECTION_OUTGOING));
|
||||
|
||||
EXPECT_TRUE(packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_INT_EXT_IP, PACKET_DIRECTION_INCOMING) == packet_ldbc_hash(&handler, PKT_LDBC_METH_OUTERMOST_INT_EXT_IP, PACKET_DIRECTION_OUTGOING));
|
||||
EXPECT_TRUE(packet_ldbc_hash(&handler, PKT_LDBC_METH_INNERMOST_INT_IP, PACKET_DIRECTION_INCOMING) == packet_ldbc_hash(&handler, PKT_LDBC_METH_INNERMOST_EXT_IP, PACKET_DIRECTION_OUTGOING));
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
3051
infra/packet_manager/test/gtest_packet_parser.cpp
Normal file
3051
infra/packet_manager/test/gtest_packet_parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
148
infra/packet_manager/test/gtest_tcp_utils.cpp
Normal file
148
infra/packet_manager/test/gtest_tcp_utils.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Transmission Control Protocol, Src Port: 55555, Dst Port: 40856, Seq: 0, Ack: 1, Len: 0
|
||||
* Source Port: 55555
|
||||
* Destination Port: 40856
|
||||
* [Stream index: 0]
|
||||
* [Conversation completeness: Complete, WITH_DATA (31)]
|
||||
* [TCP Segment Len: 0]
|
||||
* Sequence Number: 0 (relative sequence number)
|
||||
* Sequence Number (raw): 3965699644
|
||||
* [Next Sequence Number: 1 (relative sequence number)]
|
||||
* Acknowledgment Number: 1 (relative ack number)
|
||||
* Acknowledgment number (raw): 991053714
|
||||
* 1010 .... = Header Length: 40 bytes (10)
|
||||
* Flags: 0x012 (SYN, ACK)
|
||||
* 000. .... .... = Reserved: Not set
|
||||
* ...0 .... .... = Accurate ECN: Not set
|
||||
* .... 0... .... = Congestion Window Reduced: Not set
|
||||
* .... .0.. .... = ECN-Echo: Not set
|
||||
* .... ..0. .... = Urgent: Not set
|
||||
* .... ...1 .... = Acknowledgment: Set
|
||||
* .... .... 0... = Push: Not set
|
||||
* .... .... .0.. = Reset: Not set
|
||||
* .... .... ..1. = Syn: Set
|
||||
* [Expert Info (Chat/Sequence): Connection establish acknowledge (SYN+ACK): server port 55555]
|
||||
* [Connection establish acknowledge (SYN+ACK): server port 55555]
|
||||
* [Severity level: Chat]
|
||||
* [Group: Sequence]
|
||||
* .... .... ...0 = Fin: Not set
|
||||
* [TCP Flags: ·······A··S·]
|
||||
* Window: 43690
|
||||
* [Calculated window size: 43690]
|
||||
* Checksum: 0xfe30 incorrect, should be 0x65c9(maybe caused by "TCP checksum offload"?)
|
||||
* [Expert Info (Error/Checksum): Bad checksum [should be 0x65c9]]
|
||||
* [Bad checksum [should be 0x65c9]]
|
||||
* [Severity level: Error]
|
||||
* [Group: Checksum]
|
||||
* [Checksum Status: Bad]
|
||||
* [Calculated Checksum: 0x65c9]
|
||||
* Urgent Pointer: 0
|
||||
* Options: (20 bytes), Maximum segment size, SACK permitted, Timestamps, No-Operation (NOP), Window scale
|
||||
* TCP Option - Maximum segment size: 65495 bytes
|
||||
* Kind: Maximum Segment Size (2)
|
||||
* Length: 4
|
||||
* MSS Value: 65495
|
||||
* TCP Option - SACK permitted
|
||||
* Kind: SACK Permitted (4)
|
||||
* Length: 2
|
||||
* TCP Option - Timestamps
|
||||
* Kind: Time Stamp Option (8)
|
||||
* Length: 10
|
||||
* Timestamp value: 2767168460: TSval 2767168460, TSecr 2767168460
|
||||
* Timestamp echo reply: 2767168460
|
||||
* TCP Option - No-Operation (NOP)
|
||||
* Kind: No-Operation (1)
|
||||
* TCP Option - Window scale: 7 (multiply by 128)
|
||||
* Kind: Window Scale (3)
|
||||
* Length: 3
|
||||
* Shift count: 7
|
||||
* [Multiplier: 128]
|
||||
* [Timestamps]
|
||||
* [Time since first frame in this TCP stream: 475471172.552028000 seconds]
|
||||
* [Time since previous frame in this TCP stream: 475471172.552028000 seconds]
|
||||
* [SEQ/ACK analysis]
|
||||
* [This is an ACK to the segment in frame: 1]
|
||||
* [The RTT to ACK the segment was: 475471172.552028000 seconds]
|
||||
* [iRTT: 0.000039000 seconds]
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0xd9, 0x03, 0x9f, 0x98, 0xec, 0x5f, 0xc6, 0x3c, 0x3b, 0x12, 0x47, 0x92, 0xa0, 0x12, 0xaa, 0xaa, 0xfe, 0x30, 0x00, 0x00, 0x02, 0x04, 0xff, 0xd7, 0x04, 0x02,
|
||||
0x08, 0x0a, 0xa4, 0xef, 0xa3, 0xcc, 0xa4, 0xef, 0xa3, 0xcc, 0x01, 0x03, 0x03, 0x07};
|
||||
|
||||
TEST(TCP_UTILS, GET)
|
||||
{
|
||||
const struct tcphdr *hdr = (struct tcphdr *)data;
|
||||
EXPECT_TRUE(tcp_hdr_get_src_port(hdr) == 55555);
|
||||
EXPECT_TRUE(tcp_hdr_get_dst_port(hdr) == 40856);
|
||||
EXPECT_TRUE(tcp_hdr_get_seq(hdr) == 3965699644);
|
||||
EXPECT_TRUE(tcp_hdr_get_ack(hdr) == 991053714);
|
||||
EXPECT_TRUE(tcp_hdr_get_hdr_len(hdr) == 40);
|
||||
EXPECT_TRUE(tcp_hdr_get_flags(hdr) == 0x012);
|
||||
EXPECT_TRUE(tcp_hdr_get_urg_flag(hdr) == false);
|
||||
EXPECT_TRUE(tcp_hdr_get_ack_flag(hdr) == true);
|
||||
EXPECT_TRUE(tcp_hdr_get_push_flag(hdr) == false);
|
||||
EXPECT_TRUE(tcp_hdr_get_rst_flag(hdr) == false);
|
||||
EXPECT_TRUE(tcp_hdr_get_syn_flag(hdr) == true);
|
||||
EXPECT_TRUE(tcp_hdr_get_fin_flag(hdr) == false);
|
||||
EXPECT_TRUE(tcp_hdr_get_window(hdr) == 43690);
|
||||
EXPECT_TRUE(tcp_hdr_get_checksum(hdr) == 0xfe30);
|
||||
EXPECT_TRUE(tcp_hdr_get_urg_ptr(hdr) == 0);
|
||||
EXPECT_TRUE(tcp_hdr_get_opt_len(hdr) == 20);
|
||||
EXPECT_TRUE(tcp_hdr_get_opt_data(hdr) == (const char *)(data + 20));
|
||||
}
|
||||
|
||||
TEST(TCP_UTILS, SET1)
|
||||
{
|
||||
char buff[40] = {0};
|
||||
|
||||
struct tcphdr *hdr = (struct tcphdr *)buff;
|
||||
tcp_hdr_set_src_port(hdr, 55555);
|
||||
tcp_hdr_set_dst_port(hdr, 40856);
|
||||
tcp_hdr_set_seq(hdr, 3965699644);
|
||||
tcp_hdr_set_ack(hdr, 991053714);
|
||||
tcp_hdr_set_hdr_len(hdr, 40);
|
||||
tcp_hdr_set_flags(hdr, 0x012);
|
||||
tcp_hdr_set_window(hdr, 43690);
|
||||
tcp_hdr_set_checksum(hdr, 0xfe30);
|
||||
tcp_hdr_set_urg_ptr(hdr, 0);
|
||||
tcp_hdr_set_opt_len(hdr, 20);
|
||||
tcp_hdr_set_opt_data(hdr, (const char *)(data + 20));
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, data, 40) == 0);
|
||||
}
|
||||
|
||||
TEST(TCP_UTILS, SET2)
|
||||
{
|
||||
char buff[40] = {0};
|
||||
|
||||
struct tcphdr *hdr = (struct tcphdr *)buff;
|
||||
tcp_hdr_set_src_port(hdr, 55555);
|
||||
tcp_hdr_set_dst_port(hdr, 40856);
|
||||
tcp_hdr_set_seq(hdr, 3965699644);
|
||||
tcp_hdr_set_ack(hdr, 991053714);
|
||||
tcp_hdr_set_hdr_len(hdr, 40);
|
||||
tcp_hdr_set_urg_flag(hdr, false);
|
||||
tcp_hdr_set_ack_flag(hdr, true);
|
||||
tcp_hdr_set_push_flag(hdr, false);
|
||||
tcp_hdr_set_rst_flag(hdr, false);
|
||||
tcp_hdr_set_syn_flag(hdr, true);
|
||||
tcp_hdr_set_fin_flag(hdr, false);
|
||||
tcp_hdr_set_window(hdr, 43690);
|
||||
tcp_hdr_set_checksum(hdr, 0xfe30);
|
||||
tcp_hdr_set_urg_ptr(hdr, 0);
|
||||
tcp_hdr_set_opt_len(hdr, 20);
|
||||
tcp_hdr_set_opt_data(hdr, (const char *)(data + 20));
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, data, 40) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
719
infra/packet_manager/test/gtest_tunnel.cpp
Normal file
719
infra/packet_manager/test/gtest_tunnel.cpp
Normal file
@@ -0,0 +1,719 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
#include "packet_private.h"
|
||||
#include "packet_parser.h"
|
||||
#include "packet_dump.h"
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:vlan:ethertype:vlan:ethertype:ip:ip:udp:data]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 170 bytes on wire (1360 bits), 170 bytes captured (1360 bits)
|
||||
* Ethernet II, Src: HuaweiTe_3b:b3:9a (a4:c6:4f:3b:b3:9a), Dst: 00:00:00_00:00:04 (00:00:00:00:00:04)
|
||||
* Destination: 00:00:00_00:00:04 (00:00:00:00:00:04)
|
||||
* Source: HuaweiTe_3b:b3:9a (a4:c6:4f:3b:b3:9a)
|
||||
* Type: 802.1Q Virtual LAN (0x8100)
|
||||
* 802.1Q Virtual LAN, PRI: 3, DEI: 0, ID: 1624
|
||||
* 011. .... .... .... = Priority: Critical Applications (3)
|
||||
* ...0 .... .... .... = DEI: Ineligible
|
||||
* .... 0110 0101 1000 = ID: 1624
|
||||
* Type: 802.1Q Virtual LAN (0x8100)
|
||||
* 802.1Q Virtual LAN, PRI: 3, DEI: 0, ID: 505
|
||||
* 011. .... .... .... = Priority: Critical Applications (3)
|
||||
* ...0 .... .... .... = DEI: Ineligible
|
||||
* .... 0001 1111 1001 = ID: 505
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 69.67.35.146, Dst: 41.202.46.110
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0xb8 (DSCP: EF PHB, ECN: Not-ECT)
|
||||
* Total Length: 148
|
||||
* Identification: 0xe858 (59480)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 255
|
||||
* Protocol: IPIP (4)
|
||||
* Header Checksum: 0x1148 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 69.67.35.146
|
||||
* Destination Address: 41.202.46.110
|
||||
* Internet Protocol Version 4, Src: 10.10.100.25, Dst: 10.10.101.2
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0xb8 (DSCP: EF PHB, ECN: Not-ECT)
|
||||
* Total Length: 128
|
||||
* Identification: 0x0001 (1)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 254
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0xde84 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 10.10.100.25
|
||||
* Destination Address: 10.10.101.2
|
||||
* User Datagram Protocol, Src Port: 62367, Dst Port: 17000
|
||||
* Source Port: 62367
|
||||
* Destination Port: 17000
|
||||
* Length: 108
|
||||
* Checksum: 0x4b9a [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* [Time since first frame: 0.000000000 seconds]
|
||||
* [Time since previous frame: 0.000000000 seconds]
|
||||
* UDP payload (100 bytes)
|
||||
* Data (100 bytes)
|
||||
*/
|
||||
|
||||
unsigned char data1[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xa4, 0xc6, 0x4f, 0x3b, 0xb3, 0x9a, 0x81, 0x00, 0x66, 0x58, 0x81, 0x00, 0x61, 0xf9, 0x08, 0x00, 0x45, 0xb8, 0x00, 0x94,
|
||||
0xe8, 0x58, 0x00, 0x00, 0xff, 0x04, 0x11, 0x48, 0x45, 0x43, 0x23, 0x92, 0x29, 0xca, 0x2e, 0x6e, 0x45, 0xb8, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, 0xfe, 0x11,
|
||||
0xde, 0x84, 0x0a, 0x0a, 0x64, 0x19, 0x0a, 0x0a, 0x65, 0x02, 0xf3, 0x9f, 0x42, 0x68, 0x00, 0x6c, 0x4b, 0x9a, 0x00, 0x02, 0x00, 0x00, 0x04, 0x73, 0x6c, 0x10,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
|
||||
0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
|
||||
0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd,
|
||||
0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd, 0xab, 0xcd};
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:vlan:ethertype:ipv6:ip:gre:ppp:ip:udp:dns]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 272 bytes on wire (2176 bits), 272 bytes captured (2176 bits)
|
||||
* Ethernet II, Src: Cisco_e6:82:c4 (00:19:06:e6:82:c4), Dst: 10:01:00:00:61:3d (10:01:00:00:61:3d)
|
||||
* Destination: 10:01:00:00:61:3d (10:01:00:00:61:3d)
|
||||
* Source: Cisco_e6:82:c4 (00:19:06:e6:82:c4)
|
||||
* Type: 802.1Q Virtual LAN (0x8100)
|
||||
* 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 100
|
||||
* 000. .... .... .... = Priority: Best Effort (default) (0)
|
||||
* ...0 .... .... .... = DEI: Ineligible
|
||||
* .... 0000 0110 0100 = ID: 100
|
||||
* Type: IPv6 (0x86dd)
|
||||
* Internet Protocol Version 6, Src: 2607:fcd0:100:2300::b108:2a6b, Dst: 2402:f000:1:8e01::5555
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 214
|
||||
* Next Header: IPIP (4)
|
||||
* Hop Limit: 57
|
||||
* Source Address: 2607:fcd0:100:2300::b108:2a6b
|
||||
* Destination Address: 2402:f000:1:8e01::5555
|
||||
* Internet Protocol Version 4, Src: 192.52.166.154, Dst: 16.0.0.200
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 214
|
||||
* Identification: 0x842f (33839)
|
||||
* 010. .... = Flags: 0x2, Don't fragment
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 64
|
||||
* Protocol: Generic Routing Encapsulation (47)
|
||||
* Header Checksum: 0x3e33 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 192.52.166.154
|
||||
* Destination Address: 16.0.0.200
|
||||
* Generic Routing Encapsulation (PPP)
|
||||
* Flags and Version: 0x3081
|
||||
* Protocol Type: PPP (0x880b)
|
||||
* Payload Length: 178
|
||||
* Call ID: 17
|
||||
* Sequence Number: 538640
|
||||
* Acknowledgment Number: 429725
|
||||
* Point-to-Point Protocol
|
||||
* Address: 0xff
|
||||
* Control: 0x03
|
||||
* Protocol: Internet Protocol version 4 (0x0021)
|
||||
* Internet Protocol Version 4, Src: 8.8.8.8, Dst: 172.16.44.3
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 174
|
||||
* Identification: 0x2f9c (12188)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 50
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0x7080 [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 8.8.8.8
|
||||
* Destination Address: 172.16.44.3
|
||||
* User Datagram Protocol, Src Port: 53, Dst Port: 9879
|
||||
* Source Port: 53
|
||||
* Destination Port: 9879
|
||||
* Length: 154
|
||||
* Checksum: 0x45d9 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* UDP payload (146 bytes)
|
||||
* Domain Name System (response)
|
||||
*/
|
||||
|
||||
unsigned char data2[] = {
|
||||
0x10, 0x01, 0x00, 0x00, 0x61, 0x3d, 0x00, 0x19, 0x06, 0xe6, 0x82, 0xc4, 0x81, 0x00, 0x00, 0x64, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0xd6, 0x04, 0x39,
|
||||
0x26, 0x07, 0xfc, 0xd0, 0x01, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x08, 0x2a, 0x6b, 0x24, 0x02, 0xf0, 0x00, 0x00, 0x01, 0x8e, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x45, 0x00, 0x00, 0xd6, 0x84, 0x2f, 0x40, 0x00, 0x40, 0x2f, 0x3e, 0x33, 0xc0, 0x34, 0xa6, 0x9a, 0x10, 0x00, 0x00, 0xc8,
|
||||
0x30, 0x81, 0x88, 0x0b, 0x00, 0xb2, 0x00, 0x11, 0x00, 0x08, 0x38, 0x10, 0x00, 0x06, 0x8e, 0x9d, 0xff, 0x03, 0x00, 0x21, 0x45, 0x00, 0x00, 0xae, 0x2f, 0x9c,
|
||||
0x00, 0x00, 0x32, 0x11, 0x70, 0x80, 0x08, 0x08, 0x08, 0x08, 0xac, 0x10, 0x2c, 0x03, 0x00, 0x35, 0x26, 0x97, 0x00, 0x9a, 0x45, 0xd9, 0xb4, 0xe2, 0x81, 0x83,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x35, 0x78, 0x71, 0x74, 0x2d, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x2d, 0x6d, 0x6f, 0x64, 0x65, 0x32, 0x2d,
|
||||
0x37, 0x38, 0x63, 0x30, 0x36, 0x64, 0x63, 0x37, 0x2d, 0x30, 0x34, 0x61, 0x37, 0x2d, 0x34, 0x38, 0x35, 0x33, 0x2d, 0x38, 0x34, 0x38, 0x33, 0x2d, 0x61, 0x35,
|
||||
0x36, 0x32, 0x38, 0x39, 0x37, 0x36, 0x65, 0x32, 0x33, 0x33, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x02, 0xf0, 0x00, 0x40,
|
||||
0x01, 0x61, 0x0c, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x05, 0x6e, 0x73, 0x74, 0x6c, 0x64,
|
||||
0x0c, 0x76, 0x65, 0x72, 0x69, 0x73, 0x69, 0x67, 0x6e, 0x2d, 0x67, 0x72, 0x73, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x78, 0x0d, 0x09, 0x09, 0x00, 0x00, 0x07, 0x08,
|
||||
0x00, 0x00, 0x03, 0x84, 0x00, 0x09, 0x3a, 0x80, 0x00, 0x01, 0x51, 0x80};
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ipv6:udp:gtp:ipv6:tcp:ja3:tls]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 1442 bytes on wire (11536 bits), 1442 bytes captured (11536 bits)
|
||||
* Ethernet II, Src: zte_0e:f5:40 (74:4a:a4:0e:f5:40), Dst: HuaweiTe_40:e9:c2 (ac:b3:b5:40:e9:c2)
|
||||
* Destination: HuaweiTe_40:e9:c2 (ac:b3:b5:40:e9:c2)
|
||||
* Source: zte_0e:f5:40 (74:4a:a4:0e:f5:40)
|
||||
* Type: IPv6 (0x86dd)
|
||||
* Internet Protocol Version 6, Src: 2409:8034:4040:5300::105, Dst: 2409:8034:4025::60:61
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 1388
|
||||
* Next Header: UDP (17)
|
||||
* Hop Limit: 127
|
||||
* Source Address: 2409:8034:4040:5300::105
|
||||
* Destination Address: 2409:8034:4025::60:61
|
||||
* User Datagram Protocol, Src Port: 2152, Dst Port: 2152
|
||||
* Source Port: 2152
|
||||
* Destination Port: 2152
|
||||
* Length: 1388
|
||||
* Checksum: 0xeb00 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* UDP payload (1380 bytes)
|
||||
* GPRS Tunneling Protocol
|
||||
* Flags: 0x30
|
||||
* Message Type: T-PDU (0xff)
|
||||
* Length: 1372
|
||||
* TEID: 0x024c3cbd (38550717)
|
||||
* Internet Protocol Version 6, Src: 2409:8c34:4400:700:0:4:0:3, Dst: 2409:8934:5082:2100:ecad:e0e4:530a:c269
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 1332
|
||||
* Next Header: TCP (6)
|
||||
* Hop Limit: 56
|
||||
* Source Address: 2409:8c34:4400:700:0:4:0:3
|
||||
* Destination Address: 2409:8934:5082:2100:ecad:e0e4:530a:c269
|
||||
* Transmission Control Protocol, Src Port: 443, Dst Port: 46582, Seq: 1, Ack: 1, Len: 1312
|
||||
* Source Port: 443
|
||||
* Destination Port: 46582
|
||||
* [Stream index: 0]
|
||||
* [Conversation completeness: Incomplete (8)]
|
||||
* [TCP Segment Len: 1312]
|
||||
* Sequence Number: 1 (relative sequence number)
|
||||
* Sequence Number (raw): 2198097831
|
||||
* [Next Sequence Number: 1313 (relative sequence number)]
|
||||
* Acknowledgment Number: 1 (relative ack number)
|
||||
* Acknowledgment number (raw): 2264498872
|
||||
* 0101 .... = Header Length: 20 bytes (5)
|
||||
* Flags: 0x010 (ACK)
|
||||
* Window: 529
|
||||
* [Calculated window size: 529]
|
||||
* [Window size scaling factor: -1 (unknown)]
|
||||
* Checksum: 0x2c4b [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* Urgent Pointer: 0
|
||||
* [Timestamps]
|
||||
* [SEQ/ACK analysis]
|
||||
* TCP payload (1312 bytes)
|
||||
* Transport Layer Security
|
||||
*/
|
||||
|
||||
unsigned char data3[] = {
|
||||
0xac, 0xb3, 0xb5, 0x40, 0xe9, 0xc2, 0x74, 0x4a, 0xa4, 0x0e, 0xf5, 0x40, 0x86, 0xdd, 0x60, 0x00, 0x00, 0x00, 0x05, 0x6c, 0x11, 0x7f, 0x24, 0x09, 0x80, 0x34,
|
||||
0x40, 0x40, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x24, 0x09, 0x80, 0x34, 0x40, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
|
||||
0x00, 0x61, 0x08, 0x68, 0x08, 0x68, 0x05, 0x6c, 0xeb, 0x00, 0x30, 0xff, 0x05, 0x5c, 0x02, 0x4c, 0x3c, 0xbd, 0x60, 0x00, 0x00, 0x00, 0x05, 0x34, 0x06, 0x38,
|
||||
0x24, 0x09, 0x8c, 0x34, 0x44, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x24, 0x09, 0x89, 0x34, 0x50, 0x82, 0x21, 0x00, 0xec, 0xad,
|
||||
0xe0, 0xe4, 0x53, 0x0a, 0xc2, 0x69, 0x01, 0xbb, 0xb5, 0xf6, 0x83, 0x04, 0x4f, 0xa7, 0x86, 0xf9, 0x82, 0xb8, 0x50, 0x10, 0x02, 0x11, 0x2c, 0x4b, 0x00, 0x00,
|
||||
0x17, 0x03, 0x03, 0x3c, 0x8c, 0x87, 0xa0, 0x99, 0x23, 0x5b, 0x53, 0x4a, 0x12, 0x1b, 0xf8, 0xba, 0xe8, 0x83, 0xc2, 0x95, 0xda, 0xb8, 0xea, 0x5b, 0xdc, 0x84,
|
||||
0x61, 0xa9, 0x86, 0x7e, 0x43, 0xc7, 0x31, 0x44, 0x6e, 0x11, 0xc1, 0x30, 0x21, 0x03, 0xb4, 0x21, 0x4a, 0xee, 0xc9, 0x2e, 0x14, 0xd2, 0x98, 0x63, 0x12, 0xfe,
|
||||
0x79, 0x58, 0xb3, 0x18, 0xa6, 0x8d, 0x0c, 0x62, 0x67, 0x51, 0xef, 0x02, 0x5a, 0xa8, 0xb3, 0x82, 0x1f, 0xe4, 0x51, 0xba, 0xde, 0xee, 0x83, 0x9c, 0x4e, 0xac,
|
||||
0x4d, 0xa2, 0xb7, 0x6a, 0x82, 0xe7, 0xbb, 0x00, 0xf7, 0x5a, 0xe7, 0x02, 0x71, 0x7e, 0x7d, 0x6f, 0xf2, 0xe5, 0x47, 0xd0, 0xba, 0x3c, 0x51, 0x09, 0x95, 0xcd,
|
||||
0xf6, 0xc9, 0x8b, 0x6f, 0xb0, 0x39, 0x11, 0x0d, 0xe9, 0x0d, 0x4d, 0x29, 0xd4, 0xcb, 0x87, 0xba, 0x11, 0xfa, 0x0d, 0x0b, 0x82, 0x95, 0xa5, 0x84, 0x94, 0x48,
|
||||
0xa2, 0xee, 0xa4, 0xb7, 0xb6, 0x76, 0x13, 0x4d, 0x18, 0x42, 0x91, 0x77, 0xad, 0x82, 0x38, 0xee, 0x34, 0x1c, 0xb7, 0xf6, 0x39, 0xdc, 0xa4, 0x23, 0xa1, 0x7c,
|
||||
0xa5, 0x0b, 0x7e, 0x4c, 0x8b, 0x81, 0x31, 0x48, 0xea, 0xf4, 0x18, 0x37, 0x09, 0x0a, 0x53, 0x13, 0x05, 0x90, 0x26, 0x10, 0x69, 0xb2, 0xa3, 0x36, 0xbc, 0xa5,
|
||||
0x83, 0xd8, 0x16, 0x77, 0x98, 0xc8, 0x21, 0x38, 0xd9, 0x88, 0x0c, 0xa7, 0x16, 0x97, 0x4e, 0x20, 0x6d, 0x68, 0xda, 0x1b, 0x3b, 0x4a, 0x62, 0xe0, 0x36, 0x0d,
|
||||
0xbf, 0x30, 0x71, 0xb1, 0xe9, 0xbe, 0x47, 0x77, 0x99, 0xb9, 0xe6, 0x26, 0xab, 0x81, 0x2e, 0x46, 0xf1, 0x1b, 0x1e, 0xfb, 0xd7, 0x81, 0x60, 0x21, 0x4a, 0x71,
|
||||
0x85, 0xf7, 0x9c, 0x9c, 0xd4, 0x1c, 0x52, 0xc4, 0x3d, 0x8d, 0x72, 0xf6, 0x7c, 0xd3, 0x58, 0x79, 0x0d, 0x78, 0xd7, 0x7c, 0x29, 0x2b, 0xc3, 0x96, 0x1d, 0xc7,
|
||||
0x96, 0x50, 0x42, 0xd7, 0xda, 0xeb, 0x29, 0x8e, 0x2a, 0x72, 0x23, 0x57, 0x0f, 0x6f, 0x37, 0x35, 0xb2, 0x42, 0x76, 0x78, 0xbf, 0xbf, 0x8c, 0x3f, 0x31, 0xa2,
|
||||
0x51, 0xec, 0x9e, 0x0d, 0xfd, 0xf2, 0xaf, 0x71, 0xa0, 0x4f, 0xa9, 0xf6, 0x19, 0xcf, 0x3e, 0x4b, 0xc8, 0xaa, 0x38, 0x06, 0xa1, 0x15, 0xde, 0xde, 0xef, 0x9b,
|
||||
0x25, 0xa3, 0xcc, 0x47, 0xca, 0x29, 0x30, 0x65, 0x5f, 0xc1, 0x8b, 0x12, 0x63, 0x79, 0xcd, 0x57, 0x4d, 0x99, 0xc0, 0xcd, 0xbe, 0x62, 0xcb, 0xc3, 0xf2, 0x6b,
|
||||
0x0b, 0x40, 0xc5, 0xee, 0x79, 0x0a, 0xa4, 0x75, 0x56, 0xe7, 0xe7, 0xf2, 0xfd, 0xe0, 0x72, 0x78, 0x04, 0xa2, 0x50, 0x31, 0x09, 0x8b, 0x57, 0xc3, 0x85, 0x4e,
|
||||
0xc4, 0xae, 0xde, 0x8a, 0xfa, 0xf6, 0x31, 0x06, 0xd2, 0x07, 0x25, 0x40, 0xce, 0x0d, 0xfd, 0x26, 0x98, 0x41, 0xa3, 0xa9, 0xa2, 0x8d, 0x8b, 0x7f, 0x6d, 0x63,
|
||||
0x87, 0x7e, 0x75, 0x2f, 0x78, 0xc9, 0xd5, 0x04, 0xb2, 0x4f, 0xc9, 0x94, 0xa7, 0x7f, 0xbc, 0x75, 0x7b, 0xb6, 0xfb, 0x2c, 0x46, 0xf6, 0xde, 0x36, 0x31, 0x2a,
|
||||
0x32, 0x1d, 0x7f, 0x30, 0x9e, 0x4a, 0x84, 0x69, 0x66, 0xac, 0xef, 0xbe, 0xb3, 0x83, 0x8c, 0xb8, 0x30, 0xd2, 0x3f, 0xcf, 0xb5, 0xbb, 0x65, 0xaa, 0xe7, 0x6b,
|
||||
0x74, 0x48, 0x2c, 0xb2, 0x72, 0x2b, 0x78, 0xaf, 0xd0, 0x71, 0x04, 0xa9, 0xb4, 0x65, 0xd9, 0xfc, 0x74, 0x23, 0xff, 0x89, 0xc1, 0x16, 0x23, 0xac, 0x59, 0x16,
|
||||
0x89, 0x41, 0xc3, 0xdb, 0xdb, 0x5b, 0x9a, 0x3d, 0x08, 0xc4, 0x12, 0x28, 0xf8, 0x10, 0xa5, 0xad, 0xc6, 0x81, 0xc0, 0x61, 0x48, 0xba, 0x9d, 0xef, 0xc7, 0xf8,
|
||||
0xad, 0x9a, 0xbd, 0x87, 0xfa, 0x7f, 0xa2, 0x4e, 0x4d, 0xe0, 0x19, 0xd5, 0x47, 0xc7, 0xd0, 0xfb, 0x00, 0x7b, 0xbf, 0x17, 0x80, 0xfe, 0xf5, 0x27, 0xec, 0x94,
|
||||
0x44, 0x3d, 0x4a, 0x34, 0x49, 0x60, 0xb4, 0x8d, 0x71, 0x6d, 0x9c, 0xf4, 0x4c, 0x33, 0xa9, 0x49, 0x58, 0x58, 0x6f, 0xe1, 0xd1, 0x7d, 0x36, 0x51, 0xf4, 0xd8,
|
||||
0x0d, 0x0b, 0xfc, 0xeb, 0xae, 0x58, 0x06, 0x08, 0xbf, 0x67, 0x07, 0x28, 0x7e, 0x68, 0x65, 0x79, 0x86, 0xfb, 0x43, 0x0f, 0x0a, 0xef, 0xd0, 0x97, 0x33, 0x10,
|
||||
0x7a, 0x20, 0xe8, 0x22, 0xe5, 0xdc, 0x0c, 0xa2, 0xa5, 0x50, 0x1b, 0x08, 0x15, 0xc2, 0xec, 0xd2, 0x06, 0x25, 0xd0, 0x3b, 0xfd, 0xe3, 0xa2, 0x6f, 0x41, 0x15,
|
||||
0x6d, 0x9f, 0x5f, 0xc4, 0x07, 0x5c, 0x99, 0x63, 0xd9, 0xd7, 0xdc, 0x90, 0xc9, 0x8f, 0x3a, 0x4b, 0x6a, 0x84, 0xe8, 0x3c, 0xc7, 0x71, 0x50, 0x71, 0x86, 0x71,
|
||||
0x7d, 0x54, 0x84, 0x7b, 0xb7, 0xca, 0xd5, 0x42, 0xaf, 0x88, 0xa5, 0xae, 0xa4, 0x9c, 0xfd, 0x71, 0x71, 0x0f, 0x67, 0xaa, 0x1b, 0x61, 0xd7, 0xf4, 0x50, 0x21,
|
||||
0x9d, 0x80, 0x6e, 0x54, 0xcd, 0xb6, 0xb9, 0x02, 0x3e, 0x59, 0x50, 0xff, 0xf2, 0xda, 0x21, 0x5c, 0x50, 0x6d, 0x64, 0x8c, 0x33, 0x75, 0x2a, 0xa4, 0x56, 0xb3,
|
||||
0xa8, 0xdb, 0xba, 0xbe, 0x52, 0xd4, 0xe5, 0x29, 0x68, 0xe2, 0x6b, 0x94, 0x6b, 0xb3, 0x90, 0x63, 0x91, 0x1a, 0x95, 0xb5, 0xd7, 0x10, 0x1b, 0xd9, 0x93, 0x4f,
|
||||
0x33, 0xb6, 0x6a, 0x4e, 0xcd, 0x40, 0x9d, 0x47, 0x76, 0x3e, 0x4b, 0xc7, 0x2f, 0x16, 0x96, 0x64, 0x9d, 0x4e, 0x8c, 0xfb, 0x0f, 0xd2, 0xec, 0x6c, 0xba, 0xf2,
|
||||
0x9c, 0xca, 0xd2, 0x3e, 0x64, 0x37, 0x32, 0x20, 0xd7, 0x4c, 0xb0, 0xe7, 0xd3, 0x75, 0x51, 0x3a, 0x94, 0xc1, 0xdf, 0x1c, 0xb3, 0x10, 0xd5, 0x1e, 0xcf, 0x7c,
|
||||
0xb7, 0xab, 0x4a, 0x93, 0xf0, 0x78, 0x58, 0x28, 0x63, 0x10, 0xee, 0xb0, 0xd6, 0x14, 0x81, 0x47, 0xeb, 0x2e, 0xc8, 0x6e, 0x33, 0x7e, 0xf3, 0x2d, 0xc8, 0xdb,
|
||||
0x29, 0x0c, 0x80, 0xe4, 0x2f, 0x10, 0x07, 0x8e, 0x08, 0x86, 0x97, 0x1b, 0x39, 0x98, 0x39, 0x06, 0xb3, 0x85, 0x53, 0xb7, 0xbb, 0x65, 0x65, 0x85, 0x0e, 0x0a,
|
||||
0x7d, 0x29, 0x3d, 0x3f, 0x52, 0xc2, 0x7b, 0x2b, 0x30, 0x94, 0x99, 0x6a, 0x4b, 0xad, 0xe9, 0xec, 0xcb, 0xcd, 0xae, 0x97, 0x45, 0x54, 0xd5, 0x00, 0x5e, 0xd8,
|
||||
0xac, 0xeb, 0x99, 0xdc, 0x58, 0x0b, 0x01, 0xeb, 0x32, 0x22, 0xc4, 0xec, 0x4f, 0xd2, 0x15, 0x03, 0x30, 0x88, 0xc7, 0x28, 0xaf, 0x78, 0xf5, 0x38, 0x84, 0x3b,
|
||||
0x3b, 0xe9, 0x29, 0x71, 0x50, 0xa3, 0x07, 0x49, 0x3b, 0xc6, 0x97, 0xc6, 0xf9, 0x53, 0x95, 0x51, 0x65, 0x7e, 0xd7, 0xd4, 0xe8, 0x76, 0x6a, 0x6d, 0x37, 0x6b,
|
||||
0xa5, 0x59, 0xaa, 0x14, 0x18, 0x8c, 0x8d, 0x65, 0x78, 0x67, 0xfb, 0x60, 0x56, 0xab, 0x04, 0xa0, 0xc2, 0x93, 0x46, 0xf1, 0x2b, 0x0d, 0x3b, 0x38, 0x62, 0x62,
|
||||
0x5e, 0xc8, 0x30, 0xf9, 0x45, 0x28, 0x6f, 0xa1, 0xb1, 0x88, 0xf1, 0x2b, 0x3b, 0xf8, 0xae, 0x91, 0x52, 0xc3, 0x72, 0x86, 0xe4, 0xec, 0xc3, 0x54, 0x86, 0xbf,
|
||||
0x8f, 0x33, 0xb1, 0x0f, 0x42, 0xc5, 0x9c, 0xb8, 0xc2, 0x67, 0x8b, 0xac, 0x78, 0xd7, 0x63, 0xab, 0x05, 0xc6, 0x6c, 0x37, 0xa1, 0x28, 0xef, 0x95, 0xc9, 0xf5,
|
||||
0x12, 0x38, 0x54, 0x34, 0x2e, 0x03, 0x6a, 0xaa, 0xa9, 0x97, 0x72, 0x22, 0x9f, 0x20, 0xec, 0x9e, 0x29, 0x09, 0xd8, 0x38, 0xd1, 0x86, 0x82, 0x99, 0xbd, 0x2a,
|
||||
0x03, 0xe9, 0x3d, 0xbd, 0xea, 0xc5, 0x8b, 0xb0, 0x4c, 0x8b, 0x7e, 0x78, 0x08, 0xef, 0x39, 0xa8, 0xb4, 0x47, 0xce, 0x44, 0xc3, 0x3f, 0x52, 0xe4, 0xbd, 0x9e,
|
||||
0xf6, 0xed, 0x6f, 0x6c, 0x05, 0x19, 0xa6, 0x0a, 0x1e, 0x48, 0xe3, 0x9b, 0x91, 0x61, 0xef, 0xf5, 0x91, 0x39, 0x70, 0x44, 0x1c, 0x08, 0x2e, 0x2c, 0x6c, 0x27,
|
||||
0xb9, 0x0e, 0xcc, 0x74, 0x69, 0xa5, 0xf8, 0x19, 0xd6, 0xbf, 0x57, 0x6c, 0x9a, 0x91, 0x74, 0xfd, 0xc2, 0x31, 0x32, 0x12, 0x06, 0xa3, 0x69, 0x71, 0xda, 0x40,
|
||||
0xa1, 0xf3, 0xb5, 0x9a, 0x43, 0xcc, 0xb4, 0x3c, 0x16, 0x40, 0x65, 0x2b, 0x02, 0xac, 0x5c, 0xae, 0xd6, 0x34, 0x34, 0xe3, 0x69, 0x76, 0x2c, 0xa8, 0xdd, 0x04,
|
||||
0x92, 0xa6, 0x7a, 0xc0, 0x87, 0x70, 0x8b, 0x85, 0xba, 0x5d, 0xbb, 0x62, 0x70, 0xcc, 0x1f, 0x21, 0x2c, 0x7e, 0xc3, 0x77, 0xcf, 0x23, 0x22, 0xf4, 0x16, 0x8e,
|
||||
0xf1, 0x3d, 0xdc, 0x33, 0x99, 0x5e, 0xaa, 0xa2, 0x50, 0x68, 0xde, 0x03, 0x44, 0xbb, 0xc7, 0x16, 0x2a, 0xf2, 0x08, 0xeb, 0x3d, 0x12, 0x6d, 0xcb, 0x2a, 0xaf,
|
||||
0xb4, 0x79, 0xdb, 0x74, 0x5e, 0x54, 0x89, 0x73, 0x0c, 0x48, 0x9c, 0x03, 0x33, 0xd2, 0x92, 0x22, 0xdb, 0x3a, 0xa0, 0x8c, 0xe2, 0x30, 0x6f, 0x39, 0xe4, 0xa9,
|
||||
0x24, 0x04, 0xbb, 0x85, 0x7d, 0x62, 0xc5, 0xa9, 0x98, 0x92, 0xef, 0xc6, 0xc8, 0xd1, 0x81, 0xad, 0x95, 0x40, 0x27, 0x09, 0xc7, 0x43, 0xcd, 0xb6, 0x94, 0xfc,
|
||||
0x1c, 0x7d, 0x1c, 0xd3, 0x47, 0xfe, 0x62, 0x9c, 0xfa, 0xeb, 0xfc, 0x02, 0x2e, 0x48, 0x62, 0xcf, 0x63, 0xdb, 0x63, 0xd9, 0x21, 0x86, 0xe8, 0x96, 0x54, 0xeb,
|
||||
0x6a, 0xa8, 0x78, 0x3c, 0x5b, 0xb6, 0xde, 0xa9, 0x04, 0x48, 0x63, 0xb2, 0x10, 0x02, 0x6a, 0x7f, 0x6d, 0xc8, 0x04, 0xdd, 0x99, 0x25, 0x08, 0xff, 0x80, 0x11,
|
||||
0x53, 0xfb, 0x7a, 0x07, 0x39, 0xd9, 0x97, 0xca, 0xf0, 0xa7, 0x46, 0x9c, 0xc2, 0xae, 0x2e, 0x05, 0x62, 0xa0, 0xd5, 0x5d, 0x17, 0x0e, 0x5c, 0x7e, 0x9a, 0xb2,
|
||||
0xb7, 0x9d, 0xd4, 0x4f, 0xe3, 0xac, 0x64, 0xdb, 0x6f, 0x1d, 0xdf, 0xd8, 0x41, 0xd7, 0xd9, 0x50, 0x55, 0x30, 0xeb, 0x4b, 0x19, 0xce, 0x78, 0x1f, 0xa8, 0x1e,
|
||||
0x87, 0x9c, 0x8f, 0x93, 0x97, 0xd4, 0xa2, 0x28, 0x2c, 0x79, 0x22, 0xc8};
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:udp:vxlan:eth:ethertype:ip:udp:dns]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 124 bytes on wire (992 bits), 124 bytes captured (992 bits)
|
||||
* Ethernet II, Src: zte_6c:fa:43 (00:1e:73:6c:fa:43), Dst: Shanghai_0d:0a (e4:95:6e:20:0d:0a)
|
||||
* Destination: Shanghai_0d:0a (e4:95:6e:20:0d:0a)
|
||||
* Source: zte_6c:fa:43 (00:1e:73:6c:fa:43)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 10.1.1.1, Dst: 192.168.1.10
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 110
|
||||
* Identification: 0x0000 (0)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 254
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0xefca [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 10.1.1.1
|
||||
* Destination Address: 192.168.1.10
|
||||
* User Datagram Protocol, Src Port: 50709, Dst Port: 4789
|
||||
* Source Port: 50709
|
||||
* Destination Port: 4789
|
||||
* Length: 90
|
||||
* Checksum: 0x0000 [zero-value ignored]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* UDP payload (82 bytes)
|
||||
* Virtual eXtensible Local Area Network
|
||||
* Flags: 0x0800, VXLAN Network ID (VNI)
|
||||
* Group Policy ID: 0
|
||||
* VXLAN Network Identifier (VNI): 458755
|
||||
* Reserved: 0
|
||||
* Ethernet II, Src: WistronI_18:18:41 (3c:97:0e:18:18:41), Dst: DawningI_13:70:7a (e8:61:1f:13:70:7a)
|
||||
* Destination: DawningI_13:70:7a (e8:61:1f:13:70:7a)
|
||||
* Source: WistronI_18:18:41 (3c:97:0e:18:18:41)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 192.168.11.193, Dst: 114.114.114.114
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* Total Length: 60
|
||||
* Identification: 0x0cb6 (3254)
|
||||
* 000. .... = Flags: 0x0
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 64
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0xbcad [validation disabled]
|
||||
* [Header checksum status: Unverified]
|
||||
* Source Address: 192.168.11.193
|
||||
* Destination Address: 114.114.114.114
|
||||
* User Datagram Protocol, Src Port: 65290, Dst Port: 53
|
||||
* Source Port: 65290
|
||||
* Destination Port: 53
|
||||
* Length: 40
|
||||
* Checksum: 0x39e4 [unverified]
|
||||
* [Checksum Status: Unverified]
|
||||
* [Stream index: 1]
|
||||
* [Timestamps]
|
||||
* UDP payload (32 bytes)
|
||||
* Domain Name System (query)
|
||||
*/
|
||||
|
||||
unsigned char data4[] = {
|
||||
0xe4, 0x95, 0x6e, 0x20, 0x0d, 0x0a, 0x00, 0x1e, 0x73, 0x6c, 0xfa, 0x43, 0x08, 0x00, 0x45, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x11, 0xef, 0xca,
|
||||
0x0a, 0x01, 0x01, 0x01, 0xc0, 0xa8, 0x01, 0x0a, 0xc6, 0x15, 0x12, 0xb5, 0x00, 0x5a, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0xe8, 0x61,
|
||||
0x1f, 0x13, 0x70, 0x7a, 0x3c, 0x97, 0x0e, 0x18, 0x18, 0x41, 0x08, 0x00, 0x45, 0x00, 0x00, 0x3c, 0x0c, 0xb6, 0x00, 0x00, 0x40, 0x11, 0xbc, 0xad, 0xc0, 0xa8,
|
||||
0x0b, 0xc1, 0x72, 0x72, 0x72, 0x72, 0xff, 0x0a, 0x00, 0x35, 0x00, 0x28, 0x39, 0xe4, 0x86, 0x84, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x77, 0x77, 0x77, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01};
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:udp:l2tp:ppp:ip:udp:nbns]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 150 bytes on wire (1200 bits), 150 bytes captured (1200 bits)
|
||||
* Ethernet II, Src: LCFCElectron_43:38:37 (28:d2:44:43:38:37), Dst: c0:00:14:8c:00:00 (c0:00:14:8c:00:00)
|
||||
* Destination: c0:00:14:8c:00:00 (c0:00:14:8c:00:00)
|
||||
* Source: LCFCElectron_43:38:37 (28:d2:44:43:38:37)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 172.16.0.100, Dst: 172.16.0.254
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 136
|
||||
* Identification: 0x06ca (1738)
|
||||
* 000. .... = Flags: 0x0
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..0. .... = More fragments: Not set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 128
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0xda18 [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0xda18]
|
||||
* Source Address: 172.16.0.100
|
||||
* Destination Address: 172.16.0.254
|
||||
* User Datagram Protocol, Src Port: 1701, Dst Port: 1701
|
||||
* Source Port: 1701
|
||||
* Destination Port: 1701
|
||||
* Length: 116
|
||||
* Checksum: 0x962f [correct]
|
||||
* [Calculated Checksum: 0x962f]
|
||||
* [Checksum Status: Good]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* [Time since first frame: 0.000000000 seconds]
|
||||
* [Time since previous frame: 0.000000000 seconds]
|
||||
* UDP payload (108 bytes)
|
||||
* Layer 2 Tunneling Protocol
|
||||
* Flags: 0x4002, Type: Data Message, Length Bit
|
||||
* 0... .... .... .... = Type: Data Message (0)
|
||||
* .1.. .... .... .... = Length Bit: Length field is present
|
||||
* .... 0... .... .... = Sequence Bit: Ns and Nr fields are not present
|
||||
* .... ..0. .... .... = Offset bit: Offset size field is not present
|
||||
* .... ...0 .... .... = Priority: No priority
|
||||
* .... .... .... 0010 = Version: 2
|
||||
* Length: 108
|
||||
* Tunnel ID: 28998
|
||||
* Session ID: 2
|
||||
* Point-to-Point Protocol
|
||||
* Address: 0xff
|
||||
* Control: 0x03
|
||||
* Protocol: Internet Protocol version 4 (0x0021)
|
||||
* Internet Protocol Version 4, Src: 172.16.2.100, Dst: 255.255.255.255
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 96
|
||||
* Identification: 0x0004 (4)
|
||||
* 000. .... = Flags: 0x0
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..0. .... = More fragments: Not set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 128
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0x8c15 [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0x8c15]
|
||||
* Source Address: 172.16.2.100
|
||||
* Destination Address: 255.255.255.255
|
||||
* User Datagram Protocol, Src Port: 137, Dst Port: 137
|
||||
* Source Port: 137
|
||||
* Destination Port: 137
|
||||
* Length: 76
|
||||
* Checksum: 0xba80 [correct]
|
||||
* [Calculated Checksum: 0xba80]
|
||||
* [Checksum Status: Good]
|
||||
* [Stream index: 1]
|
||||
* [Timestamps]
|
||||
* [Time since first frame: 0.000000000 seconds]
|
||||
* [Time since previous frame: 0.000000000 seconds]
|
||||
* UDP payload (68 bytes)
|
||||
* NetBIOS Name Service
|
||||
*/
|
||||
|
||||
unsigned char data5[] = {
|
||||
0xc0, 0x00, 0x14, 0x8c, 0x00, 0x00, 0x28, 0xd2, 0x44, 0x43, 0x38, 0x37, 0x08, 0x00, 0x45, 0x00, 0x00, 0x88, 0x06, 0xca, 0x00, 0x00, 0x80, 0x11, 0xda, 0x18,
|
||||
0xac, 0x10, 0x00, 0x64, 0xac, 0x10, 0x00, 0xfe, 0x06, 0xa5, 0x06, 0xa5, 0x00, 0x74, 0x96, 0x2f, 0x40, 0x02, 0x00, 0x6c, 0x71, 0x46, 0x00, 0x02, 0xff, 0x03,
|
||||
0x00, 0x21, 0x45, 0x00, 0x00, 0x60, 0x00, 0x04, 0x00, 0x00, 0x80, 0x11, 0x8c, 0x15, 0xac, 0x10, 0x02, 0x64, 0xff, 0xff, 0xff, 0xff, 0x00, 0x89, 0x00, 0x89,
|
||||
0x00, 0x4c, 0xba, 0x80, 0xc6, 0x46, 0x29, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x45, 0x4a, 0x45, 0x4a, 0x45, 0x46, 0x43, 0x4e, 0x46,
|
||||
0x44, 0x45, 0x4e, 0x43, 0x4e, 0x46, 0x45, 0x45, 0x49, 0x45, 0x4a, 0x45, 0x4f, 0x45, 0x4c, 0x43, 0x41, 0x43, 0x41, 0x43, 0x41, 0x41, 0x41, 0x00, 0x00, 0x20,
|
||||
0x00, 0x01, 0xc0, 0x0c, 0x00, 0x20, 0x00, 0x01, 0x00, 0x04, 0x93, 0xe0, 0x00, 0x06, 0x00, 0x00, 0xac, 0x10, 0x02, 0x64};
|
||||
|
||||
/******************************************************************************
|
||||
* [Protocols in frame: eth:ethertype:ip:udp:teredo:ipv6:udp:data]
|
||||
******************************************************************************
|
||||
*
|
||||
* Frame 1: 108 bytes on wire (864 bits), 108 bytes captured (864 bits)
|
||||
* Ethernet II, Src: Dell_c4:5b:ea (bc:30:5b:c4:5b:ea), Dst: Dell_3e:34:9c (b8:ac:6f:3e:34:9c)
|
||||
* Destination: Dell_3e:34:9c (b8:ac:6f:3e:34:9c)
|
||||
* Source: Dell_c4:5b:ea (bc:30:5b:c4:5b:ea)
|
||||
* Type: IPv4 (0x0800)
|
||||
* Internet Protocol Version 4, Src: 193.0.0.3, Dst: 193.0.0.1
|
||||
* 0100 .... = Version: 4
|
||||
* .... 0101 = Header Length: 20 bytes (5)
|
||||
* Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* 0000 00.. = Differentiated Services Codepoint: Default (0)
|
||||
* .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* Total Length: 94
|
||||
* Identification: 0x62a0 (25248)
|
||||
* 000. .... = Flags: 0x0
|
||||
* 0... .... = Reserved bit: Not set
|
||||
* .0.. .... = Don't fragment: Not set
|
||||
* ..0. .... = More fragments: Not set
|
||||
* ...0 0000 0000 0000 = Fragment Offset: 0
|
||||
* Time to Live: 64
|
||||
* Protocol: UDP (17)
|
||||
* Header Checksum: 0x95ea [correct]
|
||||
* [Header checksum status: Good]
|
||||
* [Calculated Checksum: 0x95ea]
|
||||
* Source Address: 193.0.0.3
|
||||
* Destination Address: 193.0.0.1
|
||||
* User Datagram Protocol, Src Port: 45802, Dst Port: 3544
|
||||
* Source Port: 45802
|
||||
* Destination Port: 3544
|
||||
* Length: 74
|
||||
* Checksum: 0x4b23 [correct]
|
||||
* [Calculated Checksum: 0x4b23]
|
||||
* [Checksum Status: Good]
|
||||
* [Stream index: 0]
|
||||
* [Timestamps]
|
||||
* [Time since first frame: 0.000000000 seconds]
|
||||
* [Time since previous frame: 0.000000000 seconds]
|
||||
* UDP payload (66 bytes)
|
||||
* Teredo IPv6 over UDP tunneling
|
||||
* Internet Protocol Version 6, Src: 2002:0:c100:1:24ba:4d15:3eff:fffc, Dst: 2001:db8:1::1
|
||||
* 0110 .... = Version: 6
|
||||
* .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
|
||||
* .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
|
||||
* .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
|
||||
* .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
|
||||
* Payload Length: 26
|
||||
* Next Header: UDP (17)
|
||||
* Hop Limit: 128
|
||||
* Source Address: 2002:0:c100:1:24ba:4d15:3eff:fffc
|
||||
* Destination Address: 2001:db8:1::1
|
||||
* [Source 6to4 Gateway IPv4: 0.0.193.0]
|
||||
* [Source 6to4 SLA ID: 1]
|
||||
* User Datagram Protocol, Src Port: 32768, Dst Port: 20480
|
||||
* Source Port: 32768
|
||||
* Destination Port: 20480
|
||||
* Length: 26
|
||||
* Checksum: 0xf017 [correct]
|
||||
* [Calculated Checksum: 0xf017]
|
||||
* [Checksum Status: Good]
|
||||
* [Stream index: 1]
|
||||
* [Timestamps]
|
||||
* [Time since first frame: 0.000000000 seconds]
|
||||
* [Time since previous frame: 0.000000000 seconds]
|
||||
* UDP payload (18 bytes)
|
||||
* Data (18 bytes)
|
||||
* Data: 4fd54034712d3f014d3180b082c007d0e76c
|
||||
* [Length: 18]
|
||||
*/
|
||||
|
||||
unsigned char data6[] = {
|
||||
0xb8, 0xac, 0x6f, 0x3e, 0x34, 0x9c, 0xbc, 0x30, 0x5b, 0xc4, 0x5b, 0xea, 0x08, 0x00, 0x45, 0x00, 0x00, 0x5e, 0x62, 0xa0, 0x00, 0x00, 0x40, 0x11, 0x95, 0xea,
|
||||
0xc1, 0x00, 0x00, 0x03, 0xc1, 0x00, 0x00, 0x01, 0xb2, 0xea, 0x0d, 0xd8, 0x00, 0x4a, 0x4b, 0x23, 0x60, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x11, 0x80, 0x20, 0x02,
|
||||
0x00, 0x00, 0xc1, 0x00, 0x00, 0x01, 0x24, 0xba, 0x4d, 0x15, 0x3e, 0xff, 0xff, 0xfc, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x50, 0x00, 0x00, 0x1a, 0xf0, 0x17, 0x4f, 0xd5, 0x40, 0x34, 0x71, 0x2d, 0x3f, 0x01, 0x4d, 0x31, 0x80, 0xb0, 0x82, 0xc0,
|
||||
0x07, 0xd0, 0xe7, 0x6c};
|
||||
|
||||
TEST(TUNNEL, IPV4)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data1, sizeof(data1));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 1);
|
||||
|
||||
// IPv4 tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_IPV4);
|
||||
EXPECT_TRUE(out.layer_count == 1);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV4);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 20);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == -1);
|
||||
}
|
||||
|
||||
TEST(TUNNEL, IPV6)
|
||||
{
|
||||
// TEST ON GRE
|
||||
}
|
||||
|
||||
TEST(TUNNEL, GRE)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data2, sizeof(data2));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 2);
|
||||
|
||||
// IPv6 tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_IPV6);
|
||||
EXPECT_TRUE(out.layer_count == 1);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV6);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 40);
|
||||
|
||||
// GRE tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_GRE);
|
||||
EXPECT_TRUE(out.layer_count == 2);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV4);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 20);
|
||||
|
||||
EXPECT_TRUE(out.layers[1]->proto == LAYER_PROTO_GRE);
|
||||
EXPECT_TRUE(out.layers[1]->hdr_len == 16);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 2, &out) == -1);
|
||||
}
|
||||
|
||||
TEST(TUNNEL, GTP)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data3, sizeof(data3));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 1);
|
||||
|
||||
// GTP tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_GTP);
|
||||
EXPECT_TRUE(out.layer_count == 3);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV6);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 40);
|
||||
|
||||
EXPECT_TRUE(out.layers[1]->proto == LAYER_PROTO_UDP);
|
||||
EXPECT_TRUE(out.layers[1]->hdr_len == 8);
|
||||
|
||||
EXPECT_TRUE(out.layers[2]->proto == LAYER_PROTO_GTP_U);
|
||||
EXPECT_TRUE(out.layers[2]->hdr_len == 8);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == -1);
|
||||
}
|
||||
|
||||
TEST(TUNNEL, VXLAN)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data4, sizeof(data4));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 1);
|
||||
|
||||
// VXLAN tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_VXLAN);
|
||||
EXPECT_TRUE(out.layer_count == 3);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV4);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 20);
|
||||
|
||||
EXPECT_TRUE(out.layers[1]->proto == LAYER_PROTO_UDP);
|
||||
EXPECT_TRUE(out.layers[1]->hdr_len == 8);
|
||||
|
||||
EXPECT_TRUE(out.layers[2]->proto == LAYER_PROTO_VXLAN);
|
||||
EXPECT_TRUE(out.layers[2]->hdr_len == 8);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == -1);
|
||||
}
|
||||
|
||||
TEST(TUNNEL, L2TP)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data5, sizeof(data5));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 1);
|
||||
|
||||
// L2TP tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_L2TP);
|
||||
EXPECT_TRUE(out.layer_count == 3);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV4);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 20);
|
||||
|
||||
EXPECT_TRUE(out.layers[1]->proto == LAYER_PROTO_UDP);
|
||||
EXPECT_TRUE(out.layers[1]->hdr_len == 8);
|
||||
|
||||
EXPECT_TRUE(out.layers[2]->proto == LAYER_PROTO_L2TP);
|
||||
EXPECT_TRUE(out.layers[2]->hdr_len == 8);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == -1);
|
||||
}
|
||||
|
||||
TEST(TUNNEL, TEREDO)
|
||||
{
|
||||
struct packet pkt;
|
||||
struct tunnel out;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
packet_parse(&pkt, (const char *)data6, sizeof(data6));
|
||||
packet_print(&pkt);
|
||||
|
||||
EXPECT_TRUE(packet_get_tunnel_count(&pkt) == 1);
|
||||
|
||||
// IPv4 tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 0, &out) == 0);
|
||||
EXPECT_TRUE(out.type == TUNNEL_TEREDO);
|
||||
EXPECT_TRUE(out.layer_count == 2);
|
||||
|
||||
EXPECT_TRUE(out.layers[0]->proto == LAYER_PROTO_IPV4);
|
||||
EXPECT_TRUE(out.layers[0]->hdr_len == 20);
|
||||
|
||||
EXPECT_TRUE(out.layers[1]->proto == LAYER_PROTO_UDP);
|
||||
EXPECT_TRUE(out.layers[1]->hdr_len == 8);
|
||||
|
||||
// No tunnel
|
||||
EXPECT_TRUE(packet_get_tunnel_by_idx(&pkt, 1, &out) == -1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
43
infra/packet_manager/test/gtest_udp_utils.cpp
Normal file
43
infra/packet_manager/test/gtest_udp_utils.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 4001, Dst Port: 8000
|
||||
* Source Port: 4001
|
||||
* Destination Port: 8000
|
||||
* Length: 155
|
||||
* Checksum: 0x1e1e [correct]
|
||||
* [Calculated Checksum: 0x1e1e]
|
||||
* [Checksum Status: Good]
|
||||
*/
|
||||
|
||||
unsigned char data[] = {0x0f, 0xa1, 0x1f, 0x40, 0x00, 0x9b, 0x1e, 0x1e};
|
||||
|
||||
TEST(UDP_UTILS, GET)
|
||||
{
|
||||
const struct udphdr *hdr = (struct udphdr *)data;
|
||||
|
||||
EXPECT_TRUE(udp_hdr_get_src_port(hdr) == 4001);
|
||||
EXPECT_TRUE(udp_hdr_get_dst_port(hdr) == 8000);
|
||||
EXPECT_TRUE(udp_hdr_get_total_len(hdr) == 155);
|
||||
EXPECT_TRUE(udp_hdr_get_checksum(hdr) == 0x1e1e);
|
||||
}
|
||||
|
||||
TEST(UDP_UTILS, SET)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
struct udphdr *hdr = (struct udphdr *)buff;
|
||||
|
||||
udp_hdr_set_src_port(hdr, 4001);
|
||||
udp_hdr_set_dst_port(hdr, 8000);
|
||||
udp_hdr_set_total_len(hdr, 155);
|
||||
udp_hdr_set_checksum(hdr, 0x1e1e);
|
||||
EXPECT_TRUE(memcmp(buff, data, 8) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
42
infra/packet_manager/test/gtest_vlan_utils.cpp
Normal file
42
infra/packet_manager/test/gtest_vlan_utils.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* IEEE 802.1ad, ID: 1
|
||||
* 000. .... .... .... = Priority: 0
|
||||
* ...0 .... .... .... = DEI: 0
|
||||
* .... 0000 0000 0001 = ID: 1
|
||||
* Type: 802.1Q Virtual LAN (0x8100)
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0x00, 0x01, 0x81, 0x00};
|
||||
|
||||
TEST(VLAN_UTILS, GET)
|
||||
{
|
||||
const struct vlan_hdr *hdr = (struct vlan_hdr *)data;
|
||||
|
||||
EXPECT_TRUE(vlan_hdr_get_priority(hdr) == 0);
|
||||
EXPECT_TRUE(vlan_hdr_get_dei(hdr) == 0);
|
||||
EXPECT_TRUE(vlan_hdr_get_vid(hdr) == 1);
|
||||
EXPECT_TRUE(vlan_hdr_get_ethertype(hdr) == 0x8100);
|
||||
}
|
||||
|
||||
TEST(VLAN_UTILS, SET)
|
||||
{
|
||||
char buff[4] = {0};
|
||||
struct vlan_hdr *hdr = (struct vlan_hdr *)buff;
|
||||
|
||||
vlan_hdr_set_priority(hdr, 0);
|
||||
vlan_hdr_set_dei(hdr, 0);
|
||||
vlan_hdr_set_vid(hdr, 1);
|
||||
vlan_hdr_set_ethertype(hdr, 0x8100);
|
||||
EXPECT_TRUE(memcmp(buff, data, 4) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
43
infra/packet_manager/test/gtest_vxlan_utils.cpp
Normal file
43
infra/packet_manager/test/gtest_vxlan_utils.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_helper.h"
|
||||
|
||||
/*
|
||||
* Virtual eXtensible Local Area Network
|
||||
* Flags: 0x0800, VXLAN Network ID (VNI)
|
||||
* 0... .... .... .... = GBP Extension: Not defined
|
||||
* .... 1... .... .... = VXLAN Network ID (VNI): True
|
||||
* .... .... .0.. .... = Don't Learn: False
|
||||
* .... .... .... 0... = Policy Applied: False
|
||||
* .000 .000 0.00 .000 = Reserved(R): 0x0000
|
||||
* Group Policy ID: 0
|
||||
* VXLAN Network Identifier (VNI): 461829
|
||||
* Reserved: 0
|
||||
*/
|
||||
|
||||
unsigned char data[] = {
|
||||
0x08, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x05, 0x00};
|
||||
|
||||
TEST(VXLAN_UTILS, GET)
|
||||
{
|
||||
const struct vxlan_hdr *hdr = (struct vxlan_hdr *)data;
|
||||
|
||||
EXPECT_TRUE(vxlan_hdr_get_flags(hdr) == 0x08);
|
||||
EXPECT_TRUE(vxlan_hdr_get_vni(hdr) == 461829);
|
||||
}
|
||||
|
||||
TEST(VXLAN_UTILS, SET)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
struct vxlan_hdr *hdr = (struct vxlan_hdr *)buff;
|
||||
|
||||
vxlan_hdr_set_flags(hdr, 0x08);
|
||||
vxlan_hdr_set_vni(hdr, 461829);
|
||||
EXPECT_TRUE(memcmp(buff, data, 8) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user