aboutsummaryrefslogtreecommitdiff
path: root/example/reader_util.c
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2020-04-21 20:43:29 +0200
committerNardi Ivan <nardi.ivan@gmail.com>2020-04-23 10:55:33 +0200
commitf965983c23e1c9fc4dbbd294bc39217660f7169b (patch)
tree5736b79212f207263b47e521e5085e40f8ce934c /example/reader_util.c
parent0b702c20d32c4fab113f5c3da7e503f7fd1a9ec5 (diff)
Add basic support for some ip-in-ip tunnels
Add support for 4in4, 6in6 and 4in6 encapsulations Add support for ipv6 traffic in gtp tunnels, too To allow gtp unit test, gtp detunneling flag has been globally enabled in the test suite
Diffstat (limited to 'example/reader_util.c')
-rw-r--r--example/reader_util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index dbce3636e..eeddeab61 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1675,7 +1675,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
ip_len = ((u_int16_t)iph->ihl * 4);
iph6 = NULL;
- if(iph->protocol == IPPROTO_IPV6) {
+ if(iph->protocol == IPPROTO_IPV6 || iph->protocol == IPPROTO_IPIP) {
ip_offset += ip_len;
if(ip_len > 0)
goto iph_check;
@@ -1707,6 +1707,12 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
if(ndpi_handle_ipv6_extension_headers(NULL, &l4ptr, &ip_len, &proto) != 0) {
return(nproto);
}
+ if(proto == IPPROTO_IPV6 || proto == IPPROTO_IPIP) {
+ if(l4ptr > packet) { /* Better safe than sorry */
+ ip_offset = (l4ptr - packet);
+ goto iph_check;
+ }
+ }
iph = NULL;
} else {
@@ -1746,11 +1752,15 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
if(flags & 0x02) ip_offset += 4; /* sequence_number is present (it also includes next_ext_header and pdu_number) */
if(flags & 0x01) ip_offset += 1; /* pdu_number is present */
- iph = (struct ndpi_iphdr *) &packet[ip_offset];
-
- if(iph->version != IPVERSION) {
- // printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count);
- goto v4_warning;
+ if(ip_offset < header->caplen) {
+ iph = (struct ndpi_iphdr *)&packet[ip_offset];
+ if(iph->version == 6) {
+ iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset];
+ iph = NULL;
+ } else if(iph->version != IPVERSION) {
+ // printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count);
+ goto v4_warning;
+ }
}
}
} else if((sport == TZSP_PORT) || (dport == TZSP_PORT)) {