session manager add packet_tag: (PKT_TAG_KEY_SESS, PKT_TAG_VAL_SESS_NEW/FREE/CTRL_MSG/TCP_STREAM)

This commit is contained in:
luwenpeng
2024-11-25 10:53:21 +08:00
parent efc6f46ca0
commit cce1155ae3
11 changed files with 286 additions and 203 deletions

View File

@@ -121,16 +121,12 @@ enum session_timestamp
};
struct session;
#define SESSION_SEEN_C2S_FLOW (1 << 0)
#define SESSION_SEEN_S2C_FLOW (1 << 1)
int session_is_symmetric(const struct session *sess, unsigned char *flag);
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);
enum closing_reason session_get_closing_reason(const struct session *sess);
enum session_direction session_get_direction(const struct session *sess);
enum flow_type session_get_flow_type(const struct session *sess);
@@ -138,11 +134,8 @@ const struct packet *session_get_first_packet(const struct session *sess, enum f
uint64_t session_get_id(const struct session *sess);
uint64_t session_get_timestamp(const struct session *sess, enum session_timestamp type);
uint64_t session_get_stat(const struct session *sess, enum flow_type type, enum session_stat stat);
const char *session_get_readable_addr(const struct session *sess);
void session_set_discard(struct session *sess);
void session_set_exdata(struct session *sess, int idx, void *ex_ptr);
void *session_get_exdata(const struct session *sess, int idx);
@@ -153,7 +146,28 @@ int session_manager_new_session_exdata_index(struct session_manager *sess_mgr, c
struct session *session_manager_lookup_session_by_packet(struct session_manager *sess_mgr, uint16_t thread_id, const struct packet *pkt);
struct session *session_manager_lookup_session_by_id(struct session_manager *sess_mgr, uint16_t thread_id, uint64_t sess_id);
struct session *packet_exdata_to_session(struct packet *pkt);
void session_manager_on_packet_forward(struct packet *pkt, void *args);
void session_manager_on_packet_output(struct packet *pkt, void *args);
struct tcp_segment
{
uint32_t len;
const void *data;
struct tcp_segment *next;
};
struct session *packet_exdata_to_session(const struct session_manager *sess_mgr, const struct packet *pkt);
struct tcp_segment *packet_exdata_to_tcp_segment(const struct session_manager *sess_mgr, const struct packet *pkt);
/*
* example how to use tcp_segment
*
* struct tcp_segment *seg = packet_exdata_to_tcp_segment(sess_mgr, pkt);
* while (seg)
* {
* do_something(seg->data, seg->len);
* seg = seg->next;
* }
*/
#ifdef __cplusplus
}