aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2020-06-22 14:30:26 +0200
committerLuca Deri <deri@ntop.org>2020-06-22 14:30:26 +0200
commitd9af1562f00d2b9ac9fe5f4e745a84164656fea1 (patch)
tree3080569b67e19d10d34420436cbd851800f6114e /example/ndpiReader.c
parente29e14b7aa305b038be4c07b61bbc28dfff92cb0 (diff)
Fixes #906
Packet bins are not printed wehn empty
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index c32ab5960..a6b9ed992 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -977,28 +977,32 @@ static char* is_unsafe_cipher(ndpi_cipher_weakness c) {
/* ********************************** */
void print_bin(const char *label, struct ndpi_bin *b) {
- u_int8_t i;
- FILE *out = results_file ? results_file : stdout;
+ if(b->num_incs == 0)
+ return;
+ else {
+ u_int8_t i;
+ FILE *out = results_file ? results_file : stdout;
- ndpi_normalize_bin(b);
+ ndpi_normalize_bin(b);
- fprintf(out, "[%s: ", label);
+ fprintf(out, "[%s: ", label);
- for(i=0; i<b->num_bins; i++) {
- switch(b->family) {
- case ndpi_bin_family8:
- fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
- break;
- case ndpi_bin_family16:
- fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
- break;
- case ndpi_bin_family32:
- fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
- break;
+ for(i=0; i<b->num_bins; i++) {
+ switch(b->family) {
+ case ndpi_bin_family8:
+ fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
+ break;
+ case ndpi_bin_family16:
+ fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
+ break;
+ case ndpi_bin_family32:
+ fprintf(out, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
+ break;
+ }
}
- }
- fprintf(out, "]");
+ fprintf(out, "]");
+ }
}
/* ********************************** */