Add Packet/IPv4/TCP/UDP helpers API

This commit is contained in:
luwenpeng
2024-01-03 09:57:06 +08:00
parent 529234029f
commit 6b3fc4b560
16 changed files with 502 additions and 956 deletions

View File

@@ -386,7 +386,13 @@ static void update_udp_ex_data(struct session *sess, const struct packet *pkt, e
// return -1: tcp not syn packet, discard
static int handle_tcp_new_session(struct session_manager *mgr, struct tuple6 *key, struct session *sess, const struct packet *pkt)
{
const struct tcphdr *hdr = (const struct tcphdr *)packet_get_tcp_hdr_ptr(pkt);
const struct layer_record *tcp_layer = packet_get_innermost_layer(pkt, LAYER_TYPE_TCP);
if (tcp_layer == NULL)
{
// not tcp packet, discard
return -1;
}
const struct tcphdr *hdr = (const struct tcphdr *)tcp_layer->hdr_ptr;
if (!tcp_hdr_has_flag_syn(hdr))
{
// not syn packet, discard