Add the packet_injector tool to test the packet injection effect
This commit is contained in:
@@ -471,8 +471,6 @@ int session_to_json(struct session *sess, char *buff, int size)
|
||||
enum flow_direction dir[] = {FLOW_DIRECTION_C2S, FLOW_DIRECTION_S2C};
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
used += snprintf(buff + used, size - used, "\"%s_first_packet\":\"%p\",", str[i], session_get_first_packet(sess, dir[i]));
|
||||
|
||||
// raw packets
|
||||
used += snprintf(buff + used, size - used, "\"%s_raw_packets_received\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_RAW_PACKETS_RECEIVED));
|
||||
used += snprintf(buff + used, size - used, "\"%s_raw_bytes_received\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_RAW_BYTES_RECEIVED));
|
||||
@@ -500,7 +498,7 @@ int session_to_json(struct session *sess, char *buff, int size)
|
||||
used += snprintf(buff + used, size - used, "\"%s_control_bytes_transmitted\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_CONTROL_BYTES_TRANSMITTED));
|
||||
|
||||
used += snprintf(buff + used, size - used, "\"%s_control_packets_dropped\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_CONTROL_PACKETS_DROPPED));
|
||||
used += snprintf(buff + used, size - used, "\"%s_control_bytes_dropped\":%" PRIu64 "", str[i], session_get_stat(sess, dir[i], STAT_CONTROL_BYTES_DROPPED));
|
||||
used += snprintf(buff + used, size - used, "\"%s_control_bytes_dropped\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_CONTROL_BYTES_DROPPED));
|
||||
|
||||
if (session_get_type(sess) == SESSION_TYPE_TCP)
|
||||
{
|
||||
@@ -538,6 +536,7 @@ int session_to_json(struct session *sess, char *buff, int size)
|
||||
used += snprintf(buff + used, size - used, "\"%s_tcp_payloads_released\":%" PRIu64 ",", str[i], session_get_stat(sess, dir[i], STAT_TCP_PAYLOADS_RELEASED));
|
||||
}
|
||||
|
||||
used += snprintf(buff + used, size - used, "\"%s_first_packet\":\"%p\"", str[i], session_get_first_packet(sess, dir[i]));
|
||||
if (i == 0)
|
||||
{
|
||||
used += snprintf(buff + used, size - used, ",");
|
||||
|
||||
@@ -285,7 +285,8 @@ static void tcp_update(struct session_manager *mgr, struct session *sess, enum f
|
||||
uint8_t flags = tcp_hdr_get_flags(hdr);
|
||||
uint16_t len = tcp_layer->pld_len;
|
||||
|
||||
half->flags |= flags;
|
||||
half->flags = flags;
|
||||
half->history |= flags;
|
||||
half->seq = tcp_hdr_get_seq(hdr);
|
||||
half->ack = tcp_hdr_get_ack(hdr);
|
||||
half->len = tcp_layer->pld_len;
|
||||
@@ -771,12 +772,12 @@ static int session_manager_update_tcp_session(struct session_manager *mgr, struc
|
||||
case SESSION_STATE_CLOSING:
|
||||
if (flags & TH_FIN)
|
||||
{
|
||||
timeout = (peer->flags & TH_FIN) ? mgr->opts.tcp_time_wait_timeout : mgr->opts.tcp_half_closed_timeout;
|
||||
timeout = (peer->history & TH_FIN) ? mgr->opts.tcp_time_wait_timeout : mgr->opts.tcp_half_closed_timeout;
|
||||
}
|
||||
else if (flags & TH_RST)
|
||||
{
|
||||
// if fin is received, the expected sequence number should be increased by 1
|
||||
uint32_t expected = (peer->flags & TH_FIN) ? peer->ack + 1 : peer->ack;
|
||||
uint32_t expected = (peer->history & TH_FIN) ? peer->ack + 1 : peer->ack;
|
||||
timeout = (expected == curr->seq) ? mgr->opts.tcp_time_wait_timeout : mgr->opts.tcp_unverified_rst_timeout;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -30,6 +30,7 @@ struct tcp_half
|
||||
uint32_t ack;
|
||||
uint16_t len;
|
||||
uint8_t flags;
|
||||
uint8_t history;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user