/* * The current file is private to the plugin, and pulgin can only use session.h * The current file can only be used by session.cpp/session_pool.cpp/session_table.cpp */ #ifndef _SESSION_PRIVATE_H #define _SESSION_PRIVATE_H #ifdef __cpluscplus extern "C" { #endif #include "timeout.h" #include "uthash.h" #include "session.h" #define EX_DATA_MAX_COUNT 128 #define SESSION_EVENT_QUEUE_SIZE 256 enum tcp_ex_data { // HANDSHAKE TCP_SYN_RECVED = 1 << 0, TCP_SYNACK_RECVED = 1 << 1, TCP_ACK_RECVED = 1 << 2, // ESTABLISHED TCP_C2S_PAYLOAD_RECVED = 1 << 3, TCP_S2C_PAYLOAD_RECVED = 1 << 4, // FIN TCP_C2S_FIN_RECVED = 1 << 5, TCP_S2C_FIN_RECVED = 1 << 6, // RST TCP_C2S_RST_RECVED = 1 << 7, TCP_S2C_RST_RECVED = 1 << 8, }; enum udp_ex_data { UDP_C2S_RECVED = 1 << 0, UDP_S2C_RECVED = 1 << 1, }; struct event_queue { uint32_t head_idx; uint32_t tail_idx; uint32_t events[SESSION_EVENT_QUEUE_SIZE]; }; struct session { // session id uint64_t id; // session state enum session_state state; // session type enum session_type type; // session metrics uint64_t c2s_bytes; uint64_t s2c_bytes; uint64_t c2s_packets; uint64_t s2c_packets; // session metadata struct metadata c2s_1st_md; struct metadata s2c_1st_md; // session timestamp uint64_t create_time; uint64_t last_time; /****************************** * Session Current Packet ******************************/ // session current packet const struct packet *cur_pkt; enum session_dir cur_dir; /****************************** * Session Ev Queue Zone ******************************/ struct event_queue events; /****************************** * Session Ex Data Zone ******************************/ void *ex_data[EX_DATA_MAX_COUNT]; /****************************** * Session Timer Zone ******************************/ // session timer struct timeout timeout; session_expire_cb expire_cb; void *expire_arg; uint64_t expire_abs_ts; /****************************** * Session Pool Zone ******************************/ // session pool recycle handle struct session *next_free_ptr; /****************************** * Session Table Zone ******************************/ // session table key struct tuple6 tuple; enum session_dir tuple_dir; struct session *next_ptr; struct session *prev_ptr; // session table handle UT_hash_handle hh; /****************************** * Session Queue Zone ******************************/ struct session *next_ready_ptr; }; // tcp_builtin_ex = session_get_ex_new_index("tcp_builtin_ex", NULL, NULL); // udp_builtin_ex = session_get_ex_new_index("udp_builtin_ex", NULL, NULL); extern uint8_t tcp_builtin_ex; extern uint8_t udp_builtin_ex; #ifdef __cpluscplus } #endif #endif