This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/src/session/session_manager.h

50 lines
1.8 KiB
C
Raw Normal View History

2023-12-13 19:20:34 +08:00
#ifndef _SESSION_MANAGER_H
#define _SESSION_MANAGER_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include "session.h"
2023-12-19 10:47:26 +08:00
// #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__);
#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__);
#endif
2023-12-13 19:20:34 +08:00
2023-12-19 10:47:26 +08:00
// create and destroy
2023-12-13 19:20:34 +08:00
struct session_manager;
struct session_manager *session_manager_create(uint64_t max_session_num);
void session_manager_destroy(struct session_manager *mgr);
2023-12-19 10:47:26 +08:00
// config
2023-12-13 19:20:34 +08:00
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);
2023-12-19 10:47:26 +08:00
void session_manager_set_packet_timeout(struct session_manager *mgr, uint64_t timeout_ms);
void session_manager_set_closing_timeout(struct session_manager *mgr, uint64_t timeout_ms);
// core functions
struct session *session_manager_find_session(struct session_manager *mgr, const struct packet *pkt);
2023-12-13 19:20:34 +08:00
void session_manager_dispatch(struct session_manager *mgr);
2023-12-19 10:47:26 +08:00
// 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);
2023-12-13 19:20:34 +08:00
#ifdef __cpluscplus
}
#endif
#endif