2023-03-30 19:39:18 +08:00
|
|
|
#include <MESA/maat.h>
|
2020-08-10 18:13:44 +08:00
|
|
|
#include <tfe_resource.h>
|
|
|
|
|
#include <tfe_scan.h>
|
2023-12-14 15:08:19 +08:00
|
|
|
#include <MESA/stream.h>
|
2020-08-10 18:13:44 +08:00
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
static int scan_group(struct maat_hit_group hit_group, long long *result, struct maat_state *scan_mid, int hit_cnt, int table_id)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
size_t n_hit_result=0;
|
|
|
|
|
int scan_ret=0, hit_cnt_group=0;
|
|
|
|
|
|
|
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), table_id, &hit_group, 1,
|
|
|
|
|
result+hit_cnt+hit_cnt_group, MAX_SCAN_RESULT-hit_cnt-hit_cnt_group, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_group+=n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_id, result+hit_cnt+hit_cnt_group,
|
|
|
|
|
MAX_SCAN_RESULT-hit_cnt-hit_cnt_group, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_group+=n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
return hit_cnt_group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tfe_get_tags_id_array(char *tag_ids, long long *tag_id_array)
|
|
|
|
|
{
|
|
|
|
|
if(tag_ids==NULL)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int n_tag_ids=0;
|
|
|
|
|
char *tag_ids_tmp = ALLOC(char, strlen(tag_ids)+1);
|
|
|
|
|
strcpy(tag_ids_tmp, tag_ids);
|
|
|
|
|
|
|
|
|
|
char *tag_ids_str=strtok(tag_ids_tmp, ",");
|
|
|
|
|
while(tag_ids_str!=NULL && n_tag_ids < 128)
|
|
|
|
|
{
|
|
|
|
|
tag_id_array[n_tag_ids++]=strtoll(tag_ids_str, NULL, 10);
|
|
|
|
|
tag_ids_str=strtok(NULL, ",");
|
|
|
|
|
}
|
|
|
|
|
FREE(&tag_ids_tmp);
|
|
|
|
|
return n_tag_ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int get_route_dir(const struct tfe_stream * stream)
|
|
|
|
|
{
|
|
|
|
|
uint16_t out_size;
|
|
|
|
|
unsigned int route_dir; int ret=0;
|
|
|
|
|
|
|
|
|
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
|
|
|
|
if (cmsg != NULL)
|
|
|
|
|
{
|
|
|
|
|
ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_COMMON_DIRECTION, (unsigned char *)&route_dir, sizeof(route_dir), &out_size);
|
|
|
|
|
if (ret != 0)
|
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (route_dir==69) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_table_id(const struct tfe_stream *stream, enum scan_common_table table_type)
|
|
|
|
|
{
|
|
|
|
|
int table_id = 0, c2s = 0;
|
|
|
|
|
int dir_is_e2i = get_route_dir(stream);
|
|
|
|
|
|
|
|
|
|
if (table_type == PXY_CTRL_SOURCE_IP || table_type == PXY_CTRL_DESTINATION_IP || table_type == PXY_CTRL_SOURCE_PORT || table_type == PXY_CTRL_DESTINATION_PORT)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
c2s = (table_type == PXY_CTRL_SOURCE_IP || table_type == PXY_CTRL_SOURCE_PORT) ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
if(table_type == PXY_CTRL_SOURCE_IP || table_type == PXY_CTRL_DESTINATION_IP)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
table_id = (c2s == dir_is_e2i) ? tfe_bussiness_tableid_get(PXY_CTRL_INTERNAL_IP) : tfe_bussiness_tableid_get(PXY_CTRL_EXTERNAL_IP);
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
if(table_type == PXY_CTRL_SOURCE_PORT || table_type == PXY_CTRL_DESTINATION_PORT)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
table_id = (c2s == dir_is_e2i) ? tfe_bussiness_tableid_get(PXY_CTRL_INTERNAL_PORT) : tfe_bussiness_tableid_get(PXY_CTRL_EXTERNAL_PORT);
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
return table_id;
|
|
|
|
|
}
|
2020-08-10 18:13:44 +08:00
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
int tfe_scan_internal_exteral_by_last_group(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, enum scan_common_table table_type)
|
|
|
|
|
{
|
|
|
|
|
size_t array_size=256, n_hit_result = 0;
|
|
|
|
|
int hit_cnt_group = 0, scan_ret = 0, table_id = 0;
|
|
|
|
|
struct maat_hit_group last_hit_groups[256] = {0};
|
|
|
|
|
|
|
|
|
|
table_id = get_table_id(stream, table_type);
|
|
|
|
|
if(table_id <= 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
return hit_cnt_group;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
size_t n_last_hit_group = maat_state_get_last_hit_group_cnt(scan_mid);
|
|
|
|
|
if(n_last_hit_group > 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
maat_state_get_last_hit_groups(scan_mid, last_hit_groups, array_size);
|
|
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), table_id, last_hit_groups, array_size, result+hit_cnt+hit_cnt_group,
|
|
|
|
|
MAX_SCAN_RESULT-hit_cnt-hit_cnt_group, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_cnt_group += n_hit_result;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_id,
|
|
|
|
|
result+hit_cnt+hit_cnt_group, MAX_SCAN_RESULT-hit_cnt-hit_cnt_group, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_cnt_group += n_hit_result;
|
2023-12-14 15:08:19 +08:00
|
|
|
}
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
return hit_cnt_group;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
int tfe_get_entry_tags(const struct tfe_stream * stream, enum tfe_cmsg_tlv_type tlv_type, char *opt_val, long long *tag_id_array)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-30 10:25:16 +08:00
|
|
|
int n_tag_ids = 0;
|
|
|
|
|
uint16_t opt_out_size = 0;
|
2023-06-19 14:45:58 +08:00
|
|
|
|
2020-08-10 18:13:44 +08:00
|
|
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
2024-03-26 19:02:14 +08:00
|
|
|
if(cmsg == NULL)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-30 10:25:16 +08:00
|
|
|
return 0;
|
2024-03-26 19:02:14 +08:00
|
|
|
}
|
2024-08-30 10:25:16 +08:00
|
|
|
|
|
|
|
|
int ret = tfe_cmsg_get_value(cmsg, tlv_type, (unsigned char *)opt_val, 128, &opt_out_size);
|
|
|
|
|
if(ret == 0 && opt_out_size > 0)
|
2024-03-26 19:02:14 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
n_tag_ids = tfe_get_tags_id_array(opt_val, tag_id_array);
|
2024-08-30 10:25:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return n_tag_ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tfe_get_library_tags(const struct tfe_stream *stream, cJSON *common_obj, tfe_cmsg_tlv_type tlv_type, const char *tag_key)
|
|
|
|
|
{
|
|
|
|
|
char opt_val[128]={0};
|
|
|
|
|
long long tag_id_array[128]={0};
|
|
|
|
|
|
|
|
|
|
int n_tag_ids = tfe_get_entry_tags(stream, tlv_type, opt_val, tag_id_array);
|
|
|
|
|
if(n_tag_ids == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char value[128]={0};
|
|
|
|
|
cJSON *tags_array = cJSON_CreateArray();
|
|
|
|
|
for(int i = 0; i < n_tag_ids; i++)
|
|
|
|
|
{
|
|
|
|
|
struct library_tag_ctx *library_tag =(struct library_tag_ctx *)maat_plugin_table_get_ex_data(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_LIBRARY_TAG), (const char *)&tag_id_array[i], sizeof(long long));
|
|
|
|
|
if(library_tag != NULL)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-09-11 17:49:14 +08:00
|
|
|
if(library_tag->category == CATEGORY_TYPE_ASN && tlv_type == TFE_CMSG_SRC_IP_TAGS_IDS_STR && atol(library_tag->tag_value) > 0)
|
2024-08-30 10:25:16 +08:00
|
|
|
{
|
2024-09-11 17:49:14 +08:00
|
|
|
cJSON_AddNumberToObject(common_obj, "client_asn", atol(library_tag->tag_value));
|
2024-08-30 10:25:16 +08:00
|
|
|
}
|
|
|
|
|
|
2024-09-11 17:49:14 +08:00
|
|
|
if(library_tag->category == CATEGORY_TYPE_CONTRY_CODE && tlv_type== TFE_CMSG_SRC_IP_TAGS_IDS_STR)
|
|
|
|
|
{
|
|
|
|
|
cJSON_AddStringToObject(common_obj, "client_country", library_tag->tag_value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(library_tag->category == CATEGORY_TYPE_ASN && tlv_type == TFE_CMSG_DST_IP_TAGS_IDS_STR && atol(library_tag->tag_value) > 0)
|
2024-08-30 10:25:16 +08:00
|
|
|
{
|
|
|
|
|
cJSON_AddNumberToObject(common_obj, "server_asn", atol(library_tag->tag_value));
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 17:49:14 +08:00
|
|
|
if(library_tag->category == CATEGORY_TYPE_CONTRY_CODE && tlv_type== TFE_CMSG_DST_IP_TAGS_IDS_STR)
|
|
|
|
|
{
|
|
|
|
|
cJSON_AddStringToObject(common_obj, "server_country", library_tag->tag_value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
memset(value, 0, sizeof(value));
|
|
|
|
|
snprintf(value, sizeof(value), "%s:%s", library_tag->tag_key, library_tag->tag_value);
|
|
|
|
|
cJSON_AddItemToArray(tags_array, cJSON_CreateString(value));
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-30 10:25:16 +08:00
|
|
|
library_tag_free(library_tag);
|
|
|
|
|
}
|
|
|
|
|
cJSON_AddItemToObject(common_obj, tag_key, tags_array);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tfe_scan_ip_tags(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
|
|
|
|
{
|
|
|
|
|
size_t n_hit_result = 0;
|
|
|
|
|
long long tag_id_array[128]={0};
|
|
|
|
|
int scan_ret = 0, hit_cnt_ip = 0, n_tag_ids = 0;
|
|
|
|
|
char opt_val[128]={0};
|
|
|
|
|
|
|
|
|
|
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_SRC_IP_TAGS_IDS_STR, opt_val, tag_id_array);
|
|
|
|
|
if(n_tag_ids == 0)
|
|
|
|
|
{
|
|
|
|
|
return hit_cnt_ip;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_DEBUG(logger, "fetch src ip tags: %s", opt_val);
|
2024-08-30 10:25:16 +08:00
|
|
|
|
2024-03-26 19:02:14 +08:00
|
|
|
struct maat_hit_group hit_group;
|
2024-08-16 11:57:20 +08:00
|
|
|
for (int i = 0; i < n_tag_ids; i++)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-03-26 19:02:14 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_group.group_id=tag_id_array[i];
|
|
|
|
|
|
|
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP), &hit_group, 1, result+hit_cnt+hit_cnt_ip,
|
|
|
|
|
MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret==MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
TFE_LOG_INFO(logger, "Scan Src TAGS, Hit scan ret: %d policy_id: %lld addr: %s", scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_INFO(logger, "Scan Src TAGS, NO hit scan ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_SOURCE_IP);
|
|
|
|
|
if(scan_ret > 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_cnt_ip += scan_ret;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-03-26 19:02:14 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
memset(opt_val, 0, sizeof(opt_val));
|
2024-08-16 11:57:20 +08:00
|
|
|
memset(tag_id_array, 0, sizeof(tag_id_array));
|
2024-08-30 10:25:16 +08:00
|
|
|
|
|
|
|
|
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_DST_IP_TAGS_IDS_STR, opt_val, tag_id_array);
|
|
|
|
|
if(n_tag_ids == 0)
|
2024-03-26 19:02:14 +08:00
|
|
|
{
|
2024-08-30 10:25:16 +08:00
|
|
|
return hit_cnt_ip;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_DEBUG(logger, "fetch dst ip tags: %s", opt_val);
|
2024-08-30 10:25:16 +08:00
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
for (int i = 0; i < n_tag_ids; i++)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-03-26 19:02:14 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_group.group_id=tag_id_array[i];
|
|
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP), &hit_group, 1, result+hit_cnt+hit_cnt_ip,
|
|
|
|
|
MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret==MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
TFE_LOG_INFO(logger, "Scan Dst TAGS, Hit scan ret: %d policy_id: %lld addr: %s", scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_INFO(logger, "Scan Dst TAGS, NO hit scan ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_DESTINATION_IP);
|
|
|
|
|
if(scan_ret > 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_cnt_ip += scan_ret;
|
2023-12-14 15:08:19 +08:00
|
|
|
}
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
|
|
|
|
return hit_cnt_ip;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
int tfe_scan_fqdn_tags(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, int table_id, void *logger)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-30 10:25:16 +08:00
|
|
|
char opt_val[128]={0};
|
2024-08-16 11:57:20 +08:00
|
|
|
long long tag_id_array[128]={0};
|
|
|
|
|
int scan_ret = 0, hit_cnt_fqdn = 0, n_tag_ids = 0;
|
2024-03-26 19:02:14 +08:00
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_FQDN_TAGS_IDS_STR, opt_val, tag_id_array);
|
|
|
|
|
if(n_tag_ids == 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
return hit_cnt_fqdn;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_DEBUG(logger, "fetch fqdn tags: %s", opt_val);
|
2024-08-30 10:25:16 +08:00
|
|
|
|
2024-08-16 11:57:20 +08:00
|
|
|
struct maat_hit_group hit_group;
|
|
|
|
|
for (int i = 0; i < n_tag_ids; i++)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-03-26 19:02:14 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
2024-08-16 11:57:20 +08:00
|
|
|
hit_group.group_id=tag_id_array[i];
|
|
|
|
|
scan_ret = scan_group(hit_group, result, scan_mid, hit_cnt, table_id);
|
|
|
|
|
if (scan_ret > 0)
|
2020-08-10 18:13:44 +08:00
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_INFO(logger, "Scan Fqdn TAGS, Hit scan ret: %d policy_id: %lld addr: %s", scan_ret, result[hit_cnt + hit_cnt_fqdn], stream->str_stream_info);
|
|
|
|
|
hit_cnt_fqdn += scan_ret;
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-08-16 11:57:20 +08:00
|
|
|
TFE_LOG_INFO(logger, "Scan Fqdn TAGS, NO hit scan ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
2023-12-14 15:08:19 +08:00
|
|
|
}
|
2020-08-10 18:13:44 +08:00
|
|
|
}
|
2024-08-30 10:25:16 +08:00
|
|
|
return hit_cnt_fqdn;
|
2023-12-14 15:08:19 +08:00
|
|
|
}
|
|
|
|
|
|
2024-01-15 15:50:58 +08:00
|
|
|
int tfe_scan_app_id(long long *result, struct maat_state *scan_mid, int hit_cnt, long long app_id, int table_id)
|
2023-12-14 15:08:19 +08:00
|
|
|
{
|
|
|
|
|
int scan_ret = 0;
|
|
|
|
|
int hit_app_id = 0;
|
|
|
|
|
size_t n_hit_result = 0;
|
2024-01-03 17:26:20 +08:00
|
|
|
struct maat_hit_group hit_group;
|
2024-02-01 16:03:49 +08:00
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
struct app_id_dict *app_dict = (struct app_id_dict*)maat_plugin_table_get_ex_data(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_APP_ID_DICT),
|
2023-12-14 15:08:19 +08:00
|
|
|
(const char *)&app_id, sizeof(long long));
|
|
|
|
|
if(app_dict!=NULL)
|
|
|
|
|
{
|
2024-01-03 17:26:20 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
|
|
|
|
hit_group.group_id=app_dict->group_id;
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), table_id, &hit_group, 1, result+hit_cnt+hit_app_id,
|
2023-12-14 15:08:19 +08:00
|
|
|
MAX_SCAN_RESULT-hit_cnt-hit_app_id, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret==MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_app_id += n_hit_result;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_id, result+hit_cnt+hit_app_id, MAX_SCAN_RESULT-hit_cnt-hit_app_id, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_app_id += n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
app_id_dict_free(app_dict);
|
|
|
|
|
}
|
|
|
|
|
return hit_app_id;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
int tfe_scan_value_by_cmsg(const struct tfe_stream *stream, enum tfe_cmsg_tlv_type tlv_type, long long *result, struct maat_state *scan_mid, int hit_cnt, int table_id, char *opt_val, void *logger)
|
|
|
|
|
{
|
|
|
|
|
uint16_t opt_out_size = 0;
|
|
|
|
|
int hit_cnt_string=0;
|
|
|
|
|
|
|
|
|
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
|
|
|
|
if(cmsg == NULL)
|
|
|
|
|
{
|
|
|
|
|
return hit_cnt_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ret = tfe_cmsg_get_value(cmsg, tlv_type, (unsigned char *)opt_val, 128, &opt_out_size);
|
|
|
|
|
if(ret == 0 && opt_out_size > 0)
|
|
|
|
|
{
|
|
|
|
|
size_t n_hit_result=0;
|
|
|
|
|
|
|
|
|
|
int scan_ret = maat_scan_string(tfe_get_maat_handle(), table_id, opt_val, strlen(opt_val), result+hit_cnt+hit_cnt_string, MAX_SCAN_RESULT-hit_cnt-hit_cnt_string,
|
|
|
|
|
&n_hit_result,scan_mid);
|
|
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_string+=n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_id, result+hit_cnt+hit_cnt_string, MAX_SCAN_RESULT-hit_cnt-hit_cnt_string, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_string+=n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return hit_cnt_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tfe_scan_device(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
|
|
|
|
{
|
|
|
|
|
char opt_val[4][128]={0};
|
|
|
|
|
int scan_ret = 0, htt_cnt_device = 0;
|
|
|
|
|
|
|
|
|
|
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_IMSI_STR, result, scan_mid, hit_cnt, tfe_bussiness_tableid_get(PXY_CTRL_IMSI), opt_val[0], logger);
|
|
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
htt_cnt_device += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_IMEI_STR, result, scan_mid, hit_cnt, tfe_bussiness_tableid_get(PXY_CTRL_GTP_IMEI), opt_val[1], logger);
|
|
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
htt_cnt_device += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_PHONE_NUM_STR, result, scan_mid, hit_cnt, tfe_bussiness_tableid_get(PXY_CTRL_PHONE_NUMBER), opt_val[2], logger);
|
|
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
htt_cnt_device += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_APN_STR, result, scan_mid, hit_cnt, tfe_bussiness_tableid_get(PXY_CTRL_APN), opt_val[3], logger);
|
|
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
htt_cnt_device += scan_ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFE_LOG_DEBUG(logger, "fetch device string, imsi:%s imei:%s phone_number:%s apn:%s", opt_val[0], opt_val[1], opt_val[2], opt_val[3]);
|
|
|
|
|
|
|
|
|
|
return htt_cnt_device;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 16:03:49 +08:00
|
|
|
int tfe_scan_port(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, uint16_t source, uint16_t dest)
|
|
|
|
|
{
|
|
|
|
|
int scan_ret = 0;
|
|
|
|
|
int hit_cnt_port = 0;
|
|
|
|
|
size_t n_hit_result = 0;
|
|
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret=maat_scan_integer(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_PORT), ntohs(source),
|
2024-02-01 16:03:49 +08:00
|
|
|
result+hit_cnt+hit_cnt_port, MAX_SCAN_RESULT-hit_cnt-hit_cnt_port, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_SOURCE_PORT);
|
2024-02-01 16:03:49 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_PORT),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_port, MAX_SCAN_RESULT-hit_cnt-hit_cnt_port, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=n_hit_result;
|
|
|
|
|
}
|
2024-02-01 16:03:49 +08:00
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret=maat_scan_integer(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_PORT), ntohs(dest),
|
2024-02-01 16:03:49 +08:00
|
|
|
result+hit_cnt+hit_cnt_port, MAX_SCAN_RESULT-hit_cnt-hit_cnt_port, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_DESTINATION_PORT);
|
2024-02-01 16:03:49 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_PORT),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_port, MAX_SCAN_RESULT-hit_cnt-hit_cnt_port, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_port+=n_hit_result;
|
|
|
|
|
}
|
2024-02-01 16:03:49 +08:00
|
|
|
|
|
|
|
|
return hit_cnt_port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PROTOCOL_TCP_GROUP_ID 6
|
|
|
|
|
int tfe_scan_ipv4_addr(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, struct ipaddr sapp_addr)
|
|
|
|
|
{
|
2023-12-25 14:43:00 +08:00
|
|
|
int scan_ret = 0;
|
|
|
|
|
int hit_cnt_ip = 0;
|
|
|
|
|
size_t n_hit_result = 0;
|
2024-02-01 16:03:49 +08:00
|
|
|
struct maat_hit_group hit_group;
|
2023-12-25 14:43:00 +08:00
|
|
|
|
2024-02-01 16:03:49 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
|
|
|
|
hit_group.group_id=PROTOCOL_TCP_GROUP_ID;
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL), &hit_group, 1,
|
2024-02-01 16:03:49 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret==MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL),
|
2024-02-29 11:25:36 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-04-03 16:50:54 +08:00
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_ipv4_port(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP), sapp_addr.v4->saddr, ntohs(sapp_addr.v4->source),
|
2024-03-28 11:39:31 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_SOURCE_IP);
|
2023-12-25 14:43:00 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2023-12-14 15:08:19 +08:00
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_ipv4_port(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP), sapp_addr.v4->daddr, ntohs(sapp_addr.v4->dest),
|
2024-03-28 11:39:31 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if(scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_DESTINATION_IP);
|
2023-12-25 14:43:00 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2023-12-14 15:08:19 +08:00
|
|
|
|
|
|
|
|
return hit_cnt_ip;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 14:43:00 +08:00
|
|
|
int tfe_scan_ipv6_addr(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, struct ipaddr sapp_addr)
|
2023-12-14 15:08:19 +08:00
|
|
|
{
|
|
|
|
|
int scan_ret = 0;
|
|
|
|
|
int hit_cnt_ip = 0;
|
|
|
|
|
size_t n_hit_result = 0;
|
2024-02-01 16:03:49 +08:00
|
|
|
struct maat_hit_group hit_group;
|
2023-12-14 15:08:19 +08:00
|
|
|
|
2024-02-01 16:03:49 +08:00
|
|
|
memset(&hit_group, 0, sizeof(hit_group));
|
|
|
|
|
hit_group.group_id=PROTOCOL_TCP_GROUP_ID;
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL), &hit_group, 1,
|
2024-02-01 16:03:49 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if(scan_ret==MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL),
|
2024-04-03 16:50:54 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_ipv6_port(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP), sapp_addr.v6->saddr, ntohs(sapp_addr.v6->source),
|
2024-04-03 16:50:54 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_SOURCE_IP);
|
2023-12-25 14:43:00 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_ipv6_port(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP), sapp_addr.v6->daddr, ntohs(sapp_addr.v6->dest),
|
2024-03-28 11:39:31 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
2023-12-14 15:08:19 +08:00
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2024-08-16 11:57:20 +08:00
|
|
|
scan_ret = tfe_scan_internal_exteral_by_last_group(stream, result, scan_mid, hit_cnt, PXY_CTRL_DESTINATION_IP);
|
2023-12-25 14:43:00 +08:00
|
|
|
if(scan_ret > 0)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += scan_ret;
|
|
|
|
|
}
|
2024-07-19 18:20:04 +08:00
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP),
|
2024-05-09 11:50:43 +08:00
|
|
|
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
2023-12-25 14:43:00 +08:00
|
|
|
|
2023-12-14 15:08:19 +08:00
|
|
|
return hit_cnt_ip;
|
2024-08-16 11:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-30 10:25:16 +08:00
|
|
|
int tfe_scan_subscribe_id(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
2024-08-16 11:57:20 +08:00
|
|
|
{
|
|
|
|
|
int scan_ret = 0;
|
|
|
|
|
int hit_cnt_ip = 0;
|
|
|
|
|
size_t n_hit_result = 0;
|
|
|
|
|
uint16_t opt_out_size;
|
|
|
|
|
char source_subscribe_id[TFE_STRING_MAX] = {0};
|
|
|
|
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
|
|
|
|
if (cmsg != NULL)
|
|
|
|
|
{
|
|
|
|
|
scan_ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_SRC_SUB_ID, (unsigned char *)source_subscribe_id, sizeof(source_subscribe_id), &opt_out_size);
|
|
|
|
|
if (scan_ret != 0)
|
|
|
|
|
{
|
|
|
|
|
TFE_LOG_ERROR(logger, "fetch src sub id from cmsg failed, ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-30 10:25:16 +08:00
|
|
|
TFE_LOG_DEBUG(logger, "fetch src sub id:%s addr: %s", source_subscribe_id, stream->str_stream_info);
|
2024-08-16 11:57:20 +08:00
|
|
|
|
|
|
|
|
if (strlen(source_subscribe_id))
|
|
|
|
|
{
|
|
|
|
|
scan_ret = maat_scan_string(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SUBSCRIBER_ID),
|
|
|
|
|
source_subscribe_id, strlen(source_subscribe_id),result + hit_cnt + hit_cnt_ip,
|
|
|
|
|
MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
TFE_LOG_INFO(logger, "Scan src TSG_OBJ_SUBSCRIBER_ID, Hit subid: %s scan ret: %d policy_id: %lld addr: %s",
|
|
|
|
|
source_subscribe_id, scan_ret, result[hit_cnt + hit_cnt_ip], stream->str_stream_info);
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TFE_LOG_INFO(logger, "Scan src TSG_OBJ_SUBSCRIBER_ID, NO hit subid: %s scan ret: %d addr: %s",
|
|
|
|
|
source_subscribe_id, scan_ret, stream->str_stream_info);
|
|
|
|
|
}
|
|
|
|
|
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SUBSCRIBER_ID),
|
|
|
|
|
result + hit_cnt + hit_cnt_ip, MAX_SCAN_RESULT - hit_cnt - hit_cnt_ip, &n_hit_result, scan_mid);
|
|
|
|
|
if (scan_ret == MAAT_SCAN_HIT)
|
|
|
|
|
{
|
|
|
|
|
hit_cnt_ip += n_hit_result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hit_cnt_ip;
|
|
|
|
|
}
|