update session finite state machine & add tcp init -> opening test case

This commit is contained in:
luwenpeng
2024-01-23 14:30:46 +08:00
parent 4fbafab4e3
commit 1f668b1a01
16 changed files with 2049 additions and 1021 deletions

View File

@@ -11,6 +11,30 @@ extern "C"
#include "tuple.h"
#include "packet.h"
enum tcp_state
{
// HANDSHAKE
TCP_SYN_RECVED = 1 << 0,
TCP_SYNACK_RECVED = 1 << 1,
TCP_C2S_ACK_RECVED = 1 << 2,
TCP_S2C_ACK_RECVED = 1 << 3,
// ESTABLISHED
TCP_C2S_DATA_RECVED = 1 << 4,
TCP_S2C_DATA_RECVED = 1 << 5,
// FIN
TCP_C2S_FIN_RECVED = 1 << 6,
TCP_S2C_FIN_RECVED = 1 << 7,
// RST
TCP_C2S_RST_RECVED = 1 << 8,
TCP_S2C_RST_RECVED = 1 << 9,
};
enum udp_state
{
UDP_C2S_RECVED = 1 << 0,
UDP_S2C_RECVED = 1 << 1,
};
enum session_state
{
SESSION_STATE_OPENING = 0x1,
@@ -61,10 +85,10 @@ void session_set_id(struct session *sess, uint64_t id);
uint64_t session_get_id(const struct session *sess);
// session key
void session_set_tuple6(struct session *sess, const struct tuple6 *tuple);
const struct tuple6 *session_get0_tuple6(const struct session *sess);
void session_set_tuple6_dir(struct session *sess, enum session_dir dir);
enum session_dir session_get_tuple6_dir(const struct session *sess);
void session_set_key(struct session *sess, const struct tuple6 *tuple);
const struct tuple6 *session_get0_key(const struct session *sess);
void session_set_key_dir(struct session *sess, enum session_dir dir);
enum session_dir session_get_key_dir(const struct session *sess);
// session state
void session_set_state(struct session *sess, enum session_state state);
@@ -96,10 +120,20 @@ void session_set_last_time(struct session *sess, uint64_t timestamp);
uint64_t session_get_create_time(const struct session *sess);
uint64_t session_get_last_time(const struct session *sess);
// session tcp state
void session_set_tcp_state(struct session *sess, enum tcp_state state);
enum tcp_state session_get_tcp_state(const struct session *sess);
// session udp state
void session_set_udp_state(struct session *sess, enum udp_state state);
enum udp_state session_get_udp_state(const struct session *sess);
/******************************************************************************
* session packet
******************************************************************************/
void session_set_c2s_1st_pkt(struct session *sess, const struct packet *pkt);
void session_set_s2c_1st_pkt(struct session *sess, const struct packet *pkt);
const struct packet *session_get0_c2s_1st_pkt(const struct session *sess);
const struct packet *session_get0_s2c_1st_pkt(const struct session *sess);
const struct packet *session_get0_1st_pkt(const struct session *sess);
@@ -141,6 +175,7 @@ void *session_get0_ex_data(const struct session *sess, uint8_t idx);
* if user want to free ex_data, should use session_free_ex_data.
*/
void session_free_ex_data(struct session *sess, uint8_t idx);
void session_free(struct session *sess);
/******************************************************************************
* session expire