update IPv4 utils

This commit is contained in:
luwenpeng
2024-02-21 14:34:34 +08:00
parent 03f428681e
commit bd3735d3c4
11 changed files with 543 additions and 235 deletions

View File

@@ -12,6 +12,7 @@
#include "packet.h"
#include "udp_utils.h"
#include "tcp_utils.h"
#include "ipv4_utils.h"
#define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0)
@@ -859,8 +860,8 @@ static inline const char *parse_ipv4(struct packet *handler, const char *data, u
return data;
}
struct ip *hdr = (struct ip *)data;
uint8_t next_proto = hdr->ip_p;
uint16_t hdr_len = (hdr->ip_hl & 0xf) * 4u;
uint8_t next_proto = ipv4_get_proto(hdr);
uint16_t hdr_len = ipv4_hdr_get_hdr_len(hdr);
SET_LAYER(handler, layer, LAYER_TYPE_IPV4, hdr_len, data, len);
// ip fragmented