Add the packet_injector tool to test the packet injection effect

This commit is contained in:
luwenpeng
2024-05-11 18:58:36 +08:00
parent 7f1e7a23de
commit cda77c6f6f
17 changed files with 851 additions and 337 deletions

View File

@@ -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