feature: add GTP utils, support overwrite message length of GTP header

This commit is contained in:
luwenpeng
2024-07-09 11:17:03 +08:00
parent b435ec2ea1
commit c87ad330e0
28 changed files with 1676 additions and 648 deletions

View File

@@ -3,8 +3,8 @@
#include "eth_utils.h"
#include "vlan_utils.h"
#include "ipv4_utils.h"
#include "ipv6_utils.h"
#include "ip4_utils.h"
#include "ip6_utils.h"
#include "tcp_utils.h"
#include "udp_utils.h"
#include "packet_def.h"
@@ -144,8 +144,8 @@ static void tshark_format(const struct runtime *rte, const struct packet *pkt)
str_buff_push(&buff_proto, "ip");
ip4_hdr = (const struct ip *)layer->hdr_ptr;
src_addr_v4 = ipv4_hdr_get_src_in_addr(ip4_hdr);
dst_addr_v4 = ipv4_hdr_get_dst_in_addr(ip4_hdr);
src_addr_v4 = ip4_hdr_get_src_in_addr(ip4_hdr);
dst_addr_v4 = ip4_hdr_get_dst_in_addr(ip4_hdr);
inet_ntop(AF_INET, &src_addr_v4, tmp_src_buff, sizeof(tmp_src_buff));
inet_ntop(AF_INET, &dst_addr_v4, tmp_dst_buff, sizeof(tmp_dst_buff));
str_buff_push(&buff_ipv4_src, tmp_src_buff);
@@ -154,7 +154,7 @@ static void tshark_format(const struct runtime *rte, const struct packet *pkt)
case LAYER_PROTO_IPV6:
str_buff_push(&buff_proto, "ipv6");
ip6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
switch (ipv6_hdr_get_next_header(ip6_hdr))
switch (ip6_hdr_get_next_header(ip6_hdr))
{
case IPPROTO_HOPOPTS:
str_buff_push(&buff_proto, "ipv6.hopopts");
@@ -175,8 +175,8 @@ static void tshark_format(const struct runtime *rte, const struct packet *pkt)
break;
}
src_addr_v6 = ipv6_hdr_get_src_in6_addr(ip6_hdr);
dst_addr_v6 = ipv6_hdr_get_dst_in6_addr(ip6_hdr);
src_addr_v6 = ip6_hdr_get_src_in6_addr(ip6_hdr);
dst_addr_v6 = ip6_hdr_get_dst_in6_addr(ip6_hdr);
inet_ntop(AF_INET6, &src_addr_v6, tmp_src_buff, sizeof(tmp_src_buff));
inet_ntop(AF_INET6, &dst_addr_v6, tmp_dst_buff, sizeof(tmp_dst_buff));
str_buff_push(&buff_ipv6_src, tmp_src_buff);
@@ -219,7 +219,8 @@ static void tshark_format(const struct runtime *rte, const struct packet *pkt)
case LAYER_PROTO_VXLAN:
str_buff_push(&buff_proto, "vxlan");
break;
case LAYER_PROTO_GTP:
case LAYER_PROTO_GTP_C:
case LAYER_PROTO_GTP_U:
str_buff_push(&buff_proto, "gtp");
break;
default: