TSG-11250: 支持从REDIS中读取移动网用户标识映射关系表并执行对应策略

This commit is contained in:
刘学利
2022-07-29 10:41:09 +00:00
parent ff0fbd01f5
commit c558ea4b71
6 changed files with 200 additions and 56 deletions

View File

@@ -82,3 +82,4 @@
70 APP_SIGNATURE_UPDATE_PROFILE plugin {"key":1,"valid":5,"foreign":"2,3"} 70 APP_SIGNATURE_UPDATE_PROFILE plugin {"key":1,"valid":5,"foreign":"2,3"}
71 TSG_DYN_SUBSCRIBER_IP plugin {"key":3,"valid":5} -- 71 TSG_DYN_SUBSCRIBER_IP plugin {"key":3,"valid":5} --
72 TSG_PROFILE_TRAFFIC_MIRROR plugin {"key":1,"valid":4} -- 72 TSG_PROFILE_TRAFFIC_MIRROR plugin {"key":1,"valid":4} --
73 TSG_DYN_MOBILE_IDENTITY_APN_TEID plugin {"key":2,"valid":7} --

View File

@@ -63,6 +63,7 @@ struct subscribe_id_info
struct umts_user_info struct umts_user_info
{ {
int ref_cnt;
char *apn; char *apn;
char *imsi; char *imsi;
char *imei; char *imei;

View File

@@ -272,15 +272,6 @@ static int print_hit_path(const struct streaminfo *a_stream, struct master_conte
return 1; return 1;
} }
static void free_user_item(char *item)
{
if(item!=NULL)
{
free(item);
item=NULL;
}
}
static int is_only_monitor(struct Maat_rule_t *result, int hit_cnt) static int is_only_monitor(struct Maat_rule_t *result, int hit_cnt)
{ {
int i=0; int i=0;
@@ -1357,12 +1348,7 @@ static void free_session_attribute_label(int thread_seq, void *project_req_value
if(label->user_info!=NULL) if(label->user_info!=NULL)
{ {
free_user_item(label->user_info->apn); gtp_c_free_data(0, (MAAT_PLUGIN_EX_DATA *)&label->user_info, 0, g_tsg_para.logger);
free_user_item(label->user_info->imsi);
free_user_item(label->user_info->imei);
free_user_item(label->user_info->msisdn);
dictator_free(thread_seq, (void *)label->user_info);
label->user_info=NULL; label->user_info=NULL;
} }

View File

@@ -60,7 +60,7 @@ enum DEPLOY_MODE
DEPLOY_MODE_MAX DEPLOY_MODE_MAX
}; };
enum MASTER_TABLE{ enum MASTER_STATIC_TABLE{
TABLE_SECURITY_COMPILE=0, TABLE_SECURITY_COMPILE=0,
TABLE_IP_ADDR, TABLE_IP_ADDR,
TABLE_SUBSCRIBER_ID, TABLE_SUBSCRIBER_ID,
@@ -93,6 +93,12 @@ enum MASTER_TABLE{
TABLE_MAX TABLE_MAX
}; };
enum MASTER_DYNAMIC_TABLE{
DYN_TABLE_SUBSCRIBER_IP=0,
DYN_TABLE_GTP_SIGNALING,
DYN_TABLE_MAX
};
enum TSG_FS2_TYPE{ enum TSG_FS2_TYPE{
TSG_FS2_TCP_LINKS=0, TSG_FS2_TCP_LINKS=0,
TSG_FS2_UDP_LINKS, TSG_FS2_UDP_LINKS,
@@ -278,7 +284,7 @@ typedef struct tsg_para
int location_field_num; int location_field_num;
int app_dict_field_num; int app_dict_field_num;
int device_seq_in_dc; int device_seq_in_dc;
int datacenter_id; int datacenter_id;
int scan_signaling_switch; int scan_signaling_switch;
int hash_timeout; int hash_timeout;
int hash_slot_size; int hash_slot_size;
@@ -289,7 +295,7 @@ typedef struct tsg_para
int unknown_app_id; int unknown_app_id;
int hit_path_switch; int hit_path_switch;
int default_compile_id; int default_compile_id;
int table_id[TABLE_MAX]; int table_id[TABLE_MAX];
int dyn_table_id[DYN_TABLE_MAX]; int dyn_table_id[DYN_TABLE_MAX];
int priority_project_id; int priority_project_id;
int session_attribute_project_id; int session_attribute_project_id;
@@ -304,6 +310,7 @@ typedef struct tsg_para
char device_id_command[MAX_DOMAIN_LEN/8]; char device_id_command[MAX_DOMAIN_LEN/8];
char data_center[_MAX_TABLE_NAME_LEN]; char data_center[_MAX_TABLE_NAME_LEN];
char device_tag[MAX_DOMAIN_LEN/2]; char device_tag[MAX_DOMAIN_LEN/2];
char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN];
char dyn_table_name[DYN_TABLE_MAX][_MAX_TABLE_NAME_LEN]; char dyn_table_name[DYN_TABLE_MAX][_MAX_TABLE_NAME_LEN];
char bridge_name[BRIDGE_TYPE_MAX][_MAX_TABLE_NAME_LEN]; char bridge_name[BRIDGE_TYPE_MAX][_MAX_TABLE_NAME_LEN];
void *logger; void *logger;
@@ -426,6 +433,8 @@ void location_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void*
void location_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp); void location_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void ASN_number_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp); void ASN_number_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void subscriber_id_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp); void subscriber_id_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void app_id_dict_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void gtp_c_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void http_response_pages_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp); void http_response_pages_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
void dns_profile_records_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void *argp); void dns_profile_records_free(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void *argp);
@@ -438,7 +447,10 @@ int tsg_scan_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream
int tsg_scan_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream, tsg_protocol_t proto, scan_status_t *mid, Maat_rule_t*result, int result_num); int tsg_scan_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream, tsg_protocol_t proto, scan_status_t *mid, Maat_rule_t*result, int result_num);
int tsg_scan_shared_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, char *domain, Maat_rule_t *result, int result_num, scan_status_t *mid, int table_id, int thread_seq); int tsg_scan_shared_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, char *domain, Maat_rule_t *result, int result_num, scan_status_t *mid, int table_id, int thread_seq);
int tsg_scan_app_properties_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *property, char *district, int thread_seq); int tsg_scan_app_properties_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *property, char *district, int thread_seq);
int tsg_scan_subscribe_id_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, struct subscribe_id_info *user_info, int thread_seq);
int tsg_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);
int tsg_scan_gtp_apn_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *apn, int thread_seq); int tsg_scan_gtp_apn_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *apn, int thread_seq);
int tsg_scan_gtp_imsi_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *imsi, int thread_seq); int tsg_scan_gtp_imsi_policy(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct Maat_rule_t *result, int result_num, scan_status_t *mid, char *imsi, int thread_seq);

View File

@@ -10,6 +10,13 @@
MESA_htable_handle g_gtp_signaling_hash_handle=NULL; MESA_htable_handle g_gtp_signaling_hash_handle=NULL;
enum SIGNALING_ORIGIN
{
SIGNALING_ORIGIN_NO=0,
SIGNALING_ORIGIN_HASH=1,
SIGNALING_ORIGIN_REDIS=2,
};
static int is_gtp_tunnel(const struct streaminfo *a_stream) static int is_gtp_tunnel(const struct streaminfo *a_stream)
{ {
@@ -114,7 +121,7 @@ void tsg_free_gtp_signaling_field(void *data)
} }
static int get_umts_user_info(struct umts_user_info **user_info, unsigned int teid, int thread_seq) static int get_umts_user_info_form_hash(struct umts_user_info **user_info, unsigned int teid, int thread_seq)
{ {
long cb_ret=0; long cb_ret=0;
struct umts_user_info tmp_user_info={0}; struct umts_user_info tmp_user_info={0};
@@ -122,7 +129,8 @@ static int get_umts_user_info(struct umts_user_info **user_info, unsigned int te
MESA_htable_search_cb(g_gtp_signaling_hash_handle, (unsigned char *)&(teid), sizeof(unsigned int), copy_user_info, (void *)&tmp_user_info, &cb_ret); MESA_htable_search_cb(g_gtp_signaling_hash_handle, (unsigned char *)&(teid), sizeof(unsigned int), copy_user_info, (void *)&tmp_user_info, &cb_ret);
if(cb_ret>0) if(cb_ret>0)
{ {
*user_info=(struct umts_user_info *)dictator_malloc(thread_seq, sizeof(struct umts_user_info)); tmp_user_info.ref_cnt=1;
*user_info=(struct umts_user_info *)calloc(1, sizeof(struct umts_user_info));
memcpy(*user_info, &tmp_user_info, sizeof(struct umts_user_info)); memcpy(*user_info, &tmp_user_info, sizeof(struct umts_user_info));
return 1; return 1;
@@ -131,12 +139,24 @@ static int get_umts_user_info(struct umts_user_info **user_info, unsigned int te
return 0; return 0;
} }
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(teid);
if((*user_info)!=NULL)
{
return 1;
}
return 0;
}
int tsg_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info) int tsg_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_info **user_info)
{ {
int ret=0; int ret=0;
unsigned int uplink=0,downlink=0; unsigned int uplink=0,downlink=0;
if(g_tsg_para.hash_switch==0) if(g_tsg_para.scan_signaling_switch==SIGNALING_ORIGIN_NO)
{ {
return 0; return 0;
} }
@@ -158,34 +178,48 @@ int tsg_get_umts_user_info(const struct streaminfo *a_stream, struct umts_user_i
return 0; return 0;
} }
ret=get_umts_user_info(user_info, uplink, a_stream->threadnum); switch(g_tsg_para.scan_signaling_switch)
{
case SIGNALING_ORIGIN_HASH:
ret=get_umts_user_info_form_hash(user_info, uplink, a_stream->threadnum);
if(ret==1) if(ret==1)
{ {
return 1; return 1;
} }
ret=get_umts_user_info(user_info, downlink, a_stream->threadnum); ret=get_umts_user_info_form_hash(user_info, downlink, a_stream->threadnum);
if(ret==1) if(ret==1)
{ {
return 1; return 1;
} }
break;
case SIGNALING_ORIGIN_REDIS:
ret=get_umts_user_info_form_redis(user_info, uplink, a_stream->threadnum);
if(ret==1)
{
return 1;
}
ret=get_umts_user_info_form_redis(user_info, downlink, a_stream->threadnum);
if(ret==1)
{
return 1;
}
break;
default:
break;
}
return 0; return 0;
} }
int tsg_gtp_signaling_hash_init(const char* conffile, void *logger) int tsg_gtp_signaling_hash_init(const char* conffile, void *logger)
{ {
MESA_load_profile_int_def(conffile, "GTP_SIGNALING", "HASH_SWITCH", &g_tsg_para.hash_switch, 1);
if(g_tsg_para.hash_switch==0)
{
return 0;
}
MESA_htable_create_args_t args;
MESA_load_profile_int_def(conffile, "GTP_SIGNALING", "HASH_TIMEOUT", &g_tsg_para.hash_timeout, 300); MESA_load_profile_int_def(conffile, "GTP_SIGNALING", "HASH_TIMEOUT", &g_tsg_para.hash_timeout, 300);
MESA_load_profile_int_def(conffile, "GTP_SIGNALING", "HASH_SLOT_SIZE", &g_tsg_para.hash_slot_size, 1024*1024*32); MESA_load_profile_int_def(conffile, "GTP_SIGNALING", "HASH_SLOT_SIZE", &g_tsg_para.hash_slot_size, 1024*1024*32);
MESA_htable_create_args_t args;
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
args.thread_safe=128; args.thread_safe=128;
args.recursive=1; args.recursive=1;
@@ -202,6 +236,23 @@ int tsg_gtp_signaling_hash_init(const char* conffile, void *logger)
return -1; return -1;
} }
char signaling_origin[32]={0};
MESA_load_profile_string_def(conffile, "GTP_SIGNALING", "SIGNALING_ORIGIN", signaling_origin, sizeof(signaling_origin), "HASH");
int length=strlen(signaling_origin);
if(length==2 && (strncasecmp("NO", signaling_origin, 2)==0))
{
g_tsg_para.scan_signaling_switch=SIGNALING_ORIGIN_NO;
}
else if(length==4 && (strncasecmp("HASH", signaling_origin, 4)==0))
{
g_tsg_para.scan_signaling_switch=SIGNALING_ORIGIN_HASH;
}
else if(length==5 && (strncasecmp("REDIS", signaling_origin, 5)==0))
{
g_tsg_para.scan_signaling_switch=SIGNALING_ORIGIN_REDIS;
}
return 0; return 0;
} }

View File

@@ -356,6 +356,59 @@ static int get_integer_from_json(cJSON *object, const char *key, int *value)
return 0; return 0;
} }
void gtp_c_dup_data(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void* argp)
{
if((*from)!=NULL)
{
struct umts_user_info *user_info=(struct umts_user_info *)(*from);
atomic_inc(&user_info->ref_cnt);
*to=*from;
}
return;
}
void gtp_c_new_data(int table_id, const char* key, const char* table_line, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp)
{
int imsi=3,msisdn=4,apn=5,imei=6;
struct umts_user_info *user_info=(struct umts_user_info *)calloc(1, sizeof(struct umts_user_info));
user_info->imsi=tsg_get_column_string_value(table_line, imsi);
user_info->msisdn=tsg_get_column_string_value(table_line, msisdn);
user_info->apn=tsg_get_column_string_value(table_line, apn);
user_info->imei=tsg_get_column_string_value(table_line, imei);
str_unescape(user_info->imsi);
str_unescape(user_info->msisdn);
str_unescape(user_info->apn);
str_unescape(user_info->imei);
atomic_inc(&user_info->ref_cnt);
*ad=(MAAT_PLUGIN_EX_DATA)user_info;
return;
}
void gtp_c_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp)
{
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))
{
_free_field(user_info->imsi);
_free_field(user_info->msisdn);
_free_field(user_info->apn);
_free_field(user_info->imei);
_free_field((char *)(*ad));
*ad=NULL;
}
}
return;
}
void ASN_number_dup(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void* argp) void ASN_number_dup(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void* argp)
{ {
@@ -1694,7 +1747,6 @@ int tsg_rule_init(const char* conffile, void *logger)
int log_level=30; int log_level=30;
char log_path[128]={0}; char log_path[128]={0};
char maat_conffile[256]={0}; char maat_conffile[256]={0};
char cb_subscriber_ip_table[32]={0};
MESA_load_profile_int_def(conffile, "MAAT","APP_ID_TABLE_TYPE", &g_tsg_para.app_dict_field_num, 18); MESA_load_profile_int_def(conffile, "MAAT","APP_ID_TABLE_TYPE", &g_tsg_para.app_dict_field_num, 18);
MESA_load_profile_int_def(conffile, "MAAT","LOCATION_TABLE_TYPE", &g_tsg_para.location_field_num, 18); MESA_load_profile_int_def(conffile, "MAAT","LOCATION_TABLE_TYPE", &g_tsg_para.location_field_num, 18);
@@ -1733,11 +1785,12 @@ int tsg_rule_init(const char* conffile, void *logger)
MESA_load_profile_string_def(conffile, "MAAT", "GTP_APN", g_tsg_para.table_name[TABLE_GTP_APN], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_APN"); MESA_load_profile_string_def(conffile, "MAAT", "GTP_APN", g_tsg_para.table_name[TABLE_GTP_APN], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_APN");
MESA_load_profile_string_def(conffile, "MAAT", "GTP_IMSI", g_tsg_para.table_name[TABLE_GTP_IMSI], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_IMSI"); MESA_load_profile_string_def(conffile, "MAAT", "GTP_IMSI", g_tsg_para.table_name[TABLE_GTP_IMSI], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_IMSI");
MESA_load_profile_string_def(conffile, "MAAT", "GTP_PHONE_NUMBER", g_tsg_para.table_name[TABLE_GTP_PHONE_NUMBER], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_PHONE_NUMBER"); MESA_load_profile_string_def(conffile, "MAAT", "GTP_PHONE_NUMBER", g_tsg_para.table_name[TABLE_GTP_PHONE_NUMBER], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_PHONE_NUMBER");
MESA_load_profile_string_def(conffile, "MAAT", "GTP_PHONE_NUMBER", g_tsg_para.table_name[TABLE_GTP_PHONE_NUMBER], _MAX_TABLE_NAME_LEN, "TSG_FILED_GTP_PHONE_NUMBER");
MESA_load_profile_string_def(conffile, "MAAT", "RESPONSE_PAGES_TABLE", g_tsg_para.table_name[TABLE_RESPONSE_PAGES], _MAX_TABLE_NAME_LEN, "TSG_PROFILE_RESPONSE_PAGES"); MESA_load_profile_string_def(conffile, "MAAT", "RESPONSE_PAGES_TABLE", g_tsg_para.table_name[TABLE_RESPONSE_PAGES], _MAX_TABLE_NAME_LEN, "TSG_PROFILE_RESPONSE_PAGES");
MESA_load_profile_string_def(conffile, "MAAT", "DNS_PROFILE_RECORDS", g_tsg_para.table_name[TABLE_DNS_PROFILE_RECORD], _MAX_TABLE_NAME_LEN, (char *)"TSG_PROFILE_DNS_RECORDS"); MESA_load_profile_string_def(conffile, "MAAT", "DNS_PROFILE_RECORDS", g_tsg_para.table_name[TABLE_DNS_PROFILE_RECORD], _MAX_TABLE_NAME_LEN, (char *)"TSG_PROFILE_DNS_RECORDS");
MESA_load_profile_string_def(conffile, "MAAT", "TRAFFIC_MIRROR_PROFILE", g_tsg_para.table_name[TABLE_PROFILE_MIRROR], _MAX_TABLE_NAME_LEN, (char *)"TSG_PROFILE_TRAFFIC_MIRROR"); MESA_load_profile_string_def(conffile, "MAAT", "TRAFFIC_MIRROR_PROFILE", g_tsg_para.table_name[TABLE_PROFILE_MIRROR], _MAX_TABLE_NAME_LEN, (char *)"TSG_PROFILE_TRAFFIC_MIRROR");
MESA_load_profile_int_def(conffile, "MAAT","LOG_LEVEL", &log_level, 30); MESA_load_profile_int_def(conffile, "MAAT","LOG_LEVEL", &log_level, 30);
MESA_load_profile_string_def(conffile, "MAAT", "LOG_PATH", log_path, sizeof(log_path), "./tsglog/maat/tsg_maat.log"); MESA_load_profile_string_def(conffile, "MAAT", "LOG_PATH", log_path, sizeof(log_path), "./tsglog/maat/tsg_maat.log");
g_tsg_para.maat_logger=MESA_create_runtime_log_handle(log_path, log_level); g_tsg_para.maat_logger=MESA_create_runtime_log_handle(log_path, log_level);
@@ -1934,21 +1987,26 @@ int tsg_rule_init(const char* conffile, void *logger)
g_tsg_dynamic_maat_feather=g_tsg_maat_feather; g_tsg_dynamic_maat_feather=g_tsg_maat_feather;
} }
MESA_load_profile_string_def(conffile, "MAAT", "CB_SUBSCRIBER_IP_TABLE", cb_subscriber_ip_table, sizeof(cb_subscriber_ip_table), "TSG_DYN_SUBSCRIBER_IP"); MESA_load_profile_string_def(conffile, "MAAT", "CB_SUBSCRIBER_IP_TABLE", g_tsg_para.dyn_table_name[DYN_TABLE_SUBSCRIBER_IP], sizeof(g_tsg_para.dyn_table_name[DYN_TABLE_SUBSCRIBER_IP]), "TSG_DYN_SUBSCRIBER_IP");
MESA_load_profile_string_def(conffile, "MAAT", "GTP_SIGNALING_TABLE", g_tsg_para.dyn_table_name[DYN_TABLE_GTP_SIGNALING], sizeof(g_tsg_para.dyn_table_name[DYN_TABLE_SUBSCRIBER_IP]), (char *)"TSG_DYN_MOBILE_IDENTITY_APN_TEID");
g_tsg_para.dyn_subscribe_ip_table_id=Maat_table_register(g_tsg_dynamic_maat_feather, cb_subscriber_ip_table); for(i=0; i<DYN_TABLE_MAX; i++)
if(g_tsg_para.dyn_subscribe_ip_table_id<0) {
g_tsg_para.dyn_table_id[i]=Maat_table_register(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_table_name[i]);
if(g_tsg_para.dyn_table_id[i]<0)
{ {
MESA_handle_runtime_log(g_tsg_para.maat_logger, MESA_handle_runtime_log(g_tsg_para.maat_logger,
RLOG_LV_FATAL, RLOG_LV_FATAL,
"RULE_INIT", "RULE_INIT",
"Maat_table_register %s failed, Please check tsgconf/tsg_static_tableinfo.conf", "Maat_table_register %s failed, Please check tsgconf/tsg_static_tableinfo.conf",
cb_subscriber_ip_table g_tsg_para.dyn_table_name[i]
); );
return -1; return -1;
} }
}
ret=Maat_plugin_EX_register(g_tsg_dynamic_maat_feather, ret=Maat_plugin_EX_register(g_tsg_dynamic_maat_feather,
g_tsg_para.dyn_subscribe_ip_table_id, g_tsg_para.dyn_table_id[DYN_TABLE_SUBSCRIBER_IP],
subscriber_id_new, subscriber_id_new,
subscriber_id_free, subscriber_id_free,
subscriber_id_dup, subscriber_id_dup,
@@ -1957,7 +2015,34 @@ int tsg_rule_init(const char* conffile, void *logger)
g_tsg_para.maat_logger); g_tsg_para.maat_logger);
if(ret<0) if(ret<0)
{ {
MESA_handle_runtime_log(g_tsg_para.maat_logger, RLOG_LV_FATAL, "RULE_INIT", "Maat_plugin_EX_register failed, table_name: %s table_id: %d", cb_subscriber_ip_table, g_tsg_para.dyn_subscribe_ip_table_id); MESA_handle_runtime_log(g_tsg_para.maat_logger,
RLOG_LV_FATAL,
"RULE_INIT",
"Maat_plugin_EX_register failed, table_name: %s table_id: %d",
g_tsg_para.dyn_table_name[DYN_TABLE_SUBSCRIBER_IP],
g_tsg_para.dyn_table_id[DYN_TABLE_SUBSCRIBER_IP]
);
return -1;
}
ret=Maat_plugin_EX_register(g_tsg_dynamic_maat_feather,
g_tsg_para.dyn_table_id[DYN_TABLE_GTP_SIGNALING],
gtp_c_new_data,
gtp_c_free_data,
gtp_c_dup_data,
NULL,
0,
NULL);
if(ret<0)
{
MESA_handle_runtime_log(g_tsg_para.maat_logger,
RLOG_LV_FATAL,
"RULE_INIT",
"Maat_plugin_EX_register failed, table_name: %s table_id: %d",
g_tsg_para.dyn_table_name[DYN_TABLE_GTP_SIGNALING],
g_tsg_para.dyn_table_id[DYN_TABLE_GTP_SIGNALING]
);
return -1; return -1;
} }
@@ -2115,18 +2200,18 @@ int tsg_get_subscribe_id(const struct streaminfo *a_stream, struct subscribe_id_
if(strlen(dest_ip)>0 && *dest_subscribe_id==NULL) if(strlen(dest_ip)>0 && *dest_subscribe_id==NULL)
{ {
*dest_subscribe_id = (struct subscribe_id_info *)Maat_plugin_get_EX_data(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_subscribe_ip_table_id, dest_ip); *dest_subscribe_id = (struct subscribe_id_info *)Maat_plugin_get_EX_data(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_table_id[DYN_TABLE_SUBSCRIBER_IP], dest_ip);
} }
if(strlen(source_ip)>0 && *source_subscribe_id==NULL) if(strlen(source_ip)>0 && *source_subscribe_id==NULL)
{ {
*source_subscribe_id = (struct subscribe_id_info *)Maat_plugin_get_EX_data(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_subscribe_ip_table_id, source_ip); *source_subscribe_id = (struct subscribe_id_info *)Maat_plugin_get_EX_data(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_table_id[DYN_TABLE_SUBSCRIBER_IP], source_ip);
} }
return 0; return 0;
} }
int tsg_scan_ip_asn(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct asn_info *asn, enum MASTER_TABLE idx, scan_status_t *mid, Maat_rule_t*result, int result_num) int tsg_scan_ip_asn(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct asn_info *asn, enum MASTER_STATIC_TABLE idx, scan_status_t *mid, Maat_rule_t*result, int result_num)
{ {
int ret=0; int ret=0;
@@ -2167,7 +2252,7 @@ int tsg_scan_ip_asn(Maat_feather_t maat_feather, const struct streaminfo *a_stre
} }
int tsg_scan_ip_location(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct location_info *location, enum MASTER_TABLE idx, scan_status_t *mid, Maat_rule_t*result, int result_num) int tsg_scan_ip_location(Maat_feather_t maat_feather, const struct streaminfo *a_stream, struct location_info *location, enum MASTER_STATIC_TABLE idx, scan_status_t *mid, Maat_rule_t*result, int result_num)
{ {
int ret=0; int ret=0;
char full_address[1024]={0}; char full_address[1024]={0};
@@ -2958,3 +3043,11 @@ int tsg_get_location_type(void)
{ {
return g_tsg_para.location_field_num; return g_tsg_para.location_field_num;
} }
struct umts_user_info *tsg_get_umts_user_info_form_redis(unsigned int teid)
{
char teid_str[32]={0};
snprintf(teid_str, sizeof(teid_str), "%d", teid);
return (struct umts_user_info *)Maat_plugin_get_EX_data(g_tsg_dynamic_maat_feather, g_tsg_para.dyn_table_id[DYN_TABLE_GTP_SIGNALING], (const char *)teid_str);
}