Add stellar thread cycle
This commit is contained in:
@@ -8,42 +8,34 @@ extern "C"
|
||||
|
||||
#include "session.h"
|
||||
|
||||
// #define SESSION_MANAGER_LOG_ERROR(format, ...) void(0)
|
||||
#ifndef SESSION_MANAGER_LOG_ERROR
|
||||
#define SESSION_MANAGER_LOG_ERROR(format, ...) \
|
||||
fprintf(stderr, "ERROR (session manager), " format "\n", ##__VA_ARGS__);
|
||||
// #define SESSION_LOG_ERROR(format, ...) void(0)
|
||||
#ifndef SESSION_LOG_ERROR
|
||||
#define SESSION_LOG_ERROR(format, ...) \
|
||||
fprintf(stderr, "ERROR (session), " format "\n", ##__VA_ARGS__);
|
||||
#endif
|
||||
// #define SESSION_MANAGER_LOG_DEBUG(format, ...) void(0)
|
||||
#ifndef SESSION_MANAGER_LOG_DEBUG
|
||||
#define SESSION_MANAGER_LOG_DEBUG(format, ...) \
|
||||
fprintf(stderr, "DEBUG (session manager), " format "\n", ##__VA_ARGS__);
|
||||
// #define SESSION_LOG_DEBUG(format, ...) void(0)
|
||||
#ifndef SESSION_LOG_DEBUG
|
||||
#define SESSION_LOG_DEBUG(format, ...) \
|
||||
fprintf(stderr, "DEBUG (session), " format "\n", ##__VA_ARGS__);
|
||||
#endif
|
||||
|
||||
// create and destroy
|
||||
struct session_manager;
|
||||
struct session_manager *session_manager_create(uint64_t max_session_num);
|
||||
void session_manager_destroy(struct session_manager *mgr);
|
||||
|
||||
// config
|
||||
typedef void (*session_event_cb)(struct session *sess, uint32_t event, void *arg);
|
||||
void session_manager_set_session_eventcb(struct session_manager *mgr, session_event_cb cb, void *arg);
|
||||
void session_manager_set_timeout_toclosing(struct session_manager *mgr, uint64_t timeout_ms);
|
||||
void session_manager_set_timeout_toclosed(struct session_manager *mgr, uint64_t timeout_ms);
|
||||
|
||||
// core functions
|
||||
struct session *session_manager_lookup(struct session_manager *mgr, const struct packet *pkt);
|
||||
// return null: Invalid tuple6 or tcp first packet is not syn
|
||||
// return null: invalid tuple6 or tcp first packet is not syn
|
||||
struct session *session_manager_update(struct session_manager *mgr, const struct packet *pkt);
|
||||
struct session *session_manager_expire(struct session_manager *mgr);
|
||||
void session_manager_dispatch(struct session_manager *mgr, struct session *sess);
|
||||
|
||||
// for debug
|
||||
uint64_t session_manager_get_tcp_opening_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_tcp_closing_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_tcp_active_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_udp_opening_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_udp_closing_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_udp_active_sess_num(struct session_manager *mgr);
|
||||
uint64_t session_manager_get_sessions(struct session_manager *mgr, enum session_type type, enum session_state state);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user