aboutsummaryrefslogtreecommitdiff
path: root/example/reader_util.c
diff options
context:
space:
mode:
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)) {