2023-02-10 14:22:40 +08:00
|
|
|
#ifndef _SCE_H
|
|
|
|
|
#define _SCE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-03-27 14:37:18 +08:00
|
|
|
#include <sched.h>
|
|
|
|
|
|
2023-02-10 14:22:40 +08:00
|
|
|
#include "policy.h"
|
2023-03-27 14:37:18 +08:00
|
|
|
#include "timestamp.h"
|
2023-02-10 14:22:40 +08:00
|
|
|
#include "packet_io.h"
|
|
|
|
|
#include "session_table.h"
|
2023-10-12 16:31:53 +08:00
|
|
|
#include "global_metrics.h"
|
2023-02-10 14:22:40 +08:00
|
|
|
|
2023-03-02 16:13:02 +08:00
|
|
|
#define MAX_THREAD_NUM 128
|
|
|
|
|
|
2023-03-14 16:10:44 +08:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Struct Thread Ctx
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
struct thread_ctx
|
|
|
|
|
{
|
|
|
|
|
pthread_t tid;
|
|
|
|
|
int thread_index;
|
|
|
|
|
|
|
|
|
|
struct sf_metrics *sf_metrics;
|
|
|
|
|
struct session_table *session_table;
|
|
|
|
|
|
|
|
|
|
struct packet_io *ref_io;
|
|
|
|
|
struct sce_ctx *ref_sce_ctx;
|
2023-10-12 16:31:53 +08:00
|
|
|
struct thread_metrics thread_metrics;
|
|
|
|
|
struct global_metrics *ref_global_metrics;
|
2023-03-14 16:10:44 +08:00
|
|
|
struct policy_enforcer *ref_enforcer;
|
|
|
|
|
|
|
|
|
|
int session_table_need_reset;
|
2023-05-25 17:05:22 +08:00
|
|
|
int thread_is_runing;
|
2023-10-11 18:11:48 +08:00
|
|
|
uint64_t tx_packets_to_sf;
|
2023-03-14 16:10:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
* Struct Metadata
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
struct metadata
|
|
|
|
|
{
|
|
|
|
|
int write_ref;
|
|
|
|
|
uint64_t session_id;
|
|
|
|
|
|
|
|
|
|
char *raw_data;
|
|
|
|
|
int raw_len;
|
|
|
|
|
uint16_t l7offset;
|
|
|
|
|
|
|
|
|
|
int is_e2i_dir;
|
|
|
|
|
int is_ctrl_pkt;
|
|
|
|
|
int is_decrypted;
|
|
|
|
|
|
|
|
|
|
struct sids sids;
|
|
|
|
|
struct route_ctx route_ctx;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct metadata *metadata_new();
|
|
|
|
|
int metadata_is_empty(struct metadata *meta);
|
2023-05-06 10:41:30 +08:00
|
|
|
void metadata_shallow_copy(struct metadata *dst, struct metadata *src);
|
2023-03-14 16:10:44 +08:00
|
|
|
void metadata_deep_copy(struct metadata *dst, struct metadata *src);
|
|
|
|
|
void metadata_free(struct metadata *meta);
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
* Struct Session Ctx
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
struct session_ctx
|
|
|
|
|
{
|
|
|
|
|
uint64_t session_id;
|
|
|
|
|
char *session_addr;
|
|
|
|
|
|
2023-11-08 10:20:27 +08:00
|
|
|
struct four_tuple inner_tuple4;
|
2023-10-18 10:08:10 +08:00
|
|
|
struct mutable_array rule_ids;
|
2023-03-14 16:10:44 +08:00
|
|
|
|
2023-05-06 10:41:30 +08:00
|
|
|
struct metadata *decrypted_meta_i2e;
|
|
|
|
|
struct metadata *decrypted_meta_e2i;
|
2023-03-14 16:10:44 +08:00
|
|
|
struct metadata *raw_meta_i2e;
|
|
|
|
|
struct metadata *raw_meta_e2i;
|
|
|
|
|
struct metadata *ctrl_meta;
|
|
|
|
|
|
|
|
|
|
struct selected_chainings chainings;
|
|
|
|
|
|
|
|
|
|
struct thread_ctx *ref_thread_ctx;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct session_ctx *session_ctx_new();
|
|
|
|
|
void session_ctx_free(struct session_ctx *ctx);
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
* Struct SCE Ctx
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
struct sce_ctx
|
|
|
|
|
{
|
|
|
|
|
int enable_debug;
|
|
|
|
|
int enable_send_log;
|
|
|
|
|
int firewall_sids;
|
|
|
|
|
int nr_worker_threads;
|
|
|
|
|
int ts_update_interval_ms;
|
|
|
|
|
int cpu_affinity_mask[MAX_THREAD_NUM];
|
|
|
|
|
|
|
|
|
|
cpu_set_t coremask;
|
|
|
|
|
struct timestamp *ts;
|
|
|
|
|
struct packet_io *io;
|
|
|
|
|
struct global_metrics *metrics;
|
|
|
|
|
struct policy_enforcer *enforcer;
|
|
|
|
|
struct thread_ctx work_threads[MAX_THREAD_NUM];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct sce_ctx *sce_ctx_create(const char *profile);
|
|
|
|
|
void sce_ctx_destory(struct sce_ctx *ctx);
|
2023-02-10 14:22:40 +08:00
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|