aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2021-02-18 22:35:25 +0100
committerLuca Deri <deri@ntop.org>2021-02-18 22:35:25 +0100
commitbce54079d8666eddc0c4387ded9897fcab9fa3a2 (patch)
treef0eb275419563b0110fab7d21487622e606f6072 /src
parenta2c5adc374db1ccc6c446ce1b616fffdeda4430b (diff)
Initial geoip support
Diffstat (limited to 'src')
-rw-r--r--src/include/ndpi_api.h.in6
-rw-r--r--src/include/ndpi_typedefs.h11
-rw-r--r--src/lib/ndpi_main.c4
3 files changed, 20 insertions, 1 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in
index 6ecae02d2..81a1df925 100644
--- a/src/include/ndpi_api.h.in
+++ b/src/include/ndpi_api.h.in
@@ -1465,6 +1465,12 @@ extern "C" {
int ndpi_hash_find_entry(ndpi_str_hash *h, char *key, u_int key_len, u_int8_t *value);
int ndpi_hash_add_entry(ndpi_str_hash *h, char *key, u_int8_t key_len, u_int8_t value);
+ /* ******************************* */
+
+ int ndpi_load_geeoip(struct ndpi_detection_module_struct *ndpi_str,
+ const char *ip_city_data, const char *ip_as_data);
+ int ndpi_free_geeoip(struct ndpi_detection_module_struct *ndpi_str);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h
index 06d8f70fb..3f86ec416 100644
--- a/src/include/ndpi_typedefs.h
+++ b/src/include/ndpi_typedefs.h
@@ -26,8 +26,12 @@
#include "ndpi_define.h"
#include "ndpi_protocol_ids.h"
-
#include "ndpi_utils.h"
+
+#ifdef HAVE_MAXMINDDB
+#include <maxminddb.h>
+#endif
+
/* NDPI_LOG_LEVEL */
typedef enum {
NDPI_LOG_ERROR,
@@ -1153,6 +1157,11 @@ struct ndpi_detection_module_struct {
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
#endif
+
+#ifdef HAVE_MAXMINDDB
+ MMDB_s mmdb_city, mmdb_as;
+ u_int8_t mmdb_city_loaded, mmdb_as_loaded;
+#endif
};
#endif /* NDPI_LIB_COMPILATION */
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index d2a0dbee2..e85da0814 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2449,6 +2449,8 @@ void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_str) {
#include "../../../nDPI-custom/ndpi_exit_detection_module.c"
#endif
+ ndpi_free_geeoip(ndpi_str);
+
ndpi_free(ndpi_str);
}
}
@@ -7123,3 +7125,5 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
return(rc);
}
+
+ /* ******************************************************************** */