#include #include #include #include #include #include "session_flags_internal.h" #include "gtest/gtest.h" extern "C" { #include "dummy.h" } struct session_flags_plugin_info *sf_plugin_info = NULL; TEST(session_flags_static, bulky) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); int cur_time_ms = 1; for (int i = 0; i < 100; i++) { for (int j = 0; j < 96; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 1001, FLOW_TYPE_C2S, cur_time_ms); cur_time_ms++; session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } for (int j = 0; j < 4; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 100, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_BULKY, SESSION_FLAGS_BULKY); EXPECT_EQ(flags_info->identify[session_flags_bulky_mask], 6001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Bulky\":196,\"Client is Local\":1,\"Outbound\":196,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, download_gt_95) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); int cur_time_ms = 1; for (int i = 0; i < 100; i++) { for (int j = 0; j < 96; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 1001, FLOW_TYPE_C2S, cur_time_ms); cur_time_ms++; session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } for (int j = 0; j < 4; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 100, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_DOWNLOAD, SESSION_FLAGS_DOWNLOAD); EXPECT_EQ(flags_info->identify[session_flags_download_mask], 6001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Bulky\":195,\"Client is Local\":1,\"Outbound\":195,\"Streaming\":195,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, download_lt_95) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); int cur_time_ms = 1; for (int i = 0; i < 100; i++) { for (int j = 0; j < 94; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 1001, FLOW_TYPE_C2S, cur_time_ms); cur_time_ms++; session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } for (int j = 0; j < 6; j++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 100, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_NE(flags_info->flags & SESSION_FLAGS_DOWNLOAD, SESSION_FLAGS_DOWNLOAD); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Bulky\":195,\"Client is Local\":1,\"Outbound\":195,\"Streaming\":195,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, CBR_lt_1s) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); int std_bytes = 1000; int cur_time_ms = 1; for (int i = 0; i < 100; i++) { long delta = random() % 200; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, std_bytes + delta, FLOW_TYPE_C2S, cur_time_ms++); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms++); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_NE(flags_info->flags & SESSION_FLAGS_CBR, SESSION_FLAGS_CBR); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Bulky\":200,\"Client is Local\":1,\"Download\":200,\"Outbound\":200,\"Pseudo Unidirectional\":200,\"Streaming\":200,\"Unidirectional\":200,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, CBR) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); for (uint64_t cur_time_ms = 1; cur_time_ms < 11000; cur_time_ms += 10) { long delta = random() % 200; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 1000 + delta, FLOW_TYPE_C2S, cur_time_ms); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_CBR, SESSION_FLAGS_CBR); EXPECT_EQ(flags_info->identify[session_flags_cbr_mask], 1001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Bulky\":201,\"CBR Streaming\":2021,\"Client is Local\":1,\"Download\":201,\"Outbound\":201,\"Pseudo Unidirectional\":201,\"Streaming\":201,\"Unidirectional\":201,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, not_CBR) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); for (uint64_t cur_time_ms = 1, i = 0; cur_time_ms < 10000; cur_time_ms += 500) { int delta = (i++ % 10) * 100; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100 + delta, FLOW_TYPE_C2S, cur_time_ms); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_NE(flags_info->flags & SESSION_FLAGS_CBR, SESSION_FLAGS_CBR); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Client is Local\":1,\"Outbound\":21,\"Pseudo Unidirectional\":21,\"Unidirectional\":21,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, interactive) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); uint64_t cur_time_ms = 1; while(cur_time_ms < 60000) { long delta = random() % 100; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 1000 + delta, FLOW_TYPE_C2S, cur_time_ms++); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms++); } while(cur_time_ms < 200000) { cur_time_ms += 10000; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 80, FLOW_TYPE_C2S, cur_time_ms); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 66, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_INTERACTIVE, SESSION_FLAGS_INTERACTIVE); EXPECT_EQ(flags_info->identify[session_flags_interactive_mask], 60009); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Bulky\":1001,\"CBR Streaming\":10021,\"Client is Local\":1,\"Download\":1001,\"Interactive\":60009,\"Outbound\":1001,\"Pseudo Unidirectional\":1001,\"Streaming\":1001,\"Unidirectional\":1001,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, streaming_gt_90) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); session_set_current_payload(&sess, NULL, 100); for (uint64_t cur_time_ms = 1; cur_time_ms < 10000; cur_time_ms++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 861, FLOW_TYPE_C2S, cur_time_ms); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 139, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_STREAMING, SESSION_FLAGS_STREAMING); EXPECT_EQ(flags_info->identify[session_flags_streaming_mask], 12001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Client is Local\":1,\"Outbound\":668,\"Streaming\":669,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, streaming_lt_90) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); session_set_current_payload(&sess, NULL, 100); for (uint64_t cur_time_ms = 1; cur_time_ms < 10000; cur_time_ms++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 859, FLOW_TYPE_C2S, cur_time_ms); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 141, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_STREAMING, 0); EXPECT_EQ(flags_info->identify[session_flags_streaming_mask], 0); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Client is Local\":1,\"Outbound\":668,\"Streaming\":669,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, presu_unidirectional_gt_95) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); uint64_t cur_time_ms = 1; session_set_current_payload(&sess, NULL, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 96; j++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_C2S, cur_time_ms); cur_time_ms++; } for (int j = 0; j < 4; j++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_PSEUDO_UNIDIRECTIONAL, SESSION_FLAGS_PSEUDO_UNIDIRECTIONAL); EXPECT_EQ(flags_info->identify[session_flags_pseudo_unidirectional_mask], 6001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Client is Local\":1,\"Outbound\":1002,\"Pseudo Unidirectional\":1002,\"Streaming\":1002,\"C2S\":1,\"S2C\":99}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, presu_unidirectional_lt_95) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); uint64_t cur_time_ms = 1; session_set_current_payload(&sess, NULL, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 94; j++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_C2S, cur_time_ms); cur_time_ms++; } for (int j = 0; j < 6; j++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_S2C, cur_time_ms); cur_time_ms++; } } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_PSEUDO_UNIDIRECTIONAL, 0); EXPECT_EQ(flags_info->identify[session_flags_pseudo_unidirectional_mask], 0); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Client is Local\":1,\"Outbound\":1002,\"Pseudo Unidirectional\":1002,\"Streaming\":1002,\"C2S\":1,\"S2C\":99}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, Unidirectional) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); for (uint64_t cur_time_ms = 1; cur_time_ms < 10000; cur_time_ms++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_C2S, cur_time_ms); session_set_current_payload(&sess, NULL, 0); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 80, FLOW_TYPE_S2C, cur_time_ms); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_UNIDIRECTIONAL, SESSION_FLAGS_UNIDIRECTIONAL); EXPECT_EQ(flags_info->identify[session_flags_unidirectional_mask], 10001); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_PSEUDO_UNIDIRECTIONAL, SESSION_FLAGS_PSEUDO_UNIDIRECTIONAL); EXPECT_EQ(flags_info->identify[session_flags_pseudo_unidirectional_mask], 12001); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ("{\"Client is Local\":1,\"Outbound\":668,\"Pseudo Unidirectional\":669,\"Unidirectional\":669,\"C2S\":1,\"S2C\":2}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, not_unidirectional) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); srandom(time(NULL)); uint64_t cur_time_ms = 1; session_set_current_payload(&sess, NULL, 100); for (int i = 1; i < 10000; i++) { session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100 + random() % 1000, FLOW_TYPE_C2S, cur_time_ms++); } session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 80, FLOW_TYPE_S2C, cur_time_ms++); struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_NE(flags_info->flags & SESSION_FLAGS_UNIDIRECTIONAL, SESSION_FLAGS_UNIDIRECTIONAL); struct session_flags_message *msg = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Client is Local\":1, \"Outbound\":10000, \"C2S\":1,\"S2C\":10000}", identify_str); EXPECT_EQ(msg->packet_sequence_array[0], 1); EXPECT_EQ(msg->packet_sequence_array[1], 10000); EXPECT_EQ(msg->packet_sequence_array[2], 1); EXPECT_EQ(msg->packet_sequence_array[3], 10000); free(msg->packet_sequence_array); free(msg); free(ctx); } TEST(session_flags_static, dns) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); uint64_t cur_time_ms = 1000; session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 72, FLOW_TYPE_C2S, cur_time_ms); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 72, FLOW_TYPE_C2S, cur_time_ms); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 72, FLOW_TYPE_C2S, cur_time_ms+10000); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 72, FLOW_TYPE_C2S, cur_time_ms+10000); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 146, FLOW_TYPE_S2C, cur_time_ms+15000); session_flags(sf_plugin_info, ctx, &sess, DUMMY_UDP_TOPIC_ID, 72, FLOW_TYPE_C2S, cur_time_ms+15000); struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_NE(flags_info->flags & SESSION_FLAGS_CBR, SESSION_FLAGS_CBR); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_LOCAL_CLIENT, SESSION_FLAGS_LOCAL_CLIENT); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_C2S, SESSION_FLAGS_C2S); EXPECT_EQ(flags_info->identify[session_flags_c2s_mask], 1); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_S2C, SESSION_FLAGS_S2C); EXPECT_EQ(flags_info->identify[session_flags_s2c_mask], 5); //char *identify_str = session_flags_generate_firewall_message(flags_info->flags, flags_info->identify); //EXPECT_STREQ( "{\"Client is Local\":1,\"Outbound\":6,\"C2S\":1,\"S2C\":5}", identify_str); //free(identify_str); free(ctx); } TEST(session_flags_static, bidirectional) { struct session_flags_ctx *ctx = (struct session_flags_ctx*)calloc(1, sizeof(struct session_flags_ctx)); struct session sess; memset(&sess, 0, sizeof(sess)); session_flags_stat_init(&ctx->stat, SESSION_DIRECTION_OUTBOUND); int cur_time_ms = 1; session_set_current_payload(&sess, NULL, 100); for (int i = 0; i < 5000; i++) { session_set_current_payload(&sess, NULL, 100); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 100, FLOW_TYPE_C2S, cur_time_ms++); session_set_current_payload(&sess, NULL, 99); session_flags(sf_plugin_info, ctx, &sess, DUMMY_TCP_TOPIC_ID, 99, FLOW_TYPE_S2C, cur_time_ms++); } struct session_flags_result *flags_info = session_flags_get_flags(&ctx->stat); EXPECT_EQ(flags_info->flags & SESSION_FLAGS_BIDIRECTIONAL, SESSION_FLAGS_BIDIRECTIONAL); EXPECT_EQ(flags_info->identify[session_flags_bidirectional_mask], 6001); free(ctx); } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); //testing::GTEST_FLAG(filter) = ""; sf_plugin_info = (struct session_flags_plugin_info *)session_flags_plugin_init(NULL); sf_plugin_info->log_handle = NULL; int result = RUN_ALL_TESTS(); session_flags_plugin_exit(sf_plugin_info); return result; }