summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-10-10 21:08:40 +0800
committerliuxueli <[email protected]>2023-10-10 21:08:40 +0800
commit78c6d801985f07a2093f1c1741ce26671963d1ac (patch)
tree0e7e0fed6ce022196d06e09f62b67c2653115488
parentafd47a860848c2609aa6d2dfc00796bd3a686e26 (diff)
支持ipport映射Subscriber ID和移动用户标识(IMSI/IMEI/APN/MSISDN)
-rw-r--r--bin/tsg_dynamic_mapping_maat.json4
-rw-r--r--inc/tsg_label.h12
-rw-r--r--src/tsg_bridge.cpp24
-rw-r--r--src/tsg_bridge.h2
-rw-r--r--src/tsg_proxy.cpp23
-rw-r--r--src/tsg_rule.cpp239
-rw-r--r--src/tsg_rule_internal.h3
-rw-r--r--src/tsg_send_log.cpp43
-rw-r--r--src/tsg_stat.cpp12
-rw-r--r--src/tsg_stat.h10
-rw-r--r--test/bin/gtest_dyn_mapping_maat.json8
-rw-r--r--test/src/gtest_bridge.cpp38
-rw-r--r--test/src/gtest_rule.cpp122
13 files changed, 457 insertions, 83 deletions
diff --git a/bin/tsg_dynamic_mapping_maat.json b/bin/tsg_dynamic_mapping_maat.json
index eead3e1..407b00e 100644
--- a/bin/tsg_dynamic_mapping_maat.json
+++ b/bin/tsg_dynamic_mapping_maat.json
@@ -4,8 +4,8 @@
{
"table_name": "TSG_DYN_IPPORT_SUBSCRIBER_MAPPING",
"table_content": [
- "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
- "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1"
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1\t{\"imei\":\"1298473129873912\",\"imsi\":\"231\",\"apn\":\"ufone.pin\"}",
+ "1037\t4\t192.168.50.37\ttest37\t40001\t40255\tnull\t1"
]
}
]
diff --git a/inc/tsg_label.h b/inc/tsg_label.h
index 47fc406..6dee044 100644
--- a/inc/tsg_label.h
+++ b/inc/tsg_label.h
@@ -68,6 +68,16 @@ struct umts_user_info
char *msisdn; //MSISDN: phone number
};
+struct dynamic_ipport_mapping
+{
+ int ref_cnt;
+ char *apn;
+ char *imsi;
+ char *imei;
+ char *msisdn; //MSISDN: phone number
+ char *subscriber_id;
+};
+
struct tunnel_catalog
{
int id;
@@ -169,6 +179,8 @@ const struct asn_info *srt_attribute_get_client_ip_asn(const struct session_runt
const struct asn_info *srt_attribute_get_server_ip_asn(const struct session_runtime_attribute *srt_attribute);
const struct location_info *srt_attribute_get_client_ip_location(const struct session_runtime_attribute *srt_attribute);
const struct location_info *srt_attribute_get_server_ip_location(const struct session_runtime_attribute *srt_attribute);
+const struct dynamic_ipport_mapping *srt_attribute_get_client_ipport_mapping(const struct session_runtime_attribute *srt_attribute);
+const struct dynamic_ipport_mapping *srt_attribute_get_server_ipport_mapping(const struct session_runtime_attribute *srt_attribute);
size_t srt_attribute_get_category_ids(const struct session_runtime_attribute *srt_attribute, unsigned int *category_ids, size_t n_category_ids);
int srt_attribute_set_category_ids(const struct streaminfo *a_stream, unsigned int *category_ids, int n_category_ids);
diff --git a/src/tsg_bridge.cpp b/src/tsg_bridge.cpp
index cd6b59e..517b97b 100644
--- a/src/tsg_bridge.cpp
+++ b/src/tsg_bridge.cpp
@@ -223,6 +223,9 @@ void session_runtime_attribute_free(const struct streaminfo *a_stream, int bridg
plugin_ex_data_tunnel_endpoint_free(srt_attribute->client_endpoint);
plugin_ex_data_tunnel_endpoint_free(srt_attribute->server_endpoint);
+ plugin_ex_data_dynamic_ipport_mapping_free(srt_attribute->client_mapping);
+ plugin_ex_data_dynamic_ipport_mapping_free(srt_attribute->server_mapping);
+
if(srt_attribute->ja3_fingerprint!=NULL)
{
dictator_free(a_stream->threadnum, (void *)srt_attribute->ja3_fingerprint);
@@ -468,6 +471,7 @@ const char *srt_attribute_get_client_subscriber_id(const struct session_runtime_
return NULL;
}
+
const char *srt_attribute_get_server_subscriber_id(const struct session_runtime_attribute *srt_attribute)
{
if(srt_attribute!=NULL && srt_attribute->server_subscribe_id!=NULL)
@@ -478,6 +482,26 @@ const char *srt_attribute_get_server_subscriber_id(const struct session_runtime_
return NULL;
}
+const struct dynamic_ipport_mapping *srt_attribute_get_client_ipport_mapping(const struct session_runtime_attribute *srt_attribute)
+{
+ if(srt_attribute)
+ {
+ return (const struct dynamic_ipport_mapping *)(srt_attribute->client_mapping);
+ }
+
+ return NULL;
+}
+
+const struct dynamic_ipport_mapping *srt_attribute_get_server_ipport_mapping(const struct session_runtime_attribute *srt_attribute)
+{
+ if(srt_attribute)
+ {
+ return (const struct dynamic_ipport_mapping *)(srt_attribute->server_mapping);
+ }
+
+ return NULL;
+}
+
const struct asn_info *srt_attribute_get_client_ip_asn(const struct session_runtime_attribute *srt_attribute)
{
if(srt_attribute)
diff --git a/src/tsg_bridge.h b/src/tsg_bridge.h
index c5c63ef..6ec15fe 100644
--- a/src/tsg_bridge.h
+++ b/src/tsg_bridge.h
@@ -152,6 +152,8 @@ struct session_runtime_attribute
struct location_info *server_location;
struct subscribe_id_info *client_subscribe_id;
struct subscribe_id_info *server_subscribe_id;
+ struct dynamic_ipport_mapping *client_mapping;
+ struct dynamic_ipport_mapping *server_mapping;
const char *ja3_fingerprint;
unsigned int fqdn_category_ids[MAX_CATEGORY_ID_NUM];
struct umts_user_info *user_info;
diff --git a/src/tsg_proxy.cpp b/src/tsg_proxy.cpp
index 641a8d8..3c29b2a 100644
--- a/src/tsg_proxy.cpp
+++ b/src/tsg_proxy.cpp
@@ -371,12 +371,31 @@ static void tsg_proxy_cmsg_subscriber_fill(struct session_runtime_attribute *ses
{
const char *client_subscribe_id = srt_attribute_get_client_subscriber_id(session_attr);
const char *server_subscribe_id = srt_attribute_get_server_subscriber_id(session_attr);
- if (client_subscribe_id) {
+ if (client_subscribe_id)
+ {
cmsg->src_sub_id = (char *)client_subscribe_id;
}
- if (server_subscribe_id) {
+ else
+ {
+ const struct dynamic_ipport_mapping *client_mapping = srt_attribute_get_client_ipport_mapping(session_attr);
+ if(client_mapping && client_mapping->subscriber_id)
+ {
+ cmsg->src_sub_id = (char *)client_mapping->subscriber_id;
+ }
+ }
+
+ if (server_subscribe_id)
+ {
cmsg->dst_sub_id = (char *)server_subscribe_id;
}
+ else
+ {
+ const struct dynamic_ipport_mapping *server_mapping = srt_attribute_get_server_ipport_mapping(session_attr);
+ if(server_mapping && server_mapping->subscriber_id)
+ {
+ cmsg->dst_sub_id = (char *)server_mapping->subscriber_id;
+ }
+ }
return;
}
diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp
index 5d330a1..ff7abd7 100644
--- a/src/tsg_rule.cpp
+++ b/src/tsg_rule.cpp
@@ -449,30 +449,66 @@ void ex_data_gtp_c_new(const char *table_name, int table_id, const char* key, co
__sync_add_and_fetch(&user_info->ref_cnt, 1);
*ad=(void *)user_info;
- tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC, 1);
+ if(user_info->apn!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC_APN, 1);
+ }
+
+ if(user_info->imei!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC_IMEI, 1);
+ }
+
+ if(user_info->imsi!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC_IMSI, 1);
+ }
+
+ if(user_info->msisdn!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_GTPC_MSISDN, 1);
+ }
+
return;
}
void ex_data_gtp_c_free(int table_id, void **ad, long argl, void* argp)
{
- if(*ad!=NULL)
+ if(*ad==NULL)
{
- struct umts_user_info *user_info=(struct umts_user_info *)(*ad);
- if((__sync_sub_and_fetch(&user_info->ref_cnt, 1) == 0))
+ return ;
+ }
+
+ struct umts_user_info *user_info=(struct umts_user_info *)(*ad);
+ if((__sync_sub_and_fetch(&user_info->ref_cnt, 1) == 0))
+ {
+ if(user_info->apn!=NULL)
{
- tsg_free_field(user_info->imsi);
- tsg_free_field(user_info->msisdn);
tsg_free_field(user_info->apn);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_GTPC_APN, 1);
+ }
+
+ if(user_info->imei!=NULL)
+ {
tsg_free_field(user_info->imei);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_GTPC_IMEI, 1);
+ }
- tsg_free_field((char *)(*ad));
- *ad=NULL;
-
- tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_GTPC, 1);
+ if(user_info->imsi!=NULL)
+ {
+ tsg_free_field(user_info->imsi);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_GTPC_IMSI, 1);
}
+
+ if(user_info->msisdn!=NULL)
+ {
+ tsg_free_field(user_info->msisdn);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_GTPC_MSISDN, 1);
+ }
+
+ tsg_free_field((char *)(*ad));
+ *ad=NULL;
}
-
- return;
}
void plugin_ex_data_gtp_c_free(struct umts_user_info *user_info)
@@ -711,6 +747,130 @@ void plugin_ex_data_subscriber_id_free(struct subscribe_id_info *subscriber)
ex_data_subscriber_id_free(-1, (void **)&subscriber, 0, NULL);
}
+void ex_data_dynamic_ipport_mapping_dup(int table_id, void **to, void **from, long argl, void* argp)
+{
+ if((*from)!=NULL)
+ {
+ struct dynamic_ipport_mapping *ipport_mapping=(struct dynamic_ipport_mapping *)(*from);
+ __sync_add_and_fetch(&ipport_mapping->ref_cnt, 1);
+ *to=*from;
+ }
+
+ return;
+}
+void ipport_mapping_mobile_identify_parse(struct dynamic_ipport_mapping *ipport_mapping, char *mobile_identify)
+{
+ cJSON *object=cJSON_Parse(mobile_identify);
+ if(object==NULL)
+ {
+ return;
+ }
+
+ get_string_from_json(object, "imei", &(ipport_mapping->imei));
+ get_string_from_json(object, "imsi", &(ipport_mapping->imsi));
+ get_string_from_json(object, "phone_numer", &(ipport_mapping->msisdn));
+ get_string_from_json(object, "apn", &(ipport_mapping->apn));
+
+ cJSON_Delete(object);
+ object=NULL;
+}
+
+void ex_data_dynamic_ipport_mapping_new(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp)
+{
+ int subscriber_idx=4;
+ int mobile_identify_idx=8;
+ struct dynamic_ipport_mapping *ipport_mapping=(struct dynamic_ipport_mapping *)calloc(1, sizeof(struct dynamic_ipport_mapping));
+ ipport_mapping->subscriber_id=column_string_get_value(table_line, subscriber_idx);
+ char *mobile_identify=column_string_get_value(table_line, mobile_identify_idx);
+ if(mobile_identify!=NULL)
+ {
+ ipport_mapping_mobile_identify_parse(ipport_mapping, mobile_identify);
+ tsg_free_field(mobile_identify);
+ }
+
+ __sync_add_and_fetch(&ipport_mapping->ref_cnt, 1);
+ *ad=(void *)ipport_mapping;
+
+ if(ipport_mapping->subscriber_id!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_SUBSCRIBER, 1);
+ }
+
+ if(ipport_mapping->apn!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_APN, 1);
+ }
+
+ if(ipport_mapping->imei!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMEI, 1);
+ }
+
+ if(ipport_mapping->imsi!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMSI, 1);
+ }
+
+ if(ipport_mapping->msisdn!=NULL)
+ {
+ tsg_stat_sync_exdata_add_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_MSISDN, 1);
+ }
+
+ return;
+}
+
+void ex_data_dynamic_ipport_mapping_free(int table_id, void **ad, long argl, void* argp)
+{
+ if((*ad)==NULL)
+ {
+ return ;
+ }
+
+ struct dynamic_ipport_mapping *ipport_mapping=(struct dynamic_ipport_mapping *)(*ad);
+ if((__sync_sub_and_fetch(&ipport_mapping->ref_cnt, 1) == 0))
+ {
+ if(ipport_mapping->subscriber_id!=NULL)
+ {
+ tsg_free_field(ipport_mapping->subscriber_id);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_SUBSCRIBER, 1);
+ }
+
+ if(ipport_mapping->apn!=NULL)
+ {
+ tsg_free_field(ipport_mapping->apn);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_APN, 1);
+ }
+
+ if(ipport_mapping->imei!=NULL)
+ {
+ tsg_free_field(ipport_mapping->imei);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMEI, 1);
+ }
+
+ if(ipport_mapping->imsi!=NULL)
+ {
+ tsg_free_field(ipport_mapping->imsi);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMSI, 1);
+ }
+
+ if(ipport_mapping->msisdn!=NULL)
+ {
+ tsg_free_field(ipport_mapping->msisdn);
+ tsg_stat_sync_exdata_del_update(SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_MSISDN, 1);
+ }
+
+ tsg_free_field((char *)(*ad));
+ *ad=NULL;
+ }
+
+ return;
+}
+
+void plugin_ex_data_dynamic_ipport_mapping_free(struct dynamic_ipport_mapping *ipport_mapping)
+{
+ ex_data_dynamic_ipport_mapping_free(-1, (void **)&ipport_mapping, 0, NULL);
+}
+
static int parse_security_deny_action(char *deny_action_str, struct deny_user_region *deny_app_para)
{
if(deny_action_str==NULL)
@@ -1874,9 +2034,9 @@ int init_dynamic_mapping_plugin_table(struct maat *feather, const char *conffile
}
int ret=maat_plugin_table_ex_schema_register(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.name,
- ex_data_subscriber_id_new,
- ex_data_subscriber_id_free,
- ex_data_subscriber_id_dup,
+ ex_data_dynamic_ipport_mapping_new,
+ ex_data_dynamic_ipport_mapping_free,
+ ex_data_dynamic_ipport_mapping_dup,
0,
NULL
);
@@ -2256,7 +2416,7 @@ int srt_attribute_set_subscriber_id(const struct streaminfo *a_stream, struct ma
return 0;
}
-int srt_attribute_set_dyn_mapping_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **source_subscribe_id, struct subscribe_id_info **dest_subscribe_id)
+int srt_attribute_set_dynamic_ipport_mapping(const struct streaminfo *a_stream, struct maat *feather, struct dynamic_ipport_mapping **source_mapping, struct dynamic_ipport_mapping **dest_mapping)
{
struct ip_addr dest_ip={0}, source_ip={0};
int ret=ip_address_convert(a_stream, &source_ip, &dest_ip);
@@ -2280,14 +2440,14 @@ int srt_attribute_set_dyn_mapping_subscriber_id(const struct streaminfo *a_strea
return 0;
}
- if(*dest_subscribe_id==NULL)
+ if(*dest_mapping==NULL)
{
- maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &dest_ip, dest_port, (void **)dest_subscribe_id, 1);
+ maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &dest_ip, dest_port, (void **)dest_mapping, 1);
}
- if(*source_subscribe_id==NULL)
+ if(*source_mapping==NULL)
{
- maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &source_ip, source_port, (void **)source_subscribe_id, 1);
+ maat_ipport_plugin_table_get_ex_data(feather, g_tsg_maat_rt_para.plugin_dyn_mapping_tb.id, &source_ip, source_port, (void **)source_mapping, 1);
}
return 0;
@@ -2682,14 +2842,14 @@ size_t tsg_scan_tunnel_id(const struct streaminfo *a_stream, struct maat *feathe
return matched_cnt;
}
-size_t tsg_scan_subscribe_id_policy(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info *user_info, struct maat_state *s_mid, struct maat_rule *matched_rules, size_t n_matched_rules)
+size_t tsg_scan_subscriber_id_policy(const struct streaminfo *a_stream, struct maat *feather, char *subscriber_id, struct maat_state *s_mid, struct maat_rule *matched_rules, size_t n_matched_rules)
{
- if(user_info==NULL || user_info->subscribe_id==NULL || matched_rules==NULL || n_matched_rules==0)
+ if(subscriber_id==NULL || matched_rules==NULL || n_matched_rules==0)
{
return 0;
}
- return tsg_scan_string(a_stream, feather, user_info->subscribe_id, strlen(user_info->subscribe_id), MAAT_SCAN_SUBSCRIBER_ID, s_mid, matched_rules, n_matched_rules);
+ return tsg_scan_string(a_stream, feather, subscriber_id, strlen(subscriber_id), MAAT_SCAN_SUBSCRIBER_ID, s_mid, matched_rules, n_matched_rules);
}
size_t tsg_scan_gtp_apn_policy(const struct streaminfo *a_stream, struct maat *feather, char *apn, struct maat_state *s_mid,struct maat_rule *matched_rules, size_t n_matched_rules)
@@ -2722,6 +2882,22 @@ size_t tsg_scan_gtp_phone_number_policy(const struct streaminfo *a_stream, struc
return tsg_scan_string(a_stream, feather, phone_number, strlen(phone_number), MAAT_SCAN_GTP_PHONE_NUMBER, s_mid, matched_rules, n_matched_rules);
}
+size_t tsg_scan_dynamic_ipport_mapping_policy(const struct streaminfo *a_stream, struct maat *feather, struct dynamic_ipport_mapping *ipport_mapping, struct maat_state *s_mid, struct maat_rule *matched_rules, size_t n_matched_rules)
+{
+ if(ipport_mapping==NULL || matched_rules==NULL || n_matched_rules==0)
+ {
+ return 0;
+ }
+
+ size_t matched_cnt=0;
+ matched_cnt+=tsg_scan_subscriber_id_policy(a_stream, feather, ipport_mapping->subscriber_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ matched_cnt+=tsg_scan_gtp_apn_policy(a_stream, feather, ipport_mapping->apn, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ matched_cnt+=tsg_scan_gtp_imsi_policy(a_stream, feather, ipport_mapping->imsi, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ matched_cnt+=tsg_scan_gtp_phone_number_policy(a_stream, feather, ipport_mapping->msisdn, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+
+ return matched_cnt;
+}
+
//return value: -1: failed, 0: not hit, >0: hit count
size_t tsg_scan_shared_policy(const struct streaminfo *a_stream, struct maat *feather, char *domain, int idx, struct maat_state *s_mid, struct maat_rule *matched_rules, size_t n_matched_rules)
{
@@ -2961,15 +3137,22 @@ size_t tsg_scan_nesting_addr(const struct streaminfo *a_stream, struct maat *fea
if(matched_cnt<n_matched_rules)
{
srt_attribute_set_subscriber_id(a_stream, feather, &srt_attribute->client_subscribe_id, &srt_attribute->server_subscribe_id);
- matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->client_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
- matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->server_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ if(srt_attribute->client_subscribe_id!=NULL)
+ {
+ matched_cnt+=tsg_scan_subscriber_id_policy(a_stream, feather, srt_attribute->client_subscribe_id->subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ }
+
+ if(srt_attribute->server_subscribe_id!=NULL)
+ {
+ matched_cnt+=tsg_scan_subscriber_id_policy(a_stream, feather, srt_attribute->server_subscribe_id->subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ }
}
if(matched_cnt<n_matched_rules && g_tsg_maat_rt_para.dynamic_mapping_maat_switch==1)
{
- srt_attribute_set_dyn_mapping_subscriber_id(a_stream, g_tsg_dyn_mapping_maat_feather, &srt_attribute->client_subscribe_id, &srt_attribute->server_subscribe_id);
- matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->client_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
- matched_cnt+=tsg_scan_subscribe_id_policy(a_stream, feather, srt_attribute->server_subscribe_id, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ srt_attribute_set_dynamic_ipport_mapping(a_stream, g_tsg_dyn_mapping_maat_feather, &srt_attribute->client_mapping, &srt_attribute->server_mapping);
+ matched_cnt+=tsg_scan_dynamic_ipport_mapping_policy(a_stream, feather, srt_attribute->client_mapping, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
+ matched_cnt+=tsg_scan_dynamic_ipport_mapping_policy(a_stream, feather, srt_attribute->server_mapping, s_mid, matched_rules+matched_cnt, n_matched_rules-matched_cnt);
}
if(matched_cnt<n_matched_rules)
diff --git a/src/tsg_rule_internal.h b/src/tsg_rule_internal.h
index 8fd2926..e9fbbf7 100644
--- a/src/tsg_rule_internal.h
+++ b/src/tsg_rule_internal.h
@@ -136,12 +136,13 @@ void plugin_ex_data_http_response_pages_free(struct http_response_pages *respons
void plugin_ex_data_app_id_dict_free(struct app_id_dict * dict);
void plugin_ex_data_security_compile_free(struct maat_compile *maat_compile);
void plugin_ex_data_dns_profile_record_free(struct dns_profile_records * records);
+void plugin_ex_data_dynamic_ipport_mapping_free(struct dynamic_ipport_mapping *mapping);
void tsg_maat_state_free(struct maat_state *state);
int srt_attribute_set_ip_asn(const struct streaminfo *a_stream, struct maat *feather, struct asn_info **client_asn, struct asn_info **server_asn);
int srt_attribute_set_ip_location(const struct streaminfo *a_stream, struct maat *feather, struct location_info **client_location, struct location_info **server_location);
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 srt_attribute_set_dyn_mapping_subscriber_id(const struct streaminfo *a_stream, struct maat *feather, struct subscribe_id_info **source_subscribe_id, struct subscribe_id_info **dest_subscribe_id);
+int srt_attribute_set_dynamic_ipport_mapping(const struct streaminfo *a_stream, struct maat *feather, struct dynamic_ipport_mapping **source_mapping, struct dynamic_ipport_mapping **dest_mapping);
int session_runtine_attribute_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info);
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index c676f37..b5efcb7 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -505,6 +505,41 @@ static int set_umts_user_info(struct tsg_log_instance_t *_instance, struct TLD_h
return 1;
}
+static int set_dynamic_ipport_mapping(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct dynamic_ipport_mapping *ipport_mapping)
+{
+ if(ipport_mapping==NULL)
+ {
+ return 0;
+ }
+
+ if(ipport_mapping->subscriber_id!=NULL)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_SUBSCRIBER_ID].name, (void *)ipport_mapping->subscriber_id, TLD_TYPE_STRING);
+ }
+
+ if(ipport_mapping->apn!=NULL)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_GTP_APN].name, (void *)ipport_mapping->apn, TLD_TYPE_STRING);
+ }
+
+ if(ipport_mapping->imsi!=NULL)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_GTP_IMSI].name, (void *)ipport_mapping->imsi, TLD_TYPE_STRING);
+ }
+
+ if(ipport_mapping->imei!=NULL)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_GTP_IMEI].name, (void *)ipport_mapping->imei, TLD_TYPE_STRING);
+ }
+
+ if(ipport_mapping->msisdn!=NULL)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_GTP_MSISDN].name, (void *)ipport_mapping->msisdn, TLD_TYPE_STRING); //phone number
+ }
+
+ return 1;
+}
+
static int set_packet_bytes(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream)
{
struct tcp_flow_stat *tflow_project=NULL;
@@ -1699,6 +1734,12 @@ int set_session_attributes(struct tsg_log_instance_t *_instance, struct TLD_hand
set_umts_user_info(_instance, _handle, a_stream, srt_attribute->user_info);
+ ret=set_dynamic_ipport_mapping(_instance, _handle, srt_attribute->client_mapping);
+ if(ret==0)
+ {
+ set_dynamic_ipport_mapping(_instance, _handle, srt_attribute->server_mapping);
+ }
+
if(srt_attribute->client_endpoint!=NULL)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_TUNNELS_ENDPOINT_A_DESC].name, (void *)srt_attribute->client_endpoint->description, TLD_TYPE_STRING);
@@ -1709,6 +1750,8 @@ int set_session_attributes(struct tsg_log_instance_t *_instance, struct TLD_hand
TLD_append(_handle, _instance->id2field[LOG_COMMON_TUNNELS_ENDPOINT_B_DESC].name, (void *)srt_attribute->server_endpoint->description, TLD_TYPE_STRING);
}
+
+
return 1;
}
diff --git a/src/tsg_stat.cpp b/src/tsg_stat.cpp
index b39f64a..cc9022c 100644
--- a/src/tsg_stat.cpp
+++ b/src/tsg_stat.cpp
@@ -302,7 +302,10 @@ int tsg_stat_init(void)
const char *exdata_column_name[OP_EXDATA_MAX]={"add", "del"};
g_rt_stat_para.exdata.table_id=fieldstat_register_table(g_rt_stat_para.fs_instance, "sync_exdata", exdata_column_name, exdata_column_type, OP_EXDATA_MAX);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "asn", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_ASN]);
- fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "gtpc", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_GTPC]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "gtpc_imsi", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_GTPC_IMSI]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "gtpc_imei", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_GTPC_IMEI]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "gtpc_apn", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_GTPC_APN]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "gtpc_msisdn", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_GTPC_MSISDN]);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "location", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_LOCATION]);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "fqdn_category", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_FQDN_CATEGORY]);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "subscriber", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_SUBSCRIBER]);
@@ -313,7 +316,12 @@ int tsg_stat_init(void)
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "tunnel_catalog", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_TUNNEL_CATALOG]);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "tunnel_endpoint", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_TUNNEL_ENDPOINT]);
fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "tunnel_label", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_TUNNEL_LABEL]);
-
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "dyn_mapping_subscriber", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_IPPORT_MAPPING_SUBSCRIBER]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "dyn_mapping_gtpc_imsi", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMSI]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "dyn_mapping_gtpc_imei", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMEI]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "dyn_mapping_gtpc_apn", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_APN]);
+ fieldstat_register_table_row(g_rt_stat_para.fs_instance, g_rt_stat_para.exdata.table_id, "dyn_mapping_gtpc_msisdn", NULL, 0, g_rt_stat_para.exdata.column_id[SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_MSISDN]);
+
enum field_type flow_column_type[FLOW_STAT_MAX]={FIELD_TYPE_GAUGE, FIELD_TYPE_GAUGE, FIELD_TYPE_GAUGE, FIELD_TYPE_GAUGE, FIELD_TYPE_GAUGE};
const char *flow_column_name[FLOW_STAT_MAX]={"inject", "mirror_pkts", "mirror_bytes", "set_timeout", "tamper"};
g_rt_stat_para.flow.table_id=fieldstat_register_table(g_rt_stat_para.fs_instance, "flow", flow_column_name, flow_column_type, FLOW_STAT_MAX);
diff --git a/src/tsg_stat.h b/src/tsg_stat.h
index 640dc35..5d3740b 100644
--- a/src/tsg_stat.h
+++ b/src/tsg_stat.h
@@ -33,7 +33,10 @@ enum SYNC_APP
enum SYNC_EXDATA_ROW
{
SYNC_EXDATA_ROW_ASN=0,
- SYNC_EXDATA_ROW_GTPC,
+ SYNC_EXDATA_ROW_GTPC_IMSI,
+ SYNC_EXDATA_ROW_GTPC_IMEI,
+ SYNC_EXDATA_ROW_GTPC_APN,
+ SYNC_EXDATA_ROW_GTPC_MSISDN,
SYNC_EXDATA_ROW_LOCATION,
SYNC_EXDATA_ROW_FQDN_CATEGORY,
SYNC_EXDATA_ROW_SUBSCRIBER,
@@ -45,6 +48,11 @@ enum SYNC_EXDATA_ROW
SYNC_EXDATA_ROW_TUNNEL_CATALOG,
SYNC_EXDATA_ROW_TUNNEL_ENDPOINT,
SYNC_EXDATA_ROW_TUNNEL_LABEL,
+ SYNC_EXDATA_ROW_IPPORT_MAPPING_SUBSCRIBER,
+ SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMSI,
+ SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_IMEI,
+ SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_APN,
+ SYNC_EXDATA_ROW_IPPORT_MAPPING_GTPC_MSISDN,
SYNC_EXDATA_ROW_MAX
};
diff --git a/test/bin/gtest_dyn_mapping_maat.json b/test/bin/gtest_dyn_mapping_maat.json
index 91157e2..454b53f 100644
--- a/test/bin/gtest_dyn_mapping_maat.json
+++ b/test/bin/gtest_dyn_mapping_maat.json
@@ -4,10 +4,10 @@
{
"table_name": "TSG_DYN_IPPORT_SUBSCRIBER_MAPPING",
"table_content": [
- "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
- "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1",
- "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1",
- "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1"
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1\tnull",
+ "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1\t{\"imei\":\"1298473129873912\",\"apn\":\"test.com\"}",
+ "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1\t{\"imei\":\"1298473129873912\",\"imsi\":\"231\"}",
+ "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1\t{\"imei\":\"1298473129873912\",\"imsi\":\"231\",\"phone_numer\":\"123456789\"}"
]
}
]
diff --git a/test/src/gtest_bridge.cpp b/test/src/gtest_bridge.cpp
index 21579f6..27bd67e 100644
--- a/test/src/gtest_bridge.cpp
+++ b/test/src/gtest_bridge.cpp
@@ -59,6 +59,44 @@ void plugin_ex_data_subscriber_id_free(struct subscribe_id_info *subscriber)
}
}
+void plugin_ex_data_dynamic_ipport_mapping_free(struct dynamic_ipport_mapping *ipport_mapping)
+{
+ if(ipport_mapping==NULL)
+ {
+ return ;
+ }
+
+ if(ipport_mapping->subscriber_id!=NULL)
+ {
+ free(ipport_mapping->subscriber_id);
+ ipport_mapping->subscriber_id=NULL;
+ }
+
+ if(ipport_mapping->apn!=NULL)
+ {
+ free(ipport_mapping->apn);
+ ipport_mapping->apn=NULL;
+ }
+
+ if(ipport_mapping->imsi!=NULL)
+ {
+ free(ipport_mapping->imsi);
+ ipport_mapping->imsi=NULL;
+ }
+
+ if(ipport_mapping->imei!=NULL)
+ {
+ free(ipport_mapping->imei);
+ ipport_mapping->imei=NULL;
+ }
+
+ if(ipport_mapping->msisdn!=NULL)
+ {
+ free(ipport_mapping->msisdn);
+ ipport_mapping->msisdn=NULL;
+ }
+}
+
void plugin_ex_data_tunnel_endpoint_free(struct tunnel_endpoint *t_enpoint)
{
if (t_enpoint != NULL)
diff --git a/test/src/gtest_rule.cpp b/test/src/gtest_rule.cpp
index cf392ff..88a09d6 100644
--- a/test/src/gtest_rule.cpp
+++ b/test/src/gtest_rule.cpp
@@ -404,15 +404,15 @@ TEST(TM, ExDataDynamicIPPortMappingSubscriberID)
{
/*************************************************************************************************************************
table name: TSG_DYN_IPPORT_SUBSCRIBER_MAPPING
- id addr_type ip subscriber_id port_start port_end is_valid
- "1052\t4\t192.168.50.52\ttest52\t0\t255\t1",
- "1037\t4\t192.168.50.37\test37\t40001\t40255\t1",
- "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1",
- "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1"
+ id addr_type ip subscriber_id port_start port_end is_valid mobile_identify
+ "1052\t4\t192.168.50.52\ttest52\t0\t255\t1\tnull",
+ "1037\t4\t192.168.50.37\ttest37\t40001\t40255\t1\t{\"imei\":\"1298473129873912\",\"apn\":\"test.com\"}",
+ "1040\t6\t1030::C9B4:FF12:48AA:1040\ttest1040\t10240\t12800\t1\t{\"imei\":\"1298473129873912\",\"imsi\":\"231\"}",
+ "1041\t6\t1030::C9B4:FF12:3799:1041\ttest1041\t25600\t25856\t1\t{\"imei\":\"1298473129873912\",\"imsi\":\"231\",\"phone_numer\":\"123456789\"}"
**************************************************************************************************************************/
struct streaminfo a_stream = {0};
- struct subscribe_id_info *dest_subscribe_id = NULL;
- struct subscribe_id_info *source_subscribe_id = NULL;
+ struct dynamic_ipport_mapping *dest_mapping = NULL;
+ struct dynamic_ipport_mapping *source_mapping = NULL;
// ipv4
a_stream.addr.addrtype = ADDR_TYPE_IPV4;
struct stream_tuple4_v4 tuple4_v4 = {0};
@@ -422,31 +422,49 @@ TEST(TM, ExDataDynamicIPPortMappingSubscriberID)
tuple4_v4.dest = htons(255); //port end
tuple4_v4.source = htons(40001); //port start
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_STREQ("test52", dest_subscribe_id->subscribe_id);
- EXPECT_STREQ("test37", source_subscribe_id->subscribe_id);
-
- plugin_ex_data_subscriber_id_free(dest_subscribe_id);
- plugin_ex_data_subscriber_id_free(source_subscribe_id);
- dest_subscribe_id = NULL;
- source_subscribe_id = NULL;
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_STREQ("test52", dest_mapping->subscriber_id);
+ EXPECT_EQ(nullptr, dest_mapping->imsi);
+ EXPECT_EQ(nullptr, dest_mapping->imei);
+ EXPECT_EQ(nullptr, dest_mapping->msisdn);
+ EXPECT_EQ(nullptr, dest_mapping->apn);
+
+ EXPECT_STREQ("test37", source_mapping->subscriber_id);
+ EXPECT_STREQ("1298473129873912", source_mapping->imei);
+ EXPECT_EQ(nullptr, source_mapping->imsi);
+ EXPECT_EQ(nullptr, source_mapping->msisdn);
+ EXPECT_STREQ("test.com", source_mapping->apn);
+
+ plugin_ex_data_dynamic_ipport_mapping_free(dest_mapping);
+ plugin_ex_data_dynamic_ipport_mapping_free(source_mapping);
+ dest_mapping = NULL;
+ source_mapping = NULL;
tuple4_v4.dest = htons(250); //port in range
tuple4_v4.source = htons(40025); //port in range
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_STREQ("test52", dest_subscribe_id->subscribe_id);
- EXPECT_STREQ("test37", source_subscribe_id->subscribe_id);
-
- plugin_ex_data_subscriber_id_free(dest_subscribe_id);
- plugin_ex_data_subscriber_id_free(source_subscribe_id);
- dest_subscribe_id = NULL;
- source_subscribe_id = NULL;
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_STREQ("test52", dest_mapping->subscriber_id);
+ EXPECT_EQ(nullptr, dest_mapping->imsi);
+ EXPECT_EQ(nullptr, dest_mapping->imei);
+ EXPECT_EQ(nullptr, dest_mapping->msisdn);
+ EXPECT_EQ(nullptr, dest_mapping->apn);
+
+ EXPECT_STREQ("test37", source_mapping->subscriber_id);
+ EXPECT_STREQ("1298473129873912", source_mapping->imei);
+ EXPECT_EQ(nullptr, source_mapping->imsi);
+ EXPECT_EQ(nullptr, source_mapping->msisdn);
+ EXPECT_STREQ("test.com", source_mapping->apn);
+
+ plugin_ex_data_dynamic_ipport_mapping_free(dest_mapping);
+ plugin_ex_data_dynamic_ipport_mapping_free(source_mapping);
+ dest_mapping = NULL;
+ source_mapping = NULL;
tuple4_v4.dest = htons(256); //port not in range
tuple4_v4.source = htons(40000); //port not in range
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_EQ(nullptr, dest_subscribe_id);
- EXPECT_EQ(nullptr, source_subscribe_id);
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_EQ(nullptr, dest_mapping);
+ EXPECT_EQ(nullptr, source_mapping);
// ipv6
a_stream.addr.addrtype = ADDR_TYPE_IPV6;
@@ -456,31 +474,49 @@ TEST(TM, ExDataDynamicIPPortMappingSubscriberID)
inet_pton(AF_INET6, "1030::C9B4:FF12:3799:1041", tuple4_v6.saddr);
tuple4_v6.dest = htons(12800); //port end
tuple4_v6.source = htons(25600); //port start
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_STREQ("test1040", dest_subscribe_id->subscribe_id);
- EXPECT_STREQ("test1041", source_subscribe_id->subscribe_id);
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_STREQ("test1040", dest_mapping->subscriber_id);
+ EXPECT_STREQ("231", dest_mapping->imsi);
+ EXPECT_STREQ("1298473129873912", dest_mapping->imei);
+ EXPECT_EQ(nullptr, dest_mapping->msisdn);
+ EXPECT_EQ(nullptr, dest_mapping->apn);
+
+ EXPECT_STREQ("test1041", source_mapping->subscriber_id);
+ EXPECT_STREQ("1298473129873912", source_mapping->imei);
+ EXPECT_STREQ("231", source_mapping->imsi);
+ EXPECT_STREQ("123456789", source_mapping->msisdn);
+ EXPECT_EQ(nullptr, source_mapping->apn);
- plugin_ex_data_subscriber_id_free(dest_subscribe_id);
- plugin_ex_data_subscriber_id_free(source_subscribe_id);
- dest_subscribe_id = NULL;
- source_subscribe_id = NULL;
+ plugin_ex_data_dynamic_ipport_mapping_free(dest_mapping);
+ plugin_ex_data_dynamic_ipport_mapping_free(source_mapping);
+ dest_mapping = NULL;
+ source_mapping = NULL;
tuple4_v6.dest = htons(10244); //port in range
tuple4_v6.source = htons(25620); //port in range
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_STREQ("test1040", dest_subscribe_id->subscribe_id);
- EXPECT_STREQ("test1041", source_subscribe_id->subscribe_id);
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_STREQ("test1040", dest_mapping->subscriber_id);
+ EXPECT_STREQ("231", dest_mapping->imsi);
+ EXPECT_STREQ("1298473129873912", dest_mapping->imei);
+ EXPECT_EQ(nullptr, dest_mapping->msisdn);
+ EXPECT_EQ(nullptr, dest_mapping->apn);
+
+ EXPECT_STREQ("test1041", source_mapping->subscriber_id);
+ EXPECT_STREQ("1298473129873912", source_mapping->imei);
+ EXPECT_STREQ("231", source_mapping->imsi);
+ EXPECT_STREQ("123456789", source_mapping->msisdn);
+ EXPECT_EQ(nullptr, source_mapping->apn);
- plugin_ex_data_subscriber_id_free(dest_subscribe_id);
- plugin_ex_data_subscriber_id_free(source_subscribe_id);
- dest_subscribe_id = NULL;
- source_subscribe_id = NULL;
+ plugin_ex_data_dynamic_ipport_mapping_free(dest_mapping);
+ plugin_ex_data_dynamic_ipport_mapping_free(source_mapping);
+ dest_mapping = NULL;
+ source_mapping = NULL;
tuple4_v6.dest = htons(10144); //port not in range
tuple4_v6.source = htons(15620); //port not in range
- srt_attribute_set_dyn_mapping_subscriber_id(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_subscribe_id, &dest_subscribe_id);
- EXPECT_EQ(nullptr, dest_subscribe_id);
- EXPECT_EQ(nullptr, source_subscribe_id);
+ srt_attribute_set_dynamic_ipport_mapping(&a_stream, g_tsg_dyn_mapping_maat_feather, &source_mapping, &dest_mapping);
+ EXPECT_EQ(nullptr, dest_mapping);
+ EXPECT_EQ(nullptr, source_mapping);
}
TEST(TM, ExDataDNSRecordsProfileA)