From c2e9275a9e56f7d0567fc2512d5cab67932d39da Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Mon, 18 Nov 2024 18:33:19 +0800 Subject: remove session_manager_subscribe_xxx() API; convert session closing events to pseudo packets when a session is closed, use the packet manager to create a pseudo packet, set the session to be closed as packet Exdata, and schedule it to the packet forwarding stage. when the pseudo packet free, the session will be free. --- include/stellar/packet.h | 2 ++ include/stellar/session.h | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/stellar/packet.h b/include/stellar/packet.h index c20e1b5..ec49227 100644 --- a/include/stellar/packet.h +++ b/include/stellar/packet.h @@ -227,6 +227,8 @@ struct packet *packet_manager_build_udp_packet(struct packet_manager *pkt_mgr, c const char *udp_payload, uint16_t udp_payload_len); struct packet *packet_manager_build_l3_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len); +struct packet *packet_manager_dup_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt); +void packet_manager_free_packet(struct packet_manager *pkt_mgr, struct packet *pkt); #ifdef __cplusplus } diff --git a/include/stellar/session.h b/include/stellar/session.h index 68a69c1..a5dae67 100644 --- a/include/stellar/session.h +++ b/include/stellar/session.h @@ -130,7 +130,6 @@ int session_has_duplicate_traffic(const struct session *sess); enum session_type session_get_type(const struct session *sess); enum session_state session_get_current_state(const struct session *sess); -const struct packet *session_get_current_packet(const struct session *sess); enum closing_reason session_get_closing_reason(const struct session *sess); enum session_direction session_get_direction(const struct session *sess); @@ -152,15 +151,7 @@ struct session_manager; struct session_manager *module_to_session_manager(struct module *mod); int session_manager_new_session_exdata_index(struct session_manager *sess_mgr, const char *name, exdata_free *func, void *arg); -// When the state is SESSION_STATE_CLOSED, the packet is NULL, and the session will be destroyed. -typedef void on_session_message_callback(struct session *sess, enum session_state state, struct packet *pkt, void *args); -// When the state is SESSION_STATE_CLOSED, the tcp_payload is NULL, and the session will be destroyed. -typedef void on_tcp_payload_callback(struct session *sess, enum session_state state, const char *tcp_payload, uint32_t tcp_payload_len, void *args); - -int session_manager_subscribe_tcp(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); -int session_manager_subscribe_udp(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); -int session_manager_subscribe_control_packet(struct session_manager *sess_mgr, on_session_message_callback *cb, void *args); -int session_manager_subscribe_tcp_stream(struct session_manager *sess_mgr, on_tcp_payload_callback *cb, void *args); +struct session *packet_exdata_to_session(struct packet *pkt); #ifdef __cplusplus } -- cgit v1.2.3