update UDP utils

This commit is contained in:
luwenpeng
2024-02-21 11:14:21 +08:00
parent c0514964f9
commit c37f9869a6
6 changed files with 66 additions and 29 deletions

View File

@@ -10,6 +10,7 @@
#include "uthash.h"
#include "packet.h"
#include "udp_utils.h"
#define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0)
@@ -865,6 +866,7 @@ static inline const char *parse_ipv4(struct packet *handler, const char *data, u
if ((ntohs(hdr->ip_off) & IP_MF) || (ntohs(hdr->ip_off) & IP_OFFMASK))
{
PACKET_LOG_DEBUG("ip is fragmented");
handler->frag_layer = layer;
return layer->pld_ptr;
}
@@ -888,6 +890,8 @@ static inline const char *parse_ipv6(struct packet *handler, const char *data, u
uint8_t next_proto = ((struct ip6_hdr *)data)->ip6_nxt;
SET_LAYER(handler, layer, LAYER_TYPE_IPV6, sizeof(struct ip6_hdr), data, len);
// TODO ipv6 fragment
// TESTED
return parse_l4(handler, next_proto, layer->pld_ptr, layer->pld_len);
}
@@ -945,7 +949,7 @@ static inline const char *parse_udp(struct packet *handler, const char *data, ui
struct udphdr *hdr = (struct udphdr *)data;
SET_LAYER(handler, layer, LAYER_TYPE_UDP, sizeof(struct udphdr), data, len);
switch (ntohs(hdr->uh_dport))
switch (udp_hdr_get_dst_port(hdr))
{
// TESTED
// VXLAN_DPORT
@@ -1096,6 +1100,7 @@ static inline const char *parse_l4(struct packet *handler, uint8_t next_proto, c
// return innermost payload
const char *packet_parse(struct packet *handler, const char *data, uint16_t len)
{
handler->frag_layer = NULL;
handler->layers_used = 0;
handler->layers_size = PACKET_MAX_LAYERS;
handler->data_ptr = data;