aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/ndpiReader.c5
-rw-r--r--libndpi.sym1
-rw-r--r--src/include/ndpi_api.h6
-rw-r--r--src/lib/ndpi_main.c4
4 files changed, 16 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 38ce75b14..ddd83bb74 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -3142,6 +3142,11 @@ int main(int argc, char **argv) {
#endif
int i;
+ if(ndpi_get_api_version() != NDPI_API_VERSION) {
+ printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n");
+ return(-1);
+ }
+
automataUnitTest();
ndpi_info_mod = ndpi_init_detection_module();
diff --git a/libndpi.sym b/libndpi.sym
index 625b9e81f..9c6643db4 100644
--- a/libndpi.sym
+++ b/libndpi.sym
@@ -61,3 +61,4 @@ ndpi_category_get_name
ndpi_is_custom_category
ndpi_is_subprotocol_informative
ndpi_set_proto_category
+ndpi_get_api_version \ No newline at end of file
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index 25a7612f2..230885d6d 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -31,6 +31,11 @@
extern "C" {
#endif
+ /* The #define below is used for apps that dynamically link with nDPI to make
+ sure that datastructures and in sync across versions
+ */
+#define NDPI_API_VERSION 1
+
#define SIZEOF_ID_STRUCT (sizeof(struct ndpi_id_struct))
#define SIZEOF_FLOW_STRUCT (sizeof(struct ndpi_flow_struct))
@@ -739,6 +744,7 @@ extern "C" {
void * ndpi_malloc(size_t size);
void * ndpi_calloc(unsigned long count, size_t size);
void ndpi_free(void *ptr);
+ u_int8_t ndpi_get_api_version();
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index ee698a75f..afb0f39e7 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -5234,3 +5234,7 @@ void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a) {
printf("\n");
}
+
+u_int8_t ndpi_get_api_version() {
+ return(NDPI_API_VERSION);
+}