rename session_direction to flow_direction

This commit is contained in:
luwenpeng
2024-05-09 14:57:12 +08:00
parent 37d12ebcfc
commit cc380d9271
21 changed files with 610 additions and 556 deletions

View File

@@ -78,7 +78,30 @@ const struct packet_layer *packet_get_outermost_layer(const struct packet *pkt,
* Utils
******************************************************************************/
int8_t packet_get_layers(const struct packet *pkt);
#define MAX_SID_NUM 8
struct sid_list
{
uint16_t sid[MAX_SID_NUM];
int used;
};
enum packet_direction
{
PACKET_DIRECTION_OUTGOING = 0, // Internal -> External: 0
PACKET_DIRECTION_INCOMING = 1, // External -> Internal: 1
};
enum packet_action
{
PACKET_ACTION_FORWARD = 0,
PACKET_ACTION_DROP = 1,
};
enum packet_direction packet_get_direction(const struct packet *pkt);
uint64_t packet_get_session_id(const struct packet *pkt);
void packet_prepend_sid_list(struct packet *pkt, const struct sid_list *list);
int8_t packet_get_layers_number(const struct packet *pkt);
const struct packet_layer *packet_get_layer(const struct packet *pkt, int8_t idx);
const char *packet_get_data(const struct packet *pkt);
@@ -87,27 +110,8 @@ uint16_t packet_get_len(const struct packet *pkt);
const char *packet_get_payload(const struct packet *pkt);
uint16_t packet_get_payload_len(const struct packet *pkt);
int packet_need_drop(const struct packet *pkt);
void packet_set_drop(struct packet *pkt);
int packet_is_ctrl(const struct packet *pkt);
void packet_set_direction(struct packet *pkt, int dir);
int packet_get_direction(const struct packet *pkt); // 1: E2I, 0: I2E
void packet_set_session_id(struct packet *pkt, uint64_t sess_id);
uint64_t packet_get_session_id(const struct packet *pkt);
#define MAX_SID_NUM 8
struct sid_list
{
uint16_t sid[MAX_SID_NUM];
int used;
};
void packet_set_sid_list(struct packet *pkt, const struct sid_list *list);
void packet_get_sid_list(const struct packet *pkt, struct sid_list *list);
void packet_prepend_sid_list(struct packet *pkt, const struct sid_list *list);
void packet_append_sid_list(struct packet *pkt, const struct sid_list *list);
void packet_set_action(struct packet *pkt, enum packet_action action);
enum packet_action packet_get_action(const struct packet *pkt);
/*
******************************************************************************
@@ -138,7 +142,7 @@ void packet_append_sid_list(struct packet *pkt, const struct sid_list *list);
******************************************************************************
*
* // inorder
* int8_t layers = packet_get_layers(pkt);
* int8_t layers = packet_get_layers_number(pkt);
* for (int8_t i = 0; i < layers; i++)
* {
* const struct packet_layer *layer = packet_get_layer(pkt, i);

View File

@@ -29,10 +29,16 @@ enum session_type
enum session_direction
{
SESSION_DIRECTION_NONE = -1,
SESSION_DIRECTION_C2S = 0,
SESSION_DIRECTION_S2C = 1,
MAX_DIRECTION = 2,
SESSION_DIRECTION_INBOUND = 0,
SESSION_DIRECTION_OUTBOUND = 1,
};
enum flow_direction
{
FLOW_DIRECTION_NONE = -1,
FLOW_DIRECTION_C2S = 0,
FLOW_DIRECTION_S2C = 1,
MAX_FLOW_DIRECTION = 2,
};
enum closing_reason
@@ -118,18 +124,15 @@ int session_has_dup_traffic(const struct session *sess);
enum session_type session_get_type(const struct session *sess);
enum session_state session_get_state(const struct session *sess);
enum closing_reason session_get_closing_reason(const struct session *sess);
enum session_direction session_get_current_direction(const struct session *sess);
const struct packet *session_get_1st_packet(const struct session *sess, enum session_direction dir);
enum session_direction session_get_direction(const struct session *sess);
enum flow_direction session_get_flow_direction(const struct session *sess);
const struct packet *session_get_first_packet(const struct session *sess, enum flow_direction dir);
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 session_direction dir, enum session_stat stat);
uint64_t session_get_stat(const struct session *sess, enum flow_direction dir, enum session_stat stat);
const char *session_get_tuple_str(const struct session *sess);
const char *session_type_to_str(enum session_type type);
const char *session_state_to_str(enum session_state state);
const char *session_direction_to_str(enum session_direction dir);
const char *closing_reason_to_str(enum closing_reason reason);
#ifdef __cplusplus
}

View File

@@ -11,12 +11,9 @@ extern "C"
uint16_t stellar_get_current_thread_index();
// return 0: success, -1: failed
int stellar_inject_icmp_unreach(const struct session *sess, enum session_direction inj_dir, uint16_t thr_idx);
int stellar_inject_tcp_rst(const struct session *sess, enum session_direction inj_dir, uint16_t thr_idx);
int stellar_inject_tcp_payload(const struct session *sess, enum session_direction inj_dir, uint16_t thr_idx, const char *payload, uint16_t len);
int stellar_inject_udp_payload(const struct session *sess, enum session_direction inj_dir, uint16_t thr_idx, const char *payload, uint16_t len);
int stellar_inject_ctrl_msg(const struct session *sess, uint16_t *sids, int nr_sid, uint16_t thr_idx, const char *msg, uint16_t len);
int stellar_inject_stateless_pkt(uint16_t link_id, uint16_t thr_idx, const char *packet, uint16_t len);
int stellar_inject_tcp_flags(const struct session *sess, enum flow_direction inject_dir, uint8_t flags);
int stellar_inject_payload(const struct session *sess, enum flow_direction inject_dir, const char *payload, uint16_t len);
int stellar_inject_ctrl_msg(const struct session *sess, const struct sid_list *sids, const char *msg, uint16_t len);
#ifdef __cplusplus
}