aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorCampus <campus@ntop.org>2017-09-29 12:18:00 +0200
committerCampus <campus@ntop.org>2017-09-29 12:18:00 +0200
commit1b162234f0d1e72ccffc546f9ca84d41864f6656 (patch)
tree83845d34a62f0011857e529e66eec77cf2ce3aa1 /example/ndpiReader.c
parent50624b390e645903626e2070fbea4ed974a70f9d (diff)
parent3ac47a51041523877581180baaaf6fa54c167908 (diff)
Merge branch 'vel21ripn-dev-tests' into dev
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index e527255fd..a8a767214 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -334,10 +334,22 @@ int cmpProto(const void *_a, const void *_b) {
}
int cmpFlows(const void *_a, const void *_b) {
- struct flow_info *a = (struct flow_info*)_a;
- struct flow_info *b = (struct flow_info*)_b;
-
- return((a->flow->src2dst_bytes + a->flow->dst2src_bytes) < (b->flow->src2dst_bytes + b->flow->dst2src_bytes) ? 1 : -1);
+ struct ndpi_flow_info *fa = ((struct flow_info*)_a)->flow;
+ struct ndpi_flow_info *fb = ((struct flow_info*)_b)->flow;
+ uint64_t a_size = fa->src2dst_bytes + fa->dst2src_bytes;
+ uint64_t b_size = fb->src2dst_bytes + fb->dst2src_bytes;
+ if(a_size != b_size)
+ return a_size < b_size ? 1 : -1;
+
+// copy from ndpi_workflow_node_cmp();
+
+ if(fa->ip_version < fb->ip_version ) return(-1); else { if(fa->ip_version > fb->ip_version ) return(1); }
+ if(fa->protocol < fb->protocol ) return(-1); else { if(fa->protocol > fb->protocol ) return(1); }
+ if(htonl(fa->src_ip) < htonl(fb->src_ip) ) return(-1); else { if(htonl(fa->src_ip) > htonl(fb->src_ip) ) return(1); }
+ if(htons(fa->src_port) < htons(fb->src_port)) return(-1); else { if(htons(fa->src_port) > htons(fb->src_port)) return(1); }
+ if(htonl(fa->dst_ip) < htonl(fb->dst_ip) ) return(-1); else { if(htonl(fa->dst_ip) > htonl(fb->dst_ip) ) return(1); }
+ if(htons(fa->dst_port) < htons(fb->dst_port)) return(-1); else { if(htons(fa->dst_port) > htons(fb->dst_port)) return(1); }
+ return(0);
}
void extcap_config() {