add bool_plugin & fqdn_plugin unit-test

This commit is contained in:
liuwentan
2023-02-24 17:29:38 +08:00
parent 6f4b88d690
commit d4e1670987
29 changed files with 654 additions and 159 deletions

View File

@@ -17,12 +17,10 @@ extern "C"
#endif
#include "maat.h"
#include "maat_table.h"
#include "cJSON/cJSON.h"
struct bool_plugin_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
/* bool plugin schema API */
void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,

View File

@@ -17,12 +17,10 @@ extern "C"
#endif
#include "maat_rule.h"
#include "maat_table.h"
#include "cJSON/cJSON.h"
struct expr_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);

View File

@@ -20,11 +20,9 @@ extern "C"
#include "maat_rule.h"
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct flag_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);

View File

@@ -18,11 +18,9 @@ extern "C"
#include "maat_rule.h"
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct fqdn_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *fqdn_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);

View File

@@ -17,12 +17,10 @@ extern "C"
#endif
#include "maat.h"
#include "maat_table.h"
#include "cJSON/cJSON.h"
struct fqdn_plugin_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
/* fqdn plugin schema API */
void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,

View File

@@ -20,11 +20,9 @@ extern "C"
#include "cJSON/cJSON.h"
#include "maat_kv.h"
#include "maat_table.h"
struct maat_group;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
/* group2group schema API */
void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,

View File

@@ -18,13 +18,10 @@ extern "C"
#include <stdint.h>
#include "maat_rule.h"
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct interval_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);

View File

@@ -17,11 +17,9 @@ extern "C"
#endif
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct ip_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);

View File

@@ -18,11 +18,9 @@ extern "C"
#include "maat.h"
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct ip_plugin_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
/* ip plugin schema API */
void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,

View File

@@ -0,0 +1,54 @@
/*
**********************************************************************************************
* File: maat_port.h
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_PORT_H_
#define _MAAT_PORT_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "cJSON/cJSON.h"
#include "maat_table.h"
#include "maat_rule.h"
/* port is short for port proto */
struct port_runtime;
void *port_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);
void port_schema_free(void *port_schema);
/* ip runtime API */
void *port_runtime_new(void *port_schema, int max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger);
void port_runtime_free(void *port_runtime);
int port_runtime_update(void *port_runtime, void *port_schema,
const char *line, int valid_column);
int port_runtime_commit(void *port_runtime, const char *table_name);
struct ex_data_runtime *port_runtime_get_ex_data_rt(struct port_runtime *port_rt);
/* ip runtime scan API */
int port_runtime_scan(struct port_runtime *port_rt, int thread_id, int port,
int proto, int *group_ids, size_t group_id_size,
int vtable_id, struct maat_state *state);
void port_runtime_scan_hit_inc(struct port_runtime *port_rt, int thread_id);
long long port_runtime_scan_hit_sum(struct port_runtime *port_rt, int n_thread);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,56 +0,0 @@
/*
**********************************************************************************************
* File: maat_port_proto.h
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_PORT_PROTO_H_
#define _MAAT_PORT_PROTO_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "maat_rule.h"
#include "cJSON/cJSON.h"
/* pp is short for port proto */
struct pp_runtime;
struct table_manager;
struct log_handle;
struct maat_garbage_bin;
void *pp_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);
void pp_schema_free(void *pp_schema);
/* ip runtime API */
void *pp_runtime_new(void *pp_schema, int max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger);
void pp_runtime_free(void *pp_runtime);
int pp_runtime_update(void *pp_runtime, void *pp_schema,
const char *line, int valid_column);
int pp_runtime_commit(void *pp_runtime, const char *table_name);
struct ex_data_runtime *pp_runtime_get_ex_data_rt(struct pp_runtime *pp_rt);
/* ip runtime scan API */
int pp_runtime_scan(struct pp_runtime *pp_rt, int thread_id, int port,
int proto, int *group_ids, size_t group_id_size,
int vtable_id, struct maat_state *state);
void pp_runtime_scan_hit_inc(struct pp_runtime *pp_rt, int thread_id);
long long pp_runtime_scan_hit_sum(struct pp_runtime *pp_rt, int n_thread);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -24,7 +24,6 @@ extern "C"
#include <sys/queue.h>
#include <openssl/md5.h>
#include "log/log.h"
#include "hiredis/hiredis.h"
#include "uthash/uthash.h"
#include "maat_command.h"
@@ -32,7 +31,6 @@ extern "C"
#include "maat.h"
#include "maat_kv.h"
#include "maat_table.h"
#include "maat_rule.h"
#include "maat_virtual.h"
#define MAX_TABLE_NUM 1024

View File

@@ -19,6 +19,7 @@ extern "C"
#include <stddef.h>
#include <cJSON/cJSON.h>
#include "log/log.h"
#include "maat_garbage_collection.h"
enum table_type {

View File

@@ -17,6 +17,7 @@ extern "C"
#endif
#include "cJSON/cJSON.h"
#include "maat_table.h"
enum scan_type {
SCAN_TYPE_INVALID = -1,
@@ -32,9 +33,6 @@ enum scan_type {
SCAN_TYPE_MAX
};
struct table_manager;
struct log_handle;
void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);