TSG-22707 tfe adapts to maat interface changes
This commit is contained in:
@@ -232,38 +232,35 @@ static char* create_device_tag(const char *profile, const char *section, void *l
|
||||
return device_tag;
|
||||
}
|
||||
|
||||
void app_dict_table_new_cb(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
void app_dict_table_new_cb(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
{
|
||||
int ret=0;
|
||||
size_t offset=0, len=0;
|
||||
char *app_id_str=NULL, *group_id_str=NULL;
|
||||
cJSON* app_id_dict_json = cJSON_Parse(table_line);
|
||||
if(app_id_dict_json == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct app_id_dict *app_dict=ALLOC(struct app_id_dict, 1);
|
||||
|
||||
ret = maat_helper_read_column(table_line, 1, &offset, &len);
|
||||
if(ret >= 0)
|
||||
cJSON *item = cJSON_GetObjectItem(app_id_dict_json, "app_id");
|
||||
if(item && item->type==cJSON_Number)
|
||||
{
|
||||
app_id_str=ALLOC(char, len+1);
|
||||
memcpy(app_id_str, table_line+offset, len);
|
||||
app_dict->app_id=atoi(app_id_str);
|
||||
FREE(&app_id_str);
|
||||
}
|
||||
|
||||
ret = maat_helper_read_column(table_line, 18, &offset, &len);
|
||||
if(ret >= 0)
|
||||
{
|
||||
group_id_str=ALLOC(char, len+1);
|
||||
memcpy(group_id_str, table_line+offset, len);
|
||||
app_dict->group_id=atoll(group_id_str);
|
||||
FREE(&group_id_str);
|
||||
app_dict->app_id = item->valueint;
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(app_id_dict_json, "object_id");
|
||||
if(item && item->type==cJSON_Number)
|
||||
{
|
||||
app_dict->object_id = item->valueint;
|
||||
}
|
||||
|
||||
cJSON_Delete(app_id_dict_json);
|
||||
app_dict->ref_cnt=1;
|
||||
pthread_mutex_init(&(app_dict->lock), NULL);
|
||||
*ad=app_dict;
|
||||
return;
|
||||
}
|
||||
|
||||
void app_dict_table_free_cb(int table_id, void **ad, long argl, void* argp)
|
||||
void app_dict_table_free_cb(const char *table_name, void **ad, long argl, void* argp)
|
||||
{
|
||||
if(*ad==NULL)
|
||||
{
|
||||
@@ -291,7 +288,7 @@ void app_id_dict_free(struct app_id_dict *app_dict)
|
||||
app_dict_table_free_cb(0, (void **)&app_dict, 0, NULL);
|
||||
}
|
||||
|
||||
void app_dict_table_dup_cb(int table_id, void **to, void **from, long argl, void* argp)
|
||||
void app_dict_table_dup_cb(const char *table_name, void **to, void **from, long argl, void* argp)
|
||||
{
|
||||
struct app_id_dict *app_dict=(struct app_id_dict *)(*from);
|
||||
pthread_mutex_lock(&(app_dict->lock));
|
||||
@@ -314,52 +311,47 @@ int get_category_type_str2idx(const char *category)
|
||||
return i;
|
||||
}
|
||||
|
||||
void library_tag_new_cb(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
void library_tag_new_cb(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||
{
|
||||
int ret=0;
|
||||
size_t offset=0, len=0;
|
||||
char category[256]={0};
|
||||
cJSON* library_tag_json = cJSON_Parse(table_line);
|
||||
if(library_tag_json == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct library_tag_ctx *library_tags = ALLOC(struct library_tag_ctx, 1);
|
||||
|
||||
ret = maat_helper_read_column(table_line, 1, &offset, &len);
|
||||
if(ret >= 0)
|
||||
cJSON *item = cJSON_GetObjectItem(library_tag_json, "uuid");
|
||||
if(item && item->type==cJSON_String)
|
||||
{
|
||||
char *tag_id_str=ALLOC(char, len+1);
|
||||
memcpy(tag_id_str, table_line+offset, len);
|
||||
library_tags->tag_id=atoi(tag_id_str);
|
||||
FREE(&tag_id_str);
|
||||
library_tags->uuid=strdup(item->valuestring);
|
||||
}
|
||||
|
||||
ret = maat_helper_read_column(table_line, 3, &offset, &len);
|
||||
if(ret >= 0)
|
||||
item = cJSON_GetObjectItem(library_tag_json, "category");
|
||||
if(item && item->type==cJSON_String)
|
||||
{
|
||||
memcpy(category, table_line+offset, len);
|
||||
library_tags->category=(enum category_type)get_category_type_str2idx(category);
|
||||
library_tags->category=(enum category_type)get_category_type_str2idx(item->valuestring);
|
||||
}
|
||||
|
||||
ret = maat_helper_read_column(table_line, 4, &offset, &len);
|
||||
if(ret >= 0)
|
||||
item = cJSON_GetObjectItem(library_tag_json, "tag_key");
|
||||
if(item && item->type==cJSON_String)
|
||||
{
|
||||
library_tags->tag_key=ALLOC(char, len+1);
|
||||
memcpy(library_tags->tag_key, table_line+offset, len);
|
||||
library_tags->tag_key=strdup(item->valuestring);
|
||||
}
|
||||
|
||||
ret = maat_helper_read_column(table_line, 5, &offset, &len);
|
||||
if(ret >= 0)
|
||||
item = cJSON_GetObjectItem(library_tag_json, "tag_value");
|
||||
if(item && item->type==cJSON_String)
|
||||
{
|
||||
library_tags->tag_value=ALLOC(char, len+1);
|
||||
memcpy(library_tags->tag_value, table_line+offset, len);
|
||||
library_tags->tag_value=strdup(item->valuestring);
|
||||
}
|
||||
|
||||
library_tags->ref_cnt=1;
|
||||
pthread_mutex_init(&(library_tags->lock), NULL);
|
||||
cJSON_Delete(library_tag_json);
|
||||
|
||||
*ad=library_tags;
|
||||
return;
|
||||
}
|
||||
|
||||
void library_tag_free_cb(int table_id, void **ad, long argl, void* argp)
|
||||
void library_tag_free_cb(const char *table_name, void **ad, long argl, void* argp)
|
||||
{
|
||||
if(*ad==NULL)
|
||||
{
|
||||
@@ -385,13 +377,17 @@ void library_tag_free_cb(int table_id, void **ad, long argl, void* argp)
|
||||
{
|
||||
FREE(&library_tags->tag_value);
|
||||
}
|
||||
if(library_tags->uuid)
|
||||
{
|
||||
FREE(&library_tags->uuid);
|
||||
}
|
||||
|
||||
FREE(&library_tags);
|
||||
*ad=NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
void library_tag_dup_cb(int table_id, void **to, void **from, long argl, void* argp)
|
||||
void library_tag_dup_cb(const char *table_name, void **to, void **from, long argl, void* argp)
|
||||
{
|
||||
struct library_tag_ctx *library_tags=(struct library_tag_ctx *)(*from);
|
||||
pthread_mutex_lock(&(library_tags->lock));
|
||||
@@ -408,33 +404,6 @@ void library_tag_free(struct library_tag_ctx *library_tags)
|
||||
|
||||
static int maat_common_table_init()
|
||||
{
|
||||
const char * table_name[__SCAN_COMMON_TABLE_MAX];
|
||||
table_name[PXY_CTRL_SOURCE_IP] = "ATTR_SOURCE_IP";
|
||||
table_name[PXY_CTRL_DESTINATION_IP]="ATTR_DESTINATION_IP";
|
||||
table_name[PXY_CTRL_INTERNAL_IP] = "ATTR_INTERNAL_IP";
|
||||
table_name[PXY_CTRL_EXTERNAL_IP] = "ATTR_EXTERNAL_IP";
|
||||
table_name[PXY_CTRL_SOURCE_PORT] = "ATTR_SOURCE_PORT";
|
||||
table_name[PXY_CTRL_DESTINATION_PORT] = "ATTR_DESTINATION_PORT";
|
||||
table_name[PXY_CTRL_INTERNAL_PORT] = "ATTR_INTERNAL_PORT";
|
||||
table_name[PXY_CTRL_EXTERNAL_PORT] = "ATTR_EXTERNAL_PORT";
|
||||
table_name[PXY_CTRL_IP_PROTOCOL] = "ATTR_IP_PROTOCOL";
|
||||
table_name[PXY_CTRL_SUBSCRIBER_ID] = "ATTR_SUBSCRIBER_ID";
|
||||
table_name[PXY_CTRL_APP_ID_DICT] = "APP_ID_DICT";
|
||||
table_name[PXY_CTRL_LIBRARY_TAG] = "LIBRARY_TAG";
|
||||
table_name[PXY_CTRL_IMSI]="ATTR_GTP_IMSI";
|
||||
table_name[PXY_CTRL_APN]="ATTR_GTP_APN";
|
||||
table_name[PXY_CTRL_PHONE_NUMBER]="ATTR_GTP_PHONE_NUMBER";
|
||||
table_name[PXY_CTRL_GTP_IMEI]="ATTR_GTP_IMEI";
|
||||
|
||||
for (int i = 0; i < __SCAN_COMMON_TABLE_MAX; i++)
|
||||
{
|
||||
scan_table_id[i] = maat_get_table_id(maat_handle, table_name[i]);
|
||||
if (scan_table_id[i] < 0)
|
||||
{
|
||||
TFE_LOG_ERROR(g_default_logger, "Maat table %s register failed.", table_name[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
maat_plugin_table_ex_schema_register(maat_handle, "APP_ID_DICT", app_dict_table_new_cb, app_dict_table_free_cb, app_dict_table_dup_cb, 0, NULL);
|
||||
maat_plugin_table_ex_schema_register(maat_handle, "LIBRARY_TAG", library_tag_new_cb, library_tag_free_cb, library_tag_dup_cb, 0, NULL);
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
#include <tfe_scan.h>
|
||||
#include <MESA/stream.h>
|
||||
|
||||
static int scan_group(struct maat_hit_group hit_group, long long *result, struct maat_state *scan_mid, int hit_cnt, int table_id)
|
||||
static int scan_string(uuid_t *result, struct maat_state *scan_mid, int hit_cnt,const char *data, const char *table_name, const char *attribute_name)
|
||||
{
|
||||
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);
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), table_name, attribute_name, data, strlen(data), 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,
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_name, attribute_name, 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)
|
||||
{
|
||||
@@ -23,27 +23,6 @@ static int scan_group(struct maat_hit_group hit_group, long long *result, struct
|
||||
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;
|
||||
@@ -61,9 +40,10 @@ static int get_route_dir(const struct tfe_stream * stream)
|
||||
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;
|
||||
const char *get_attribute_name(const struct tfe_stream *stream, enum scan_common_table table_type)
|
||||
{
|
||||
int c2s = 0;
|
||||
const char *attribute_name=NULL;
|
||||
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)
|
||||
@@ -72,40 +52,65 @@ int get_table_id(const struct tfe_stream *stream, enum scan_common_table table_t
|
||||
|
||||
if(table_type == PXY_CTRL_SOURCE_IP || table_type == PXY_CTRL_DESTINATION_IP)
|
||||
{
|
||||
table_id = (c2s == dir_is_e2i) ? tfe_bussiness_tableid_get(PXY_CTRL_INTERNAL_IP) : tfe_bussiness_tableid_get(PXY_CTRL_EXTERNAL_IP);
|
||||
attribute_name = (c2s == dir_is_e2i) ? "ATTR_INTERNAL_IP" : "ATTR_EXTERNAL_IP";
|
||||
}
|
||||
if(table_type == PXY_CTRL_SOURCE_PORT || table_type == PXY_CTRL_DESTINATION_PORT)
|
||||
{
|
||||
table_id = (c2s == dir_is_e2i) ? tfe_bussiness_tableid_get(PXY_CTRL_INTERNAL_PORT) : tfe_bussiness_tableid_get(PXY_CTRL_EXTERNAL_PORT);
|
||||
attribute_name = (c2s == dir_is_e2i) ? "ATTR_INTERNAL_PORT" : "ATTR_EXTERNAL_PORT";
|
||||
}
|
||||
}
|
||||
return table_id;
|
||||
return attribute_name;
|
||||
}
|
||||
|
||||
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)
|
||||
const char *get_table_name(const struct tfe_stream *stream, enum scan_common_table table_type)
|
||||
{
|
||||
const char *table_name=NULL;
|
||||
switch (table_type)
|
||||
{
|
||||
case PXY_CTRL_SOURCE_IP:
|
||||
case PXY_CTRL_DESTINATION_IP:
|
||||
table_name = "TSG_OBJ_IP_ADDR";
|
||||
break;
|
||||
case PXY_CTRL_SOURCE_PORT:
|
||||
case PXY_CTRL_DESTINATION_PORT:
|
||||
table_name = "TSG_OBJ_PORT";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return table_name;
|
||||
}
|
||||
|
||||
int tfe_scan_internal_exteral_by_last_group(const struct tfe_stream *stream, uuid_t *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)
|
||||
int hit_cnt_group = 0, scan_ret = 0;
|
||||
struct maat_hit_object last_hit_objects[128] = {0};
|
||||
|
||||
const char *table_name = get_table_name(stream, table_type);
|
||||
if(table_name == NULL)
|
||||
{
|
||||
return hit_cnt_group;
|
||||
}
|
||||
|
||||
size_t n_last_hit_group = maat_state_get_last_hit_group_cnt(scan_mid);
|
||||
if(n_last_hit_group > 0)
|
||||
const char *attribute_name = get_attribute_name(stream, table_type);
|
||||
if(attribute_name == NULL)
|
||||
{
|
||||
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);
|
||||
return hit_cnt_group;
|
||||
}
|
||||
|
||||
size_t n_last_hit_object = maat_state_get_last_hit_object_cnt(scan_mid);
|
||||
if(n_last_hit_object > 0)
|
||||
{
|
||||
maat_state_get_last_hit_objects(scan_mid, last_hit_objects, array_size);
|
||||
scan_ret = maat_scan_object(tfe_get_maat_handle(), table_name, attribute_name, last_hit_objects, 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)
|
||||
{
|
||||
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);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_name, attribute_name,
|
||||
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;
|
||||
@@ -114,7 +119,7 @@ int tfe_scan_internal_exteral_by_last_group(const struct tfe_stream *stream, lon
|
||||
return hit_cnt_group;
|
||||
}
|
||||
|
||||
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)
|
||||
int tfe_get_entry_tags(const struct tfe_stream * stream, enum tfe_cmsg_tlv_type tlv_type, uuid_t *opt_val, char **tag_id_array)
|
||||
{
|
||||
int n_tag_ids = 0;
|
||||
uint16_t opt_out_size = 0;
|
||||
@@ -124,22 +129,41 @@ int tfe_get_entry_tags(const struct tfe_stream * stream, enum tfe_cmsg_tlv_type
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ret = tfe_cmsg_get_value(cmsg, tlv_type, (unsigned char *)opt_val, 128, &opt_out_size);
|
||||
if(ret == 0 && opt_out_size > 0)
|
||||
{
|
||||
n_tag_ids = tfe_get_tags_id_array(opt_val, tag_id_array);
|
||||
n_tag_ids = opt_out_size/(int)sizeof(uuid_t);
|
||||
for (int i=0; i<n_tag_ids; i++)
|
||||
{
|
||||
uuid_unparse(opt_val[i],tag_id_array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return n_tag_ids;
|
||||
}
|
||||
|
||||
void tfe_tags_log(char **tag_id_array, int n_tag_ids, const char *log_key, void *logger)
|
||||
{
|
||||
char *tag_uuids_for_log = ALLOC(char, n_tag_ids*UUID_STRING_SIZE);
|
||||
for(int i = 0; i < n_tag_ids; i++)
|
||||
{
|
||||
strcat(tag_uuids_for_log, tag_id_array[i]);
|
||||
if (i < n_tag_ids - 1)
|
||||
{
|
||||
strcat(tag_uuids_for_log, ",");
|
||||
}
|
||||
}
|
||||
TFE_LOG_DEBUG(logger, "fetch %s tags: %s", log_key, tag_uuids_for_log);
|
||||
FREE(&tag_uuids_for_log);
|
||||
}
|
||||
|
||||
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};
|
||||
uuid_t opt_val[128]={0};
|
||||
char tag_id_array[128][UUID_STRING_SIZE];
|
||||
|
||||
int n_tag_ids = tfe_get_entry_tags(stream, tlv_type, opt_val, tag_id_array);
|
||||
int n_tag_ids = tfe_get_entry_tags(stream, tlv_type, opt_val, (char **)tag_id_array);
|
||||
if(n_tag_ids == 0)
|
||||
{
|
||||
return 0;
|
||||
@@ -149,7 +173,7 @@ int tfe_get_library_tags(const struct tfe_stream *stream, cJSON *common_obj, tfe
|
||||
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));
|
||||
struct library_tag_ctx *library_tag =(struct library_tag_ctx *)maat_plugin_table_get_ex_data(tfe_get_maat_handle(), "LIBRARY_TAG", (const char *)tag_id_array[i], strlen(tag_id_array[i]));
|
||||
if(library_tag != NULL)
|
||||
{
|
||||
if(library_tag->category == CATEGORY_TYPE_ASN && tlv_type == TFE_CMSG_SRC_IP_TAGS_IDS_ARR && atol(library_tag->tag_value) > 0)
|
||||
@@ -183,33 +207,33 @@ int tfe_get_library_tags(const struct tfe_stream *stream, cJSON *common_obj, tfe
|
||||
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)
|
||||
int tfe_scan_ip_tags(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
||||
{
|
||||
size_t n_hit_result = 0;
|
||||
long long tag_id_array[128]={0};
|
||||
char tag_id_array[128][UUID_STRING_SIZE];
|
||||
char result_str[UUID_STRING_SIZE]={0};
|
||||
int scan_ret = 0, hit_cnt_ip = 0, n_tag_ids = 0;
|
||||
char opt_val[128]={0};
|
||||
uuid_t opt_val[128]={0};
|
||||
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_SRC_IP_TAGS_IDS_ARR, opt_val, tag_id_array);
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_SRC_IP_TAGS_IDS_ARR, opt_val, (char **)tag_id_array);
|
||||
if(n_tag_ids == 0)
|
||||
{
|
||||
TFE_LOG_DEBUG(logger, "fetch src ip tags: NULL");
|
||||
return hit_cnt_ip;
|
||||
}
|
||||
TFE_LOG_DEBUG(logger, "fetch src ip tags: %s", opt_val);
|
||||
tfe_tags_log((char **)tag_id_array, n_tag_ids, "src ip", logger);
|
||||
|
||||
struct maat_hit_group hit_group;
|
||||
for (int i = 0; i < n_tag_ids; i++)
|
||||
{
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
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;
|
||||
}
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_SOURCE_IP", tag_id_array[i], strlen(tag_id_array[i]), 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)
|
||||
{
|
||||
memset(result_str, 0, sizeof(result_str));
|
||||
uuid_unparse(result[hit_cnt + hit_cnt_ip], result_str);
|
||||
TFE_LOG_INFO(logger, "Scan Src TAGS, Hit scan ret: %d policy_id: %s addr: %s", scan_ret, result_str, stream->str_stream_info);
|
||||
hit_cnt_ip+=n_hit_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFE_LOG_INFO(logger, "Scan Src TAGS, NO hit scan ret: %d addr: %s", scan_ret, stream->str_stream_info);
|
||||
@@ -224,22 +248,23 @@ int tfe_scan_ip_tags(const struct tfe_stream *stream, long long *result, struct
|
||||
memset(opt_val, 0, sizeof(opt_val));
|
||||
memset(tag_id_array, 0, sizeof(tag_id_array));
|
||||
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_DST_IP_TAGS_IDS_ARR, opt_val, tag_id_array);
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_DST_IP_TAGS_IDS_ARR, opt_val, (char **)tag_id_array);
|
||||
if(n_tag_ids == 0)
|
||||
{
|
||||
TFE_LOG_DEBUG(logger, "fetch dst ip tags: NULL");
|
||||
return hit_cnt_ip;
|
||||
}
|
||||
TFE_LOG_DEBUG(logger, "fetch dst ip tags: %s", opt_val);
|
||||
tfe_tags_log((char **)tag_id_array, n_tag_ids, "dst ip", logger);
|
||||
|
||||
for (int i = 0; i < n_tag_ids; i++)
|
||||
{
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
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);
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_DESTINATION_IP", tag_id_array[i], strlen(tag_id_array[i]), 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);
|
||||
memset(result_str, 0, sizeof(result_str));
|
||||
uuid_unparse(result[hit_cnt + hit_cnt_ip], result_str);
|
||||
TFE_LOG_INFO(logger, "Scan Dst TAGS, Hit scan ret: %d policy_id: %s addr: %s", scan_ret, result_str, stream->str_stream_info);
|
||||
hit_cnt_ip += scan_ret;
|
||||
}
|
||||
else
|
||||
@@ -255,28 +280,28 @@ int tfe_scan_ip_tags(const struct tfe_stream *stream, long long *result, struct
|
||||
return hit_cnt_ip;
|
||||
}
|
||||
|
||||
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)
|
||||
int tfe_scan_fqdn_tags(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
||||
{
|
||||
char opt_val[128]={0};
|
||||
long long tag_id_array[128]={0};
|
||||
uuid_t opt_val[128]={0};
|
||||
char tag_id_array[128][UUID_STRING_SIZE];
|
||||
int scan_ret = 0, hit_cnt_fqdn = 0, n_tag_ids = 0;
|
||||
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_FQDN_TAGS_IDS_ARR, opt_val, tag_id_array);
|
||||
n_tag_ids = tfe_get_entry_tags(stream, (enum tfe_cmsg_tlv_type)TFE_CMSG_FQDN_TAGS_IDS_ARR, opt_val, (char **)tag_id_array);
|
||||
if(n_tag_ids == 0)
|
||||
{
|
||||
TFE_LOG_DEBUG(logger, "fetch fqdn tags: NULL");
|
||||
return hit_cnt_fqdn;
|
||||
}
|
||||
TFE_LOG_DEBUG(logger, "fetch fqdn tags: %s", opt_val);
|
||||
tfe_tags_log((char **)tag_id_array, n_tag_ids, "fqdn", logger);
|
||||
|
||||
struct maat_hit_group hit_group;
|
||||
for (int i = 0; i < n_tag_ids; i++)
|
||||
{
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
hit_group.group_id=tag_id_array[i];
|
||||
scan_ret = scan_group(hit_group, result, scan_mid, hit_cnt, table_id);
|
||||
scan_ret = scan_string(result, scan_mid, hit_cnt, tag_id_array[i], "TSG_OBJ_FQDN", "ATTR_SERVER_FQDN");
|
||||
if (scan_ret > 0)
|
||||
{
|
||||
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);
|
||||
char result_str[UUID_STRING_SIZE]={0};
|
||||
uuid_unparse( result[hit_cnt + hit_cnt_fqdn], result_str);
|
||||
TFE_LOG_INFO(logger, "Scan Fqdn TAGS, Hit scan ret: %d policy_id: %s addr: %s", scan_ret, result_str, stream->str_stream_info);
|
||||
hit_cnt_fqdn += scan_ret;
|
||||
}
|
||||
else
|
||||
@@ -287,26 +312,22 @@ int tfe_scan_fqdn_tags(const struct tfe_stream *stream, long long *result, struc
|
||||
return hit_cnt_fqdn;
|
||||
}
|
||||
|
||||
int tfe_scan_app_id(long long *result, struct maat_state *scan_mid, int hit_cnt, long long app_id, int table_id)
|
||||
int tfe_scan_app_id(uuid_t *result, struct maat_state *scan_mid, int hit_cnt, long long app_id)
|
||||
{
|
||||
int scan_ret = 0;
|
||||
int hit_app_id = 0;
|
||||
size_t n_hit_result = 0;
|
||||
struct maat_hit_group hit_group;
|
||||
|
||||
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),
|
||||
(const char *)&app_id, sizeof(long long));
|
||||
|
||||
struct app_id_dict *app_dict = (struct app_id_dict*)maat_plugin_table_get_ex_data(tfe_get_maat_handle(), "APP_ID_DICT", (const char *)&app_id, sizeof(long long));
|
||||
if(app_dict!=NULL)
|
||||
{
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
hit_group.group_id=app_dict->group_id;
|
||||
scan_ret = maat_scan_group(tfe_get_maat_handle(), table_id, &hit_group, 1, result+hit_cnt+hit_app_id,
|
||||
MAX_SCAN_RESULT-hit_cnt-hit_app_id, &n_hit_result, scan_mid);
|
||||
scan_ret=maat_scan_integer(tfe_get_maat_handle(), "APP_ID_DICT", "ATTR_APP_ID", app_dict->object_id, result+hit_cnt+hit_app_id,
|
||||
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;
|
||||
}
|
||||
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);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "APP_ID_DICT", "ATTR_APP_ID", result+hit_cnt+hit_app_id, 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;
|
||||
@@ -316,7 +337,7 @@ int tfe_scan_app_id(long long *result, struct maat_state *scan_mid, int hit_cnt,
|
||||
return hit_app_id;
|
||||
}
|
||||
|
||||
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)
|
||||
int tfe_scan_value_by_cmsg(const struct tfe_stream *stream, enum tfe_cmsg_tlv_type tlv_type, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, const char *table_name, const char *attribute_name, char *opt_val)
|
||||
{
|
||||
uint16_t opt_out_size = 0;
|
||||
int hit_cnt_string=0;
|
||||
@@ -332,13 +353,13 @@ int tfe_scan_value_by_cmsg(const struct tfe_stream *stream, enum tfe_cmsg_tlv_ty
|
||||
{
|
||||
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,
|
||||
int scan_ret = maat_scan_string(tfe_get_maat_handle(), table_name, attribute_name, 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);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), table_name, attribute_name, 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;
|
||||
@@ -347,30 +368,30 @@ int tfe_scan_value_by_cmsg(const struct tfe_stream *stream, enum tfe_cmsg_tlv_ty
|
||||
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)
|
||||
int tfe_scan_device(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
||||
{
|
||||
char opt_val[4][128]={0};
|
||||
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);
|
||||
|
||||
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_IMSI_STR, result, scan_mid, hit_cnt, "TSG_OBJ_IMSI", "ATTR_GTP_IMSI", opt_val[0]);
|
||||
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);
|
||||
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_IMEI_STR, result, scan_mid, hit_cnt, "TSG_OBJ_IMEI","ATTR_GTP_IMEI", opt_val[1]);
|
||||
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);
|
||||
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_PHONE_NUM_STR, result, scan_mid, hit_cnt, "TSG_OBJ_PHONE_NUMBER","ATTR_GTP_PHONE_NUMBER", opt_val[2]);
|
||||
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);
|
||||
scan_ret = tfe_scan_value_by_cmsg(stream, TFE_CMSG_SRC_APN_STR, result, scan_mid, hit_cnt, "TSG_OBJ_APN", "ATTR_GTP_APN", opt_val[3]);
|
||||
if(scan_ret > 0)
|
||||
{
|
||||
htt_cnt_device += scan_ret;
|
||||
@@ -381,13 +402,13 @@ int tfe_scan_device(const struct tfe_stream *stream, long long *result, struct m
|
||||
return htt_cnt_device;
|
||||
}
|
||||
|
||||
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 tfe_scan_port(const struct tfe_stream *stream, uuid_t *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;
|
||||
|
||||
scan_ret=maat_scan_integer(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_PORT), ntohs(source),
|
||||
scan_ret=maat_scan_integer(tfe_get_maat_handle(), "TSG_OBJ_PORT", "ATTR_SOURCE_PORT", ntohs(source),
|
||||
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)
|
||||
{
|
||||
@@ -398,14 +419,14 @@ int tfe_scan_port(const struct tfe_stream *stream, long long *result, struct maa
|
||||
{
|
||||
hit_cnt_port+=scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_PORT),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_PORT", "ATTR_SOURCE_PORT",
|
||||
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;
|
||||
}
|
||||
|
||||
scan_ret=maat_scan_integer(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_PORT), ntohs(dest),
|
||||
scan_ret=maat_scan_integer(tfe_get_maat_handle(), "TSG_OBJ_PORT", "ATTR_DESTINATION_PORT", ntohs(dest),
|
||||
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)
|
||||
{
|
||||
@@ -416,8 +437,8 @@ int tfe_scan_port(const struct tfe_stream *stream, long long *result, struct maa
|
||||
{
|
||||
hit_cnt_port+=scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_PORT),
|
||||
result+hit_cnt+hit_cnt_port, MAX_SCAN_RESULT-hit_cnt-hit_cnt_port, &n_hit_result, scan_mid);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_PORT", "ATTR_DESTINATION_PORT", 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;
|
||||
@@ -426,30 +447,28 @@ int tfe_scan_port(const struct tfe_stream *stream, long long *result, struct maa
|
||||
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)
|
||||
#define PROTOCOL_TCP_UUID_ID "6"
|
||||
int tfe_scan_ipv4_addr(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, struct ipaddr sapp_addr)
|
||||
{
|
||||
int scan_ret = 0;
|
||||
int hit_cnt_ip = 0;
|
||||
size_t n_hit_result = 0;
|
||||
struct maat_hit_group hit_group;
|
||||
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
hit_group.group_id=PROTOCOL_TCP_GROUP_ID;
|
||||
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL), &hit_group, 1,
|
||||
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
||||
const char *protocol_uuid =PROTOCOL_TCP_UUID_ID;
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), "TSG_OBJ_IP_PROTOCOL", "ATTR_IP_PROTOCOL", protocol_uuid, strlen(protocol_uuid), 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;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL),
|
||||
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_PROTOCOL", "ATTR_IP_PROTOCOL", 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;
|
||||
}
|
||||
|
||||
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),
|
||||
|
||||
scan_ret = maat_scan_ipv4_port(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_SOURCE_IP", sapp_addr.v4->saddr, ntohs(sapp_addr.v4->source),
|
||||
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)
|
||||
{
|
||||
@@ -460,14 +479,14 @@ int tfe_scan_ipv4_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
{
|
||||
hit_cnt_ip += scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP),
|
||||
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_SOURCE_IP", 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;
|
||||
}
|
||||
|
||||
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),
|
||||
scan_ret = maat_scan_ipv4_port(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_DESTINATION_IP", sapp_addr.v4->daddr, ntohs(sapp_addr.v4->dest),
|
||||
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)
|
||||
{
|
||||
@@ -478,7 +497,7 @@ int tfe_scan_ipv4_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
{
|
||||
hit_cnt_ip += scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_DESTINATION_IP",
|
||||
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)
|
||||
{
|
||||
@@ -488,28 +507,26 @@ int tfe_scan_ipv4_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
return hit_cnt_ip;
|
||||
}
|
||||
|
||||
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)
|
||||
int tfe_scan_ipv6_addr(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, struct ipaddr sapp_addr)
|
||||
{
|
||||
int scan_ret = 0;
|
||||
int hit_cnt_ip = 0;
|
||||
size_t n_hit_result = 0;
|
||||
struct maat_hit_group hit_group;
|
||||
|
||||
memset(&hit_group, 0, sizeof(hit_group));
|
||||
hit_group.group_id=PROTOCOL_TCP_GROUP_ID;
|
||||
scan_ret = maat_scan_group(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL), &hit_group, 1,
|
||||
result+hit_cnt+hit_cnt_ip, MAX_SCAN_RESULT-hit_cnt-hit_cnt_ip, &n_hit_result, scan_mid);
|
||||
const char *protocol_uuid =PROTOCOL_TCP_UUID_ID;
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), "TSG_OBJ_IP_PROTOCOL", "ATTR_IP_PROTOCOL", protocol_uuid, strlen(protocol_uuid), 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;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_IP_PROTOCOL),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_PROTOCOL", "ATTR_IP_PROTOCOL",
|
||||
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;
|
||||
}
|
||||
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),
|
||||
scan_ret = maat_scan_ipv6_port(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_SOURCE_IP", sapp_addr.v6->saddr, ntohs(sapp_addr.v6->source),
|
||||
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)
|
||||
{
|
||||
@@ -520,14 +537,14 @@ int tfe_scan_ipv6_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
{
|
||||
hit_cnt_ip += scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SOURCE_IP),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_SOURCE_IP",
|
||||
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;
|
||||
}
|
||||
|
||||
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),
|
||||
scan_ret = maat_scan_ipv6_port(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_DESTINATION_IP", sapp_addr.v6->daddr, ntohs(sapp_addr.v6->dest),
|
||||
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)
|
||||
{
|
||||
@@ -538,7 +555,7 @@ int tfe_scan_ipv6_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
{
|
||||
hit_cnt_ip += scan_ret;
|
||||
}
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_DESTINATION_IP),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_IP_ADDR", "ATTR_DESTINATION_IP",
|
||||
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)
|
||||
{
|
||||
@@ -548,7 +565,7 @@ int tfe_scan_ipv6_addr(const struct tfe_stream *stream, long long *result, struc
|
||||
return hit_cnt_ip;
|
||||
}
|
||||
|
||||
int tfe_scan_subscribe_id(const struct tfe_stream *stream, long long *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
||||
int tfe_scan_subscribe_id(const struct tfe_stream *stream, uuid_t *result, struct maat_state *scan_mid, int hit_cnt, void *logger)
|
||||
{
|
||||
int scan_ret = 0;
|
||||
int hit_cnt_ip = 0;
|
||||
@@ -568,13 +585,15 @@ int tfe_scan_subscribe_id(const struct tfe_stream *stream, long long *result, st
|
||||
|
||||
if (strlen(source_subscribe_id))
|
||||
{
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), tfe_bussiness_tableid_get(PXY_CTRL_SUBSCRIBER_ID),
|
||||
scan_ret = maat_scan_string(tfe_get_maat_handle(), "TSG_OBJ_SUBSCRIBER_ID", "ATTR_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);
|
||||
char result_str[UUID_STRING_SIZE]={0};
|
||||
uuid_unparse(result[hit_cnt + hit_cnt_ip], result_str);
|
||||
TFE_LOG_INFO(logger, "Scan src TSG_OBJ_SUBSCRIBER_ID, Hit subid: %s scan ret: %d policy_id: %s addr: %s",
|
||||
source_subscribe_id, scan_ret, result_str, stream->str_stream_info);
|
||||
hit_cnt_ip += n_hit_result;
|
||||
}
|
||||
else
|
||||
@@ -582,7 +601,7 @@ int tfe_scan_subscribe_id(const struct tfe_stream *stream, long long *result, st
|
||||
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),
|
||||
scan_ret = maat_scan_not_logic(tfe_get_maat_handle(), "TSG_OBJ_SUBSCRIBER_ID", "ATTR_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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user