TSG-13837 支持decrypted traffic steering/mirroring,并重构packet_io

This commit is contained in:
luwenpeng
2023-03-14 16:10:44 +08:00
parent 29755f2162
commit 0e85d3c9c5
26 changed files with 1960 additions and 1941 deletions

View File

@@ -15,85 +15,100 @@ extern "C"
#define MAX_THREAD_NUM 128
/******************************************************************************
* Struct For Thread
******************************************************************************/
/******************************************************************************
* Struct Thread Ctx
******************************************************************************/
struct thread_ctx
{
pthread_t tid;
int thread_index;
struct session_table *session_table;
struct sf_metrics *sf_metrics;
struct thread_ctx
{
pthread_t tid;
int thread_index;
struct packet_io *ref_io;
struct global_metrics *ref_metrics;
struct policy_enforcer *ref_enforcer;
struct sce_ctx *ref_sce_ctx;
struct sf_metrics *sf_metrics;
struct session_table *session_table;
int session_table_need_reset;
};
struct packet_io *ref_io;
struct sce_ctx *ref_sce_ctx;
struct global_metrics *ref_metrics;
struct policy_enforcer *ref_enforcer;
/******************************************************************************
* Struct For Session
******************************************************************************/
int session_table_need_reset;
};
struct packet_info
{
int dir_is_e2i;
struct addr_tuple4 tuple4;
char *addr_string;
/******************************************************************************
* Struct Metadata
******************************************************************************/
char *header_data;
int header_len;
struct metadata
{
int write_ref;
uint64_t session_id;
struct sids sids;
struct route_ctx route_ctx;
};
char *raw_data;
int raw_len;
uint16_t l7offset;
struct session_ctx
{
struct fixed_num_array policy_ids;
uint64_t session_id;
int is_e2i_dir;
int is_ctrl_pkt;
int is_decrypted;
struct route_ctx raw_pkt_i2e_route_ctx;
struct route_ctx raw_pkt_e2i_route_ctx;
struct sids sids;
struct route_ctx route_ctx;
};
struct sids raw_pkt_i2e_sids;
struct sids raw_pkt_e2i_sids;
struct metadata *metadata_new();
int metadata_is_empty(struct metadata *meta);
void metadata_deep_copy(struct metadata *dst, struct metadata *src);
void metadata_shadow_copy(struct metadata *dst, struct metadata *src);
void metadata_free(struct metadata *meta);
// depending on first control packet
struct packet_info first_ctrl_pkt;
struct selected_chaining *chaining;
/******************************************************************************
* Struct Session Ctx
******************************************************************************/
struct thread_ctx *ref_thread_ctx;
};
struct session_ctx
{
uint64_t session_id;
char *session_addr;
struct session_ctx *session_ctx_new();
void session_ctx_free(struct session_ctx *ctx);
struct addr_tuple4 inner_tuple4;
struct fixed_num_array policy_ids;
/******************************************************************************
* Struct For SCE
******************************************************************************/
struct metadata *raw_meta_i2e;
struct metadata *raw_meta_e2i;
struct metadata *ctrl_meta;
struct sce_ctx
{
int enable_debug;
int firewall_sids;
int nr_worker_threads;
int ts_update_interval_ms;
int cpu_affinity_mask[MAX_THREAD_NUM];
struct selected_chainings chainings;
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 thread_ctx *ref_thread_ctx;
};
struct sce_ctx *sce_ctx_create(const char *profile);
void sce_ctx_destory(struct sce_ctx *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);
#ifdef __cpluscplus
}