diff options
author | Ravi Kerur <ravi.kerur@viasat.com> | 2019-09-14 10:06:37 -0700 |
---|---|---|
committer | Ravi Kerur <ravi.kerur@viasat.com> | 2019-09-14 10:06:37 -0700 |
commit | 9f83bf4624d982c5ec654f36dc7563de393c29df (patch) | |
tree | ce09450b8133608a0eedddf43f0617d1de671335 /example/reader_util.c | |
parent | d7c2ced475603228c8999b416719f0cd84b971c7 (diff) |
Add icmp and icmp6 to calculate splt and bd values.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
Diffstat (limited to 'example/reader_util.c')
-rw-r--r-- | example/reader_util.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/example/reader_util.c b/example/reader_util.c index 9ec50486c..b981d2f7a 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -688,7 +688,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow *proto = iph->protocol; l4 = ((const u_int8_t *) l3 + l4_offset); - if(iph->protocol == IPPROTO_TCP && l4_packet_len >= 20) { + if(iph->protocol == IPPROTO_TCP && l4_packet_len >= sizeof(struct ndpi_tcphdr)) { u_int tcp_len; // tcp @@ -699,7 +699,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow *payload = (u_int8_t*)&l4[tcp_len]; *payload_len = ndpi_max(0, l4_packet_len-4*(*tcph)->doff); l4_data_len = l4_packet_len - sizeof(struct ndpi_tcphdr); - } else if(iph->protocol == IPPROTO_UDP && l4_packet_len >= 8) { + } else if(iph->protocol == IPPROTO_UDP && l4_packet_len >= sizeof(struct ndpi_udphdr)) { // udp workflow->stats.udp_count++; @@ -708,6 +708,16 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow *payload = (u_int8_t*)&l4[sizeof(struct ndpi_udphdr)]; *payload_len = (l4_packet_len > sizeof(struct ndpi_udphdr)) ? l4_packet_len-sizeof(struct ndpi_udphdr) : 0; l4_data_len = l4_packet_len - sizeof(struct ndpi_udphdr); + } else if(iph->protocol == IPPROTO_ICMP || iph->protocol == IPPROTO_ICMPV6) { + if (iph->protocol == IPPROTO_ICMP) { + *payload = (u_int8_t*)&l4[sizeof(struct ndpi_icmphdr )]; + *payload_len = (l4_packet_len > sizeof(struct ndpi_icmphdr)) ? l4_packet_len-sizeof(struct ndpi_icmphdr) : 0; + l4_data_len = l4_packet_len - sizeof(struct ndpi_icmphdr); + } else { + *payload = (u_int8_t*)&l4[sizeof(struct ndpi_icmp6hdr)]; + *payload_len = (l4_packet_len > sizeof(struct ndpi_icmp6hdr)) ? l4_packet_len-sizeof(struct ndpi_icmp6hdr) : 0; + l4_data_len = l4_packet_len - sizeof(struct ndpi_icmp6hdr); + } } else { // non tcp/udp protocols *sport = *dport = 0; |