aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2016-04-04 21:40:23 +0200
committerLuca Deri <deri@ntop.org>2016-04-04 21:40:23 +0200
commit6a63ea46a469b6af61a03b0eefc37cafc94f7e5c (patch)
tree6b6f348b9f795612054b6dc2cc0ef696ced3eb01
parentf437fac4129cacba09cb5869861801d4f434b41e (diff)
Added check for alerting when nDPI modified packet payload (should not happen)
-rw-r--r--example/ndpiReader.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 082871346..52fac6a65 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -1620,8 +1620,8 @@ static void pcap_packet_callback(u_char *args,
int llc_off;
int pyld_eth_len = 0;
int check;
- u_int32_t fcs;
-
+ char packet_copy[1600];
+ u_int32_t fcs, packet_copy_len = sizeof(packet_copy);;
u_int64_t time;
u_int16_t ip_offset, ip_len, ip6_offset;
u_int16_t frag_off = 0, vlan_id = 0;
@@ -1643,6 +1643,9 @@ static void pcap_packet_callback(u_char *args,
return;
}
+ if(header->caplen < packet_copy_len) packet_copy_len = header->caplen;
+ memcpy(packet_copy, packet, packet_copy_len);
+
/* Check if capture is live or not */
if (!live_capture) {
if (!pcap_start.tv_sec) pcap_start.tv_sec = header->ts.tv_sec, pcap_start.tv_usec = header->ts.tv_usec;
@@ -1931,6 +1934,10 @@ static void pcap_packet_callback(u_char *args,
/* process the packet */
packet_processing(thread_id, time, vlan_id, iph, iph6,
ip_offset, header->len - ip_offset, header->len);
+
+ if(memcmp(packet_copy, packet, packet_copy_len) != 0)
+ printf("INTERNAL ERROR: ingress packet was nodified by nDPI: this should not happen [thread_id=%u, packetId=%lu]\n",
+ thread_id, (unsigned long)ndpi_thread_info[thread_id].stats.raw_packet_count);
}
/* ******************************************************************** */