From ad25affcb7e40e64fa06c5f63e2eab0f12c7f517 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Sat, 10 Feb 2024 09:16:27 +0100 Subject: [PATCH] reader_util: fix GRE detunneling (#2314) --- example/reader_util.c | 3 +-- src/include/ndpi_typedefs.h | 2 +- tests/cfgs/default/pcap/gre.pcapng | Bin 0 -> 668 bytes tests/cfgs/default/result/gre.pcapng.out | 28 +++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/cfgs/default/pcap/gre.pcapng create mode 100644 tests/cfgs/default/result/gre.pcapng.out diff --git a/example/reader_util.c b/example/reader_util.c index bdf723e61..d42b92d25 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1783,10 +1783,9 @@ static uint32_t ndpi_is_valid_gre_tunnel(const struct pcap_pkthdr *header, struct ndpi_gre_basehdr *grehdr = (struct ndpi_gre_basehdr*)&packet[offset]; offset += sizeof(struct ndpi_gre_basehdr); /* - rfc-1701 The GRE flags are encoded in the first two octets. Bit 0 is the most significant bit, bit 15 is the least significant bit. Bits - 13 through 15 are reserved for the Version field. Bits 5 through + 13 through 15 are reserved for the Version field. Bits 9 through 12 are reserved for future use and MUST be transmitted as zero. */ if(NDPI_GRE_IS_FLAGS(grehdr->flags)) diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index ee3128360..324e31c12 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -596,7 +596,7 @@ struct ndpi_vxlanhdr { #define NDPI_GRE_STRICT ntohs(0x0800) #define NDPI_GRE_REC ntohs(0x0700) #define NDPI_GRE_ACK ntohs(0x0080) -#define NDPI_GRE_FLAGS ntohs(0x00f8) +#define NDPI_GRE_FLAGS ntohs(0x0078) #define NDPI_GRE_VERSION ntohs(0x0007) #define NDPI_GRE_IS_CSUM(f) ((f) & NDPI_GRE_CSUM) diff --git a/tests/cfgs/default/pcap/gre.pcapng b/tests/cfgs/default/pcap/gre.pcapng new file mode 100644 index 0000000000000000000000000000000000000000..af3f6eb42a29cea3a11c31b3dee9150f05c5d6df GIT binary patch literal 668 zcmd<$<>m5VU|{gI(UxKa(*L1=nL&)fCo`|KLcv7OM9)Ci)Lb_`H7~U&Gns*bg@J=1 zH?=4|H94^WsD%NfAEZ|VO8@_lU=L<7HlTYKfE*44Hm8W`)D7+9Gam>F0X733F{*g}}8$*GxTsVTOo>a3HB67!NXY^y9Y z+)a|a;~hPX3=9k$OVbU^Oe_tJ&CHFA%nc0 192.168.103.40:5060 [VLAN: 142][proto: GRE:100/SIP][IP: 0/Unknown][ClearText][Confidence: DPI][DPI packets: 1][cat: VoIP/10][1 pkts/384 bytes -> 0 pkts/0 bytes][Goodput ratio: 77/0][< 1 sec][Risk: ** Unidirectional Traffic **][Risk Score: 10][Risk Info: No server to client traffic][PLAIN TEXT (SIP/2.0 100 Trying)][Plen Bins: 0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]