feature: support session manager scan
This commit is contained in:
@@ -5,6 +5,9 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "tuple.h"
|
||||
#include "session_private.h"
|
||||
|
||||
struct session_manager_options
|
||||
{
|
||||
// max session number
|
||||
@@ -89,6 +92,42 @@ struct session_manager_stat
|
||||
uint64_t tcp_segs_freed; // sum
|
||||
};
|
||||
|
||||
enum session_scan_flags
|
||||
{
|
||||
SESSION_SCAN_TYPE = 1 << 0,
|
||||
SESSION_SCAN_STATE = 1 << 1,
|
||||
|
||||
SESSION_SCAN_SIP = 1 << 2,
|
||||
SESSION_SCAN_DIP = 1 << 3,
|
||||
|
||||
SESSION_SCAN_SPORT = 1 << 4,
|
||||
SESSION_SCAN_DPORT = 1 << 5,
|
||||
|
||||
SESSION_SCAN_CREATE_TIME = 1 << 6,
|
||||
SESSION_SCAN_LAST_PKT_TIME = 1 << 7,
|
||||
};
|
||||
|
||||
struct session_scan_opts
|
||||
{
|
||||
// required
|
||||
uint32_t flags;
|
||||
uint32_t cursor;
|
||||
uint32_t count;
|
||||
|
||||
// optional
|
||||
enum session_type type;
|
||||
enum session_state state;
|
||||
|
||||
uint32_t addr_family; // AF_INET or AF_INET6
|
||||
union ip_address src_addr[2]; // network byte order
|
||||
union ip_address dst_addr[2]; // network byte order
|
||||
uint16_t src_port; // network byte order
|
||||
uint16_t dst_port; // network byte order
|
||||
|
||||
uint64_t create_time_ms[2];
|
||||
uint64_t last_pkt_time_ms[2];
|
||||
};
|
||||
|
||||
struct session_manager;
|
||||
struct session_manager *session_manager_new(struct session_manager_options *opts, uint64_t now_ms);
|
||||
void session_manager_free(struct session_manager *mgr);
|
||||
@@ -110,6 +149,7 @@ struct session *session_manager_get_evicted_session(struct session_manager *mgr)
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user