TSG-18285 TFE的Packet IO模块支持重复流量识别
This commit is contained in:
@@ -3,8 +3,26 @@
|
||||
|
||||
#include "tfe_session_table.h"
|
||||
|
||||
#define INIT_ADDR_V4(addr, src_ip_str, src_port_num, dst_ip_str, dst_port_num) \
|
||||
struct tuple4 addr; \
|
||||
memset(&addr, 0, sizeof(addr)); \
|
||||
addr.ip_type = IP_TYPE_V4; \
|
||||
addr.src_addr.v4.s_addr = inet_addr(src_ip_str); \
|
||||
addr.dst_addr.v4.s_addr = inet_addr(dst_ip_str); \
|
||||
addr.src_port = htons(src_port_num); \
|
||||
addr.dst_port = htons(dst_port_num);
|
||||
|
||||
#define INIT_ADDR_V6(addr, src_ip_str, src_port_num, dst_ip_str, dst_port_num) \
|
||||
struct tuple4 addr; \
|
||||
memset(&addr, 0, sizeof(addr)); \
|
||||
addr.ip_type = IP_TYPE_V6; \
|
||||
inet_pton(AF_INET6, src_ip_str, &addr.src_addr.v6); \
|
||||
inet_pton(AF_INET6, dst_ip_str, &addr.dst_addr.v6); \
|
||||
addr.src_port = htons(src_port_num); \
|
||||
addr.dst_port = htons(dst_port_num);
|
||||
|
||||
bool g_print_to_stderr = true;
|
||||
void * g_packet_io_logger = NULL;
|
||||
void *g_packet_io_logger = NULL;
|
||||
|
||||
TEST(STREAM_TABLE, INSERT)
|
||||
{
|
||||
@@ -104,10 +122,10 @@ TEST(STREAM_TABLE, SEARCH_BY_REVERSE_ADDR)
|
||||
char *val_world = strdup("WORLD");
|
||||
INIT_ADDR_V4(addr1, "1.2.3.4", 1234, "4.3.2.1", 4321);
|
||||
INIT_ADDR_V6(addr2, "2:3:4::5", 2345, "5:4:3::2", 5342);
|
||||
struct addr_tuple4 addr1_reverse;
|
||||
struct addr_tuple4 addr2_reverse;
|
||||
addr_tuple4_reverse(&addr1, &addr1_reverse);
|
||||
addr_tuple4_reverse(&addr2, &addr2_reverse);
|
||||
struct tuple4 addr1_reverse;
|
||||
struct tuple4 addr2_reverse;
|
||||
tuple4_reverse(&addr1, &addr1_reverse);
|
||||
tuple4_reverse(&addr2, &addr2_reverse);
|
||||
|
||||
// TEST Insert
|
||||
EXPECT_TRUE(session_table_insert(table, 1, &addr1, val_hello, free) == 0);
|
||||
@@ -137,10 +155,10 @@ TEST(STREAM_TABLE, DELETE_BY_ID)
|
||||
char *val_world = strdup("WORLD");
|
||||
INIT_ADDR_V4(addr1, "1.2.3.4", 1234, "4.3.2.1", 4321);
|
||||
INIT_ADDR_V6(addr2, "2:3:4::5", 2345, "5:4:3::2", 5342);
|
||||
struct addr_tuple4 addr1_reverse;
|
||||
struct addr_tuple4 addr2_reverse;
|
||||
addr_tuple4_reverse(&addr1, &addr1_reverse);
|
||||
addr_tuple4_reverse(&addr2, &addr2_reverse);
|
||||
struct tuple4 addr1_reverse;
|
||||
struct tuple4 addr2_reverse;
|
||||
tuple4_reverse(&addr1, &addr1_reverse);
|
||||
tuple4_reverse(&addr2, &addr2_reverse);
|
||||
|
||||
// TEST Insert
|
||||
EXPECT_TRUE(session_table_insert(table, 1, &addr1, val_hello, free) == 0);
|
||||
@@ -174,10 +192,10 @@ TEST(STREAM_TABLE, DELETE_BY_ADDR)
|
||||
char *val_world = strdup("WORLD");
|
||||
INIT_ADDR_V4(addr1, "1.2.3.4", 1234, "4.3.2.1", 4321);
|
||||
INIT_ADDR_V6(addr2, "2:3:4::5", 2345, "5:4:3::2", 5342);
|
||||
struct addr_tuple4 addr1_reverse;
|
||||
struct addr_tuple4 addr2_reverse;
|
||||
addr_tuple4_reverse(&addr1, &addr1_reverse);
|
||||
addr_tuple4_reverse(&addr2, &addr2_reverse);
|
||||
struct tuple4 addr1_reverse;
|
||||
struct tuple4 addr2_reverse;
|
||||
tuple4_reverse(&addr1, &addr1_reverse);
|
||||
tuple4_reverse(&addr2, &addr2_reverse);
|
||||
|
||||
// TEST Insert
|
||||
EXPECT_TRUE(session_table_insert(table, 1, &addr1, val_hello, free) == 0);
|
||||
@@ -211,10 +229,10 @@ TEST(STREAM_TABLE, DELETE_BY_REVERSE_ADDR)
|
||||
char *val_world = strdup("WORLD");
|
||||
INIT_ADDR_V4(addr1, "1.2.3.4", 1234, "4.3.2.1", 4321);
|
||||
INIT_ADDR_V6(addr2, "2:3:4::5", 2345, "5:4:3::2", 5342);
|
||||
struct addr_tuple4 addr1_reverse;
|
||||
struct addr_tuple4 addr2_reverse;
|
||||
addr_tuple4_reverse(&addr1, &addr1_reverse);
|
||||
addr_tuple4_reverse(&addr2, &addr2_reverse);
|
||||
struct tuple4 addr1_reverse;
|
||||
struct tuple4 addr2_reverse;
|
||||
tuple4_reverse(&addr1, &addr1_reverse);
|
||||
tuple4_reverse(&addr2, &addr2_reverse);
|
||||
|
||||
// TEST Insert
|
||||
EXPECT_TRUE(session_table_insert(table, 1, &addr1, val_hello, free) == 0);
|
||||
|
||||
Reference in New Issue
Block a user