#ifndef _SCE_H #define _SCE_H #ifdef __cplusplus extern "C" { #endif #include #include "kafka.h" #include "policy.h" #include "timestamp.h" #include "packet_io.h" #include "session_table.h" #include "global_metrics.h" #define MAX_THREAD_NUM 256 /****************************************************************************** * 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; struct thread_metrics thread_metrics; struct global_metrics *ref_global_metrics; struct policy_enforcer *ref_enforcer; int session_table_need_reset; int thread_is_runing; uint64_t tx_packets_ipid; }; char *memdup(const char *src, int len); /****************************************************************************** * Struct Session Ctx ******************************************************************************/ struct session_ctx { uint64_t session_id; char *session_addr; uint32_t rehash_index; // dup from received control packet, for sending control packet char *ctrl_pkt_hdr_ptr; uint16_t ctrl_pkt_hdr_len; uint16_t vxlan_src_port; struct four_tuple inner_tuple4; struct mutable_array rule_ids; // route ctx struct route_ctx decrypted_e2i_route_ctx; struct route_ctx decrypted_i2e_route_ctx; struct route_ctx raw_e2i_route_ctx; struct route_ctx raw_i2e_route_ctx; struct route_ctx ctrl_route_ctx; // sids struct sids decrypted_e2i_sids; struct sids decrypted_i2e_sids; struct sids raw_e2i_sids; struct sids raw_i2e_sids; struct sids ctrl_sids; // chaining struct selected_chaining *chaining_raw; struct selected_chaining *chaining_decrypted; 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 stateless_sids; int nr_worker_threads; int ts_update_interval_ms; int cpu_affinity_mask[MAX_THREAD_NUM]; cpu_set_t coremask; struct kafka *kfk; 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 __cplusplus } #endif #endif