aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorberat <beratiz@gmail.com>2017-06-16 11:24:16 +0200
committerberat <beratiz@gmail.com>2017-06-16 11:24:16 +0200
commit6edece628e578ffb437b99cce4cc1a8e728f5037 (patch)
treebfa5e14be00d39bff610b0c283e24ce0ad937d56 /example
parentbe749e75a502b14e249143eb4353e0a0cea764aa (diff)
Fixed bug causing wrong results in (-b) diagnose statistics
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 6d5f5d5ee..0dd83f899 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -990,7 +990,7 @@ static void port_stats_walker(const void *node, ndpi_VISIT which, int depth, voi
flow->detected_protocol.app_protocol),sizeof(proto));
updatePortStats(&srcStats, sport, saddr, flow->src2dst_packets, flow->src2dst_bytes, proto);
- if(flow->dst2src_packets > 0) updatePortStats(&dstStats, dport, daddr, flow->dst2src_packets, flow->dst2src_bytes, proto);
+ updatePortStats(&dstStats, dport, daddr, flow->dst2src_packets, flow->dst2src_bytes, proto);
}
}
@@ -1336,7 +1336,6 @@ static void saveTopStats(json_object **jObj_group, struct top_stats *stats, int
json_object *jObj_stat = json_object_new_object();
json_object_object_add(jObj_stat,"port",json_object_new_int(s->port));
json_object_object_add(jObj_stat,"packets.number",json_object_new_int64(s->num_pkts));
- json_object_object_add(jObj_stat,"packets.percent",json_object_new_double(s->prcnt_pkt));
json_object_object_add(jObj_stat,"flows.number",json_object_new_double(s->num_flows));
json_object_object_add(jObj_stat,"aggressive.ip",json_object_new_string(s->top_ip));
json_object_object_add(jObj_stat,"protocol",json_object_new_string(s->proto));
@@ -1665,6 +1664,15 @@ static void printResults(u_int64_t tot_usec) {
}
+ if(verbose == 3) {
+ printf("\n\nSource Ports Stats:\n");
+ printPortStats(srcStats);
+
+ printf("\nDestination Ports Stats:\n");
+ printPortStats(dstStats);
+ }
+
+
if(stats_flag) {
#ifdef HAVE_JSON_C
u_int64_t total_src_addr = getTopStats(&topSrcStats, srcStats, cumulative_stats.ip_packet_count);
@@ -1686,17 +1694,12 @@ static void printResults(u_int64_t tot_usec) {
#endif
}
+ if(verbose == 3 || stats_flag){
+ deletePortsStats(srcStats), deletePortsStats(dstStats);
+ srcStats = NULL, dstStats = NULL;
+ }
- if(verbose == 3) {
- printf("\n\nSource Ports Stats:\n");
- printPortStats(srcStats);
-
- printf("\nDestination Ports Stats:\n");
- printPortStats(dstStats);
- deletePortsStats(srcStats), deletePortsStats(dstStats);
- srcStats = NULL, dstStats = NULL;
- }
}