rename terminology "group" to "object"
This commit is contained in:
@@ -13,7 +13,7 @@ add_definitions(-D_GNU_SOURCE)
|
||||
add_definitions(-fPIC)
|
||||
set(MAAT_SRC alignment.c json2iris.c maat_api.c rcu_hash.c maat_garbage_collection.c maat_config_monitor.c
|
||||
maat_core.c maat_kv.c maat_ex_data.c maat_utils.c maat_command.c maat_redis_monitor.c maat_table.c
|
||||
maat_rule.c maat_group.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
|
||||
maat_rule.c maat_object.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
|
||||
maat_ip_plugin.c maat_ipport_plugin.c maat_bool_plugin.c maat_fqdn_plugin.c maat_attribute.c maat_stat.c)
|
||||
|
||||
set(LIB_SOURCE_FILES
|
||||
|
||||
@@ -44,7 +44,7 @@ extern "C"
|
||||
#define INVALID_VERSION -1
|
||||
|
||||
#define mr_region_id_var "SEQUENCE_REGION"
|
||||
#define mr_group_id_var "SEQUENCE_GROUP"
|
||||
#define mr_object_id_var "SEQUENCE_OBJECT"
|
||||
|
||||
enum tag_match {
|
||||
TAG_MATCH_ERR = -1,
|
||||
@@ -54,7 +54,7 @@ enum tag_match {
|
||||
|
||||
struct maat_item {
|
||||
long long item_id;
|
||||
long long group_id;
|
||||
long long object_id;
|
||||
};
|
||||
|
||||
struct maat_runtime {
|
||||
@@ -121,7 +121,7 @@ struct maat_options {
|
||||
int stat_on;
|
||||
int perf_on;
|
||||
int hit_path_on;
|
||||
int hit_group_on;
|
||||
int hit_object_on;
|
||||
int deferred_load_on;
|
||||
|
||||
int maat_json_is_gzipped;
|
||||
|
||||
@@ -45,9 +45,9 @@ long long expr_runtime_get_version(void *expr_runtime);
|
||||
|
||||
/* expr runtime scan API */
|
||||
/**
|
||||
* @brief scan string to get hit group_ids
|
||||
* @brief scan string to get hit object_ids
|
||||
*
|
||||
* @retval the num of hit group_id
|
||||
* @retval the num of hit object_id
|
||||
*/
|
||||
int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id, const char *data,
|
||||
size_t data_len, int attribute_id, struct maat_state *state);
|
||||
|
||||
@@ -43,9 +43,9 @@ long long flag_runtime_rule_count(void *flag_runtime);
|
||||
|
||||
/* flag runtime scan API */
|
||||
/**
|
||||
* @brief scan flag to get hit group_ids
|
||||
* @brief scan flag to get hit object_ids
|
||||
*
|
||||
* @retval the num of hit group_id
|
||||
* @retval the num of hit object_id
|
||||
*/
|
||||
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id, long long flag,
|
||||
int attribute_id, struct maat_state *state);
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: maat_group.h
|
||||
* Description:
|
||||
* Authors: Liu wentan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-10-31
|
||||
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _MAAT_GROUP_H_
|
||||
#define _MAAT_GROUP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cJSON/cJSON.h"
|
||||
#include "maat_kv.h"
|
||||
#include "maat_table.h"
|
||||
|
||||
struct maat_group;
|
||||
struct group2group_runtime;
|
||||
|
||||
/* group2group schema API */
|
||||
void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger);
|
||||
void group2group_schema_free(void *g2g_schema);
|
||||
|
||||
/* group2group runtime API */
|
||||
void *group2group_runtime_new(void *g2g_schema, size_t max_thread_num,
|
||||
struct maat_garbage_bin *garbage_bin,
|
||||
struct log_handle *logger);
|
||||
void group2group_runtime_free(void *g2g_runtime);
|
||||
|
||||
int group2group_runtime_update(void *g2g_runtime, void *g2g_schema, const char *table_name,
|
||||
const char *line, int valid_column);
|
||||
|
||||
int group2group_runtime_commit(void *g2g_runtime, const char *table_name, long long maat_rt_version);
|
||||
|
||||
size_t group2group_runtime_get_super_groups(void *g2g_runtime, long long *group_ids,
|
||||
size_t n_group_ids, long long *super_group_ids,
|
||||
size_t super_group_ids_size);
|
||||
|
||||
long long group2group_runtime_rule_count(void *g2g_runtime);
|
||||
|
||||
long long group2group_runtime_exclude_rule_count(void *g2g_runtime);
|
||||
|
||||
long long group2group_runtime_update_err_count(void *g2g_runtime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -44,9 +44,9 @@ long long interval_runtime_rule_count(void *interval_runtime);
|
||||
|
||||
/* interval runtime scan API */
|
||||
/**
|
||||
* @brief scan interval to get hit group_ids
|
||||
* @brief scan interval to get hit object_ids
|
||||
*
|
||||
* @retval the num of hit group_id
|
||||
* @retval the num of hit object_id
|
||||
*/
|
||||
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
|
||||
long long integer, int attribute_id, struct maat_state *state);
|
||||
|
||||
@@ -22,8 +22,8 @@ extern "C"
|
||||
#define MAX_NAME_STR_LEN 128
|
||||
#define MAX_IP_STR_LEN 64
|
||||
#define MAX_INSTANCE_NAME_LEN 15
|
||||
#define MAX_GROUP_IDS_STR_LEN 256
|
||||
#define MAX_GROUP_CNT 128
|
||||
#define MAX_OBJECT_IDS_STR_LEN 256
|
||||
#define MAX_OBJECT_CNT 128
|
||||
#define MAX_CONJ_PARENTS_NUM 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
58
src/inc_internal/maat_object.h
Normal file
58
src/inc_internal/maat_object.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: maat_object.h
|
||||
* Description:
|
||||
* Authors: Liu wentan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-10-31
|
||||
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _MAAT_OBJECT_H_
|
||||
#define _MAAT_OBJECT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cJSON/cJSON.h"
|
||||
#include "maat_kv.h"
|
||||
#include "maat_table.h"
|
||||
|
||||
struct maat_object;
|
||||
struct object2object_runtime;
|
||||
|
||||
/* object2object schema API */
|
||||
void *object2object_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger);
|
||||
void object2object_schema_free(void *g2g_schema);
|
||||
|
||||
/* object2object runtime API */
|
||||
void *object2object_runtime_new(void *g2g_schema, size_t max_thread_num,
|
||||
struct maat_garbage_bin *garbage_bin,
|
||||
struct log_handle *logger);
|
||||
void object2object_runtime_free(void *g2g_runtime);
|
||||
|
||||
int object2object_runtime_update(void *g2g_runtime, void *g2g_schema, const char *table_name,
|
||||
const char *line, int valid_column);
|
||||
|
||||
int object2object_runtime_commit(void *g2g_runtime, const char *table_name, long long maat_rt_version);
|
||||
|
||||
size_t object2object_runtime_get_super_objects(void *g2g_runtime, long long *object_ids,
|
||||
size_t n_object_ids, long long *super_object_ids,
|
||||
size_t super_object_ids_size);
|
||||
|
||||
long long object2object_runtime_rule_count(void *g2g_runtime);
|
||||
|
||||
long long object2object_runtime_exclude_rule_count(void *g2g_runtime);
|
||||
|
||||
long long object2object_runtime_update_err_count(void *g2g_runtime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -25,17 +25,17 @@ extern "C"
|
||||
struct rule_schema;
|
||||
struct rule_runtime;
|
||||
struct rule_state;
|
||||
struct group2group_runtime;
|
||||
struct object2object_runtime;
|
||||
|
||||
/* rule schema API */
|
||||
void *rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger);
|
||||
void rule_schema_free(void *rule_schema);
|
||||
|
||||
void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
void *object2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
const char *table_name, struct log_handle *logger);
|
||||
void group2rule_schema_free(void *g2c_schema);
|
||||
int group2rule_associated_rule_table_id(void *g2c_schema);
|
||||
void object2rule_schema_free(void *g2c_schema);
|
||||
int object2rule_associated_rule_table_id(void *g2c_schema);
|
||||
|
||||
/* rule runtime API */
|
||||
void *rule_runtime_new(void *rule_schema, size_t max_thread_num,
|
||||
@@ -64,24 +64,24 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
|
||||
struct maat_hit_path *hit_path_array,
|
||||
size_t array_size, size_t n_hit_path);
|
||||
|
||||
/* group2rule runtime API */
|
||||
void *group2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
|
||||
/* object2rule runtime API */
|
||||
void *object2rule_runtime_new(void *g2c_schema, size_t max_thread_num,
|
||||
struct maat_garbage_bin *garbage_bin,
|
||||
struct log_handle *logger);
|
||||
|
||||
void group2rule_runtime_init(void *g2c_runtime, void *rule_runtime);
|
||||
void object2rule_runtime_init(void *g2c_runtime, void *rule_runtime);
|
||||
|
||||
void group2rule_runtime_free(void *g2c_runtime);
|
||||
void object2rule_runtime_free(void *g2c_runtime);
|
||||
|
||||
int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
|
||||
int object2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
|
||||
const char *table_name, const char *line,
|
||||
int valid_column);
|
||||
|
||||
long long group2rule_runtime_not_condition_count(void *g2c_runtime);
|
||||
long long object2rule_runtime_not_condition_count(void *g2c_runtime);
|
||||
|
||||
long long group2rule_runtime_rule_count(void *g2c_runtime);
|
||||
long long object2rule_runtime_rule_count(void *g2c_runtime);
|
||||
|
||||
long long group2rule_runtime_update_err_count(void *g2c_runtime);
|
||||
long long object2rule_runtime_update_err_count(void *g2c_runtime);
|
||||
|
||||
/* maat rule state API */
|
||||
struct rule_state;
|
||||
@@ -96,7 +96,7 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
|
||||
int attribute_id, int custom_rule_tbl_id, int Nth_scan,
|
||||
struct maat_item *hit_items, size_t n_hit_item);
|
||||
|
||||
void rule_state_clear_last_hit_group(struct rule_state *rule_state);
|
||||
void rule_state_clear_last_hit_object(struct rule_state *rule_state);
|
||||
|
||||
void rule_state_not_logic_update(struct rule_state *rule_state,
|
||||
struct rule_runtime *rule_rt,
|
||||
@@ -105,27 +105,27 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
|
||||
|
||||
size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
|
||||
struct rule_runtime *rule_rt,
|
||||
struct group2group_runtime *g2g_rt,
|
||||
struct object2object_runtime *g2g_rt,
|
||||
struct maat_hit_path *hit_path_array,
|
||||
size_t array_size);
|
||||
|
||||
size_t rule_state_get_direct_hit_groups(struct rule_state *rule_state,
|
||||
struct maat_hit_group *group_array,
|
||||
size_t rule_state_get_direct_hit_objects(struct rule_state *rule_state,
|
||||
struct maat_hit_object *object_array,
|
||||
size_t array_size);
|
||||
|
||||
size_t rule_state_get_direct_hit_group_cnt(struct rule_state *rule_state);
|
||||
size_t rule_state_get_direct_hit_object_cnt(struct rule_state *rule_state);
|
||||
|
||||
size_t rule_state_get_indirect_hit_groups(struct rule_state *rule_state,
|
||||
struct maat_hit_group *group_array,
|
||||
size_t rule_state_get_indirect_hit_objects(struct rule_state *rule_state,
|
||||
struct maat_hit_object *object_array,
|
||||
size_t array_size);
|
||||
|
||||
size_t rule_state_get_indirect_hit_group_cnt(struct rule_state *rule_state);
|
||||
size_t rule_state_get_indirect_hit_object_cnt(struct rule_state *rule_state);
|
||||
|
||||
size_t rule_state_get_last_hit_groups(struct rule_state *rule_state,
|
||||
struct maat_hit_group *group_arary,
|
||||
size_t rule_state_get_last_hit_objects(struct rule_state *rule_state,
|
||||
struct maat_hit_object *object_arary,
|
||||
size_t array_size);
|
||||
|
||||
size_t rule_state_get_last_hit_group_cnt(struct rule_state *rule_state);
|
||||
size_t rule_state_get_last_hit_object_cnt(struct rule_state *rule_state);
|
||||
|
||||
int rule_state_get_rule_table_id(struct rule_state *rule_state,
|
||||
long long rule_id);
|
||||
|
||||
@@ -40,8 +40,8 @@ enum table_type {
|
||||
//above are physical table
|
||||
TABLE_TYPE_ATTRIBUTE,
|
||||
TABLE_TYPE_RULE,
|
||||
TABLE_TYPE_GROUP2GROUP,
|
||||
TABLE_TYPE_GROUP2RULE,
|
||||
TABLE_TYPE_OBJECT2OBJECT,
|
||||
TABLE_TYPE_OBJECT2RULE,
|
||||
TABLE_TYPE_MAX
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ const char *table_manager_get_table_schema_tag(struct table_manager *tbl_mgr, in
|
||||
enum table_type table_manager_get_table_type(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr);
|
||||
int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr);
|
||||
int table_manager_get_object2object_table_id(struct table_manager *tbl_mgr);
|
||||
|
||||
int table_manager_get_valid_column(struct table_manager *tbl_mgr, int table_id);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ extern "C"
|
||||
|
||||
#define MAX_HIT_PATH_NUM 4096
|
||||
#define MAX_HIT_RULE_NUM 4096
|
||||
#define MAX_HIT_GROUP_NUM 4096
|
||||
#define MAX_HIT_OBJECT_NUM 4096
|
||||
#define MAX_HIT_ITEM_NUM 4096
|
||||
|
||||
#define IPV4 4
|
||||
|
||||
466
src/json2iris.c
466
src/json2iris.c
@@ -28,22 +28,22 @@
|
||||
#define MAX_COLUMN_NUM 32
|
||||
#define MAX_PATH_LINE 512
|
||||
#define MAX_BUFF_LEN 4096
|
||||
#define MAX_GROUP_ID_STR 128
|
||||
#define MAX_OBJECT_ID_STR 128
|
||||
|
||||
const int json_version = 1;
|
||||
const char *untitled_group_name = "Untitled";
|
||||
long long untitled_group_id = 123456789;
|
||||
const char *untitled_object_name = "Untitled";
|
||||
long long untitled_object_id = 123456789;
|
||||
|
||||
enum maat_group_relation {
|
||||
enum maat_object_relation {
|
||||
PARENT_TYPE_RULE = 0,
|
||||
PARENT_TYPE_GROUP
|
||||
PARENT_TYPE_OBJECT
|
||||
};
|
||||
|
||||
struct group_info {
|
||||
int group_id;
|
||||
char group_name[NAME_MAX];
|
||||
UT_array *incl_sub_group_ids;
|
||||
UT_array *excl_sub_group_ids;
|
||||
struct object_info {
|
||||
int object_id;
|
||||
char object_name[NAME_MAX];
|
||||
UT_array *incl_sub_object_ids;
|
||||
UT_array *excl_sub_object_ids;
|
||||
UT_hash_handle hh;
|
||||
};
|
||||
|
||||
@@ -59,19 +59,19 @@ struct iris_table {
|
||||
};
|
||||
|
||||
struct iris_description {
|
||||
int group_cnt;
|
||||
int object_cnt;
|
||||
int region_cnt;
|
||||
|
||||
char tmp_iris_dir[MAX_PATH_LINE];
|
||||
char tmp_iris_index_dir[MAX_PATH_LINE];
|
||||
char index_path[PATH_MAX];
|
||||
|
||||
struct iris_table *group_table;
|
||||
struct iris_table *group2group_table;
|
||||
struct iris_table *group2rule_table;
|
||||
struct iris_table *object_table;
|
||||
struct iris_table *object2object_table;
|
||||
struct iris_table *object2rule_table;
|
||||
struct iris_table *rule_table;
|
||||
|
||||
struct group_info *group_name_map;
|
||||
struct object_info *object_name_map;
|
||||
struct iris_table *iris_table_map;
|
||||
|
||||
struct maat_kv_store *str2int_map;
|
||||
@@ -130,8 +130,8 @@ static void free_iris_table_info(void *p)
|
||||
static int
|
||||
set_iris_descriptor(const char *json_file, cJSON *json,
|
||||
const char *encrypt_key, const char *encrypt_algo,
|
||||
const char *rule_tn, const char *group2rule_tn,
|
||||
const char* group2group_tn, redisContext *redis_write_ctx,
|
||||
const char *rule_tn, const char *object2rule_tn,
|
||||
const char* object2object_tn, redisContext *redis_write_ctx,
|
||||
struct iris_description *iris_cfg)
|
||||
{
|
||||
memset(iris_cfg, 0, sizeof(struct iris_description));
|
||||
@@ -183,10 +183,10 @@ set_iris_descriptor(const char *json_file, cJSON *json,
|
||||
|
||||
iris_cfg->rule_table = query_table_info(iris_cfg, rule_tn,
|
||||
TABLE_TYPE_RULE);
|
||||
iris_cfg->group2rule_table = query_table_info(iris_cfg, group2rule_tn,
|
||||
TABLE_TYPE_GROUP2RULE);
|
||||
iris_cfg->group2group_table = query_table_info(iris_cfg, group2group_tn,
|
||||
TABLE_TYPE_GROUP2GROUP);
|
||||
iris_cfg->object2rule_table = query_table_info(iris_cfg, object2rule_tn,
|
||||
TABLE_TYPE_OBJECT2RULE);
|
||||
iris_cfg->object2object_table = query_table_info(iris_cfg, object2object_tn,
|
||||
TABLE_TYPE_OBJECT2OBJECT);
|
||||
|
||||
if (encrypt_key && encrypt_algo) {
|
||||
iris_cfg->encrypt_key = maat_strdup(encrypt_key);
|
||||
@@ -198,21 +198,21 @@ set_iris_descriptor(const char *json_file, cJSON *json,
|
||||
|
||||
static void clear_iris_descriptor(struct iris_description *iris_cfg)
|
||||
{
|
||||
if (iris_cfg->group_name_map != NULL) {
|
||||
struct group_info *node = NULL;
|
||||
struct group_info *tmp = NULL;
|
||||
HASH_ITER(hh, iris_cfg->group_name_map, node, tmp) {
|
||||
if (node->incl_sub_group_ids != NULL) {
|
||||
utarray_free(node->incl_sub_group_ids);
|
||||
node->incl_sub_group_ids = NULL;
|
||||
if (iris_cfg->object_name_map != NULL) {
|
||||
struct object_info *node = NULL;
|
||||
struct object_info *tmp = NULL;
|
||||
HASH_ITER(hh, iris_cfg->object_name_map, node, tmp) {
|
||||
if (node->incl_sub_object_ids != NULL) {
|
||||
utarray_free(node->incl_sub_object_ids);
|
||||
node->incl_sub_object_ids = NULL;
|
||||
}
|
||||
|
||||
if (node->excl_sub_group_ids != NULL) {
|
||||
utarray_free(node->excl_sub_group_ids);
|
||||
node->excl_sub_group_ids = NULL;
|
||||
if (node->excl_sub_object_ids != NULL) {
|
||||
utarray_free(node->excl_sub_object_ids);
|
||||
node->excl_sub_object_ids = NULL;
|
||||
}
|
||||
|
||||
HASH_DELETE(hh, iris_cfg->group_name_map, node);
|
||||
HASH_DELETE(hh, iris_cfg->object_name_map, node);
|
||||
FREE(node);
|
||||
}
|
||||
}
|
||||
@@ -301,31 +301,31 @@ write_plugin_line(cJSON *plug_table_json, int sequence,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct group_info *group_info_read(struct group_info *group_name_map,
|
||||
const char *group_name)
|
||||
static struct object_info *object_info_read(struct object_info *object_name_map,
|
||||
const char *object_name)
|
||||
{
|
||||
struct group_info *node = NULL;
|
||||
HASH_FIND(hh, group_name_map, group_name, strlen(group_name), node);
|
||||
struct object_info *node = NULL;
|
||||
HASH_FIND(hh, object_name_map, object_name, strlen(object_name), node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
UT_icd ut_json2iris_group_id_icd = {sizeof(int), NULL, NULL, NULL};
|
||||
static struct group_info *
|
||||
group_info_add_unsafe(struct iris_description *p_iris, const char *group_name,
|
||||
long long group_id)
|
||||
UT_icd ut_json2iris_object_id_icd = {sizeof(int), NULL, NULL, NULL};
|
||||
static struct object_info *
|
||||
object_info_add_unsafe(struct iris_description *p_iris, const char *object_name,
|
||||
long long object_id)
|
||||
{
|
||||
struct group_info *group_info = ALLOC(struct group_info, 1);
|
||||
utarray_new(group_info->incl_sub_group_ids, &ut_json2iris_group_id_icd);
|
||||
utarray_new(group_info->excl_sub_group_ids, &ut_json2iris_group_id_icd);
|
||||
struct object_info *object_info = ALLOC(struct object_info, 1);
|
||||
utarray_new(object_info->incl_sub_object_ids, &ut_json2iris_object_id_icd);
|
||||
utarray_new(object_info->excl_sub_object_ids, &ut_json2iris_object_id_icd);
|
||||
|
||||
group_info->group_id = group_id;
|
||||
strncpy(group_info->group_name, group_name, sizeof(group_info->group_name));
|
||||
object_info->object_id = object_id;
|
||||
strncpy(object_info->object_name, object_name, sizeof(object_info->object_name));
|
||||
|
||||
HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name,
|
||||
strlen(group_name), group_info);
|
||||
HASH_ADD_KEYPTR(hh, p_iris->object_name_map, object_info->object_name,
|
||||
strlen(object_name), object_info);
|
||||
|
||||
return group_info;
|
||||
return object_info;
|
||||
}
|
||||
|
||||
static int get_region_seq(struct iris_description *iris_cfg)
|
||||
@@ -435,7 +435,7 @@ write_flag_line(cJSON *region_json, struct iris_description *p_iris,
|
||||
json_cmd[cmd_cnt].json_type=cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string = "group_id";
|
||||
json_cmd[cmd_cnt].json_string = "object_id";
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
@@ -473,7 +473,7 @@ write_expr_line(cJSON *region_json, struct iris_description *p_iris,
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string = "group_id";
|
||||
json_cmd[cmd_cnt].json_string = "object_id";
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
@@ -512,7 +512,7 @@ write_ip_line(cJSON *region_json, struct iris_description *p_iris,
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string = "group_id";
|
||||
json_cmd[cmd_cnt].json_string = "object_id";
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
@@ -548,7 +548,7 @@ write_interval_line(cJSON *region_json, struct iris_description *p_iris,
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string = "group_id";
|
||||
json_cmd[cmd_cnt].json_string = "object_id";
|
||||
json_cmd[cmd_cnt].json_type = cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
@@ -571,7 +571,7 @@ write_interval_line(cJSON *region_json, struct iris_description *p_iris,
|
||||
}
|
||||
|
||||
static int
|
||||
write_region_rule(cJSON *region_json, int rule_id, int group_id,
|
||||
write_region_rule(cJSON *region_json, int rule_id, int object_id,
|
||||
struct iris_description *p_iris, struct log_handle *logger)
|
||||
{
|
||||
cJSON *item = cJSON_GetObjectItem(region_json, "table_name");
|
||||
@@ -613,7 +613,7 @@ write_region_rule(cJSON *region_json, int rule_id, int group_id,
|
||||
|
||||
int region_id = get_region_seq(p_iris);
|
||||
cJSON_AddNumberToObject(table_content, "region_id", region_id);
|
||||
cJSON_AddNumberToObject(table_content, "group_id", group_id);
|
||||
cJSON_AddNumberToObject(table_content, "object_id", object_id);
|
||||
cJSON_AddNumberToObject(table_content, "is_valid", 1);
|
||||
|
||||
struct iris_table *table_info = query_table_info(p_iris, table_name,
|
||||
@@ -642,8 +642,8 @@ write_region_rule(cJSON *region_json, int rule_id, int group_id,
|
||||
}
|
||||
|
||||
static int
|
||||
write_group2rule_line(int *group_ids, size_t n_group_id,
|
||||
int rule_id, int group_negate_option,
|
||||
write_object2rule_line(int *object_ids, size_t n_object_id,
|
||||
int rule_id, int object_negate_option,
|
||||
int condition_index, const char *attribute,
|
||||
struct iris_description *p_iris,
|
||||
struct iris_table *g2c_table)
|
||||
@@ -654,26 +654,26 @@ write_group2rule_line(int *group_ids, size_t n_group_id,
|
||||
if (g2c_table != NULL) {
|
||||
table = g2c_table;
|
||||
} else {
|
||||
if (NULL == p_iris->group2rule_table) {
|
||||
if (NULL == p_iris->object2rule_table) {
|
||||
return -1;
|
||||
}
|
||||
table = p_iris->group2rule_table;
|
||||
table = p_iris->object2rule_table;
|
||||
}
|
||||
|
||||
if (n_group_id > 1) {
|
||||
if (n_object_id > 1) {
|
||||
char tmp_str[64] = {0};
|
||||
char group_id_str[2048] = {0};
|
||||
char object_id_str[2048] = {0};
|
||||
|
||||
for (size_t i = 0; i < n_group_id; i++) {
|
||||
snprintf(tmp_str, sizeof(tmp_str), "%d,", group_ids[i]);
|
||||
strcat(group_id_str, tmp_str);
|
||||
for (size_t i = 0; i < n_object_id; i++) {
|
||||
snprintf(tmp_str, sizeof(tmp_str), "%d,", object_ids[i]);
|
||||
strcat(object_id_str, tmp_str);
|
||||
}
|
||||
group_id_str[strlen(group_id_str) - 1] = '\0';
|
||||
snprintf(buff, sizeof(buff), "%s\t%d\t%d\t%s\t%d\t1\n", group_id_str,
|
||||
rule_id, group_negate_option, attribute, condition_index);
|
||||
object_id_str[strlen(object_id_str) - 1] = '\0';
|
||||
snprintf(buff, sizeof(buff), "%s\t%d\t%d\t%s\t%d\t1\n", object_id_str,
|
||||
rule_id, object_negate_option, attribute, condition_index);
|
||||
} else {
|
||||
snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", group_ids[0],
|
||||
rule_id, group_negate_option, attribute, condition_index);
|
||||
snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", object_ids[0],
|
||||
rule_id, object_negate_option, attribute, condition_index);
|
||||
}
|
||||
|
||||
table->write_pos += memcat(&(table->buff), table->write_pos,
|
||||
@@ -684,60 +684,60 @@ write_group2rule_line(int *group_ids, size_t n_group_id,
|
||||
}
|
||||
|
||||
static int
|
||||
write_group2group_line(int group_id, UT_array *incl_sub_group_ids,
|
||||
UT_array *excl_sub_group_ids,
|
||||
write_object2object_line(int object_id, UT_array *incl_sub_object_ids,
|
||||
UT_array *excl_sub_object_ids,
|
||||
struct iris_description *p_iris)
|
||||
{
|
||||
char buff[MAX_BUFF_LEN*4] = {0};
|
||||
struct iris_table *table = p_iris->group2group_table;
|
||||
struct iris_table *table = p_iris->object2object_table;
|
||||
if (NULL == table) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t i = 0, pos = 0;
|
||||
char incl_sub_group_id_str[MAX_BUFF_LEN] = {0};
|
||||
char excl_sub_group_id_str[MAX_BUFF_LEN] = {0};
|
||||
char incl_sub_object_id_str[MAX_BUFF_LEN] = {0};
|
||||
char excl_sub_object_id_str[MAX_BUFF_LEN] = {0};
|
||||
|
||||
if (0 == utarray_len(incl_sub_group_ids) &&
|
||||
0 == utarray_len(excl_sub_group_ids)) {
|
||||
if (0 == utarray_len(incl_sub_object_ids) &&
|
||||
0 == utarray_len(excl_sub_object_ids)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int *tmp_id = NULL;
|
||||
char tmp_str[MAX_GROUP_ID_STR] = {0};
|
||||
for (i = 0; i < utarray_len(incl_sub_group_ids); i++) {
|
||||
tmp_id = (int *)utarray_eltptr(incl_sub_group_ids, i);
|
||||
char tmp_str[MAX_OBJECT_ID_STR] = {0};
|
||||
for (i = 0; i < utarray_len(incl_sub_object_ids); i++) {
|
||||
tmp_id = (int *)utarray_eltptr(incl_sub_object_ids, i);
|
||||
sprintf(tmp_str, "%d,", *tmp_id);
|
||||
sprintf(incl_sub_group_id_str + pos, "%s", tmp_str);
|
||||
sprintf(incl_sub_object_id_str + pos, "%s", tmp_str);
|
||||
pos += strlen(tmp_str);
|
||||
}
|
||||
|
||||
const char *null_str = "null";
|
||||
size_t str_len = strlen(incl_sub_group_id_str);
|
||||
size_t str_len = strlen(incl_sub_object_id_str);
|
||||
if (str_len > 0) {
|
||||
incl_sub_group_id_str[str_len - 1] = '\0';
|
||||
incl_sub_object_id_str[str_len - 1] = '\0';
|
||||
} else {
|
||||
memcpy(incl_sub_group_id_str, null_str, strlen(null_str));
|
||||
memcpy(incl_sub_object_id_str, null_str, strlen(null_str));
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
memset(tmp_str, 0, sizeof(tmp_str));
|
||||
for (i = 0; i < utarray_len(excl_sub_group_ids); i++) {
|
||||
tmp_id = (int *)utarray_eltptr(excl_sub_group_ids, i);
|
||||
for (i = 0; i < utarray_len(excl_sub_object_ids); i++) {
|
||||
tmp_id = (int *)utarray_eltptr(excl_sub_object_ids, i);
|
||||
sprintf(tmp_str, "%d,", *tmp_id);
|
||||
sprintf(excl_sub_group_id_str + pos, "%s", tmp_str);
|
||||
sprintf(excl_sub_object_id_str + pos, "%s", tmp_str);
|
||||
pos += strlen(tmp_str);
|
||||
}
|
||||
|
||||
str_len = strlen(excl_sub_group_id_str);
|
||||
str_len = strlen(excl_sub_object_id_str);
|
||||
if (str_len > 0) {
|
||||
excl_sub_group_id_str[str_len - 1] = '\0';
|
||||
excl_sub_object_id_str[str_len - 1] = '\0';
|
||||
} else {
|
||||
memcpy(excl_sub_group_id_str, null_str, strlen(null_str));
|
||||
memcpy(excl_sub_object_id_str, null_str, strlen(null_str));
|
||||
}
|
||||
|
||||
snprintf(buff, sizeof(buff), "%d\t%s\t%s\t1\n", group_id,
|
||||
incl_sub_group_id_str, excl_sub_group_id_str);
|
||||
snprintf(buff, sizeof(buff), "%d\t%s\t%s\t1\n", object_id,
|
||||
incl_sub_object_id_str, excl_sub_object_id_str);
|
||||
|
||||
table->write_pos += memcat(&(table->buff), table->write_pos,
|
||||
&(table->buff_sz), buff, strlen(buff));
|
||||
@@ -747,119 +747,119 @@ write_group2group_line(int group_id, UT_array *incl_sub_group_ids,
|
||||
}
|
||||
|
||||
static int
|
||||
write_group_rule(cJSON *group_json, int parent_id,
|
||||
write_object_rule(cJSON *object_json, int parent_id,
|
||||
int parent_type, int tracking_rule_id,
|
||||
int Nth_group, struct iris_description *p_iris,
|
||||
int Nth_object, struct iris_description *p_iris,
|
||||
struct log_handle *logger)
|
||||
{
|
||||
int ret = 0;
|
||||
int group_negate_option = 0;
|
||||
int object_negate_option = 0;
|
||||
int condition_index = 0;
|
||||
const char *group_name = NULL;
|
||||
char group_name_array[32][MAX_NAME_STR_LEN];
|
||||
size_t group_name_cnt = 0;
|
||||
long long group_id = -1;
|
||||
const char *object_name = NULL;
|
||||
char object_name_array[32][MAX_NAME_STR_LEN];
|
||||
size_t object_name_cnt = 0;
|
||||
long long object_id = -1;
|
||||
const char *attribute = NULL;
|
||||
struct iris_table *g2c_table = NULL;
|
||||
|
||||
cJSON *item = cJSON_GetObjectItem(group_json, "group_name");
|
||||
cJSON *item = cJSON_GetObjectItem(object_json, "object_name");
|
||||
if (NULL == item) {
|
||||
group_name = untitled_group_name;
|
||||
object_name = untitled_object_name;
|
||||
} else if (item->type == cJSON_String) {
|
||||
group_name = item->valuestring;
|
||||
object_name = item->valuestring;
|
||||
} else if (item->type == cJSON_Array) {
|
||||
group_name_cnt = cJSON_GetArraySize(item);
|
||||
assert(group_name_cnt <= 32);
|
||||
for (size_t i = 0; i < group_name_cnt; i++) {
|
||||
object_name_cnt = cJSON_GetArraySize(item);
|
||||
assert(object_name_cnt <= 32);
|
||||
for (size_t i = 0; i < object_name_cnt; i++) {
|
||||
cJSON *tmp_json = cJSON_GetArrayItem(item, i);
|
||||
if (NULL == tmp_json || tmp_json->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] group_name of rule:%d format error",
|
||||
"[%s:%d] object_name of rule:%d format error",
|
||||
__FUNCTION__, __LINE__, parent_id);
|
||||
return -1;
|
||||
}
|
||||
memset(group_name_array[i], 0, sizeof(group_name_array[i]));
|
||||
memcpy(group_name_array[i], tmp_json->valuestring,
|
||||
memset(object_name_array[i], 0, sizeof(object_name_array[i]));
|
||||
memcpy(object_name_array[i], tmp_json->valuestring,
|
||||
strlen(tmp_json->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(group_json, "group_id");
|
||||
item = cJSON_GetObjectItem(object_json, "object_id");
|
||||
if (item != NULL && item->type == cJSON_Number) {
|
||||
group_id = item->valueint;
|
||||
object_id = item->valueint;
|
||||
}
|
||||
|
||||
if (parent_type == PARENT_TYPE_RULE) {
|
||||
item = cJSON_GetObjectItem(group_json, "attribute");
|
||||
item = cJSON_GetObjectItem(object_json, "attribute");
|
||||
if (NULL == item || item->type != cJSON_String) {
|
||||
attribute = "null";
|
||||
} else {
|
||||
attribute = item->valuestring;
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(group_json, "negate_option");
|
||||
item = cJSON_GetObjectItem(object_json, "negate_option");
|
||||
if (NULL == item || item->type != cJSON_Number) {
|
||||
group_negate_option = 0;
|
||||
object_negate_option = 0;
|
||||
} else {
|
||||
group_negate_option = item->valueint;
|
||||
object_negate_option = item->valueint;
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(group_json, "condition_index");
|
||||
item = cJSON_GetObjectItem(object_json, "condition_index");
|
||||
if (NULL == item || item->type != cJSON_Number) {
|
||||
condition_index = Nth_group;
|
||||
condition_index = Nth_object;
|
||||
} else {
|
||||
condition_index = item->valueint;
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(group_json, "g2c_table_name");
|
||||
item = cJSON_GetObjectItem(object_json, "g2c_table_name");
|
||||
if (item != NULL && item->type == cJSON_String) {
|
||||
g2c_table = query_table_info(p_iris, item->valuestring,
|
||||
TABLE_TYPE_GROUP2RULE);
|
||||
TABLE_TYPE_OBJECT2RULE);
|
||||
}
|
||||
}
|
||||
|
||||
if (group_name_cnt > 0) {
|
||||
int group_ids[group_name_cnt];
|
||||
for (size_t i = 0; i < group_name_cnt; i++) {
|
||||
struct group_info *group_info =
|
||||
group_info_read(p_iris->group_name_map, group_name_array[i]);
|
||||
if (NULL == group_info) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] group_name:%s"
|
||||
" has no group_id", __FUNCTION__, __LINE__,
|
||||
group_name_array[i]);
|
||||
if (object_name_cnt > 0) {
|
||||
int object_ids[object_name_cnt];
|
||||
for (size_t i = 0; i < object_name_cnt; i++) {
|
||||
struct object_info *object_info =
|
||||
object_info_read(p_iris->object_name_map, object_name_array[i]);
|
||||
if (NULL == object_info) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] object_name:%s"
|
||||
" has no object_id", __FUNCTION__, __LINE__,
|
||||
object_name_array[i]);
|
||||
return -1;
|
||||
}
|
||||
group_ids[i] = group_info->group_id;
|
||||
object_ids[i] = object_info->object_id;
|
||||
}
|
||||
assert(parent_type == PARENT_TYPE_RULE);
|
||||
ret = write_group2rule_line(group_ids, group_name_cnt, parent_id,
|
||||
group_negate_option, condition_index,
|
||||
ret = write_object2rule_line(object_ids, object_name_cnt, parent_id,
|
||||
object_negate_option, condition_index,
|
||||
attribute, p_iris, g2c_table);
|
||||
|
||||
} else {
|
||||
struct group_info *group_info =
|
||||
group_info_read(p_iris->group_name_map, group_name);
|
||||
// exist group name, regions and sub groups will be ommit.
|
||||
if (NULL == group_info) {
|
||||
if (0 == strncasecmp(group_name, untitled_group_name,
|
||||
strlen(untitled_group_name))) {
|
||||
group_id = untitled_group_id;
|
||||
struct object_info *object_info =
|
||||
object_info_read(p_iris->object_name_map, object_name);
|
||||
// exist object name, regions and sub objects will be ommit.
|
||||
if (NULL == object_info) {
|
||||
if (0 == strncasecmp(object_name, untitled_object_name,
|
||||
strlen(untitled_object_name))) {
|
||||
object_id = untitled_object_id;
|
||||
}
|
||||
|
||||
if (-1 == group_id) {
|
||||
if (-1 == object_id) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] group_name:<%s> has no group_id",
|
||||
__FUNCTION__, __LINE__, group_name);
|
||||
"[%s:%d] object_name:<%s> has no object_id",
|
||||
__FUNCTION__, __LINE__, object_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
group_info = group_info_add_unsafe(p_iris, group_name, group_id);
|
||||
cJSON *region_json = cJSON_GetObjectItem(group_json, "regions");
|
||||
object_info = object_info_add_unsafe(p_iris, object_name, object_id);
|
||||
cJSON *region_json = cJSON_GetObjectItem(object_json, "regions");
|
||||
if (region_json != NULL) {
|
||||
cJSON *region_rule = NULL;
|
||||
cJSON_ArrayForEach(region_rule, region_json) {
|
||||
ret = write_region_rule(region_rule, tracking_rule_id,
|
||||
group_info->group_id, p_iris, logger);
|
||||
object_info->object_id, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] rule rule %d write region error",
|
||||
@@ -869,14 +869,14 @@ write_group_rule(cJSON *group_json, int parent_id,
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *sub_groups = cJSON_GetObjectItem(group_json, "sub_groups");
|
||||
if (sub_groups != NULL) {
|
||||
cJSON *sub_objects = cJSON_GetObjectItem(object_json, "sub_objects");
|
||||
if (sub_objects != NULL) {
|
||||
// recursively
|
||||
int i = 0;
|
||||
cJSON_ArrayForEach(item, sub_groups) {
|
||||
cJSON_ArrayForEach(item, sub_objects) {
|
||||
i++;
|
||||
ret = write_group_rule(item, group_info->group_id,
|
||||
PARENT_TYPE_GROUP, tracking_rule_id,
|
||||
ret = write_object_rule(item, object_info->object_id,
|
||||
PARENT_TYPE_OBJECT, tracking_rule_id,
|
||||
i, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
@@ -884,21 +884,21 @@ write_group_rule(cJSON *group_json, int parent_id,
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == region_json && NULL == sub_groups) {
|
||||
if (NULL == region_json && NULL == sub_objects) {
|
||||
log_info(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] A group of rule rule %d has neither regions, "
|
||||
"sub groups, nor refered another existed group",
|
||||
"[%s:%d] A object of rule rule %d has neither regions, "
|
||||
"sub objects, nor refered another existed object",
|
||||
__FUNCTION__, __LINE__, tracking_rule_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (parent_type == PARENT_TYPE_RULE) {
|
||||
ret = write_group2rule_line(&(group_info->group_id), 1, parent_id,
|
||||
group_negate_option, condition_index,
|
||||
ret = write_object2rule_line(&(object_info->object_id), 1, parent_id,
|
||||
object_negate_option, condition_index,
|
||||
attribute, p_iris, g2c_table);
|
||||
if (ret < 0) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] rule:%d write group error",
|
||||
"[%s:%d] rule:%d write object error",
|
||||
__FUNCTION__, __LINE__, parent_id);
|
||||
return -1;
|
||||
}
|
||||
@@ -921,14 +921,14 @@ write_rule_line(cJSON *rule, struct iris_description *p_iris,
|
||||
}
|
||||
int rule_id = item->valueint;
|
||||
|
||||
cJSON *group_array = cJSON_GetObjectItem(rule, "groups");
|
||||
int group_num = cJSON_GetArraySize(group_array);
|
||||
int *condition_ids = ALLOC(int, group_num);
|
||||
cJSON *object_array = cJSON_GetObjectItem(rule, "objects");
|
||||
int object_num = cJSON_GetArraySize(object_array);
|
||||
int *condition_ids = ALLOC(int, object_num);
|
||||
int condition_num = 0;
|
||||
cJSON *group_obj = NULL;
|
||||
cJSON *object_obj = NULL;
|
||||
|
||||
cJSON_ArrayForEach(group_obj, group_array) {
|
||||
item = cJSON_GetObjectItem(group_obj, "condition_index");
|
||||
cJSON_ArrayForEach(object_obj, object_array) {
|
||||
item = cJSON_GetObjectItem(object_obj, "condition_index");
|
||||
if (item) {
|
||||
int i = 0;
|
||||
int condition_index = item->valueint;
|
||||
@@ -947,7 +947,7 @@ write_rule_line(cJSON *rule, struct iris_description *p_iris,
|
||||
FREE(condition_ids);
|
||||
|
||||
if (condition_num == 0) {
|
||||
condition_num = group_num;
|
||||
condition_num = object_num;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(rule, "condition_num", condition_num);
|
||||
@@ -1086,67 +1086,67 @@ static int write_index_file(struct iris_description *p_iris,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int recursive_traverse_sub_groups(cJSON *group_obj, struct iris_description *p_iris,
|
||||
int recursive_traverse_sub_objects(cJSON *object_obj, struct iris_description *p_iris,
|
||||
struct log_handle *logger)
|
||||
{
|
||||
cJSON *sub_group_array = cJSON_GetObjectItem(group_obj, "sub_groups");
|
||||
if (NULL == sub_group_array) {
|
||||
cJSON *sub_object_array = cJSON_GetObjectItem(object_obj, "sub_objects");
|
||||
if (NULL == sub_object_array) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cJSON *item = cJSON_GetObjectItem(group_obj, "group_name");
|
||||
cJSON *item = cJSON_GetObjectItem(object_obj, "object_name");
|
||||
if (NULL == item || item->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] has no group_name before sub_groups.");
|
||||
"[%s:%d] has no object_name before sub_objects.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *parent_group_name = item->valuestring;
|
||||
struct group_info *parent_group = group_info_read(p_iris->group_name_map,
|
||||
const char *parent_object_name = item->valuestring;
|
||||
struct object_info *parent_object = object_info_read(p_iris->object_name_map,
|
||||
item->valuestring);
|
||||
if (NULL == parent_group) {
|
||||
item = cJSON_GetObjectItem(group_obj, "group_id");
|
||||
if (NULL == parent_object) {
|
||||
item = cJSON_GetObjectItem(object_obj, "object_id");
|
||||
if (NULL == item || item->type != cJSON_Number) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] group_name:%s has no group_id.", parent_group_name);
|
||||
"[%s:%d] object_name:%s has no object_id.", parent_object_name);
|
||||
return -1;
|
||||
}
|
||||
parent_group = group_info_add_unsafe(p_iris, parent_group_name, item->valueint);
|
||||
parent_object = object_info_add_unsafe(p_iris, parent_object_name, item->valueint);
|
||||
}
|
||||
|
||||
cJSON *sub_group_obj = NULL;
|
||||
cJSON_ArrayForEach(sub_group_obj, sub_group_array) {
|
||||
cJSON *tmp_item1 = cJSON_GetObjectItem(sub_group_obj, "group_name");
|
||||
cJSON *sub_object_obj = NULL;
|
||||
cJSON_ArrayForEach(sub_object_obj, sub_object_array) {
|
||||
cJSON *tmp_item1 = cJSON_GetObjectItem(sub_object_obj, "object_name");
|
||||
if (NULL == tmp_item1 || tmp_item1->type != cJSON_String) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d]group:%s's sub_groups has no group_name",
|
||||
__FUNCTION__, __LINE__, parent_group_name);
|
||||
"[%s:%d]object:%s's sub_objects has no object_name",
|
||||
__FUNCTION__, __LINE__, parent_object_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int group_id = -1;
|
||||
int object_id = -1;
|
||||
int is_exclude = 0;
|
||||
cJSON *tmp_item2 = cJSON_GetObjectItem(sub_group_obj, "group_id");
|
||||
cJSON *tmp_item2 = cJSON_GetObjectItem(sub_object_obj, "object_id");
|
||||
if (NULL == tmp_item2) {
|
||||
struct group_info *group = group_info_read(p_iris->group_name_map,
|
||||
struct object_info *object = object_info_read(p_iris->object_name_map,
|
||||
tmp_item1->valuestring);
|
||||
assert(group != NULL);
|
||||
group_id = group->group_id;
|
||||
assert(object != NULL);
|
||||
object_id = object->object_id;
|
||||
} else {
|
||||
group_id = tmp_item2->valueint;
|
||||
object_id = tmp_item2->valueint;
|
||||
}
|
||||
|
||||
cJSON *tmp_item3 = cJSON_GetObjectItem(sub_group_obj, "is_exclude");
|
||||
cJSON *tmp_item3 = cJSON_GetObjectItem(sub_object_obj, "is_exclude");
|
||||
if (tmp_item3 != NULL && tmp_item3->type == cJSON_Number) {
|
||||
is_exclude = tmp_item3->valueint;
|
||||
}
|
||||
if (0 == is_exclude) {
|
||||
utarray_push_back(parent_group->incl_sub_group_ids, &group_id);
|
||||
utarray_push_back(parent_object->incl_sub_object_ids, &object_id);
|
||||
} else {
|
||||
utarray_push_back(parent_group->excl_sub_group_ids, &group_id);
|
||||
utarray_push_back(parent_object->excl_sub_object_ids, &object_id);
|
||||
}
|
||||
|
||||
int ret = recursive_traverse_sub_groups(sub_group_obj, p_iris, logger);
|
||||
int ret = recursive_traverse_sub_objects(sub_object_obj, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1155,21 +1155,21 @@ int recursive_traverse_sub_groups(cJSON *group_obj, struct iris_description *p_i
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int write_group2group_rule(struct iris_description *p_iris,
|
||||
static int write_object2object_rule(struct iris_description *p_iris,
|
||||
struct log_handle *logger)
|
||||
{
|
||||
int ret = 0;
|
||||
struct group_info *group_info = NULL, *tmp_group_info = NULL;
|
||||
struct object_info *object_info = NULL, *tmp_object_info = NULL;
|
||||
|
||||
HASH_ITER(hh, p_iris->group_name_map, group_info, tmp_group_info) {
|
||||
ret = write_group2group_line(group_info->group_id,
|
||||
group_info->incl_sub_group_ids,
|
||||
group_info->excl_sub_group_ids,
|
||||
HASH_ITER(hh, p_iris->object_name_map, object_info, tmp_object_info) {
|
||||
ret = write_object2object_line(object_info->object_id,
|
||||
object_info->incl_sub_object_ids,
|
||||
object_info->excl_sub_object_ids,
|
||||
p_iris);
|
||||
if (ret < 0) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] write group2group line failed for super_group:%d",
|
||||
__FUNCTION__, __LINE__, group_info->group_id);
|
||||
"[%s:%d] write object2object line failed for super_object:%d",
|
||||
__FUNCTION__, __LINE__, object_info->object_id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
|
||||
{
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
static struct group_info *parent_group = NULL; // TODO
|
||||
static struct object_info *parent_object = NULL; // TODO
|
||||
|
||||
cJSON *plug_tables = cJSON_GetObjectItem(json, "plugin_table");
|
||||
if (plug_tables != NULL) {
|
||||
@@ -1193,35 +1193,35 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *group_array = cJSON_GetObjectItem(json, "groups"); // sub-group to group
|
||||
if (group_array != NULL) {
|
||||
cJSON *group_obj = NULL;
|
||||
cJSON_ArrayForEach(group_obj, group_array) {
|
||||
const char *parent_group_name = NULL;
|
||||
cJSON *item = cJSON_GetObjectItem(group_obj, "parent_group");
|
||||
cJSON *object_array = cJSON_GetObjectItem(json, "objects"); // sub-object to object
|
||||
if (object_array != NULL) {
|
||||
cJSON *object_obj = NULL;
|
||||
cJSON_ArrayForEach(object_obj, object_array) {
|
||||
const char *parent_object_name = NULL;
|
||||
cJSON *item = cJSON_GetObjectItem(object_obj, "parent_object");
|
||||
if (NULL == item || item->type != cJSON_String) {
|
||||
parent_group_name = untitled_group_name;
|
||||
parent_object_name = untitled_object_name;
|
||||
} else {
|
||||
parent_group_name = item->string;
|
||||
parent_object_name = item->string;
|
||||
}
|
||||
|
||||
parent_group = group_info_read(p_iris->group_name_map, parent_group_name);
|
||||
if (NULL == parent_group) {
|
||||
parent_group = group_info_add_unsafe(p_iris, parent_group_name,
|
||||
untitled_group_id);
|
||||
parent_object = object_info_read(p_iris->object_name_map, parent_object_name);
|
||||
if (NULL == parent_object) {
|
||||
parent_object = object_info_add_unsafe(p_iris, parent_object_name,
|
||||
untitled_object_id);
|
||||
}
|
||||
|
||||
item = cJSON_GetObjectItem(group_obj, "group_id");
|
||||
item = cJSON_GetObjectItem(object_obj, "object_id");
|
||||
if (NULL == item || item->type != cJSON_Number) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d]Global groups has group with no group_id.",
|
||||
"[%s:%d]Global objects has object with no object_id.",
|
||||
__FUNCTION__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
utarray_push_back(parent_group->incl_sub_group_ids, &item->valueint);
|
||||
ret = write_group_rule(group_obj, parent_group->group_id,
|
||||
PARENT_TYPE_GROUP, 0, 0, p_iris, logger);
|
||||
utarray_push_back(parent_object->incl_sub_object_ids, &item->valueint);
|
||||
ret = write_object_rule(object_obj, parent_object->object_id,
|
||||
PARENT_TYPE_OBJECT, 0, 0, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1245,26 +1245,26 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
|
||||
return -1;
|
||||
}
|
||||
|
||||
group_array = cJSON_GetObjectItem(rule_obj, "groups");
|
||||
if (NULL == group_array) {
|
||||
object_array = cJSON_GetObjectItem(rule_obj, "objects");
|
||||
if (NULL == object_array) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] rule rule %d have no group",
|
||||
"[%s:%d] rule rule %d have no object",
|
||||
__FUNCTION__, __LINE__, rule_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int group_cnt = cJSON_GetArraySize(group_array);
|
||||
if (group_cnt <= 0) {
|
||||
int object_cnt = cJSON_GetArraySize(object_array);
|
||||
if (object_cnt <= 0) {
|
||||
log_fatal(logger, MODULE_JSON2IRIS,
|
||||
"[%s:%d] rule rule %d have no groups",
|
||||
"[%s:%d] rule rule %d have no objects",
|
||||
__FUNCTION__, __LINE__, rule_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
cJSON *group_obj = NULL;
|
||||
cJSON_ArrayForEach(group_obj, group_array) {
|
||||
ret = write_group_rule(group_obj, rule_id, PARENT_TYPE_RULE,
|
||||
cJSON *object_obj = NULL;
|
||||
cJSON_ArrayForEach(object_obj, object_array) {
|
||||
ret = write_object_rule(object_obj, rule_id, PARENT_TYPE_RULE,
|
||||
rule_id, i, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
@@ -1274,11 +1274,11 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
|
||||
}
|
||||
|
||||
cJSON_ArrayForEach(rule_obj, rule_array) {
|
||||
cJSON *group_array = cJSON_GetObjectItem(rule_obj, "groups");
|
||||
cJSON *object_array = cJSON_GetObjectItem(rule_obj, "objects");
|
||||
|
||||
cJSON *group_obj = NULL;
|
||||
cJSON_ArrayForEach(group_obj, group_array) {
|
||||
ret = recursive_traverse_sub_groups(group_obj, p_iris, logger);
|
||||
cJSON *object_obj = NULL;
|
||||
cJSON_ArrayForEach(object_obj, object_array) {
|
||||
ret = recursive_traverse_sub_objects(object_obj, p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1286,7 +1286,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
|
||||
}
|
||||
}
|
||||
|
||||
ret = write_group2group_rule(p_iris, logger);
|
||||
ret = write_object2object_rule(p_iris, logger);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1307,8 +1307,8 @@ int json2iris(const char *json_buff, const char *json_filename,
|
||||
int ret = -1;
|
||||
cJSON *tmp_obj = NULL;
|
||||
const char *rule_tbl_name = NULL;
|
||||
const char *group2rule_tbl_name = NULL;
|
||||
const char *group2group_tbl_name = NULL;
|
||||
const char *object2rule_tbl_name = NULL;
|
||||
const char *object2object_tbl_name = NULL;
|
||||
struct iris_description iris_cfg;
|
||||
|
||||
memset(&iris_cfg, 0, sizeof(iris_cfg));
|
||||
@@ -1326,19 +1326,19 @@ int json2iris(const char *json_buff, const char *json_filename,
|
||||
rule_tbl_name = tmp_obj->valuestring;
|
||||
}
|
||||
|
||||
tmp_obj = cJSON_GetObjectItem(json, "group2rule_table");
|
||||
tmp_obj = cJSON_GetObjectItem(json, "object2rule_table");
|
||||
if (tmp_obj) {
|
||||
group2rule_tbl_name = tmp_obj->valuestring;
|
||||
object2rule_tbl_name = tmp_obj->valuestring;
|
||||
}
|
||||
|
||||
tmp_obj = cJSON_GetObjectItem(json, "group2group_table");
|
||||
tmp_obj = cJSON_GetObjectItem(json, "object2object_table");
|
||||
if (tmp_obj) {
|
||||
group2group_tbl_name = tmp_obj->valuestring;
|
||||
object2object_tbl_name = tmp_obj->valuestring;
|
||||
}
|
||||
|
||||
ret = set_iris_descriptor(json_filename, json, encrypt_key, encrypt_algo,
|
||||
rule_tbl_name, group2rule_tbl_name,
|
||||
group2group_tbl_name, redis_write_ctx, &iris_cfg);
|
||||
rule_tbl_name, object2rule_tbl_name,
|
||||
object2object_tbl_name, redis_write_ctx, &iris_cfg);
|
||||
if (ret < 0) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
224
src/maat_api.c
224
src/maat_api.c
@@ -29,7 +29,7 @@
|
||||
#include "ip_matcher.h"
|
||||
#include "adapter_hs.h"
|
||||
#include "maat_garbage_collection.h"
|
||||
#include "maat_group.h"
|
||||
#include "maat_object.h"
|
||||
#include "maat_expr.h"
|
||||
#include "maat_flag.h"
|
||||
#include "maat_interval.h"
|
||||
@@ -288,13 +288,13 @@ int maat_options_set_hit_path_enabled(struct maat_options *opts)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int maat_options_set_hit_group_enabled(struct maat_options *opts)
|
||||
int maat_options_set_hit_object_enabled(struct maat_options *opts)
|
||||
{
|
||||
if (NULL == opts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
opts->hit_group_on = 1;
|
||||
opts->hit_object_on = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1081,22 +1081,22 @@ flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = flag_runtime_scan((struct flag_runtime *)flag_rt,
|
||||
int object_hit_cnt = flag_runtime_scan((struct flag_runtime *)flag_rt,
|
||||
thread_id, flag, attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
thread_id, group_hit_cnt);
|
||||
thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
|
||||
}
|
||||
|
||||
flag_runtime_hit_times_inc((struct flag_runtime *)flag_rt, thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1133,22 +1133,22 @@ interval_scan(struct table_manager *tbl_mgr, int thread_id, long long integer,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = interval_runtime_scan((struct interval_runtime *)interval_rt,
|
||||
int object_hit_cnt = interval_runtime_scan((struct interval_runtime *)interval_rt,
|
||||
thread_id, integer, attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
thread_id, group_hit_cnt);
|
||||
thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
|
||||
}
|
||||
|
||||
interval_runtime_hit_times_inc((struct interval_runtime *)interval_rt, thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1179,22 +1179,22 @@ ipv4_scan(struct table_manager *tbl_mgr, int thread_id, uint32_t ip_addr,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv4,
|
||||
int object_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv4,
|
||||
(uint8_t *)&ip_addr, port, attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
thread_id, group_hit_cnt);
|
||||
thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
|
||||
}
|
||||
|
||||
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1225,22 +1225,22 @@ ipv6_scan(struct table_manager *tbl_mgr, int thread_id, uint8_t *ip_addr,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv6,
|
||||
int object_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv6,
|
||||
ip_addr, port, attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
thread_id, group_hit_cnt);
|
||||
thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
|
||||
}
|
||||
|
||||
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1280,27 +1280,27 @@ string_scan(struct table_manager *tbl_mgr, int thread_id,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = expr_runtime_scan((struct expr_runtime *)expr_rt,
|
||||
int object_hit_cnt = expr_runtime_scan((struct expr_runtime *)expr_rt,
|
||||
thread_id, data, data_len,
|
||||
attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
thread_id, group_hit_cnt);
|
||||
thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
|
||||
}
|
||||
|
||||
expr_runtime_hit_times_inc((struct expr_runtime *)expr_rt, thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
static size_t
|
||||
group_to_rule(struct maat *maat_inst, long long *results, size_t n_result,
|
||||
object_to_rule(struct maat *maat_inst, long long *results, size_t n_result,
|
||||
struct maat_state *state)
|
||||
{
|
||||
int rule_table_id =
|
||||
@@ -1363,9 +1363,9 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
|
||||
}
|
||||
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
int hit_group_cnt = flag_scan(maat_inst->tbl_mgr, state->thread_id, flag,
|
||||
int hit_object_cnt = flag_scan(maat_inst->tbl_mgr, state->thread_id, flag,
|
||||
phy_table_id, attribute_id, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
@@ -1373,8 +1373,8 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -1397,7 +1397,7 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
@@ -1448,9 +1448,9 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
|
||||
}
|
||||
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
int hit_group_cnt = interval_scan(maat_inst->tbl_mgr, state->thread_id, integer,
|
||||
int hit_object_cnt = interval_scan(maat_inst->tbl_mgr, state->thread_id, integer,
|
||||
phy_table_id, attribute_id, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
@@ -1458,8 +1458,8 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -1482,7 +1482,7 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
@@ -1532,9 +1532,9 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
|
||||
}
|
||||
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
int hit_group_cnt = ipv4_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
|
||||
int hit_object_cnt = ipv4_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
|
||||
phy_table_id, attribute_id, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
@@ -1542,8 +1542,8 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -1566,7 +1566,7 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
@@ -1616,9 +1616,9 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
|
||||
}
|
||||
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
int hit_group_cnt = ipv6_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
|
||||
int hit_object_cnt = ipv6_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
|
||||
phy_table_id, attribute_id, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
@@ -1626,8 +1626,8 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -1650,7 +1650,7 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
@@ -1719,9 +1719,9 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
|
||||
}
|
||||
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
int hit_group_cnt = string_scan(maat_inst->tbl_mgr, state->thread_id, data,
|
||||
int hit_object_cnt = string_scan(maat_inst->tbl_mgr, state->thread_id, data,
|
||||
data_len, phy_table_id, attribute_id, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
@@ -1729,8 +1729,8 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -1753,21 +1753,21 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static void maat_state_add_hit_group(struct maat_state *state, int table_id,
|
||||
struct maat_hit_group *groups, size_t n_group)
|
||||
static void maat_state_add_hit_object(struct maat_state *state, int table_id,
|
||||
struct maat_hit_object *objects, size_t n_object)
|
||||
{
|
||||
struct maat *maat_inst = state->maat_inst;
|
||||
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (NULL == state->rule_state) {
|
||||
@@ -1776,15 +1776,15 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
|
||||
state->thread_id, 1);
|
||||
}
|
||||
|
||||
size_t n_hit_item = n_group;
|
||||
if (n_group >= MAX_HIT_GROUP_NUM) {
|
||||
n_hit_item = MAX_HIT_GROUP_NUM;
|
||||
size_t n_hit_item = n_object;
|
||||
if (n_object >= MAX_HIT_OBJECT_NUM) {
|
||||
n_hit_item = MAX_HIT_OBJECT_NUM;
|
||||
}
|
||||
|
||||
struct maat_item hit_items[n_hit_item];
|
||||
for (size_t i = 0; i < n_hit_item; i++) {
|
||||
hit_items[i].item_id = groups[i].item_id;
|
||||
hit_items[i].group_id = groups[i].group_id;
|
||||
hit_items[i].item_id = objects[i].item_id;
|
||||
hit_items[i].object_id = objects[i].object_id;
|
||||
}
|
||||
|
||||
rule_state_update(state->rule_state, maat_inst, table_id,
|
||||
@@ -1793,7 +1793,7 @@ static void maat_state_add_hit_group(struct maat_state *state, int table_id,
|
||||
}
|
||||
|
||||
static void
|
||||
maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
|
||||
maat_state_activate_hit_not_object(struct maat_state *state, int table_id)
|
||||
{
|
||||
if (NULL == state) {
|
||||
return;
|
||||
@@ -1812,22 +1812,22 @@ maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
|
||||
return;
|
||||
}
|
||||
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
rule_state_not_logic_update(state->rule_state, rule_rt, maat_inst,
|
||||
table_id, state->Nth_scan);
|
||||
}
|
||||
|
||||
int maat_scan_group(struct maat *maat_inst, int table_id,
|
||||
struct maat_hit_group *groups, size_t n_group,
|
||||
int maat_scan_object(struct maat *maat_inst, int table_id,
|
||||
struct maat_hit_object *objects, size_t n_object,
|
||||
long long *results, size_t n_result,
|
||||
size_t *n_hit_result, struct maat_state *state)
|
||||
{
|
||||
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|
||||
(NULL == groups) || (0 == n_group) || (NULL == results) ||
|
||||
(NULL == objects) || (0 == n_object) || (NULL == results) ||
|
||||
(0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
|
||||
(state->thread_id < 0)) {
|
||||
return -1;
|
||||
@@ -1852,15 +1852,15 @@ int maat_scan_group(struct maat *maat_inst, int table_id,
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt,
|
||||
state->thread_id);
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
state->thread_id, n_group);
|
||||
state->thread_id, n_object);
|
||||
}
|
||||
}
|
||||
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
|
||||
maat_state_add_hit_group(state, table_id, groups, n_group);
|
||||
size_t hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
maat_state_add_hit_object(state, table_id, objects, n_object);
|
||||
size_t hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = hit_rule_cnt;
|
||||
|
||||
maat_runtime_ref_dec(maat_rt, state->thread_id);
|
||||
@@ -1895,8 +1895,8 @@ int maat_scan_not_logic(struct maat *maat_inst, int table_id,
|
||||
maat_runtime_ref_inc(maat_rt, state->thread_id);
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
|
||||
|
||||
maat_state_activate_hit_not_group(state, table_id);
|
||||
size_t hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
maat_state_activate_hit_not_object(state, table_id);
|
||||
size_t hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = hit_rule_cnt;
|
||||
|
||||
maat_runtime_ref_dec(maat_rt, state->thread_id);
|
||||
@@ -2004,22 +2004,22 @@ static int expr_stream_scan(struct maat_stream *stream, const char *data,
|
||||
}
|
||||
}
|
||||
|
||||
int group_hit_cnt = expr_runtime_stream_scan(stream->expr_rt_stream, data,
|
||||
int object_hit_cnt = expr_runtime_stream_scan(stream->expr_rt_stream, data,
|
||||
data_len, stream->attribute_id, state);
|
||||
if (group_hit_cnt <= 0) {
|
||||
return group_hit_cnt;
|
||||
if (object_hit_cnt <= 0) {
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
if (virt_rt != NULL) {
|
||||
//Note: group_hit_cnt is equivalent to item_hit_cnt
|
||||
//Note: object_hit_cnt is equivalent to item_hit_cnt
|
||||
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
|
||||
stream->thread_id, group_hit_cnt);
|
||||
stream->thread_id, object_hit_cnt);
|
||||
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, stream->thread_id);
|
||||
}
|
||||
|
||||
expr_runtime_stream_hit_times_inc(stream->expr_rt_stream, stream->thread_id);
|
||||
|
||||
return group_hit_cnt;
|
||||
return object_hit_cnt;
|
||||
}
|
||||
|
||||
int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data_len,
|
||||
@@ -2055,15 +2055,15 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
|
||||
alignment_int64_array_add(maat_inst->stat->thread_call_cnt,
|
||||
maat_stream->thread_id, 1);
|
||||
|
||||
int hit_group_cnt = expr_stream_scan(maat_stream, data, data_len, state);
|
||||
if (hit_group_cnt < 0) {
|
||||
int hit_object_cnt = expr_stream_scan(maat_stream, data, data_len, state);
|
||||
if (hit_object_cnt < 0) {
|
||||
maat_inst->stat->scan_err_cnt++;
|
||||
return MAAT_SCAN_ERR;
|
||||
}
|
||||
|
||||
size_t sum_hit_rule_cnt = 0;
|
||||
if (hit_group_cnt > 0) {
|
||||
sum_hit_rule_cnt = group_to_rule(maat_inst, results, n_result, state);
|
||||
if (hit_object_cnt > 0) {
|
||||
sum_hit_rule_cnt = object_to_rule(maat_inst, results, n_result, state);
|
||||
*n_hit_result = sum_hit_rule_cnt;
|
||||
}
|
||||
|
||||
@@ -2081,7 +2081,7 @@ int maat_stream_scan(struct maat_stream *maat_stream, const char *data, int data
|
||||
|
||||
if (sum_hit_rule_cnt > 0) {
|
||||
return MAAT_SCAN_HIT;
|
||||
} else if (hit_group_cnt > 0) {
|
||||
} else if (hit_object_cnt > 0) {
|
||||
return MAAT_SCAN_HALF_HIT;
|
||||
} else {
|
||||
return MAAT_SCAN_OK;
|
||||
@@ -2309,13 +2309,13 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
|
||||
return -1;
|
||||
}
|
||||
|
||||
int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
|
||||
int g2g_table_id = table_manager_get_object2object_table_id(maat_inst->tbl_mgr);
|
||||
void *g2g_runtime = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
|
||||
|
||||
size_t hit_path_cnt =
|
||||
rule_state_get_internal_hit_paths(state->rule_state,
|
||||
(struct rule_runtime *)rule_rt,
|
||||
(struct group2group_runtime *)g2g_runtime,
|
||||
(struct object2object_runtime *)g2g_runtime,
|
||||
path_array, array_size);
|
||||
|
||||
return rule_runtime_get_hit_paths((struct rule_runtime *)rule_rt,
|
||||
@@ -2332,11 +2332,11 @@ size_t maat_state_get_scan_count(struct maat_state *state)
|
||||
return state->Nth_scan;
|
||||
}
|
||||
|
||||
int maat_state_get_direct_hit_groups(struct maat_state *state,
|
||||
struct maat_hit_group *group_array,
|
||||
int maat_state_get_direct_hit_objects(struct maat_state *state,
|
||||
struct maat_hit_object *object_array,
|
||||
size_t array_size)
|
||||
{
|
||||
if (NULL == state || NULL == group_array || 0 == array_size) {
|
||||
if (NULL == state || NULL == object_array || 0 == array_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2344,24 +2344,24 @@ int maat_state_get_direct_hit_groups(struct maat_state *state,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_direct_hit_groups(state->rule_state,
|
||||
group_array, array_size);
|
||||
return rule_state_get_direct_hit_objects(state->rule_state,
|
||||
object_array, array_size);
|
||||
}
|
||||
|
||||
size_t maat_state_get_direct_hit_group_cnt(struct maat_state *state)
|
||||
size_t maat_state_get_direct_hit_object_cnt(struct maat_state *state)
|
||||
{
|
||||
if (NULL == state || NULL == state->rule_state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_direct_hit_group_cnt(state->rule_state);
|
||||
return rule_state_get_direct_hit_object_cnt(state->rule_state);
|
||||
}
|
||||
|
||||
int maat_state_get_indirect_hit_groups(struct maat_state *state,
|
||||
struct maat_hit_group *group_array,
|
||||
int maat_state_get_indirect_hit_objects(struct maat_state *state,
|
||||
struct maat_hit_object *object_array,
|
||||
size_t array_size)
|
||||
{
|
||||
if (NULL == state || NULL == group_array || 0 == array_size) {
|
||||
if (NULL == state || NULL == object_array || 0 == array_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2369,36 +2369,36 @@ int maat_state_get_indirect_hit_groups(struct maat_state *state,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_indirect_hit_groups(state->rule_state,
|
||||
group_array, array_size);
|
||||
return rule_state_get_indirect_hit_objects(state->rule_state,
|
||||
object_array, array_size);
|
||||
}
|
||||
|
||||
size_t maat_state_get_indirect_hit_group_cnt(struct maat_state *state)
|
||||
size_t maat_state_get_indirect_hit_object_cnt(struct maat_state *state)
|
||||
{
|
||||
if (NULL == state || NULL == state->rule_state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_indirect_hit_group_cnt(state->rule_state);
|
||||
return rule_state_get_indirect_hit_object_cnt(state->rule_state);
|
||||
}
|
||||
|
||||
int maat_state_get_last_hit_groups(struct maat_state *state,
|
||||
struct maat_hit_group *group_array,
|
||||
int maat_state_get_last_hit_objects(struct maat_state *state,
|
||||
struct maat_hit_object *object_array,
|
||||
size_t array_size)
|
||||
{
|
||||
if (NULL == state || NULL == state->rule_state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_last_hit_groups(state->rule_state,
|
||||
group_array, array_size);
|
||||
return rule_state_get_last_hit_objects(state->rule_state,
|
||||
object_array, array_size);
|
||||
}
|
||||
|
||||
size_t maat_state_get_last_hit_group_cnt(struct maat_state *state)
|
||||
size_t maat_state_get_last_hit_object_cnt(struct maat_state *state)
|
||||
{
|
||||
if (NULL == state || NULL == state->rule_state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rule_state_get_last_hit_group_cnt(state->rule_state);
|
||||
return rule_state_get_last_hit_object_cnt(state->rule_state);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ redis_flushDB(redisContext *ctx, int db_index, struct log_handle *logger)
|
||||
append_cmd_cnt++;
|
||||
redisAppendCommand(ctx, "SET %s 1", mr_region_id_var);
|
||||
append_cmd_cnt++;
|
||||
redisAppendCommand(ctx, "SET %s 1", mr_group_id_var);
|
||||
redisAppendCommand(ctx, "SET %s 1", mr_object_id_var);
|
||||
append_cmd_cnt++;
|
||||
redisAppendCommand(ctx, "EXEC");
|
||||
append_cmd_cnt++;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "maat.h"
|
||||
#include "maat_core.h"
|
||||
#include "maat_rule.h"
|
||||
#include "maat_group.h"
|
||||
#include "maat_object.h"
|
||||
#include "alignment.h"
|
||||
#include "maat_garbage_collection.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
struct expr_schema {
|
||||
int item_id_column;
|
||||
int group_id_column;
|
||||
int object_id_column;
|
||||
int district_column;
|
||||
int keywords_column;
|
||||
int expr_type_column;
|
||||
@@ -63,7 +63,7 @@ enum match_method {
|
||||
|
||||
struct expr_item {
|
||||
long long item_id;
|
||||
long long group_id;
|
||||
long long object_id;
|
||||
char keywords[MAX_KEYWORDS_STR_LEN + 1];
|
||||
enum expr_type expr_type;
|
||||
void *user_data;
|
||||
@@ -175,15 +175,15 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
|
||||
}
|
||||
expr_item->item_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, expr_schema->group_id_column, &column_offset,
|
||||
ret = get_column_pos(line, expr_schema->object_id_column, &column_offset,
|
||||
&column_len);
|
||||
if (ret < 0) {
|
||||
log_fatal(expr_rt->logger, MODULE_EXPR,
|
||||
"[%s:%d] expr table:<%s> has no group_id in line:%s",
|
||||
"[%s:%d] expr table:<%s> has no object_id in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
expr_item->group_id = atoll(line + column_offset);
|
||||
expr_item->object_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, expr_schema->keywords_column, &column_offset, &column_len);
|
||||
if (ret < 0) {
|
||||
@@ -311,12 +311,12 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
goto error;
|
||||
}
|
||||
|
||||
custom_item = cJSON_GetObjectItem(item, "group_id");
|
||||
custom_item = cJSON_GetObjectItem(item, "object_id");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
expr_schema->group_id_column = custom_item->valueint;
|
||||
expr_schema->object_id_column = custom_item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_EXPR,
|
||||
"[%s:%d] expr table:<%s> schema has no group_id column",
|
||||
"[%s:%d] expr table:<%s> schema has no object_id column",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -953,9 +953,9 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
|
||||
const char *data, size_t data_len,
|
||||
int attribute_id, struct maat_state *state)
|
||||
{
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (0 == expr_rt->rule_num) {
|
||||
@@ -1002,7 +1002,7 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
|
||||
}
|
||||
|
||||
hit_maat_items[real_hit_item_num].item_id = item_id;
|
||||
hit_maat_items[real_hit_item_num].group_id = expr_item->group_id;
|
||||
hit_maat_items[real_hit_item_num].object_id = expr_item->object_id;
|
||||
real_hit_item_num++;
|
||||
}
|
||||
}
|
||||
@@ -1049,9 +1049,9 @@ int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
|
||||
{
|
||||
struct expr_runtime *expr_rt = expr_rt_stream->ref_expr_rt;
|
||||
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (0 == expr_rt->rule_num) {
|
||||
@@ -1097,7 +1097,7 @@ int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
|
||||
}
|
||||
|
||||
hit_maat_items[real_hit_item_cnt].item_id = item_id;
|
||||
hit_maat_items[real_hit_item_cnt].group_id = expr_item->group_id;
|
||||
hit_maat_items[real_hit_item_cnt].object_id = expr_item->object_id;
|
||||
real_hit_item_cnt++;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
struct flag_schema {
|
||||
int item_id_column;
|
||||
int group_id_column;
|
||||
int object_id_column;
|
||||
int district_column;
|
||||
int flag_column;
|
||||
int flag_mask_column;
|
||||
@@ -36,7 +36,7 @@ struct flag_schema {
|
||||
|
||||
struct flag_item {
|
||||
long long item_id;
|
||||
long long group_id;
|
||||
long long object_id;
|
||||
long long flag;
|
||||
long long flag_mask;
|
||||
void *user_data;
|
||||
@@ -104,12 +104,12 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
goto error;
|
||||
}
|
||||
|
||||
custom_item = cJSON_GetObjectItem(item, "group_id");
|
||||
custom_item = cJSON_GetObjectItem(item, "object_id");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
schema->group_id_column = custom_item->valueint;
|
||||
schema->object_id_column = custom_item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_FLAG,
|
||||
"[%s:%d] flag table:<%s> schema has no group_id column",
|
||||
"[%s:%d] flag table:<%s> schema has no object_id column",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -326,15 +326,15 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
|
||||
}
|
||||
item->item_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, schema->group_id_column, &column_offset,
|
||||
ret = get_column_pos(line, schema->object_id_column, &column_offset,
|
||||
&column_len);
|
||||
if (ret < 0) {
|
||||
log_fatal(flag_rt->logger, MODULE_FLAG,
|
||||
"[%s:%d] flag table:<%s> has no group_id in line:%s",
|
||||
"[%s:%d] flag table:<%s> has no object_id in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
item->group_id = atoll(line + column_offset);
|
||||
item->object_id = atoll(line + column_offset);
|
||||
|
||||
table_type = table_manager_get_table_type(schema->ref_tbl_mgr, schema->table_id);
|
||||
if (table_type == TABLE_TYPE_INTERVAL_PLUS) {
|
||||
@@ -555,9 +555,9 @@ long long flag_runtime_rule_count(void *flag_runtime)
|
||||
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
|
||||
long long flag, int attribute_id, struct maat_state *state)
|
||||
{
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (0 == flag_rt->rule_num) {
|
||||
@@ -598,7 +598,7 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
|
||||
}
|
||||
|
||||
hit_maat_items[real_hit_item_cnt].item_id = item_id;
|
||||
hit_maat_items[real_hit_item_cnt].group_id = flag_item->group_id;
|
||||
hit_maat_items[real_hit_item_cnt].object_id = flag_item->object_id;
|
||||
real_hit_item_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
1252
src/maat_group.c
1252
src/maat_group.c
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
|
||||
struct interval_schema {
|
||||
int item_id_column;
|
||||
int group_id_column;
|
||||
int object_id_column;
|
||||
int district_column;
|
||||
int interval_column;
|
||||
int table_id;
|
||||
@@ -32,7 +32,7 @@ struct interval_schema {
|
||||
|
||||
struct interval_item {
|
||||
long long item_id;
|
||||
long long group_id;
|
||||
long long object_id;
|
||||
int low_boundary;
|
||||
int up_boundary;
|
||||
void *user_data;
|
||||
@@ -100,12 +100,12 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
goto error;
|
||||
}
|
||||
|
||||
custom_item = cJSON_GetObjectItem(item, "group_id");
|
||||
custom_item = cJSON_GetObjectItem(item, "object_id");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
schema->group_id_column = custom_item->valueint;
|
||||
schema->object_id_column = custom_item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_INTERVAL,
|
||||
"[%s:%d] interval table:<%s> schema has no group_id column",
|
||||
"[%s:%d] interval table:<%s> schema has no object_id column",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -289,15 +289,15 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
|
||||
}
|
||||
item->item_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, schema->group_id_column, &column_offset,
|
||||
ret = get_column_pos(line, schema->object_id_column, &column_offset,
|
||||
&column_len);
|
||||
if (ret < 0) {
|
||||
log_fatal(interval_rt->logger, MODULE_INTERVAL,
|
||||
"[%s:%d] interval table:<%s> has no group_id in line:%s",
|
||||
"[%s:%d] interval table:<%s> has no object_id in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
item->group_id = atoll(line + column_offset);
|
||||
item->object_id = atoll(line + column_offset);
|
||||
|
||||
table_type = table_manager_get_table_type(schema->ref_tbl_mgr, schema->table_id);
|
||||
if (table_type == TABLE_TYPE_INTERVAL_PLUS) {
|
||||
@@ -544,9 +544,9 @@ long long interval_runtime_rule_count(void *interval_runtime)
|
||||
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
|
||||
long long integer, int attribute_id, struct maat_state *state)
|
||||
{
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (0 == interval_rt->rule_num) {
|
||||
@@ -587,7 +587,7 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
|
||||
}
|
||||
|
||||
hit_maat_items[real_hit_item_cnt].item_id = item_id;
|
||||
hit_maat_items[real_hit_item_cnt].group_id = int_item->group_id;
|
||||
hit_maat_items[real_hit_item_cnt].object_id = int_item->object_id;
|
||||
real_hit_item_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
struct ip_schema {
|
||||
int item_id_column;
|
||||
int group_id_column;
|
||||
int object_id_column;
|
||||
int ip_column;
|
||||
int table_id;
|
||||
int port_column;
|
||||
@@ -44,7 +44,7 @@ struct ipv6_item_rule {
|
||||
|
||||
struct ip_item {
|
||||
long long item_id;
|
||||
long long group_id;
|
||||
long long object_id;
|
||||
int addr_type;
|
||||
union {
|
||||
struct ipv4_item_rule ipv4;
|
||||
@@ -107,12 +107,12 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
|
||||
goto error;
|
||||
}
|
||||
|
||||
custom_item = cJSON_GetObjectItem(item, "group_id");
|
||||
custom_item = cJSON_GetObjectItem(item, "object_id");
|
||||
if (custom_item != NULL && custom_item->type == cJSON_Number) {
|
||||
ip_schema->group_id_column = custom_item->valueint;
|
||||
ip_schema->object_id_column = custom_item->valueint;
|
||||
} else {
|
||||
log_fatal(logger, MODULE_IP,
|
||||
"[%s:%d] ip table:<%s> schema has no group_id column",
|
||||
"[%s:%d] ip table:<%s> schema has no object_id column",
|
||||
__FUNCTION__, __LINE__, table_name);
|
||||
goto error;
|
||||
}
|
||||
@@ -164,15 +164,15 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
|
||||
}
|
||||
ip_item->item_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, ip_schema->group_id_column, &column_offset,
|
||||
ret = get_column_pos(line, ip_schema->object_id_column, &column_offset,
|
||||
&column_len);
|
||||
if (ret < 0) {
|
||||
log_fatal(logger, MODULE_IP,
|
||||
"[%s:%d] ip table:<%s> has no group_id in line:%s",
|
||||
"[%s:%d] ip table:<%s> has no object_id in line:%s",
|
||||
__FUNCTION__, __LINE__, table_name, line);
|
||||
goto error;
|
||||
}
|
||||
ip_item->group_id = atoll(line + column_offset);
|
||||
ip_item->object_id = atoll(line + column_offset);
|
||||
|
||||
ret = get_column_pos(line, ip_schema->ip_column, &column_offset,
|
||||
&column_len);
|
||||
@@ -522,9 +522,9 @@ long long ip_runtime_ipv6_rule_count(void *ip_runtime)
|
||||
int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
|
||||
uint8_t *ip_addr, int port, int attribute_id, struct maat_state *state)
|
||||
{
|
||||
//clear rule_state->last_hit_group
|
||||
//clear rule_state->last_hit_object
|
||||
if (state != NULL && state->rule_state != NULL) {
|
||||
rule_state_clear_last_hit_group(state->rule_state);
|
||||
rule_state_clear_last_hit_object(state->rule_state);
|
||||
}
|
||||
|
||||
if (0 == ip_rt->rule_num) {
|
||||
@@ -584,7 +584,7 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
|
||||
}
|
||||
|
||||
hit_maat_items[real_hit_item_cnt].item_id = ip_results[i].rule_id;
|
||||
hit_maat_items[real_hit_item_cnt].group_id = ip_item->group_id;
|
||||
hit_maat_items[real_hit_item_cnt].object_id = ip_item->object_id;
|
||||
real_hit_item_cnt++;
|
||||
}
|
||||
|
||||
|
||||
1252
src/maat_object.c
Normal file
1252
src/maat_object.c
Normal file
File diff suppressed because it is too large
Load Diff
568
src/maat_rule.c
568
src/maat_rule.c
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
#include "alignment.h"
|
||||
#include "maat_ip.h"
|
||||
#include "maat_rule.h"
|
||||
#include "maat_group.h"
|
||||
#include "maat_object.h"
|
||||
#include "maat_plugin.h"
|
||||
#include "maat_expr.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ enum MAAT_FS_STATUS {
|
||||
STATUS_PLUGIN_CACHE_NUM,
|
||||
STATUS_PLUGIN_ACC_NUM,
|
||||
STATUS_CONDITION_REF_NOT_NUM,
|
||||
STATUS_GROUP_REF_EXCL_NUM, //group reference exclude group num
|
||||
STATUS_OBJECT_REF_EXCL_NUM, //object reference exclude object num
|
||||
STATUS_HIT_RULE_NUM,
|
||||
STATUS_MAAT_STATE_NUM,
|
||||
STATUS_MAAT_PER_STATE_MEM,
|
||||
@@ -78,7 +78,7 @@ static void fs_global_metric_register(struct maat_stat *stat)
|
||||
stat->g_metric_id[STATUS_CONDITION_REF_NOT_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "NOT_condition_num");
|
||||
|
||||
stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM] =
|
||||
stat->g_metric_id[STATUS_OBJECT_REF_EXCL_NUM] =
|
||||
fieldstat_easy_register_counter(stat->fs_handle, "excl_grp");
|
||||
|
||||
stat->g_metric_id[STATUS_GARBAGE_QUEUE_LEN] =
|
||||
@@ -272,11 +272,11 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
|
||||
plugin_cache_num += plugin_runtime_cached_row_count(runtime);
|
||||
plugin_rule_num += plugin_runtime_rule_count(runtime);
|
||||
break;
|
||||
case TABLE_TYPE_GROUP2RULE:
|
||||
g2c_not_condition_num += group2rule_runtime_not_condition_count(runtime);
|
||||
case TABLE_TYPE_OBJECT2RULE:
|
||||
g2c_not_condition_num += object2rule_runtime_not_condition_count(runtime);
|
||||
break;
|
||||
case TABLE_TYPE_GROUP2GROUP:
|
||||
g2g_excl_rule_num += group2group_runtime_exclude_rule_count(runtime);
|
||||
case TABLE_TYPE_OBJECT2OBJECT:
|
||||
g2g_excl_rule_num += object2object_runtime_exclude_rule_count(runtime);
|
||||
break;
|
||||
case TABLE_TYPE_EXPR:
|
||||
case TABLE_TYPE_EXPR_PLUS:
|
||||
@@ -419,7 +419,7 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
|
||||
NULL, 0, g2c_not_condition_num);
|
||||
|
||||
fieldstat_easy_counter_set(stat->fs_handle, 0,
|
||||
stat->g_metric_id[STATUS_GROUP_REF_EXCL_NUM],
|
||||
stat->g_metric_id[STATUS_OBJECT_REF_EXCL_NUM],
|
||||
NULL, 0, g2g_excl_rule_num);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "maat_expr.h"
|
||||
#include "maat_ip.h"
|
||||
#include "maat_rule.h"
|
||||
#include "maat_group.h"
|
||||
#include "maat_object.h"
|
||||
#include "maat_flag.h"
|
||||
#include "maat_plugin.h"
|
||||
#include "maat_ip_plugin.h"
|
||||
@@ -289,26 +289,26 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
|
||||
.update_err_count = rule_runtime_update_err_count
|
||||
},
|
||||
{
|
||||
.type = TABLE_TYPE_GROUP2GROUP,
|
||||
.new_schema = group2group_schema_new,
|
||||
.free_schema = group2group_schema_free,
|
||||
.new_runtime = group2group_runtime_new,
|
||||
.free_runtime = group2group_runtime_free,
|
||||
.update_runtime = group2group_runtime_update,
|
||||
.commit_runtime = group2group_runtime_commit,
|
||||
.rule_count = group2group_runtime_rule_count,
|
||||
.update_err_count = group2group_runtime_update_err_count
|
||||
.type = TABLE_TYPE_OBJECT2OBJECT,
|
||||
.new_schema = object2object_schema_new,
|
||||
.free_schema = object2object_schema_free,
|
||||
.new_runtime = object2object_runtime_new,
|
||||
.free_runtime = object2object_runtime_free,
|
||||
.update_runtime = object2object_runtime_update,
|
||||
.commit_runtime = object2object_runtime_commit,
|
||||
.rule_count = object2object_runtime_rule_count,
|
||||
.update_err_count = object2object_runtime_update_err_count
|
||||
},
|
||||
{
|
||||
.type = TABLE_TYPE_GROUP2RULE,
|
||||
.new_schema = group2rule_schema_new,
|
||||
.free_schema = group2rule_schema_free,
|
||||
.new_runtime = group2rule_runtime_new,
|
||||
.free_runtime = group2rule_runtime_free,
|
||||
.update_runtime = group2rule_runtime_update,
|
||||
.type = TABLE_TYPE_OBJECT2RULE,
|
||||
.new_schema = object2rule_schema_new,
|
||||
.free_schema = object2rule_schema_free,
|
||||
.new_runtime = object2rule_runtime_new,
|
||||
.free_runtime = object2rule_runtime_free,
|
||||
.update_runtime = object2rule_runtime_update,
|
||||
.commit_runtime = NULL,
|
||||
.rule_count = group2rule_runtime_rule_count,
|
||||
.update_err_count = group2rule_runtime_update_err_count
|
||||
.rule_count = object2rule_runtime_rule_count,
|
||||
.update_err_count = object2rule_runtime_update_err_count
|
||||
}
|
||||
};
|
||||
|
||||
@@ -500,8 +500,8 @@ static void maat_table_schema_free(void *schema, enum table_type table_type)
|
||||
static void register_reserved_word(struct maat_kv_store *reserved_word_map)
|
||||
{
|
||||
maat_kv_register(reserved_word_map, "rule", TABLE_TYPE_RULE);
|
||||
maat_kv_register(reserved_word_map, "group2rule", TABLE_TYPE_GROUP2RULE);
|
||||
maat_kv_register(reserved_word_map, "group2group", TABLE_TYPE_GROUP2GROUP);
|
||||
maat_kv_register(reserved_word_map, "object2rule", TABLE_TYPE_OBJECT2RULE);
|
||||
maat_kv_register(reserved_word_map, "object2object", TABLE_TYPE_OBJECT2OBJECT);
|
||||
maat_kv_register(reserved_word_map, "flag", TABLE_TYPE_FLAG);
|
||||
maat_kv_register(reserved_word_map, "flag_plus", TABLE_TYPE_FLAG_PLUS);
|
||||
maat_kv_register(reserved_word_map, "expr", TABLE_TYPE_EXPR);
|
||||
@@ -905,7 +905,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
|
||||
}
|
||||
}
|
||||
|
||||
if (maat_tbl->table_type == TABLE_TYPE_GROUP2GROUP) {
|
||||
if (maat_tbl->table_type == TABLE_TYPE_OBJECT2OBJECT) {
|
||||
g2g_table_id = maat_tbl->table_id;
|
||||
}
|
||||
|
||||
@@ -930,7 +930,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
|
||||
tbl_mgr->g2g_table_id = g2g_table_id;
|
||||
|
||||
log_info(logger, MODULE_TABLE, "default rule table id: %d", default_rule_table_id);
|
||||
log_info(logger, MODULE_TABLE, "group2group table id: %d", g2g_table_id);
|
||||
log_info(logger, MODULE_TABLE, "object2object table id: %d", g2g_table_id);
|
||||
next:
|
||||
FREE(json_buff);
|
||||
maat_kv_store_free(reserved_word_map);
|
||||
@@ -990,18 +990,18 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
|
||||
garbage_bin, tbl_mgr->logger);
|
||||
}
|
||||
|
||||
/* group2rule runtime depends on associated rule runtime,
|
||||
/* object2rule runtime depends on associated rule runtime,
|
||||
must make sure associated rule runtime already exist */
|
||||
for (i = 0; i < MAX_TABLE_NUM; i++) {
|
||||
table_type = table_manager_get_table_type(tbl_mgr, i);
|
||||
if (table_type != TABLE_TYPE_GROUP2RULE) {
|
||||
if (table_type != TABLE_TYPE_OBJECT2RULE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
void *schema = table_manager_get_schema(tbl_mgr, i);
|
||||
if (NULL == schema) {
|
||||
log_fatal(tbl_mgr->logger, MODULE_TABLE,
|
||||
"[%s:%d] group2rule table(table_id:%d) schema is null",
|
||||
"[%s:%d] object2rule table(table_id:%d) schema is null",
|
||||
__FUNCTION__, __LINE__, i);
|
||||
continue;
|
||||
}
|
||||
@@ -1011,9 +1011,9 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
|
||||
continue;
|
||||
}
|
||||
|
||||
int asso_rule_table_id = group2rule_associated_rule_table_id(schema);
|
||||
int asso_rule_table_id = object2rule_associated_rule_table_id(schema);
|
||||
void *rule_updating_rt = table_manager_get_updating_runtime(tbl_mgr, asso_rule_table_id);
|
||||
group2rule_runtime_init(g2c_updating_rt, rule_updating_rt);
|
||||
object2rule_runtime_init(g2c_updating_rt, rule_updating_rt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1163,7 +1163,7 @@ int table_manager_get_default_rule_table_id(struct table_manager *tbl_mgr)
|
||||
return tbl_mgr->default_rule_table_id;
|
||||
}
|
||||
|
||||
int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr)
|
||||
int table_manager_get_object2object_table_id(struct table_manager *tbl_mgr)
|
||||
{
|
||||
if (NULL == tbl_mgr) {
|
||||
return -1;
|
||||
|
||||
@@ -603,8 +603,8 @@ int ids_str2longlong_array(const char *ids_str, UT_array *ids_array)
|
||||
subtoken = strtok_r(str, seps, &saveptr);
|
||||
if (subtoken == NULL)
|
||||
break;
|
||||
long long group_id = atoll(subtoken);
|
||||
utarray_push_back(ids_array, &group_id);
|
||||
long long object_id = atoll(subtoken);
|
||||
utarray_push_back(ids_array, &object_id);
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user