From 312dc424bdf93f6680562e7f925e782c766383e6 Mon Sep 17 00:00:00 2001 From: Mark Jeffery Date: Mon, 10 Jun 2024 19:45:19 +0200 Subject: Added NDPI_PROTOCOL_NTOP assert and removed percentage comparison (#2460) Close #2413 --- example/ndpiReader.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index d07fdd0b0..1cccd2fbd 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -5950,6 +5950,7 @@ void domainSearchUnitTest() { char *domain = "ntop.org"; u_int16_t class_id; struct ndpi_detection_module_struct *ndpi_str = ndpi_init_detection_module(NULL); + u_int8_t trace = 0; assert(ndpi_str); assert(sc); @@ -5957,6 +5958,7 @@ void domainSearchUnitTest() { ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, ".ntop.org"); ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, domain); assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, domain)); + assert(class_id == NDPI_PROTOCOL_NTOP); ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_CATEGORY_GAMBLING, "123vc.club"); assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "123vc.club")); @@ -5966,16 +5968,9 @@ void domainSearchUnitTest() { assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "blog.ntop.org")); assert(class_id == NDPI_PROTOCOL_NTOP); -#ifdef DEBUG_TRACE - struct stat st; - - if(stat(fname, &st) == 0) { - u_int32_t s = ndpi_domain_classify_size(ndpi_str, sc); - - printf("Size: %u [%.1f %% of the original filename size]\n", - s, (float)(s * 100) / (float)st.st_size); - } -#endif + u_int32_t s = ndpi_domain_classify_size(sc); + if(trace) printf("ndpi_domain_classify size: %u \n",s); + ndpi_domain_classify_free(sc); ndpi_exit_detection_module(ndpi_str); -- cgit v1.2.3