build against latest nDPI
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2021-05-07 04:37:23 +02:00
parent cda6f4f877
commit fda01cb7e5
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 67 additions and 6 deletions

View File

@ -62,13 +62,19 @@ steps:
- export MAKEFLAGS="$MAKEFLAGS -j$(nproc)" && printf "$MAKEFLAGS\n"
- git clone https://github.com/ntop/nDPI.git /drone/nDPI
- cd /drone/nDPI
- git checkout 1.7
- ./autogen.sh
- ./configure
- make
- make install
depends_on: [deps]
- name: apply patch nDPI
pull: if-not-exists
image: immawanderer/archlinux-cdev:latest
commands:
- git apply src/patches/dev-ndpi.patch
depends_on: [deps]
- name: build fastnetmon
pull: if-not-exists
image: immawanderer/archlinux-cdev:latest
@ -84,7 +90,7 @@ steps:
- make clean fastnetmon all
when:
status: [success, failure]
depends_on: [build-install nDPI]
depends_on: [build-install nDPI, apply patch nDPI]
- name: print shared object deps
pull: if-not-exists
@ -158,6 +164,12 @@ trigger:
event: [push, pull_request]
steps:
- name: apply patch nDPI
pull: always
image: immawanderer/fedora-cpp:linux-amd64
commands:
- git apply src/patches/dev-ndpi.patch
- name: build fastnetmon
pull: if-not-exists
image: immawanderer/fedora-cpp:linux-amd64
@ -176,6 +188,7 @@ steps:
- make clean fastnetmon all
when:
status: [success]
depends_on: [apply patch nDPI]
- name: print shared object deps
pull: if-not-exists

View File

@ -290,16 +290,16 @@ if (ENABLE_DPI_SUPPORT)
add_library(fast_dpi STATIC fast_dpi.cpp)
set(NDPI_INCLUDE_DIRS "/usr/local/include/libndpi-1.7.1" "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/include/libndpi-1.7.1" "/usr/include/ndpi")
set(NDPI_INCLUDE_DIRS "/usr/include/ndpi" "/usr/local/include/libndpi-1.7.1" "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/include/libndpi-1.7.1")
find_library(NDPI_LIBRARIES NAMES ndpi PATHS "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/lib" "/usr/local/lib" NO_DEFAULT_PATH)
find_library(NDPI_LIBRARIES NAMES ndpi PATHS "/usr/lib" "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/lib" "/usr/local/lib" NO_DEFAULT_PATH)
if (NOT NDPI_LIBRARIES)
message(FATAL_ERROR "Could not find nDPI library")
endif()
link_directories("/usr/local/lib" "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/lib")
include_directories("/usr/local/include/libndpi-1.7.1" "/usr/include/ndpi" ${NDPI_INCLUDE_DIRS})
link_directories("/usr/lib" "/usr/local/lib" "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/ndpi/lib")
include_directories("/usr/include/ndpi" "/usr/local/include/libndpi-1.7.1" ${NDPI_INCLUDE_DIRS})
add_definitions(-DENABLE_DPI)

View File

@ -0,0 +1,48 @@
src/fast_dpi.cpp | 16 ++++++++--------
src/fast_dpi.h | 3 ++-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/fast_dpi.cpp b/src/fast_dpi.cpp
index 7e9f7bf..e0e8d6f 100644
--- a/src/fast_dpi.cpp
+++ b/src/fast_dpi.cpp
@@ -32,17 +32,17 @@ void debug_printf(u_int32_t protocol, void* id_struct, ndpi_log_level_t log_leve
}
struct ndpi_detection_module_struct* init_ndpi() {
- u_int32_t detection_tick_resolution = 1000;
-
- struct ndpi_detection_module_struct* my_ndpi_struct =
-#if NDPI_MAJOR >= 2
- ndpi_init_detection_module();
+ // logic here was incorrectly reverted and ndpi 2.* is way old anyway
+#if NDPI_MAJOR <= 2
+ struct ndpi_detection_module_struct* my_ndpi_struct = ndpi_init_detection_module();
#else
- ndpi_init_detection_module(detection_tick_resolution, malloc, free, debug_printf);
+ // new init after https://github.com/ntop/nDPI/commit/8181d63a
+ // Added ndpi_init_detection_module() API preferences
+ ndpi_init_prefs prefs = ndpi_no_prefs;
+ struct ndpi_detection_module_struct* my_ndpi_struct = ndpi_init_detection_module(prefs);
#endif
-
if (my_ndpi_struct == NULL) {
- // printf("Can't init nDPI");
+ printf("Can't init nDPI");
return NULL;
}
diff --git a/src/fast_dpi.h b/src/fast_dpi.h
index a502643..f92977e 100644
--- a/src/fast_dpi.h
+++ b/src/fast_dpi.h
@@ -1,7 +1,8 @@
#ifndef FAST_DPI_H
#define FAST_DPI_H
-#include "libndpi/ndpi_api.h"
+// newer version are not installed in libndpi anymore
+#include "ndpi/ndpi_api.h"
#include <stdlib.h>
struct ndpi_detection_module_struct* init_ndpi();