#ifndef _SCE_H #define _SCE_H #ifdef __cpluscplus extern "C" { #endif #include "utils.h" #include "policy.h" #include "packet_io.h" #include "session_table.h" /****************************************************************************** * Struct For Global ******************************************************************************/ struct global_metrics { struct throughput_metrics dev_endpoint_rx; // 累计值 struct throughput_metrics dev_endpoint_tx; // 累计值 struct throughput_metrics dev_endpoint_err_drop; // 累计值 struct throughput_metrics dev_nf_interface_rx; // 累计值 struct throughput_metrics dev_nf_interface_tx; // 累计值 struct throughput_metrics dev_nf_interface_err_bypass; // 累计值 struct throughput_metrics hit_block_policy; // 累计值 struct throughput_metrics hit_bypass_policy; // 累计值 uint64_t session_nums; // 瞬时值 }; struct global_metrics *global_metrics_create(); void global_metrics_destory(struct global_metrics *metrics); void global_metrics_dump(struct global_metrics *metrics); /****************************************************************************** * Struct For Thread ******************************************************************************/ struct thread_ctx { pthread_t tid; int thread_index; struct session_table *session_table; struct packet_io *ref_io; struct global_metrics *ref_metrics; struct policy_enforcer *ref_enforcer; struct sce_ctx *ref_sce_ctx; int session_table_need_reset; }; /****************************************************************************** * Struct For Session ******************************************************************************/ struct packet_info { int dir_is_e2i; struct addr_tuple4 tuple4; char *addr_string; char *header_data; int header_len; }; struct session_ctx { struct fixed_num_array policy_ids; uint64_t session_id; char raw_pkt_i2e_route_ctx[64]; char raw_pkt_e2i_route_ctx[64]; struct sids raw_pkt_i2e_sids; struct sids raw_pkt_e2i_sids; // depending on first control packet struct packet_info first_ctrl_pkt; struct selected_chaining *chaining; }; struct session_ctx *session_ctx_new(); void session_ctx_free(struct session_ctx *ctx); /****************************************************************************** * Struct For SCE ******************************************************************************/ struct sce_ctx { int firewall_sids; int nr_worker_threads; struct packet_io *io; struct global_metrics *metrics; struct policy_enforcer *enforcer; struct thread_ctx work_threads[128]; }; struct sce_ctx *sce_ctx_create(const char *profile); void sce_ctx_destory(struct sce_ctx *ctx); #ifdef __cpluscplus } #endif #endif