This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-maat/src/inc_internal/maat_table.h

101 lines
3.5 KiB
C
Raw Normal View History

2023-01-30 21:59:35 +08:00
/*
**********************************************************************************************
* File: maat_table.h
* Description: maat table schema and runtime
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
2023-01-30 21:59:35 +08:00
***********************************************************************************************
*/
#ifndef _MAAT_TABLE_H_
#define _MAAT_TABLE_H_
#ifdef __cplusplus
2023-01-30 21:59:35 +08:00
extern "C"
{
#endif
#include <stddef.h>
#include <cJSON/cJSON.h>
#include "maat.h"
#include "log/log.h"
#include "maat_garbage_collection.h"
2023-01-30 21:59:35 +08:00
enum table_type {
TABLE_TYPE_INVALID = -1,
2023-02-06 08:14:25 +08:00
TABLE_TYPE_FLAG = 0,
2023-03-01 17:44:07 +08:00
TABLE_TYPE_FLAG_PLUS,
2023-02-06 08:14:25 +08:00
TABLE_TYPE_EXPR,
2023-01-30 21:59:35 +08:00
TABLE_TYPE_EXPR_PLUS,
TABLE_TYPE_IP_PLUS,
TABLE_TYPE_INTERVAL,
TABLE_TYPE_INTERVAL_PLUS,
TABLE_TYPE_PLUGIN,
TABLE_TYPE_IP_PLUGIN,
TABLE_TYPE_FQDN_PLUGIN,
TABLE_TYPE_BOOL_PLUGIN,
//above are physical table
TABLE_TYPE_VIRTUAL,
TABLE_TYPE_COMPILE,
TABLE_TYPE_GROUP2GROUP,
TABLE_TYPE_GROUP2COMPILE,
TABLE_TYPE_MAX
};
struct table_manager;
2023-02-03 17:28:14 +08:00
struct table_manager *
table_manager_create(const char *table_info_path, const char *accept_tags,
enum maat_expr_engine expr_engine, struct maat_garbage_bin *garbage_bin,
struct log_handle *logger);
2023-04-20 15:34:56 +08:00
int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_thread_num,
2023-01-31 20:39:53 +08:00
struct maat_garbage_bin *garbage_bin);
2023-01-31 20:39:53 +08:00
void table_manager_runtime_destroy(struct table_manager *tbl_mgr);
2023-01-30 21:59:35 +08:00
void table_manager_destroy(struct table_manager *tbl_mgr);
2023-04-20 15:34:56 +08:00
size_t table_manager_table_size(struct table_manager *tbl_mgr);
2023-01-30 21:59:35 +08:00
size_t table_manager_table_count(struct table_manager *tbl_mgr);
2023-04-20 15:34:56 +08:00
2023-01-30 21:59:35 +08:00
int table_manager_get_table_id(struct table_manager *tbl_mgr, const char *name);
2023-04-20 15:34:56 +08:00
const char *table_manager_get_table_name(struct table_manager *tbl_mgr, int table_id);
2023-01-30 21:59:35 +08:00
enum table_type table_manager_get_table_type(struct table_manager *tbl_mgr, int table_id);
2023-02-03 17:28:14 +08:00
int table_manager_get_default_compile_table_id(struct table_manager *tbl_mgr);
2023-02-03 17:28:14 +08:00
int table_manager_get_group2group_table_id(struct table_manager *tbl_mgr);
2023-01-30 21:59:35 +08:00
int table_manager_get_valid_column(struct table_manager *tbl_mgr, int table_id);
2023-02-03 17:28:14 +08:00
enum maat_expr_engine table_manager_get_expr_engine(struct table_manager *tbl_mgr);
2023-02-03 17:28:14 +08:00
size_t table_manager_accept_tags_count(struct table_manager *tbl_mgr);
2023-01-31 20:39:53 +08:00
int table_manager_accept_tags_match(struct table_manager *tbl_mgr, const char *tags);
2023-01-30 21:59:35 +08:00
2023-02-03 17:28:14 +08:00
void *table_manager_get_schema(struct table_manager *tbl_mgr, int table_id);
2023-01-30 21:59:35 +08:00
void *table_manager_get_runtime(struct table_manager *tbl_mgr, int table_id);
2023-04-12 20:48:19 +08:00
void *table_manager_get_updating_runtime(struct table_manager *tbl_mgr, int table_id);
2023-02-03 17:28:14 +08:00
2023-04-12 20:48:19 +08:00
int table_manager_update_runtime(struct table_manager *tbl_mgr, const char *table_name,
int table_id, const char *line, int update_type);
void table_manager_commit_runtime(struct table_manager *tbl_mgr, int table_id,
int update_type, long long maat_rt_version);
2023-01-30 21:59:35 +08:00
2023-04-12 19:20:05 +08:00
long long table_manager_runtime_rule_count(struct table_manager *tbl_mgr, int table_id);
2023-04-20 15:34:56 +08:00
long long table_manager_runtime_scan_count(struct table_manager *tbl_mgr, int table_id);
long long table_manager_runtime_scan_cpu_time(struct table_manager *tbl_mgr, int table_id);
long long table_manager_runtime_hit_count(struct table_manager *tbl_mgr, int table_id);
long long table_manager_runtime_update_err_count(struct table_manager *tbl_mgr, int table_id);
#ifdef __cplusplus
2023-01-30 21:59:35 +08:00
}
#endif
#endif