Compilation fixes

This commit is contained in:
Luca Deri
2020-04-20 15:08:51 +02:00
parent 97badc574b
commit 25cd2a23a6
+19 -19
View File
@@ -693,7 +693,7 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
l3 = (const u_int8_t*)iph6;
}
if (ipsize < l4_offset + l4_packet_len)
if(ipsize < l4_offset + l4_packet_len)
return NULL;
*proto = iph->protocol;
@@ -848,12 +848,12 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
*src = newflow->src_id, *dst = newflow->dst_id;
newflow->entropy.src2dst_pkt_len[newflow->entropy.src2dst_pkt_count] = l4_data_len;
newflow->entropy.src2dst_pkt_time[newflow->entropy.src2dst_pkt_count] = when;
if (newflow->entropy.src2dst_pkt_count == 0) {
if(newflow->entropy.src2dst_pkt_count == 0) {
newflow->entropy.src2dst_start = when;
}
newflow->entropy.src2dst_pkt_count++;
// Non zero app data.
if (l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
if(l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
newflow->entropy.src2dst_opackets++;
newflow->entropy.src2dst_l4_bytes += l4_data_len;
}
@@ -882,29 +882,29 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
else
*src = rflow->dst_id, *dst = rflow->src_id, *src_to_dst_direction = 0, rflow->bidirectional = 1;
}
if (src_to_dst_direction) {
if (rflow->entropy.src2dst_pkt_count < max_num_packets_per_flow) {
if(src_to_dst_direction) {
if(rflow->entropy.src2dst_pkt_count < max_num_packets_per_flow) {
rflow->entropy.src2dst_pkt_len[rflow->entropy.src2dst_pkt_count] = l4_data_len;
rflow->entropy.src2dst_pkt_time[rflow->entropy.src2dst_pkt_count] = when;
rflow->entropy.src2dst_l4_bytes += l4_data_len;
rflow->entropy.src2dst_pkt_count++;
}
// Non zero app data.
if (l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
if(l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
rflow->entropy.src2dst_opackets++;
}
} else {
if (rflow->entropy.dst2src_pkt_count < max_num_packets_per_flow) {
if(rflow->entropy.dst2src_pkt_count < max_num_packets_per_flow) {
rflow->entropy.dst2src_pkt_len[rflow->entropy.dst2src_pkt_count] = l4_data_len;
rflow->entropy.dst2src_pkt_time[rflow->entropy.dst2src_pkt_count] = when;
if (rflow->entropy.dst2src_pkt_count == 0) {
if(rflow->entropy.dst2src_pkt_count == 0) {
rflow->entropy.dst2src_start = when;
}
rflow->entropy.dst2src_l4_bytes += l4_data_len;
rflow->entropy.dst2src_pkt_count++;
}
// Non zero app data.
if (l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
if(l4_data_len != 0XFEEDFACE && l4_data_len != 0) {
rflow->entropy.dst2src_opackets++;
}
}
@@ -1590,7 +1590,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
return(nproto);
}
ether_type_check:
ether_type_check:
recheck_type = 0;
/* check ether type */
@@ -1643,7 +1643,7 @@ ether_type_check:
iph_check:
/* Check and set IP header size and total packet length */
if (header->caplen < ip_offset + sizeof(struct ndpi_iphdr))
if(header->caplen < ip_offset + sizeof(struct ndpi_iphdr))
return(nproto); /* Too short for next IP header*/
iph = (struct ndpi_iphdr *) &packet[ip_offset];
@@ -1671,7 +1671,7 @@ ether_type_check:
if(iph->protocol == IPPROTO_IPV6) {
ip_offset += ip_len;
if (ip_len > 0)
if(ip_len > 0)
goto iph_check;
}
@@ -1689,20 +1689,18 @@ ether_type_check:
return(nproto);
}
} else if(iph->version == 6) {
if (header->caplen < ip_offset + sizeof(struct ndpi_ipv6hdr))
if(header->caplen < ip_offset + sizeof(struct ndpi_ipv6hdr))
return(nproto); /* Too short for IPv6 header*/
iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset];
proto = iph6->ip6_hdr.ip6_un1_nxt;
ip_len = ntohs(iph6->ip6_hdr.ip6_un1_plen);
if (header->caplen < ip_offset + sizeof(struct ndpi_ipv6hdr + ntohs(iph_v6->ip6_hdr.ip6_un1_plen))
if(header->caplen < (ip_offset + sizeof(struct ndpi_ipv6hdr) + ntohs(iph6->ip6_hdr.ip6_un1_plen)))
return(nproto); /* Too short for IPv6 payload*/
const u_int8_t *l4ptr = (((const u_int8_t *) iph6) + sizeof(struct ndpi_ipv6hdr));
if(ndpi_handle_ipv6_extension_headers(NULL, &l4ptr, &ip_len, &proto) != 0) {
return(nproto);
}
iph6->ip6_hdr.ip6_un1_nxt = proto;
iph = NULL;
} else {
@@ -1720,8 +1718,9 @@ ether_type_check:
}
if(workflow->prefs.decode_tunnels && (proto == IPPROTO_UDP)) {
if (header->caplen < ip_offset + ip_len + sizeof(struct ndpi_udphdr))
if(header->caplen < ip_offset + ip_len + sizeof(struct ndpi_udphdr))
return(nproto); /* Too short for UDP header*/
else {
struct ndpi_udphdr *udp = (struct ndpi_udphdr *)&packet[ip_offset+ip_len];
u_int16_t sport = ntohs(udp->source), dport = ntohs(udp->dest);
@@ -1750,7 +1749,7 @@ ether_type_check:
}
} else if((sport == TZSP_PORT) || (dport == TZSP_PORT)) {
/* https://en.wikipedia.org/wiki/TZSP */
if (header->caplen < ip_offset + ip_len + sizeof(struct ndpi_udphdr) + 4)
if(header->caplen < ip_offset + ip_len + sizeof(struct ndpi_udphdr) + 4)
return(nproto); /* Too short for TZSP*/
u_int offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr);
@@ -1815,6 +1814,7 @@ ether_type_check:
}
}
}
}
/* process the packet */
return(packet_processing(workflow, time, vlan_id, tunnel_type, iph, iph6,
@@ -1879,7 +1879,7 @@ u_int32_t ethernet_crc32(const void* data, size_t n_bytes) {
#include <rte_ether.h>
static const struct rte_eth_conf port_conf_default = {
#if (RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0))
#if(RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0))
.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
#else
.rxmode = { .max_rx_pkt_len = RTE_ETHER_MAX_LEN }