TSG-15379: 适配MAAT4头文件变化

This commit is contained in:
刘学利
2023-06-08 09:17:53 +00:00
parent 4b023ef230
commit cad3ae8cad
7 changed files with 116 additions and 81 deletions

View File

@@ -634,7 +634,8 @@
"valid_column": 4,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 2
}
},
{
@@ -697,7 +698,8 @@
"valid_column": 18,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 8
}
},
{
@@ -721,7 +723,8 @@
"valid_column": 7,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 8
}
},
{
@@ -731,7 +734,8 @@
"valid_column": 7,
"custom": {
"key": 2,
"key_type": "integer"
"key_type": "integer",
"key_len": 4
}
},
{
@@ -741,7 +745,8 @@
"valid_column": 5,
"custom": {
"key": 3,
"key_type": "pointer"
"key_type": "ip_addr",
"addr_type": 2
}
},
{
@@ -751,7 +756,8 @@
"valid_column": 5,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 8
}
},
{
@@ -762,6 +768,7 @@
"custom": {
"key": 1,
"key_type": "integer",
"key_len": 8,
"foreign": [
4
]
@@ -774,7 +781,8 @@
"valid_column": 4,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 4
}
},
{
@@ -784,7 +792,8 @@
"valid_column": 3,
"custom": {
"key": 1,
"key_type": "integer"
"key_type": "integer",
"key_len": 4
}
},
{

View File

@@ -103,7 +103,7 @@ int dns_set_response_question(char *payload, int payload_len, dns_query_question
int compress_len=0, used_len=0;
u_char compress_name[DNS_MAX_NAME+1];
/* ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
/* ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
memset(compress_name, 0, sizeof(compress_name));
compress_len=compress_domain_record(query_question->qname,strlen((char *)(query_question->qname)), compress_name);
@@ -195,7 +195,7 @@ static int dns_set_answer_records(char *payload, int payload_len, struct dns_ans
int used_len=0;
if(answer_records->record_val.selected_flag==1)
{
struct dns_profile_records *profile_records=(struct dns_profile_records *)matched_rule_cites_dns_profile_record(g_tsg_maat_feather, answer_records->record_val.selected.profile_id);
struct dns_profile_records *profile_records=(struct dns_profile_records *)matched_rule_cites_dns_profile_record(g_tsg_maat_feather, (long long)answer_records->record_val.selected.profile_id);
if(profile_records==NULL)
{
return 0;

View File

@@ -150,7 +150,7 @@ static int get_umts_user_info_form_hash(struct umts_user_info **user_info, unsig
static int get_umts_user_info_form_redis(struct umts_user_info **user_info, unsigned int teid, int thread_seq)
{
(*user_info) = tsg_get_umts_user_info_form_redis(g_tsg_maat_feather, (long long)teid);
(*user_info) = tsg_get_umts_user_info_form_redis(g_tsg_maat_feather, teid);
if((*user_info)!=NULL)
{
return 1;

View File

@@ -2200,23 +2200,32 @@ int srt_attribute_set_ip_location(const struct streaminfo *a_stream, struct maat
int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **source_subscribe_id, struct subscribe_id_info **dest_subscribe_id)
{
char source_ip[MAX_IPV6_ADDR_LEN]={0};
char dest_ip[MAX_IPV6_ADDR_LEN]={0};
switch(a_stream->addr.addrtype)
{
case ADDR_TYPE_IPV4:
if(*dest_subscribe_id==NULL)
{
*dest_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, (const char *)&a_stream->addr.tuple4_v4->daddr, sizeof(UINT32));
}
int ret=ip_int2string(a_stream, source_ip, MAX_IPV6_ADDR_LEN, dest_ip, MAX_IPV6_ADDR_LEN);
if(ret==0)
{
return 0;
}
if(strlen(dest_ip)>0 && *dest_subscribe_id==NULL)
{
*dest_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, dest_ip);
}
if(*source_subscribe_id==NULL)
{
*source_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, (const char *)&a_stream->addr.tuple4_v4->saddr, sizeof(UINT32));
}
break;
case ADDR_TYPE_IPV6:
if(*dest_subscribe_id==NULL)
{
*dest_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, (const char *)a_stream->addr.tuple4_v6->daddr, IPV6_ADDR_LEN);
}
if(strlen(source_ip)>0 && *source_subscribe_id==NULL)
{
*source_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, source_ip);
if(*source_subscribe_id==NULL)
{
*source_subscribe_id=(struct subscribe_id_info *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, (const char *)a_stream->addr.tuple4_v6->saddr, IPV6_ADDR_LEN);
}
break;
default:
break;
}
return 0;
@@ -2227,7 +2236,7 @@ size_t matche_rules_convert(struct maat *feather,long long *matched_rules, size_
size_t offset=0;
for(size_t i=0; i<n_matched_rules && offset<n_results; i++)
{
struct maat_compile *maat_compile=(struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(matched_rules[i]));
struct maat_compile *maat_compile=(struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(matched_rules[i]), sizeof(long long));
if(maat_compile==NULL)
{
continue;
@@ -2621,7 +2630,7 @@ int tsg_get_vlan_label_id(struct maat *feather, struct single_layer_vlan_addr *v
int idx=0;
for(int i=0; i<vlan_array_num; i++)
{
void *label_id=maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_TUNNEL_LABEL].id, (const char *)&(vlan_array[i].VID));
void *label_id=maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_TUNNEL_LABEL].id, (const char *)&(vlan_array[i].VID), sizeof(unsigned short));
if(label_id==NULL)
{
continue;
@@ -2948,7 +2957,7 @@ int tsg_get_app_name_by_id(struct maat *feather, int app_id, char *app_name, int
int offset=0;
long long ll_app_id=(long long)app_id;
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&(ll_app_id));
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&(ll_app_id), sizeof(long long));
if(dict!=NULL)
{
if((int)strlen(dict->app_name) > app_name_len)
@@ -2976,7 +2985,7 @@ int tsg_get_app_name_by_id(struct maat *feather, int app_id, char *app_name, int
struct maat_compile *matched_rule_cites_security_compile(struct maat *feather, struct maat_rule *result)
{
return (struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(result->rule_id));
return (struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(result->rule_id), sizeof(long long));
}
int session_packet_capture_by_rules_notify(const struct streaminfo *a_stream, struct maat_rule *rules, size_t n_rules, int thread_seq)
@@ -3005,7 +3014,7 @@ int session_packet_capture_by_rules_notify(const struct streaminfo *a_stream, st
if(maat_compile->user_region->method_type==TSG_METHOD_TYPE_MIRRORED && maat_compile->user_region->mirror!=NULL && maat_compile->user_region->mirror->enabled==1)
{
mirror_profile=(struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(maat_compile->user_region->mirror->profile_id));
mirror_profile=(struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(maat_compile->user_region->mirror->profile_id), sizeof(int));
if(mirror_profile!=NULL)
{
session_mirror_packets_sync(a_stream, &rules[i], &(mirror_profile->vlan));
@@ -3029,14 +3038,14 @@ int session_packet_capture_by_rules_notify(const struct streaminfo *a_stream, st
return 1;
}
struct umts_user_info *tsg_get_umts_user_info_form_redis(struct maat *feather, long long teid)
struct umts_user_info *tsg_get_umts_user_info_form_redis(struct maat *feather, unsigned int teid)
{
return (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&(teid));
return (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&(teid), sizeof(unsigned int));
}
void *matched_rule_cites_http_response_pages(struct maat *feather, long long profile_id)
{
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
}
void plugin_ex_data_http_response_pages_free(struct http_response_pages *response_pages)
@@ -3046,7 +3055,7 @@ void plugin_ex_data_http_response_pages_free(struct http_response_pages *respons
void *matched_rule_cites_security_compile(struct maat *feather, long long compile_id)
{
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&compile_id);
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&compile_id, sizeof(long long));
}
void plugin_ex_data_security_compile_free(struct maat_compile *maat_compile)
@@ -3056,7 +3065,7 @@ void plugin_ex_data_security_compile_free(struct maat_compile *maat_compile)
void *matched_rule_cites_app_id_dict(struct maat *feather, long long app_id)
{
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&app_id);
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&app_id, sizeof(long long));
}
void plugin_ex_data_app_id_dict_free(struct app_id_dict *dict)
@@ -3066,7 +3075,7 @@ void plugin_ex_data_app_id_dict_free(struct app_id_dict *dict)
void *matched_rule_cites_dns_profile_record(struct maat *feather, long long profile_id)
{
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
return maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
}
void plugin_ex_data_dns_profile_record_free(struct dns_profile_records *records)
@@ -3079,7 +3088,7 @@ size_t tsg_matched_rules_select(struct maat *feather, TSG_SERVICE service, long
size_t offset=0;
for(size_t i=0; i<n_matched_rules; i++)
{
struct maat_compile *maat_compile=(struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(matched_rules[i]));
struct maat_compile *maat_compile=(struct maat_compile *)maat_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SECURITY_COMPILE].id, (const char *)&(matched_rules[i]), sizeof(long long));
if(maat_compile==NULL)
{
continue;

View File

@@ -141,7 +141,6 @@ int srt_attribute_set_ip_location(const struct streaminfo *a_stream, struct maat
int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **client_subscriber_id, struct subscribe_id_info **server_subscriber_id);
int session_runtine_attribute_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info);
struct umts_user_info *tsg_get_umts_user_info_form_redis(unsigned int teid);
void *matched_rule_cites_http_response_pages(struct maat *feather, long long profile_id);
void *matched_rule_cites_app_id_dict(struct maat *feather, long long app_id);
@@ -173,4 +172,4 @@ int tsg_scan_intercept_exclusion(const struct streaminfo *a_stream, struct maat
struct maat_rule *tsg_select_deny_rule(struct maat_rule *rules, size_t n_rules);
size_t tsg_select_rules_by_action(struct maat_rule *matched_rules, size_t n_matched_rules, struct maat_rule *rules, size_t n_rules, unsigned char action);
struct umts_user_info *tsg_get_umts_user_info_form_redis(struct maat *feather, long long teid);
struct umts_user_info *tsg_get_umts_user_info_form_redis(struct maat *feather, unsigned int teid);

View File

@@ -2392,7 +2392,9 @@
"table_name": "TSG_DYN_SUBSCRIBER_IP",
"table_content": [
"1299\t4\t192.168.56.28\ttest5628\t1",
"1300\t4\t192.168.56.27\ttest5627\t1"
"1300\t4\t192.168.56.27\ttest5627\t1",
"1301\t6\t1030::C9B4:FF12:48AA:1A2B\ttest5630\t1",
"1302\t6\t1030::C9B4:FF12:3799:1A2B\ttest5629\t1"
]
},
{

View File

@@ -48,8 +48,8 @@ TEST(TM, ExDataGTPC)
"2\t111052899\t460045157053102\t861440152041083\tcmiott.wkctf.mcto60g.com\t8626070583008402\t1"
******************************************************************************************************/
long long teid=111039813;
struct umts_user_info *user_info=(struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid);
int teid=111039813;
struct umts_user_info *user_info=(struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid, sizeof(int));
EXPECT_NE(nullptr, user_info);
EXPECT_STREQ("460045157065560", user_info->imsi);
EXPECT_STREQ("861440152009856", user_info->msisdn);
@@ -57,7 +57,7 @@ TEST(TM, ExDataGTPC)
EXPECT_STREQ("8626070583075127", user_info->imei);
teid=111052899;
user_info=(struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid);
user_info=(struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid, sizeof(int));
EXPECT_NE(nullptr, user_info);
EXPECT_STREQ("460045157053102", user_info->imsi);
EXPECT_STREQ("861440152041083", user_info->msisdn);
@@ -73,8 +73,8 @@ TEST(TM, ExDataAPPIDDictUnknown)
"4\tunknown\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\tnull\t1\t3600\t3600\t1800\t1800\t1"
**************************************************************************************************************************/
long long ll_app_id=4;
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
EXPECT_NE(nullptr, dict);
EXPECT_EQ(4, dict->app_id);
EXPECT_STREQ("unknown", dict->app_name);
@@ -106,7 +106,7 @@ TEST(TM, ExDataAPPIDDictDenyActionDrop)
"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",
**************************************************************************************************************************/
long long ll_app_id=67;
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
EXPECT_NE(nullptr, dict);
EXPECT_EQ(67, dict->app_id);
EXPECT_STREQ("http", dict->app_name);
@@ -144,7 +144,7 @@ TEST(TM, ExDataAPPIDDictDenyActionRatelimit)
"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",
**************************************************************************************************************************/
long long ll_app_id=68;
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict=(struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
EXPECT_NE(nullptr, dict);
EXPECT_EQ(68, dict->app_id);
EXPECT_STREQ("https", dict->app_name);
@@ -369,7 +369,7 @@ TEST(TM, ExDataTunnelLabel)
"15560\t15560\tVLAN_ID\t1",
"15561\t15561\tVLAN_ID\t1"
**************************************************************************************************************************/
void *label_id = maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_TUNNEL_LABEL].id, "VLAN_ID");
void *label_id = maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_TUNNEL_LABEL].id, "VLAN_ID", strlen("VLAN_ID"));
EXPECT_EQ(0, (long long)label_id);
}
@@ -379,16 +379,32 @@ TEST(TM, ExDataSubscriberID)
table name: TSG_DYN_SUBSCRIBER_IP
id addr_type ip subscriber_id is_valid
"1299\t4\t192.168.56.28\ttest5628\t1",
"1300\t4\t192.168.56.28\ttest5627\t1"
"1300\t4\t192.168.56.27\ttest5627\t1",
"1301\t6\t1030::C9B4:FF12:48AA:1A2B\ttest5630\t1",
"1302\t6\t1030::C9B4:FF12:3799:1A2B\ttest5629\t1"
**************************************************************************************************************************/
struct subscribe_id_info *subscribe_id = (struct subscribe_id_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, "192.168.56.28");
EXPECT_STREQ("test5628", subscribe_id->subscribe_id);
struct streaminfo a_stream = {0};
a_stream.addr.addrtype = ADDR_TYPE_IPV4;
struct stream_tuple4_v4 tuple4_v4 = {0};
a_stream.addr.tuple4_v4 = &tuple4_v4;
inet_pton(AF_INET, "192.168.56.28", &tuple4_v4.daddr);
inet_pton(AF_INET, "192.168.56.27", &tuple4_v4.saddr);
struct subscribe_id_info *dest_subscribe_id = NULL;
struct subscribe_id_info *source_subscribe_id = NULL;
srt_attribute_set_subscriber_id(&a_stream, g_tsg_maat_feather, &source_subscribe_id, &dest_subscribe_id);
EXPECT_STREQ("test5628", dest_subscribe_id->subscribe_id);
EXPECT_STREQ("test5627", source_subscribe_id->subscribe_id);
subscribe_id = (struct subscribe_id_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, "192.168.56.27");
EXPECT_STREQ("test5627", subscribe_id->subscribe_id);
subscribe_id = (struct subscribe_id_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_SUBSCRIBER_IP2ID].id, "192.168.56.26");
EXPECT_EQ(NULL, subscribe_id);
a_stream.addr.addrtype = ADDR_TYPE_IPV6;
dest_subscribe_id = NULL;
source_subscribe_id = NULL;
struct stream_tuple4_v6 tuple4_v6 = {0};
a_stream.addr.tuple4_v6 = &tuple4_v6;
inet_pton(AF_INET6, "1030::C9B4:FF12:48AA:1A2B", &tuple4_v6.daddr);
inet_pton(AF_INET6, "1030::C9B4:FF12:3799:1A2B", &tuple4_v6.saddr);
srt_attribute_set_subscriber_id(&a_stream, g_tsg_maat_feather, &source_subscribe_id, &dest_subscribe_id);
EXPECT_STREQ("test5630", dest_subscribe_id->subscribe_id);
EXPECT_STREQ("test5629", source_subscribe_id->subscribe_id);
}
TEST(TM, ExDataDNSRecordsProfileA)
@@ -401,7 +417,7 @@ TEST(TM, ExDataDNSRecordsProfileA)
"7701\tTypeCNAME\tCNAME\t[{\"value\":\"www.facebook.com\",\"priority\":null},{\"value\":\"www.twitter.com\",\"priority\":null}]\t1"
**************************************************************************************************************************/
long long profile_id = 8119;
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(8119, profile_records->record_id);
EXPECT_EQ(1, profile_records->answer_type);
EXPECT_EQ(3, profile_records->record_num);
@@ -422,7 +438,7 @@ TEST(TM, ExDataDNSRecordsProfileA)
EXPECT_EQ(inet_addr("3.3.3.3"), profile_records->record_val[2].v4_addr.s_addr);
profile_id = 8110;
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(NULL, profile_records);
}
@@ -437,7 +453,7 @@ TEST(TM, ExDataDNSRecordsProfileAAAA)
**************************************************************************************************************************/
long long profile_id = 7961;
uint8_t u6_addr8[16] = {0};
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(7961, profile_records->record_id);
EXPECT_EQ(28, profile_records->answer_type);
EXPECT_EQ(2, profile_records->record_num);
@@ -455,7 +471,7 @@ TEST(TM, ExDataDNSRecordsProfileAAAA)
EXPECT_EQ(0, memcmp(u6_addr8, profile_records->record_val[1].v6_addr.__in6_u.__u6_addr8, 16));
profile_id = 8110;
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(NULL, profile_records);
}
@@ -469,7 +485,7 @@ TEST(TM, ExDataDNSRecordsProfileCNAME)
"7701\tTypeCNAME\tCNAME\t[{\"value\":\"www.facebook.com\",\"priority\":null},{\"value\":\"www.twitter.com\",\"priority\":null}]\t1"
**************************************************************************************************************************/
long long profile_id = 7701;
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
struct dns_profile_records *profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(7701, profile_records->record_id);
EXPECT_EQ(5, profile_records->answer_type);
EXPECT_EQ(2, profile_records->record_num);
@@ -485,7 +501,7 @@ TEST(TM, ExDataDNSRecordsProfileCNAME)
EXPECT_STREQ("www.twitter.com", profile_records->record_val[1].cname);
profile_id = 8110;
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
profile_records = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(NULL, profile_records);
}
@@ -498,21 +514,21 @@ TEST(TM, ExDataResponsePagesProfile)
"958\ttest-html-2\thtml\tforeign_files/TSG_PROFILE_RESPONSE_PAGES.2\t1"
**************************************************************************************************************************/
long long profile_id = 957;
struct http_response_pages *response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
struct http_response_pages *response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(957, response_pages->profile_id);
EXPECT_EQ(HTTP_RESPONSE_FORMAT_HTML, response_pages->format);
EXPECT_EQ(strlen("test1"), response_pages->content_len);
EXPECT_STREQ("test1", response_pages->content);
profile_id = 958;
response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(958, response_pages->profile_id);
EXPECT_EQ(HTTP_RESPONSE_FORMAT_HTML, response_pages->format);
EXPECT_EQ(strlen("test2"), response_pages->content_len);
EXPECT_STREQ("test2", response_pages->content);
profile_id = 959;
response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
response_pages = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
EXPECT_EQ(NULL, response_pages);
}
@@ -524,8 +540,8 @@ TEST(TM, ExDataTrafficMirrorProfile)
"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"
**************************************************************************************************************************/
long long profile_id = 845;
struct traffic_mirror_profile *mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id));
int profile_id = 845;
struct traffic_mirror_profile *mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id), sizeof(int));
EXPECT_EQ(845, mirror_profile->profile_id);
EXPECT_EQ(32, mirror_profile->vlan.num);
for (int i = 0; i < 32; i++)
@@ -534,13 +550,13 @@ TEST(TM, ExDataTrafficMirrorProfile)
}
profile_id = 123;
mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id));
mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id), sizeof(int));
EXPECT_EQ(123, mirror_profile->profile_id);
EXPECT_EQ(1, mirror_profile->vlan.num);
EXPECT_EQ(66, mirror_profile->vlan.id[0]);
profile_id = 124;
mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id));
mirror_profile = (struct traffic_mirror_profile *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_PROFILE_MIRROR].id, (const char *)&(profile_id), sizeof(long long));
EXPECT_EQ(NULL, mirror_profile);
}
@@ -563,14 +579,14 @@ TEST(TMAPI, GetUmtsUserInfoFromRedis)
"2\t111052899\t460045157053102\t861440152041083\tcmiott.wkctf.mcto60g.com\t8626070583008402\t1"
******************************************************************************************************/
long long teid = 111039813;
int teid = 111039813;
struct umts_user_info *user_info = (struct umts_user_info *)tsg_get_umts_user_info_form_redis(g_tsg_maat_feather, teid);
struct umts_user_info *user_info_right = (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid);
struct umts_user_info *user_info_right = (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid, sizeof(int));
EXPECT_EQ(user_info, user_info_right);
teid = 111052899;
user_info = (struct umts_user_info *)tsg_get_umts_user_info_form_redis(g_tsg_maat_feather, teid);
user_info_right = (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid);
user_info_right = (struct umts_user_info *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_GTP_IP2SIGNALING].id, (const char *)&teid, sizeof(int));
EXPECT_EQ(user_info, user_info_right);
user_info = NULL;
@@ -585,7 +601,7 @@ TEST(TMAPI, GetAppIdDictUnknown)
"4\tunknown\t0\tnull\tcategory\tsubcategory\ttechnology\trisk\tcharacteristics\tnull\tnull\tnull\t1\t3600\t3600\t1800\t1800\t1"
**************************************************************************************************************************/
long long ll_app_id = 4;
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
struct app_id_dict *dict = (struct app_id_dict *)matched_rule_cites_app_id_dict(g_tsg_maat_feather, ll_app_id);
EXPECT_EQ(dict_right, dict);
@@ -601,7 +617,7 @@ TEST(TMAPI, GetAppIdDictDenyActionDrop)
"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",
**************************************************************************************************************************/
long long ll_app_id = 67;
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
struct app_id_dict *dict = (struct app_id_dict *)matched_rule_cites_app_id_dict(g_tsg_maat_feather, ll_app_id);
EXPECT_EQ(dict_right, dict);
@@ -617,7 +633,7 @@ TEST(TMAPI, GetAppIdDictDenyActionRatelimit)
"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",
**************************************************************************************************************************/
long long ll_app_id = 68;
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id);
struct app_id_dict *dict_right = (struct app_id_dict *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_APP_ID_DICT].id, (const char *)&ll_app_id, sizeof(long long));
struct app_id_dict *dict = (struct app_id_dict *)matched_rule_cites_app_id_dict(g_tsg_maat_feather, ll_app_id);
EXPECT_EQ(dict_right, dict);
@@ -998,14 +1014,14 @@ TEST(TMAPI, GetDNSProfileRecord)
// void *matched_rule_cites_dns_profile_record(struct maat * feather, long long profile_id);
long long profile_id = 8119;
struct dns_profile_records *profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
struct dns_profile_records *profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
struct dns_profile_records *profile_records = (struct dns_profile_records *)matched_rule_cites_dns_profile_record(g_tsg_maat_feather, profile_id);
EXPECT_EQ(profile_records_right, profile_records);
profile_records = NULL;
profile_records_right = NULL;
profile_id = 7961;
profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
profile_records = (struct dns_profile_records *)matched_rule_cites_dns_profile_record(g_tsg_maat_feather, profile_id);
EXPECT_TRUE(profile_records_right);
EXPECT_EQ(profile_records_right, profile_records);
@@ -1013,7 +1029,7 @@ TEST(TMAPI, GetDNSProfileRecord)
profile_records = NULL;
profile_records_right = NULL;
profile_id = 7701;
profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id);
profile_records_right = (struct dns_profile_records *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_DNS_PROFILE_RECORD].id, (const char *)&profile_id, sizeof(long long));
profile_records = (struct dns_profile_records *)matched_rule_cites_dns_profile_record(g_tsg_maat_feather, profile_id);
EXPECT_TRUE(profile_records_right);
EXPECT_EQ(profile_records_right, profile_records);
@@ -1030,13 +1046,13 @@ TEST(TMAPI, GetHttpResponsePagesProfile)
// void *matched_rule_cites_http_response_pages(struct maat *feather, long long profile_id)
long long profile_id = 957;
struct http_response_pages *response_pages_right = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
struct http_response_pages *response_pages_right = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
struct http_response_pages *response_pages = (struct http_response_pages *)matched_rule_cites_http_response_pages(g_tsg_maat_feather, profile_id);
EXPECT_EQ(957, response_pages->profile_id);
EXPECT_EQ(response_pages_right, response_pages);
profile_id = 958;
response_pages_right = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id);
response_pages_right = (struct http_response_pages *)maat_plugin_table_get_ex_data(g_tsg_maat_feather, g_tsg_maat_rt_para.plugin_tb[MAAT_PLUGIN_RESPONSE_PAGES].id, (const char *)&profile_id, sizeof(long long));
response_pages = (struct http_response_pages *)matched_rule_cites_http_response_pages(g_tsg_maat_feather, profile_id);
EXPECT_EQ(958, response_pages->profile_id);
EXPECT_EQ(response_pages_right, response_pages);