refactor(session manager): rename original session_manager to session_manager_runtime

This commit is contained in:
luwenpeng
2024-09-18 18:32:20 +08:00
parent 60caf1bda1
commit 620019cf8e
26 changed files with 1637 additions and 1552 deletions

View File

@@ -61,7 +61,7 @@ struct session_manager_config
} tcp_reassembly;
};
struct __attribute__((aligned(64))) session_manager_stat
struct session_manager_stat
{
// TCP session
uint64_t history_tcp_sessions;
@@ -104,7 +104,7 @@ struct __attribute__((aligned(64))) session_manager_stat
uint64_t tcp_segs_reordered; // sum
uint64_t tcp_segs_buffered; // sum
uint64_t tcp_segs_freed; // sum
};
} __attribute__((aligned(64)));
enum session_scan_flags
{
@@ -142,34 +142,35 @@ struct session_scan_opts
uint64_t last_pkt_time_ms[2];
};
// new/free/print config
struct session_manager_config *session_manager_config_new(const char *toml_file);
void session_manager_config_free(struct session_manager_config *cfg);
void session_manager_config_print(struct session_manager_config *cfg);
void session_manager_config_free(struct session_manager_config *sess_mgr_cfg);
void session_manager_config_print(struct session_manager_config *sess_mgr_cfg);
struct session_manager;
struct session_manager *session_manager_new(const struct session_manager_config *cfg, uint64_t now_ms);
void session_manager_free(struct session_manager *mgr);
// new/free runtime
struct session_manager_runtime;
struct session_manager_runtime *session_manager_runtime_new(const struct session_manager_config *sess_mgr_cfg, uint64_t now_ms);
void session_manager_runtime_free(struct session_manager_runtime *sess_mgr_rt);
void session_manager_record_duplicated_packet(struct session_manager *mgr, const struct packet *pkt);
// new/free/lookup/update/clean session
struct session *session_manager_runtime_new_session(struct session_manager_runtime *sess_mgr_rt, const struct packet *pkt, uint64_t now_ms);
void session_manager_runtime_free_session(struct session_manager_runtime *sess_mgr_rt, struct session *sess);
struct session *session_manager_runtime_lookup_session_by_packet(struct session_manager_runtime *sess_mgr_rt, const struct packet *pkt);
struct session *session_manager_runtime_lookup_session_by_id(struct session_manager_runtime *sess_mgr_rt, uint64_t sess_id);
int session_manager_runtime_update_session(struct session_manager_runtime *sess_mgr_rt, struct session *sess, const struct packet *pkt, uint64_t now_ms);
struct session *session_manager_runtime_get_expired_session(struct session_manager_runtime *sess_mgr_rt, uint64_t now_ms);
struct session *session_manager_runtime_get_evicted_session(struct session_manager_runtime *sess_mgr_rt);
uint64_t session_manager_runtime_clean_session(struct session_manager_runtime *sess_mgr_rt, uint64_t now_ms, struct session *cleaned_sess[], uint64_t array_size);
struct session *session_manager_new_session(struct session_manager *mgr, const struct packet *pkt, uint64_t now_ms);
void session_manager_free_session(struct session_manager *mgr, struct session *sess);
// stat
struct session_manager_stat *session_manager_runtime_get_stat(struct session_manager_runtime *sess_mgr_rt);
void session_manager_runtime_print_stat(struct session_manager_runtime *sess_mgr_rt);
struct session *session_manager_lookup_session_by_packet(struct session_manager *mgr, const struct packet *pkt);
struct session *session_manager_lookup_session_by_id(struct session_manager *mgr, uint64_t sess_id);
int session_manager_update_session(struct session_manager *mgr, struct session *sess, const struct packet *pkt, uint64_t now_ms);
// scan
uint64_t session_manager_runtime_scan(const struct session_manager_runtime *sess_mgr_rt, const struct session_scan_opts *opts, uint64_t mached_sess_ids[], uint64_t array_size);
// return session need free by session_manager_free_session()
struct session *session_manager_get_expired_session(struct session_manager *mgr, uint64_t now_ms);
struct session *session_manager_get_evicted_session(struct session_manager *mgr);
uint64_t session_manager_clean_session(struct session_manager *mgr, uint64_t now_ms, struct session *cleaned_sess[], uint64_t array_size);
// return 0: have already timeout session
// return >0: next expire interval
uint64_t session_manager_get_expire_interval(struct session_manager *mgr);
struct session_manager_stat *session_manager_stat(struct session_manager *mgr);
uint64_t session_manager_scan(const struct session_manager *mgr, const struct session_scan_opts *opts, uint64_t mached_sess_ids[], uint64_t array_size);
// duplicated packet
void session_manager_runtime_record_duplicated_packet(struct session_manager_runtime *sess_mgr_rt, const struct packet *pkt);
#ifdef __cplusplus
}