TSG-13778 TSG master支持MAAT4
This commit is contained in:
1
test/bin/foreign_files/TSG_PROFILE_RESPONSE_PAGES.1
Normal file
1
test/bin/foreign_files/TSG_PROFILE_RESPONSE_PAGES.1
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
||||
1
test/bin/foreign_files/TSG_PROFILE_RESPONSE_PAGES.2
Normal file
1
test/bin/foreign_files/TSG_PROFILE_RESPONSE_PAGES.2
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compile_table": "TSG_SECURITY_COMPILE",
|
||||
"group2compile_table": "GROUP_COMPILE_RELATION",
|
||||
"group2group_table": "GROUP_GROUP_RELATION",
|
||||
"compile_table": "TSG_COMPILE",
|
||||
"group2compile_table": "TSG_GROUP_COMPILE_RELATION",
|
||||
"group2group_table": "TSG_GROUP_GROUP_RELATION",
|
||||
"rules": [
|
||||
{
|
||||
"compile_id": 1,
|
||||
@@ -9,9 +9,10 @@
|
||||
"action": 1,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 1,
|
||||
"effective_rage": 0,
|
||||
"user_region": "Virtual",
|
||||
"tags": "{}",
|
||||
"user_region": "{}",
|
||||
"is_valid": "yes",
|
||||
"evaluation_order": "2.111",
|
||||
"groups": [
|
||||
{
|
||||
"group_name":"OBJ_DST_IP_ADDR",
|
||||
@@ -23,12 +24,12 @@
|
||||
"table_name": "TSG_OBJ_IP_ADDR",
|
||||
"table_content": {
|
||||
"addr_type": "ipv4",
|
||||
"saddr_format": "range",
|
||||
"src_ip1": "0.0.0.0",
|
||||
"src_ip2": "255.255.255.255",
|
||||
"sport_format": "range",
|
||||
"src_port1": "0",
|
||||
"src_port2": "0",
|
||||
"addr_format": "range",
|
||||
"ip1": "0.0.0.0",
|
||||
"ip2": "255.255.255.255",
|
||||
"port_format": "range",
|
||||
"port1": "0",
|
||||
"port2": "0",
|
||||
"protocol": 0,
|
||||
"direction": "double"
|
||||
}
|
||||
@@ -43,9 +44,10 @@
|
||||
"action": 16,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 1,
|
||||
"effective_rage": 0,
|
||||
"tags": "{}",
|
||||
"user_region": "{\"method\":\"rate_limit\",\"bps\":1024,\"packet_capture\":{\"enable\":1,\"capture_depth\":2000}}",
|
||||
"is_valid": "yes",
|
||||
"evaluation_order": "2.111",
|
||||
"groups": [
|
||||
{
|
||||
"group_name": "OBJ_DST_IP_ADDR",
|
||||
@@ -57,12 +59,12 @@
|
||||
"table_name": "TSG_OBJ_IP_ADDR",
|
||||
"table_content": {
|
||||
"addr_type": "ipv4",
|
||||
"saddr_format": "range",
|
||||
"src_ip1": "0.0.0.0",
|
||||
"src_ip2": "255.255.255.255",
|
||||
"sport_format": "range",
|
||||
"src_port1": "0",
|
||||
"src_port2": "0",
|
||||
"addr_format": "range",
|
||||
"ip1": "0.0.0.0",
|
||||
"ip2": "255.255.255.255",
|
||||
"format": "range",
|
||||
"port1": "0",
|
||||
"port2": "0",
|
||||
"protocol": 0,
|
||||
"direction": "double"
|
||||
}
|
||||
@@ -70,20 +72,185 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 3,
|
||||
"service": 0,
|
||||
"action": 1,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 1,
|
||||
"tags": "{}",
|
||||
"user_region": "{}",
|
||||
"is_valid": "yes",
|
||||
"evaluation_order": "0.0",
|
||||
"groups": [
|
||||
{
|
||||
"not_flag": 0,
|
||||
"clause_index": 0,
|
||||
"virtual_table": "TSG_SECURITY_TUNNEL",
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_TUNNEL_ID",
|
||||
"table_type": "interval",
|
||||
"table_content": {
|
||||
"low_boundary": 900,
|
||||
"up_boundary": 1003
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 4,
|
||||
"service": 0,
|
||||
"action": 16,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 1,
|
||||
"tags": "{}",
|
||||
"user_region": "{\"method\":\"rate_limit\",\"bps\":1024,\"packet_capture\":{\"enable\":1,\"capture_depth\":2000}}",
|
||||
"is_valid": "yes",
|
||||
"evaluation_order": "0.0",
|
||||
"groups": [
|
||||
{
|
||||
"not_flag": 0,
|
||||
"clause_index": 0,
|
||||
"virtual_table": "TSG_SECURITY_TUNNEL",
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "TSG_OBJ_TUNNEL_ID",
|
||||
"table_type": "interval",
|
||||
"table_content": {
|
||||
"low_boundary": 900,
|
||||
"up_boundary": 1003
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"plugin_table": [
|
||||
{
|
||||
"table_name": "APP_ID_DICT",
|
||||
"table_content": [
|
||||
"4\tunknown\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"67\thttp\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"156\tqq\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"336\tOPENVPN\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"199\tSSL\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"1241\tqq_web\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1",
|
||||
"3145\tqq_r2\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\t1\t0\t3600\t3600\t1800\t1800\t1"
|
||||
"67\thttp\t0\tnull\tnetworking\tinfrastructure\tnetwork-protocol\t3\tused-by-malware,vulnerability,widely-used\tnull\tnull\t{\"method\":\"drop\",\"after_n_packets\":0,\"send_icmp_unreachable\":1,\"send_tcp_reset\":1}\t0\t60\t120\t30\t30\t1",
|
||||
"68\thttps\t0\tnull\tnetworking\tinfrastructure\tnetwork-protocol\t3\tused-by-malware,vulnerability,widely-used\tnull\tnull\t{\"method\":\"rate_limit\",\"bps\":1000}\t0\t0\t0\t0\t0\t1",
|
||||
"4\tunknown\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\tnull\t1\t3600\t3600\t1800\t1800\t1",
|
||||
"70\thttps\t1\tssl\tnetworking\tinfrastructure\tnetwork-protocol\t3\tused-by-malware,vulnerability,widely-used\tnull\tnull\t{\"method\":\"rate_limit\",\"bps\":1000}\t0\t0\t0\t0\t0\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_DYN_MOBILE_IDENTITY_APN_TEID",
|
||||
"table_content": [
|
||||
"1\t111039813\t460045157065560\t861440152009856\t111039813.cmiott.gxqli.mcto60g.com\t8626070583075127\t1",
|
||||
"2\t111052899\t460045157053102\t861440152041083\t111052899.cmiott.wkctf.mcto60g.com\t8626070583008402\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_IP_ASN_BUILT_IN",
|
||||
"table_content": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_IP_ASN_USER_DEFINED",
|
||||
"table_content": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_IP_LOCATION_BUILT_IN",
|
||||
"table_content": [
|
||||
"6777621\t1819730\t4\t124.156.128.0\t124.156.191.255\t22.25\t114.1667\t50.0\ten\tAS\tAsia\tHK\tHong\\bKong\tOther\tOther\tOther\tRoad1\tAsia/Hong_Kong\t1",
|
||||
"3716523\t1814992\t4\t192.168.50.1\t192.168.50.255\t34.7725\t113.7266\t50.0\ten\tAS\tAsia\tCN\tChina\tBeijing\tBeijing\tXin\\bXi\\bGang\tRoad1\tAsia/Shanghai\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_IP_LOCATION_USER_DEFINED",
|
||||
"table_content": [
|
||||
"371652\t181499\t4\t192.168.50.10\t192.168.50.255\t34.7725\t113.7266\t50.0\ten\tAS\tAsia\tCN\tChina\tBeijing\tBeijing\tHua\\bYan\\bBei\\bLi\tRoad1\tAsia/Shanghai\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_FQDN_CATEGORY_BUILT_IN",
|
||||
"table_content": [
|
||||
"106285681\t4\t106285681.201198.com\t1\t1",
|
||||
"106285682\t5\t106285682.201198.com\t1\t1",
|
||||
"106285688\t8\t106285688.201198.com\t1\t1",
|
||||
"106285689\t9\t106285689.201198.com\t1\t1",
|
||||
"106285690\t9\t106285689.201198.com\t1\t1",
|
||||
"106285691\t10\t1106285683.201198.com\t1\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_FQDN_CATEGORY_USER_DEFINED",
|
||||
"table_content": [
|
||||
"1106285681\t4\t1106285681.201198.com\t1\t1",
|
||||
"1106285682\t5\t1106285682.201198.com\t1\t1",
|
||||
"1106285683\t6\t1106285683.201198.com\t1\t1",
|
||||
"1106285684\t7\t1106285684.201198.com\t1\t1",
|
||||
"1106285685\t7\t1106285684.201198.com\t1\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_TUNNEL_CATALOG",
|
||||
"table_content": [
|
||||
"977\t1.1.1.1-1.1.1.1\tGTP\t1367\t1",
|
||||
"978\t1.1.1.1-1.1.1.1\tGTP\t1367&1605\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_TUNNEL_ENDPOINT",
|
||||
"table_content": [
|
||||
"989\t4\t192.50.0.0\t192.50.255.255\ttest\t1",
|
||||
"990\t4\t192.50.0.0\t192.50.255.255\ttest\t1",
|
||||
"991\t4\t192.40.128.0\t192.40.255.255\ttest\t1",
|
||||
"992\t4\t192.40.0.0\t192.40.127.255\ttest\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_TUNNEL_LABEL",
|
||||
"table_content": [
|
||||
"15560\t15560\tVLAN_ID\t1",
|
||||
"15561\t15561\tVLAN_ID\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_DYN_SUBSCRIBER_IP",
|
||||
"table_content": [
|
||||
"1299\t4\t192.168.56.28\ttest5628\t1",
|
||||
"1300\t4\t192.168.56.27\ttest5627\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_PROFILE_DNS_RECORDS",
|
||||
"table_content": [
|
||||
"8119\teditTypeA\tA\t[{\"value\":\"1.1.1.1\",\"priority\":null},{\"value\":\"2.2.2.2\",\"priority\":null},{\"value\":\"3.3.3.3\",\"priority\":null}]\t1",
|
||||
"7961\tFile\tAAAA\t[{\"value\":\"1030::C9B4:FF12:48AA:1A2B\",\"priority\":null},{\"value\":\"1030::C9B4:FF12:48AA:1A2C\",\"priority\":null}]\t1",
|
||||
"7701\tTypeCNAME\tCNAME\t[{\"value\":\"www.facebook.com\",\"priority\":null},{\"value\":\"www.twitter.com\",\"priority\":null}]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_PROFILE_RESPONSE_PAGES",
|
||||
"table_content": [
|
||||
"957\ttest-html-1\thtml\tforeign_files/TSG_PROFILE_RESPONSE_PAGES.1\t1",
|
||||
"958\ttest-html-2\thtml\tforeign_files/TSG_PROFILE_RESPONSE_PAGES.2\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TSG_PROFILE_TRAFFIC_MIRROR",
|
||||
"table_content": [
|
||||
"845\t168.50.28yinyong\t[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]\t1",
|
||||
"123\ttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest\t[66]\t1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "T_VSYS_INFO",
|
||||
"table_content": [
|
||||
"6\t1\t1"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,17 @@ include_directories(${PROJECT_SOURCE_DIR}/src/)
|
||||
add_definitions(-std=c++11)
|
||||
LINK_DIRECTORIES(/opt/MESA/lib)
|
||||
|
||||
#add_executable(gtest_rule ${PROJECT_SOURCE_DIR}/src/tsg_rule.cpp ${PROJECT_SOURCE_DIR}/src/tsg_bridge.cpp ${PROJECT_SOURCE_DIR}/src/tsg_leaky_bucket.cpp gtest_common.cpp gtest_rule.cpp)
|
||||
#target_link_libraries(gtest_rule gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maatframe)
|
||||
add_executable(gtest_rule ${PROJECT_SOURCE_DIR}/src/tsg_rule.cpp ${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp gtest_common.cpp gtest_rule.cpp)
|
||||
target_link_libraries(gtest_rule gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger maat4)
|
||||
|
||||
add_executable(gtest_bridge ${PROJECT_SOURCE_DIR}/src/tsg_bridge.cpp ${PROJECT_SOURCE_DIR}/src/tsg_protocol.cpp ${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp gtest_common.cpp gtest_bridge.cpp)
|
||||
target_link_libraries(gtest_bridge gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger maat4)
|
||||
|
||||
add_executable(gtest_action ${PROJECT_SOURCE_DIR}/src/tsg_action.cpp ${PROJECT_SOURCE_DIR}/src/tsg_leaky_bucket.cpp ${PROJECT_SOURCE_DIR}/src/tsg_dns.cpp ${PROJECT_SOURCE_DIR}/src/tsg_icmp.cpp ${PROJECT_SOURCE_DIR}/src/tsg_tamper.cpp ${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp gtest_common.cpp gtest_action.cpp)
|
||||
target_link_libraries(gtest_action gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger maat4 MESA_field_stat2)
|
||||
|
||||
add_executable(gtest_sendlog ${PROJECT_SOURCE_DIR}/src/tsg_send_log.cpp ${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp gtest_common.cpp gtest_sendlog.cpp)
|
||||
target_link_libraries(gtest_sendlog gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger maat4 rdkafka MESA_field_stat2)
|
||||
|
||||
set(TSG_MASTER_SRC ${PROJECT_SOURCE_DIR}/src/tsg_entry.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_rule.cpp
|
||||
@@ -26,10 +35,12 @@ set(TSG_MASTER_SRC ${PROJECT_SOURCE_DIR}/src/tsg_entry.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_tamper.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_bridge.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_sync_state.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_variable.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/tsg_protocol.cpp
|
||||
)
|
||||
|
||||
add_executable(gtest_master ${TSG_MASTER_SRC} gtest_kafka.cpp gtest_common.cpp gtest_master.cpp)
|
||||
target_link_libraries(gtest_master gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maatframe MESA_htable)
|
||||
target_link_libraries(gtest_master gtest-static ctemplate-static cjson MESA_prof_load MESA_handle_logger MESA_jump_layer MESA_field_stat2 maat4 MESA_htable)
|
||||
|
||||
add_executable(gtest_sync_session_state ${PROJECT_SOURCE_DIR}/src/tsg_sync_state.cpp gtest_common.cpp gtest_session_state.cpp)
|
||||
target_link_libraries(gtest_sync_session_state gtest-static cjson ctemplate-static)
|
||||
|
||||
111
test/src/gtest_action.cpp
Normal file
111
test/src/gtest_action.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tsg_rule.h"
|
||||
#include "tsg_label.h"
|
||||
#include "tsg_entry.h"
|
||||
#include "tsg_variable.h"
|
||||
#include "tsg_rule_internal.h"
|
||||
#include "tsg_protocol_common.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
struct maat *g_tsg_maat_feather;
|
||||
|
||||
const struct session_runtime_attribute *session_runtime_attribute_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *matched_rule_cites_http_response_pages(struct maat *feather, long long profile_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_ex_data_http_response_pages_free(struct http_response_pages * response_pages)
|
||||
{
|
||||
}
|
||||
|
||||
void *matched_rule_cites_app_id_dict(struct maat *feather, long long app_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_ex_data_app_id_dict_free(struct app_id_dict * dict)
|
||||
{
|
||||
}
|
||||
|
||||
void *matched_rule_cites_security_compile(struct maat *feather, long long profile_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_ex_data_security_compile_free(struct maat_compile * maat_compile)
|
||||
{
|
||||
}
|
||||
|
||||
void *matched_rule_cites_dns_profile_record(struct maat *feather, long long profile_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_ex_data_dns_profile_record_free(struct dns_profile_records * records)
|
||||
{
|
||||
}
|
||||
|
||||
int session_runtime_action_context_async(const struct streaminfo * a_stream, void * data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_attribute_set_reponse_size(const struct streaminfo * a_stream, int http_action_file_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_action_context_set_leaky_bucket(const struct streaminfo * a_stream, struct leaky_bucket * bucket, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_action_context_set_l7_protocol(const struct streaminfo * a_stream, enum TSG_PROTOCOL protocol, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_action_context_set_rule_method(const struct streaminfo * a_stream, enum TSG_METHOD_TYPE method_type, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_action_context_set_after_n_packet(const struct streaminfo * a_stream, int after_n_packets, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct session_runtime_action_context *session_runtime_action_context_get(const struct streaminfo *a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int tsg_set_statistic_opt(int value, enum _STATISTIC_OPT_TYPE type, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int session_packet_capture_notify(const struct streaminfo * a_stream, struct maat_rule *results, size_t n_results, int thread_seq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST(TM_ACTION, Http)
|
||||
{
|
||||
EXPECT_EQ(1, 1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
101
test/src/gtest_bridge.cpp
Normal file
101
test/src/gtest_bridge.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tsg_rule.h"
|
||||
#include "tsg_label.h"
|
||||
#include "tsg_entry.h"
|
||||
#include "tsg_variable.h"
|
||||
#include "tsg_rule_internal.h"
|
||||
#include "tsg_protocol_common.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
void tsg_maat_state_free(struct maat_state *state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void destroy_bucket(struct leaky_bucket * * bucket, int thread_seq)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void plugin_ex_data_gtp_c_free(struct umts_user_info *user_info)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_ex_data_asn_number_free(struct asn_info *asn)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_ex_data_location_free(struct location_info *location)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_ex_data_subscriber_id_free(struct subscribe_id_info *subscriber)
|
||||
{
|
||||
}
|
||||
|
||||
void plugin_ex_data_tunnel_endpoint_free(struct tunnel_endpoint *t_enpoint)
|
||||
{
|
||||
}
|
||||
|
||||
int srt_attribute_set_ip_asn(const struct streaminfo * a_stream, struct maat *feather, struct asn_info **client_asn, struct asn_info **server_asn)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_attribute_set_ip_location(const struct streaminfo * a_stream, struct maat *feather, struct location_info **client_location, struct location_info **server_location)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **client_subscribe_id, struct subscribe_id_info **server_subscribe_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int session_runtine_attribute_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct umts_user_info *tsg_get_umts_user_info_form_redis(struct maat *feather, unsigned int teid)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int session_app_identify_result_cb(const struct streaminfo * a_stream, int bridge_id, void * data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int session_flags_identify_result_cb(const struct streaminfo * a_stream, int bridge_id, void * data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsg_sync_policy_update(const struct streaminfo *a_stream, struct update_policy *policy_array, int policy_array_num)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST(TM_Bridge, HitedSecurityPolicyResult)
|
||||
{
|
||||
EXPECT_EQ(1,1);
|
||||
EXPECT_NE(nullptr, "");
|
||||
EXPECT_STREQ("460045157065560", "460045157065560");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret=tsg_bridge_init("tsgconf/main.conf");
|
||||
if(ret<0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#include "tsg_send_log.h"
|
||||
|
||||
extern "C" int TSG_MASTER_INIT();
|
||||
void free_shaping_result(const struct streaminfo *stream, int bridge_id, void *data);
|
||||
void session_matched_rules_free(const struct streaminfo *stream, int bridge_id, void *data);
|
||||
|
||||
int TLD_convert_json(struct TLD_handle_t *_handle, char *buff, unsigned int buff_len);
|
||||
int set_app_id(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream);
|
||||
int set_shaping_rule_ids(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream);
|
||||
int set_app_id(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream);
|
||||
int set_shaping_rule_ids(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream);
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,6 @@ using namespace rapidjson;
|
||||
using namespace std;
|
||||
|
||||
extern "C" int TSG_MASTER_INIT();
|
||||
int set_vlan(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct single_layer_vlan_addr *vlan_addr, int layer_num, Value *tunnel_object, tsg_log_field_id_t id);
|
||||
int set_app_full_path(struct TLD_handle_t *_handle, char *field_name, struct gather_app_result *result);
|
||||
int set_vlan(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, struct single_layer_vlan_addr *vlan_addr, int layer_num, Value *tunnel_object, tsg_log_field_id_t id);
|
||||
int set_app_full_path(struct TLD_handle_t *handle, char *field_name, struct gather_app_result *result);
|
||||
|
||||
|
||||
@@ -3,41 +3,46 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "gtest_common.h"
|
||||
#include "tsg_rule.h"
|
||||
#include "tsg_entry.h"
|
||||
#include "tsg_rule_internal.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
extern int rd_kafka_get_sendlog_cnt(void);
|
||||
extern const char *rd_kafka_get_sendlog_payload(int idx);
|
||||
extern int matched_shaping_rules_deal(const struct streaminfo *a_stream, struct maat_rule *shaping_rules, size_t n_shaping_rules, int thread_seq);;
|
||||
extern int matched_service_chaining_rules_deal(const struct streaminfo *a_stream, struct maat_rule *service_chaining_rules, size_t n_service_chaining_rules, int thread_seq);;
|
||||
|
||||
extern void session_segment_id_free(const struct streaminfo * a_stream, int bridge_id, void * data);
|
||||
|
||||
|
||||
TEST(TSGMaster, SetAPPIDHttp)
|
||||
{
|
||||
struct streaminfo a_stream={0};
|
||||
struct gather_app_result gather_result[ORIGIN_MAX]={0};
|
||||
const struct streaminfo a_stream={0};
|
||||
struct gather_app_result async_gather_result[ORIGIN_MAX]={0};
|
||||
|
||||
gather_result[ORIGIN_BASIC_PROTOCOL].app_num=1;
|
||||
gather_result[ORIGIN_BASIC_PROTOCOL].origin=ORIGIN_BASIC_PROTOCOL;
|
||||
gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id=67; //HTTP
|
||||
async_gather_result[ORIGIN_BASIC_PROTOCOL].app_num=1;
|
||||
async_gather_result[ORIGIN_BASIC_PROTOCOL].origin=ORIGIN_BASIC_PROTOCOL;
|
||||
async_gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id=67; //HTTP
|
||||
|
||||
tsg_set_xxx_to_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_GATHER_APP_RESULT].id, (void *)gather_result);
|
||||
struct gather_app_result *get_result=(struct gather_app_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_GATHER_APP_RESULT].id);
|
||||
EXPECT_NE(nullptr, get_result);
|
||||
EXPECT_EQ(1, get_result[ORIGIN_BASIC_PROTOCOL].app_num);
|
||||
EXPECT_EQ(67, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
|
||||
EXPECT_EQ(0, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].packet_sequence);
|
||||
EXPECT_EQ(0, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
|
||||
EXPECT_EQ(ORIGIN_BASIC_PROTOCOL, get_result[ORIGIN_BASIC_PROTOCOL].origin);
|
||||
session_gather_app_results_async(&a_stream, (void *)async_gather_result);
|
||||
struct gather_app_result *gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
|
||||
EXPECT_NE(nullptr, gather_result);
|
||||
EXPECT_EQ(1, gather_result[ORIGIN_BASIC_PROTOCOL].app_num);
|
||||
EXPECT_EQ(67, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
|
||||
EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].packet_sequence);
|
||||
EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
|
||||
EXPECT_EQ(ORIGIN_BASIC_PROTOCOL, gather_result[ORIGIN_BASIC_PROTOCOL].origin);
|
||||
|
||||
struct TLD_handle_t *handle=TLD_create(0);
|
||||
set_app_id(g_tsg_log_instance, handle, (struct streaminfo *)&a_stream);
|
||||
char app_ids[256]={0};
|
||||
TLD_convert_json(handle, app_ids, sizeof(app_ids));
|
||||
EXPECT_STREQ("{\"common_app_full_path\":\"http\",\"common_app_label\":\"http\"}", app_ids);
|
||||
EXPECT_STREQ("{\"common_app_full_path\":\"http\",\"common_app_label\":\"http\",\"common_app_id\":{\"LPI_L7\":[{\"app_name\":\"http\",\"app_id\":67,\"surrogate_id\":0,\"packet_sequence\":0}]}}", app_ids);
|
||||
|
||||
|
||||
tsg_set_xxx_to_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_GATHER_APP_RESULT].id, NULL);
|
||||
get_result=(struct gather_app_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_GATHER_APP_RESULT].id);
|
||||
EXPECT_EQ(nullptr, get_result);
|
||||
session_gather_app_results_async(&a_stream, NULL);
|
||||
gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
|
||||
EXPECT_EQ(nullptr, gather_result);
|
||||
}
|
||||
|
||||
TEST(TSGMaster, SetAPPIDUnknown)
|
||||
@@ -55,45 +60,53 @@ TEST(TSGMaster, SetAPPIDUnknown)
|
||||
TEST(TSGMaster, ShapingSetRuleIds)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t shaping_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM; i++)
|
||||
{
|
||||
shaping_result[i].action=TSG_ACTION_SHAPING;
|
||||
shaping_result[i].config_id=TSG_ACTION_SHAPING+i;
|
||||
shaping_result[i].rule_id=TSG_ACTION_SHAPING+i;
|
||||
}
|
||||
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
|
||||
struct TLD_handle_t *handle=TLD_create(0);
|
||||
set_shaping_rule_ids(g_tsg_log_instance, handle, (struct streaminfo *)&a_stream);
|
||||
set_shaping_rule_ids(g_tsg_log_instance, handle, &a_stream);
|
||||
char shaping_rule_ids[256]={0};
|
||||
TLD_convert_json(handle, shaping_rule_ids, sizeof(shaping_rule_ids));
|
||||
EXPECT_STREQ("{\"common_shaping_rule_ids\":[32,33,34,35,36,37,38,39]}", shaping_rule_ids);
|
||||
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
const struct matched_policy_rules *hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, (void *)shaping_label);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id));
|
||||
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.shaping_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SHAPING, (void *)hited_shaping);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING));
|
||||
}
|
||||
|
||||
int shaping_policy_notify_cb(const struct streaminfo *stream, int bridge_id, void *data)
|
||||
{
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)data;
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
struct matched_policy_rules *hited_shaping=(struct matched_policy_rules *)data;
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -102,37 +115,38 @@ int shaping_policy_notify_cb(const struct streaminfo *stream, int bridge_id, voi
|
||||
TEST(TSGMaster, ShapingPolicyNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t shaping_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM; i++)
|
||||
{
|
||||
shaping_result[i].action=TSG_ACTION_SHAPING;
|
||||
shaping_result[i].config_id=TSG_ACTION_SHAPING+i;
|
||||
shaping_result[i].rule_id=TSG_ACTION_SHAPING+i;
|
||||
}
|
||||
|
||||
stream_bridge_register_data_sync_cb(g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, shaping_policy_notify_cb);
|
||||
stream_bridge_register_data_sync_cb(stream_bridge_build("NOTIFY_SHAPING_RESULT", "w"), shaping_policy_notify_cb);
|
||||
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
int shaping_result_num=tsg_pull_shaping_result((struct streaminfo *)&a_stream, shaping_result, MAX_RESULT_NUM);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, shaping_result_num);
|
||||
for(int i=0; i<shaping_result_num; i++)
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
|
||||
const struct matched_policy_rules *hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_result[i].config_id);
|
||||
}
|
||||
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, (void *)shaping_label);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id));
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.shaping_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SHAPING, (void *)hited_shaping);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING));
|
||||
}
|
||||
|
||||
int shaping_policy_notify_null_cb(const struct streaminfo *stream, int bridge_id, void *data)
|
||||
@@ -144,24 +158,24 @@ int shaping_policy_notify_null_cb(const struct streaminfo *stream, int bridge_id
|
||||
TEST(TSGMaster, ShapingPolicyNotifyNULL)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t shaping_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
stream_bridge_register_data_sync_cb(g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, shaping_policy_notify_null_cb);
|
||||
stream_bridge_register_data_sync_cb(stream_bridge_build("NOTIFY_SHAPING_RESULT", "w"), shaping_policy_notify_cb);
|
||||
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, 0, 0);
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_EQ(nullptr, shaping_label);
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, 0, 0);
|
||||
const struct matched_policy_rules *hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_EQ(nullptr, hited_shaping);
|
||||
}
|
||||
|
||||
int shaping_duplicate_policy_notify_cb(const struct streaminfo *stream, int bridge_id, void *data)
|
||||
{
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)data;
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
struct matched_policy_rules *hited_shaping=(struct matched_policy_rules *)data;
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -170,126 +184,120 @@ int shaping_duplicate_policy_notify_cb(const struct streaminfo *stream, int brid
|
||||
TEST(TSGMaster, ShapingDuplicatePolicyNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t shaping_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM; i++)
|
||||
{
|
||||
shaping_result[i].action=TSG_ACTION_SHAPING;
|
||||
shaping_result[i].config_id=TSG_ACTION_SHAPING+(i%4);
|
||||
shaping_result[i].rule_id=TSG_ACTION_SHAPING+(i%4);
|
||||
}
|
||||
|
||||
stream_bridge_register_data_sync_cb(g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, shaping_duplicate_policy_notify_cb);
|
||||
stream_bridge_register_data_sync_cb(stream_bridge_build("NOTIFY_SHAPING_RESULT", "w"), shaping_policy_notify_cb);
|
||||
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
int shaping_result_num=tsg_pull_shaping_result((struct streaminfo *)&a_stream, shaping_result, MAX_RESULT_NUM);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_result_num);
|
||||
for(int i=0; i<shaping_result_num; i++)
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM, 0);
|
||||
|
||||
const struct matched_policy_rules *hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
}
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.shaping_sid, segment_ids->sid_list[0]);
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, (void *)shaping_label);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id));
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SHAPING, (void *)hited_shaping);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING));
|
||||
}
|
||||
|
||||
TEST(TSGMaster, ShapingDuplicatePolicyMultipleNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t shaping_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
shaping_result[i].action=TSG_ACTION_SHAPING;
|
||||
shaping_result[i].config_id=TSG_ACTION_SHAPING+i;
|
||||
shaping_result[i].rule_id=TSG_ACTION_SHAPING+i;
|
||||
}
|
||||
|
||||
stream_bridge_register_data_sync_cb(g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, shaping_duplicate_policy_notify_cb);
|
||||
stream_bridge_register_data_sync_cb(stream_bridge_build("NOTIFY_SHAPING_RESULT", "w"), shaping_policy_notify_cb);
|
||||
|
||||
// First notify
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, MAX_RESULT_NUM/2, 0);
|
||||
int shaping_result_num=tsg_pull_shaping_result((struct streaminfo *)&a_stream, shaping_result, MAX_RESULT_NUM);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_result_num);
|
||||
for(int i=0; i<shaping_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_result[i].config_id);
|
||||
}
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
struct notify_shaping_policy *shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
const struct matched_policy_rules *hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
// Second notify
|
||||
tsg_notify_hited_shaping_result(&a_stream, shaping_result, MAX_RESULT_NUM/2, 0);
|
||||
shaping_result_num=tsg_pull_shaping_result((struct streaminfo *)&a_stream, shaping_result, MAX_RESULT_NUM);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_result_num);
|
||||
for(int i=0; i<shaping_result_num; i++)
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
hited_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hited_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_shaping->n_rules);
|
||||
for(size_t i=0; i<hited_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_result[i].config_id);
|
||||
}
|
||||
|
||||
shaping_label=(struct notify_shaping_policy *)stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id);
|
||||
EXPECT_NE(nullptr, shaping_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, shaping_label->shaping_result_num);
|
||||
for(int i=0; i<shaping_label->shaping_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, shaping_label->shaping_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, shaping_label->shaping_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hited_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hited_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, (void *)shaping_label);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_NOTIFY_SHAPING_RESULT].id));
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.shaping_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SHAPING, (void *)hited_shaping);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING));
|
||||
}
|
||||
|
||||
TEST(TSGMaster, SecurityPolicySendlog)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t security_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule matched_policy[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM; i++)
|
||||
{
|
||||
security_result[i].do_log=1;
|
||||
security_result[i].action=TSG_ACTION_MONITOR;
|
||||
security_result[i].config_id=TSG_ACTION_MONITOR+i;
|
||||
matched_policy[i].do_log=1;
|
||||
matched_policy[i].action=TSG_ACTION_MONITOR;
|
||||
matched_policy[i].rule_id=TSG_ACTION_MONITOR+i;
|
||||
}
|
||||
|
||||
// First notify
|
||||
tsg_notify_hited_security_result(&a_stream, security_result, MAX_RESULT_NUM, 0);
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_SECURITY, matched_policy, MAX_RESULT_NUM, 0);
|
||||
|
||||
struct policy_priority_label *priority_label=(struct policy_priority_label *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id);
|
||||
EXPECT_NE(nullptr, priority_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, priority_label->security_result_num);
|
||||
for(int i=0; i<priority_label->security_result_num; i++)
|
||||
const struct matched_policy_rules *hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_NE(nullptr, hited_security);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, hited_security->n_rules);
|
||||
for(size_t i=0; i<hited_security->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, priority_label->security_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, priority_label->security_result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, hited_security->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, hited_security->rules[i].rule_id);
|
||||
}
|
||||
|
||||
struct TLD_handle_t * handle=TLD_create(0);
|
||||
struct Maat_rule_t session_record={0, 2, 1, 0, 0, 0, 0, {0}};
|
||||
tsg_log_t log_msg={1, &session_record, (struct streaminfo*)&a_stream};
|
||||
tsg_send_log(g_tsg_log_instance, handle, &log_msg, 0);
|
||||
struct maat_rule session_record={0, 0, 2, 1, 0};
|
||||
tsg_send_log(g_tsg_log_instance, handle, &a_stream, LOG_TYPE_SESSION_RECORD, &session_record, 1, 0);
|
||||
|
||||
int sendlog_cnt=rd_kafka_get_sendlog_cnt();
|
||||
EXPECT_EQ(8, sendlog_cnt);
|
||||
EXPECT_EQ(9, sendlog_cnt);
|
||||
//EXPECT_STREQ("{}", rd_kafka_get_sendlog_payload(0));
|
||||
//EXPECT_STREQ("{}", rd_kafka_get_sendlog_payload(1));
|
||||
//EXPECT_STREQ("{}", rd_kafka_get_sendlog_payload(2));
|
||||
@@ -300,169 +308,331 @@ TEST(TSGMaster, SecurityPolicySendlog)
|
||||
//EXPECT_STREQ("{}", rd_kafka_get_sendlog_payload(7));
|
||||
//EXPECT_STREQ("{}", rd_kafka_get_sendlog_payload(8));
|
||||
|
||||
priority_label=(struct policy_priority_label *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id);
|
||||
EXPECT_EQ(nullptr, priority_label);
|
||||
hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_EQ(nullptr, hited_security);
|
||||
}
|
||||
|
||||
TEST(TSGMaster, SecurityDuplicatePolicyMultipleNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t security_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
security_result[i].action=TSG_ACTION_MONITOR;
|
||||
security_result[i].config_id=TSG_ACTION_MONITOR+i;
|
||||
}
|
||||
|
||||
// First notify
|
||||
tsg_notify_hited_security_result(&a_stream, security_result, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
struct policy_priority_label *priority_label=(struct policy_priority_label *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id);
|
||||
EXPECT_NE(nullptr, priority_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, priority_label->security_result_num);
|
||||
for(int i=0; i<priority_label->security_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, priority_label->security_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, priority_label->security_result[i].config_id);
|
||||
}
|
||||
|
||||
// Second notify
|
||||
tsg_notify_hited_security_result(&a_stream, security_result, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
priority_label=(struct policy_priority_label *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id);
|
||||
EXPECT_NE(nullptr, priority_label);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, priority_label->security_result_num);
|
||||
for(int i=0; i<priority_label->security_result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, priority_label->security_result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, priority_label->security_result[i].config_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id, (void *)priority_label);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_POLICY_PRIORITY].id));
|
||||
}
|
||||
|
||||
extern void set_s_chaining_result_to_bridge(const struct streaminfo * a_stream, struct Maat_rule_t * p_result, int p_result_num, int thread_seq);
|
||||
|
||||
TEST(TSGMaster, ServiceChainingPolicyNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
s_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
s_chaining_result[i].config_id=TSG_ACTION_S_CHAINING+i;
|
||||
s_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
set_s_chaining_result_to_bridge(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
struct tm_hited_result *hited_s_chaining=(struct tm_hited_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id);
|
||||
matched_service_chaining_rules_deal(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
const struct matched_policy_rules *hited_s_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, hited_s_chaining->sid);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->result_num);
|
||||
for(int i=0; i<hited_s_chaining->result_num; i++)
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->n_rules);
|
||||
for(size_t i=0; i<hited_s_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, (void *)hited_s_chaining);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id));
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_CHAINING, (void *)hited_s_chaining);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING));
|
||||
}
|
||||
|
||||
TEST(TSGMaster, ServiceChainingDuplicatePolicyMultipleNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
// first
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
s_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
s_chaining_result[i].config_id=TSG_ACTION_S_CHAINING+i;
|
||||
s_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
set_s_chaining_result_to_bridge(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
struct tm_hited_result *hited_s_chaining=(struct tm_hited_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id);
|
||||
matched_service_chaining_rules_deal(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
const struct matched_policy_rules *hited_s_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, hited_s_chaining->sid);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->result_num);
|
||||
for(int i=0; i<hited_s_chaining->result_num; i++)
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->n_rules);
|
||||
for(size_t i=0; i<hited_s_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
// second
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
s_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
s_chaining_result[i].config_id=TSG_ACTION_S_CHAINING+i;
|
||||
s_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
tsg_notify_hited_s_chaining_result(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 1);
|
||||
hited_s_chaining=(struct tm_hited_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id);
|
||||
matched_service_chaining_rules_deal(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
hited_s_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, hited_s_chaining->sid);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->result_num);
|
||||
for(int i=0; i<hited_s_chaining->result_num; i++)
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->n_rules);
|
||||
for(size_t i=0; i<hited_s_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, (void *)hited_s_chaining);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id));
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_CHAINING, (void *)hited_s_chaining);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING));
|
||||
}
|
||||
|
||||
TEST(TSGMaster, ServiceChainingPolicyMultipleNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct Maat_rule_t s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
struct maat_rule s_chaining_result[MAX_RESULT_NUM]={0};
|
||||
|
||||
// first
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
s_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
s_chaining_result[i].config_id=TSG_ACTION_S_CHAINING+i;
|
||||
s_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
set_s_chaining_result_to_bridge(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
struct tm_hited_result *hited_s_chaining=(struct tm_hited_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id);
|
||||
matched_service_chaining_rules_deal(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
const struct matched_policy_rules *hited_s_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, hited_s_chaining->sid);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->result_num);
|
||||
for(int i=0; i<hited_s_chaining->result_num; i++)
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->n_rules);
|
||||
for(size_t i=0; i<hited_s_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->result[i].config_id);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
// second
|
||||
for(int i=MAX_RESULT_NUM/2; i<MAX_RESULT_NUM; i++)
|
||||
{
|
||||
s_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
s_chaining_result[i].config_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
tsg_notify_hited_s_chaining_result(&a_stream, &(s_chaining_result[MAX_RESULT_NUM/2]), MAX_RESULT_NUM/2, 1);
|
||||
hited_s_chaining=(struct tm_hited_result *)tsg_get_xxx_from_bridge(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, hited_s_chaining->sid);
|
||||
EXPECT_EQ(MAX_RESULT_NUM, hited_s_chaining->result_num);
|
||||
for(int i=0; i<hited_s_chaining->result_num; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->result[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->result[i].config_id);
|
||||
s_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
|
||||
free_shaping_result(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, (void *)hited_s_chaining);
|
||||
stream_bridge_async_data_put(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id, NULL);
|
||||
EXPECT_EQ(nullptr, stream_bridge_async_data_get(&a_stream, g_tsg_para.bridge[BRIDGE_TYPE_SERVICE_CHAINING].id));
|
||||
matched_service_chaining_rules_deal(&a_stream, s_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
hited_s_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hited_s_chaining);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_s_chaining->n_rules);
|
||||
for(size_t i=0; i<hited_s_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hited_s_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hited_s_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(1, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, segment_ids->sid_list[0]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_CHAINING, (void *)hited_s_chaining);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING));
|
||||
}
|
||||
|
||||
TEST(TSGMaster, SecurityDuplicatePolicyMultipleNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct maat_rule matched_policy[MAX_RESULT_NUM]={0};
|
||||
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
matched_policy[i].action=TSG_ACTION_MONITOR;
|
||||
matched_policy[i].rule_id=TSG_ACTION_MONITOR+i;
|
||||
}
|
||||
|
||||
// First notify
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_SECURITY, matched_policy, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
const struct matched_policy_rules *hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_NE(nullptr, hited_security);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_security->n_rules);
|
||||
for(size_t i=0; i<hited_security->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, hited_security->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, hited_security->rules[i].rule_id);
|
||||
}
|
||||
|
||||
// Second notify
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_SECURITY, matched_policy, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_NE(nullptr, hited_security);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hited_security->n_rules);
|
||||
for(size_t i=0; i<hited_security->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, hited_security->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR+i, hited_security->rules[i].rule_id);
|
||||
}
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SECURITY, (void *)hited_security);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SECURITY, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY));
|
||||
}
|
||||
|
||||
extern int session_packet_capture_notify(const struct streaminfo *a_stream, struct maat_rule *rules, size_t n_rules, int thread_seq);
|
||||
|
||||
TEST(TSGMaster, SecurityPolicyIntercept)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct maat_rule matched_policy[MAX_RESULT_NUM]={0};
|
||||
|
||||
matched_policy[1].action=TSG_ACTION_INTERCEPT;
|
||||
matched_policy[1].rule_id=TSG_ACTION_INTERCEPT;
|
||||
|
||||
// Set Intercept
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_SECURITY, &matched_policy[1], 1, 0);
|
||||
|
||||
const struct matched_policy_rules *hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_NE(nullptr, hited_security);
|
||||
EXPECT_EQ(1, hited_security->n_rules);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, hited_security->rules[0].action);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, hited_security->rules[0].rule_id);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SECURITY, (void *)hited_security);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SECURITY, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY));
|
||||
}
|
||||
|
||||
|
||||
TEST(TSGMaster, SecurityMultiplePolicyMonitorToIntercept)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
struct maat_rule matched_policy[MAX_RESULT_NUM]={0};
|
||||
|
||||
matched_policy[0].action=TSG_ACTION_MONITOR;
|
||||
matched_policy[0].rule_id=TSG_ACTION_MONITOR;
|
||||
|
||||
matched_policy[1].action=TSG_ACTION_INTERCEPT;
|
||||
matched_policy[1].rule_id=TSG_ACTION_INTERCEPT;
|
||||
|
||||
// First Monitor, second Intercpt
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_SECURITY, &matched_policy[0], 1, 0);
|
||||
|
||||
int ret=session_matched_rules_copy(&a_stream, TSG_SERVICE_INTERCEPT, &(matched_policy[2]), 1);
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
ret=session_matched_rules_copy(&a_stream, TSG_SERVICE_SECURITY, &(matched_policy[2]), 1);
|
||||
EXPECT_EQ(1, ret);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, matched_policy[2].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, matched_policy[2].rule_id);
|
||||
|
||||
ret=session_matched_rules_copy(&a_stream, TSG_SERVICE_SECURITY, &(matched_policy[2]), 1);
|
||||
EXPECT_EQ(1, ret);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, matched_policy[2].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, matched_policy[2].rule_id);
|
||||
|
||||
const struct matched_policy_rules *hited_security=session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY);
|
||||
EXPECT_NE(nullptr, hited_security);
|
||||
EXPECT_EQ(1, hited_security->n_rules);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, hited_security->rules[0].action);
|
||||
EXPECT_EQ(TSG_ACTION_MONITOR, hited_security->rules[0].rule_id);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SECURITY, (void *)hited_security);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SECURITY, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SECURITY));
|
||||
|
||||
// Set Intercept
|
||||
session_matched_rules_notify(&a_stream, TSG_SERVICE_INTERCEPT, &matched_policy[1], 1, 0);
|
||||
|
||||
ret=session_matched_rules_copy(&a_stream, TSG_SERVICE_INTERCEPT, &(matched_policy[2]), 1);
|
||||
EXPECT_EQ(1, ret);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, matched_policy[2].action);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, matched_policy[2].rule_id);
|
||||
|
||||
ret=session_matched_rules_copy(&a_stream, TSG_SERVICE_INTERCEPT, &(matched_policy[2]), 1);
|
||||
EXPECT_EQ(1, ret);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, matched_policy[2].action);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, matched_policy[2].rule_id);
|
||||
|
||||
const struct matched_policy_rules *hited_intercept=session_matched_rules_get(&a_stream, TSG_SERVICE_INTERCEPT);
|
||||
EXPECT_NE(nullptr, hited_intercept);
|
||||
EXPECT_EQ(1, hited_intercept->n_rules);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, hited_intercept->rules[0].action);
|
||||
EXPECT_EQ(TSG_ACTION_INTERCEPT, hited_intercept->rules[0].rule_id);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_INTERCEPT, (void *)hited_intercept);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_INTERCEPT, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_INTERCEPT));
|
||||
}
|
||||
|
||||
|
||||
TEST(TSGMaster, ShapingAndServiceChainingPolicyNotify)
|
||||
{
|
||||
const struct streaminfo a_stream={0};
|
||||
|
||||
// service chaining notify
|
||||
struct maat_rule service_chaining_result[MAX_RESULT_NUM]={0};
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
service_chaining_result[i].action=TSG_ACTION_S_CHAINING;
|
||||
service_chaining_result[i].rule_id=TSG_ACTION_S_CHAINING+i;
|
||||
}
|
||||
matched_service_chaining_rules_deal(&a_stream, service_chaining_result, MAX_RESULT_NUM/2, 0);
|
||||
|
||||
const struct matched_policy_rules *hitted_service_chaining=session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING);
|
||||
EXPECT_NE(nullptr, hitted_service_chaining);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hitted_service_chaining->n_rules);
|
||||
for(size_t i=0; i<hitted_service_chaining->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING, hitted_service_chaining->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_S_CHAINING+i, hitted_service_chaining->rules[i].rule_id);
|
||||
}
|
||||
|
||||
// shping notify
|
||||
struct maat_rule shaping_result[MAX_RESULT_NUM]={0};
|
||||
for(int i=0; i<MAX_RESULT_NUM/2; i++)
|
||||
{
|
||||
shaping_result[i].action=TSG_ACTION_SHAPING;
|
||||
shaping_result[i].rule_id=TSG_ACTION_SHAPING+i;
|
||||
}
|
||||
|
||||
matched_shaping_rules_deal(&a_stream, shaping_result, MAX_RESULT_NUM/2, 0);
|
||||
const struct matched_policy_rules *hitted_shaping=session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING);
|
||||
EXPECT_NE(nullptr, hitted_shaping);
|
||||
EXPECT_EQ(MAX_RESULT_NUM/2, hitted_shaping->n_rules);
|
||||
for(size_t i=0; i<hitted_shaping->n_rules; i++)
|
||||
{
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING, hitted_shaping->rules[i].action);
|
||||
EXPECT_EQ(TSG_ACTION_SHAPING+i, hitted_shaping->rules[i].rule_id);
|
||||
}
|
||||
|
||||
struct segment_id_list *segment_ids=(struct segment_id_list *)session_control_segment_ids_get(&a_stream);
|
||||
EXPECT_NE(nullptr, segment_ids);
|
||||
EXPECT_EQ(2, segment_ids->sz_sidlist);
|
||||
EXPECT_EQ(g_tsg_para.service_chaining_sid, segment_ids->sid_list[0]);
|
||||
EXPECT_EQ(g_tsg_para.shaping_sid, segment_ids->sid_list[1]);
|
||||
|
||||
session_segment_id_free(&a_stream, 0, (void *)segment_ids);
|
||||
session_control_segment_ids_async(&a_stream, NULL);
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_SHAPING, (void *)hitted_shaping);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_SHAPING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_SHAPING));
|
||||
|
||||
session_matched_rules_free(&a_stream, TSG_SERVICE_CHAINING, (void *)hitted_service_chaining);
|
||||
session_matched_rules_async(&a_stream, TSG_SERVICE_CHAINING, NULL);
|
||||
EXPECT_EQ(nullptr, session_matched_rules_get(&a_stream, TSG_SERVICE_CHAINING));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,37 +2,128 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tsg_rule.h"
|
||||
|
||||
#include "gtest_common.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int tsg_app_id2name(int app_id, char *app_name, int app_name_len, int is_joint_parent)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
struct maat *g_tsg_maat_feather;
|
||||
|
||||
int tsg_get_location_type(void)
|
||||
{
|
||||
return 19;
|
||||
}
|
||||
|
||||
char *tsg_l7_protocol_id2name(unsigned int l7_protocol_id)
|
||||
char *tsg_device_tag_get(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char get_direction_from_tcpall(const struct streaminfo *a_stream)
|
||||
char *tsg_data_center_get(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int tsg_location_type_get(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsg_session_record_switch_get(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *session_mac_linkinfo_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_gather_app_results_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_conn_sketch_notify_data_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_business_data_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_session_flags_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_application_behavior_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_mirrored_and_capture_packets_exec_result_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_lua_user_defined_attribute_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_nat_c2s_linkinfo_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *session_nat_s2c_linkinfo_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int session_matched_rules_async(const struct streaminfo * a_stream, TSG_SERVICE service, void * data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct matched_policy_rules *session_matched_rules_get(const struct streaminfo *a_stream, enum TSG_SERVICE service)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void session_matched_rules_free(const struct streaminfo * a_stream, TSG_SERVICE service, void * data)
|
||||
{
|
||||
}
|
||||
|
||||
char srt_action_context_get_direction(const struct streaminfo * a_stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tsg_get_app_name_by_id(struct maat *feahter, int app_id, char * app_name, int app_name_len, int is_joint_parent)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct session_runtime_attribute *session_runtime_attribute_get(const struct streaminfo * a_stream)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *matched_rule_cites_security_compile(struct maat * feather, long long compile_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void plugin_ex_data_security_compile_free(struct maat_compile * maat_compile)
|
||||
{
|
||||
}
|
||||
|
||||
TEST(MasterTest, SetVlan)
|
||||
{
|
||||
//int ret=set_vlan(NULL, NULL, NULL, 0, NULL, LOG_COMMON_TUNNELS_VLAN_SRC_ID);
|
||||
//EXPECT_EQ(1, ret);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
@@ -10,7 +10,7 @@ extern int get_ctrl_pkt(char *buf, int len);
|
||||
|
||||
struct parse_handle test_handle;
|
||||
|
||||
unsigned long long tsg_get_stream_id(struct streaminfo * a_stream)
|
||||
unsigned long long tsg_get_stream_trace_id(const struct streaminfo * a_stream)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
@@ -131,11 +131,11 @@ TEST(SESSION_STATE, ActiveStateServiceChainingAndShaping1)
|
||||
int ctrl_pkt_len = 0;
|
||||
memset(&policy_array, 0, sizeof(struct update_policy) * 2);
|
||||
policy_array[0].type = POLICY_UPDATE_SHAPING;
|
||||
policy_array[0].id_num = 3;
|
||||
policy_array[0].n_ids = 3;
|
||||
policy_array[0].ids[0] = 1;
|
||||
policy_array[0].ids[1] = 2;
|
||||
policy_array[0].ids[2] = 3;
|
||||
policy_array[1].id_num = 3;
|
||||
policy_array[1].n_ids = 3;
|
||||
policy_array[1].ids[0] = 4;
|
||||
policy_array[1].ids[1] = 5;
|
||||
policy_array[1].ids[2] = 6;
|
||||
|
||||
Reference in New Issue
Block a user