aboutsummaryrefslogtreecommitdiff
path: root/tests/performance
diff options
context:
space:
mode:
Diffstat (limited to 'tests/performance')
-rw-r--r--tests/performance/Makefile.in8
-rw-r--r--tests/performance/geo.c37
-rw-r--r--tests/performance/patriciasearch.c2
-rw-r--r--tests/performance/substringsearch.c2
4 files changed, 46 insertions, 3 deletions
diff --git a/tests/performance/Makefile.in b/tests/performance/Makefile.in
index d342f8483..3041d22f5 100644
--- a/tests/performance/Makefile.in
+++ b/tests/performance/Makefile.in
@@ -2,7 +2,7 @@ INC=-I ../../src/include/ -I ../../src/lib/third_party/include/
LIB=../../src/lib/libndpi.a @ADDITIONAL_LIBS@ @LIBS@
TOOLS=substringsearch patriciasearch gcrypt-int gcrypt-gnu strnstr
-TESTS=substring_test patricia_test strnstr_test
+TESTS=substring_test patricia_test strnstr_test geo_test
all: $(TESTS)
@@ -21,12 +21,18 @@ substringsearch: substringsearch.c Makefile
strnstr: strnstr.cpp Makefile
$(CXX) $(INC) @CFLAGS@ strnstr.cpp -o strnstr
+geo: geo.c Makefile
+ $(CC) $(INC) @CFLAGS@ geo.c -o geo $(LIB)
+
substring_test: substringsearch top-1m.csv
./substringsearch
strnstr_test: strnstr
./strnstr
+geo_test: geo
+ ./geo
+
#
patriciasearch: patriciasearch.c Makefile
diff --git a/tests/performance/geo.c b/tests/performance/geo.c
new file mode 100644
index 000000000..4c7c138fb
--- /dev/null
+++ b/tests/performance/geo.c
@@ -0,0 +1,37 @@
+#include <ndpi_api.h>
+#include <stdio.h>
+
+int main()
+{
+ struct ndpi_detection_module_struct *ndpi_info_mod;
+ int rc;
+
+ ndpi_info_mod = ndpi_init_detection_module(NULL);
+ if (ndpi_info_mod == NULL)
+ return 1;
+
+ if(ndpi_finalize_initialization(ndpi_info_mod) != 0)
+ return 1;
+
+ rc = ndpi_load_geoip(ndpi_info_mod, "GeoLite2-City.mmdb", "GeoLite2-ASN.mmdb");
+ if(rc != 0) {
+ fprintf(stderr, "Error loading db files: %d\n", rc);
+ return 1;
+ }
+
+ char country[50], continent[50], city[50], aso[50];
+ u_int32_t asn;
+
+ char *ips[] = {"24.124.1.8", "8.8.8.8", "161.148.164.31", "184.74.73.88"};
+
+ for (u_int8_t i = 0; i < sizeof(ips)/sizeof(ips[0]); i++) {
+ ndpi_get_geoip_country_continent_city(ndpi_info_mod, ips[i], country, sizeof(country), continent, sizeof(continent), city, sizeof(city));
+ ndpi_get_geoip_aso(ndpi_info_mod, ips[i], aso, sizeof(aso));
+ ndpi_get_geoip_asn(ndpi_info_mod, ips[i], &asn);
+ printf("%u\n\tCountry: %s\n\tContinent: %s\n\tCity: %s\n\tASN: %u\n\tASO: %s\n\n", i + 1, country, continent, city, asn, aso);
+ }
+
+ ndpi_exit_detection_module(ndpi_info_mod);
+
+ return 0;
+}
diff --git a/tests/performance/patriciasearch.c b/tests/performance/patriciasearch.c
index 03736769c..2b9cc258b 100644
--- a/tests/performance/patriciasearch.c
+++ b/tests/performance/patriciasearch.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-22 - ntop.org
+ * Copyright (C) 2011-25 - ntop.org
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/tests/performance/substringsearch.c b/tests/performance/substringsearch.c
index be4f61e4f..7f4008690 100644
--- a/tests/performance/substringsearch.c
+++ b/tests/performance/substringsearch.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-22 - ntop.org
+ * Copyright (C) 2011-25 - ntop.org
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by