mirror of
https://github.com/optim-enterprises-bv/nDPId.git
synced 2025-10-29 09:22:23 +00:00
Fix example build error if memory profiling enabled.
* CI: build against libnDPI with `-DNDPI_NO_PKGCONFIG=ON` and `-DSTATIC_LIBNDPI_INSTALLDIR=/usr` * CI: `ENABLE_DBUS=ON` for most builds Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
|||||||
ndpid_examples: "-DBUILD_EXAMPLES=ON"
|
ndpid_examples: "-DBUILD_EXAMPLES=ON"
|
||||||
ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=ON"
|
ndpid_gcrypt: "-DNDPI_WITH_GCRYPT=ON"
|
||||||
ndpid_zlib: "-DENABLE_ZLIB=ON"
|
ndpid_zlib: "-DENABLE_ZLIB=ON"
|
||||||
ndpid_extras: "-DNDPI_WITH_MAXMINDDB=ON -DNDPI_WITH_PCRE=ON"
|
ndpid_extras: "-DNDPI_WITH_MAXMINDDB=ON -DNDPI_WITH_PCRE=ON -DENABLE_MEMORY_PROFILING=ON"
|
||||||
sanitizer: "-DENABLE_SANITIZER=OFF -DENABLE_SANITIZER_THREAD=OFF"
|
sanitizer: "-DENABLE_SANITIZER=OFF -DENABLE_SANITIZER_THREAD=OFF"
|
||||||
coverage: "-DENABLE_COVERAGE=OFF"
|
coverage: "-DENABLE_COVERAGE=OFF"
|
||||||
poll: "-DFORCE_POLL=OFF"
|
poll: "-DFORCE_POLL=OFF"
|
||||||
@@ -188,7 +188,7 @@ jobs:
|
|||||||
if: startsWith(matrix.os, 'ubuntu')
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev zlib1g-dev libcurl4-openssl-dev
|
sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev zlib1g-dev libcurl4-openssl-dev libdbus-1-dev
|
||||||
sudo apt-get install ${{ matrix.compiler }} lcov iproute2
|
sudo apt-get install ${{ matrix.compiler }} lcov iproute2
|
||||||
- name: Install Ubuntu Prerequisites (libgcrypt)
|
- name: Install Ubuntu Prerequisites (libgcrypt)
|
||||||
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=ON')
|
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=ON')
|
||||||
@@ -210,7 +210,7 @@ jobs:
|
|||||||
- name: Configure nDPId
|
- name: Configure nDPId
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" -DCMAKE_MODULE_LINKER_FLAGS="$CMAKE_MODULE_LINKER_FLAGS" -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \
|
cmake -S . -B build -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" -DCMAKE_MODULE_LINKER_FLAGS="$CMAKE_MODULE_LINKER_FLAGS" -DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \
|
||||||
-DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \
|
-DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \
|
||||||
${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.sanitizer }} ${{ matrix.ndpi_build }} \
|
${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.sanitizer }} ${{ matrix.ndpi_build }} \
|
||||||
${{ matrix.ndpid_examples }} ${{ matrix.ndpid_zlib }} ${{ matrix.ndpid_gcrypt }} ${{ matrix.ndpid_extras }}
|
${{ matrix.ndpid_examples }} ${{ matrix.ndpid_zlib }} ${{ matrix.ndpid_gcrypt }} ${{ matrix.ndpid_extras }}
|
||||||
- name: Build nDPId
|
- name: Build nDPId
|
||||||
@@ -291,11 +291,21 @@ jobs:
|
|||||||
echo "Configure arguments: '$NDPI_CONFIGURE_ARGS'"
|
echo "Configure arguments: '$NDPI_CONFIGURE_ARGS'"
|
||||||
./autogen.sh --prefix=/usr --with-only-libndpi $NDPI_CONFIGURE_ARGS CC="${{ matrix.compiler }}" CXX=false \
|
./autogen.sh --prefix=/usr --with-only-libndpi $NDPI_CONFIGURE_ARGS CC="${{ matrix.compiler }}" CXX=false \
|
||||||
CFLAGS="$CMAKE_C_FLAGS" && make && sudo make install; cd ..; }
|
CFLAGS="$CMAKE_C_FLAGS" && make && sudo make install; cd ..; }
|
||||||
test $WGET_RET -ne 0 || { echo "::info file=CMakeLists.txt::Running CMake.."; \
|
test $WGET_RET -ne 0 || { echo "Running CMake.."; \
|
||||||
cmake -S .. -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
|
cmake -S .. -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
|
||||||
-DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \
|
-DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \
|
||||||
-DBUILD_NDPI=OFF \
|
-DBUILD_NDPI=OFF -DBUILD_EXAMPLES=ON \
|
||||||
|
-DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \
|
||||||
${{ matrix.poll }} ${{ matrix.coverage }} \
|
${{ matrix.poll }} ${{ matrix.coverage }} \
|
||||||
${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; }
|
${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; }
|
||||||
test $WGET_RET -ne 0 || { echo "::info file=CMakeLists.txt:Running Make.."; cmake --build . --verbose; }
|
test $WGET_RET -ne 0 || { echo "Running Make.."; cmake --build . --verbose; }
|
||||||
|
test $WGET_RET -ne 0 || { echo "Running CMake.."; \
|
||||||
|
cmake -S .. -DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
|
||||||
|
-DCMAKE_C_EXE_LINKER_FLAGS="$CMAKE_C_EXE_LINKER_FLAGS" \
|
||||||
|
-DBUILD_NDPI=OFF -DBUILD_EXAMPLES=ON \
|
||||||
|
-DENABLE_DBUS=ON -DENABLE_CURL=ON -DENABLE_SYSTEMD=ON \
|
||||||
|
-DNDPI_NO_PKGCONFIG=ON -DSTATIC_LIBNDPI_INSTALLDIR=/usr \
|
||||||
|
${{ matrix.poll }} ${{ matrix.coverage }} ${{ matrix.ndpid_gcrypt }} \
|
||||||
|
${{ matrix.sanitizer }} ${{ matrix.ndpid_examples }}; }
|
||||||
|
test $WGET_RET -ne 0 || { echo "Running Make.."; cmake --build . --verbose; }
|
||||||
test $WGET_RET -eq 0 -o $WGET_RET -eq 8
|
test $WGET_RET -eq 0 -o $WGET_RET -eq 8
|
||||||
|
|||||||
@@ -81,8 +81,10 @@ option(ENABLE_MEMORY_PROFILING "Enable dynamic memory tracking." OFF)
|
|||||||
option(ENABLE_ZLIB "Enable zlib support for nDPId (experimental)." OFF)
|
option(ENABLE_ZLIB "Enable zlib support for nDPId (experimental)." OFF)
|
||||||
option(ENABLE_SYSTEMD "Install systemd components." OFF)
|
option(ENABLE_SYSTEMD "Install systemd components." OFF)
|
||||||
option(BUILD_EXAMPLES "Build C examples." ON)
|
option(BUILD_EXAMPLES "Build C examples." ON)
|
||||||
|
if(BUILD_EXAMPLES)
|
||||||
option(ENABLE_DBUS "Build DBus notification example." OFF)
|
option(ENABLE_DBUS "Build DBus notification example." OFF)
|
||||||
option(ENABLE_CURL "Build influxdb data write example." OFF)
|
option(ENABLE_CURL "Build influxdb data write example." OFF)
|
||||||
|
endif()
|
||||||
option(BUILD_NDPI "Clone and build nDPI from github." OFF)
|
option(BUILD_NDPI "Clone and build nDPI from github." OFF)
|
||||||
if(BUILD_NDPI)
|
if(BUILD_NDPI)
|
||||||
option(BUILD_NDPI_FORCE_GIT_UPDATE "Forcefully instruments nDPI build script to update the git submodule." OFF)
|
option(BUILD_NDPI_FORCE_GIT_UPDATE "Forcefully instruments nDPI build script to update the git submodule." OFF)
|
||||||
@@ -174,11 +176,13 @@ if(ENABLE_ZLIB)
|
|||||||
set(ZLIB_DEFS "-DENABLE_ZLIB=1")
|
set(ZLIB_DEFS "-DENABLE_ZLIB=1")
|
||||||
pkg_check_modules(ZLIB REQUIRED zlib)
|
pkg_check_modules(ZLIB REQUIRED zlib)
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_DBUS)
|
if(BUILD_EXAMPLES)
|
||||||
pkg_check_modules(DBUS REQUIRED dbus-1)
|
if(ENABLE_DBUS)
|
||||||
endif()
|
pkg_check_modules(DBUS REQUIRED dbus-1)
|
||||||
if(ENABLE_CURL)
|
endif()
|
||||||
pkg_check_modules(CURL REQUIRED libcurl)
|
if(ENABLE_CURL)
|
||||||
|
pkg_check_modules(CURL REQUIRED libcurl)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NDPI_WITH_GCRYPT)
|
if(NDPI_WITH_GCRYPT)
|
||||||
message(STATUS "nDPI: Enable GCRYPT")
|
message(STATUS "nDPI: Enable GCRYPT")
|
||||||
@@ -290,13 +294,13 @@ if(STATIC_LIBNDPI_INSTALLDIR OR BUILD_NDPI)
|
|||||||
add_definitions("-DLIBNDPI_STATIC=1")
|
add_definitions("-DLIBNDPI_STATIC=1")
|
||||||
set(STATIC_LIBNDPI_INC "${STATIC_LIBNDPI_INSTALLDIR}/include/ndpi")
|
set(STATIC_LIBNDPI_INC "${STATIC_LIBNDPI_INSTALLDIR}/include/ndpi")
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
if(EXISTS "${STATIC_LIBNDPI_INSTALLDIR}/lib64")
|
if(EXISTS "${STATIC_LIBNDPI_INSTALLDIR}/lib64/libndpi.a")
|
||||||
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib64/libndpi.a")
|
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib64/libndpi.a")
|
||||||
else()
|
else()
|
||||||
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib/libndpi.a")
|
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib/libndpi.a")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(EXISTS "${STATIC_LIBNDPI_INSTALLDIR}/lib32")
|
if(EXISTS "${STATIC_LIBNDPI_INSTALLDIR}/lib32/libndpi.a")
|
||||||
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib32/libndpi.a")
|
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib32/libndpi.a")
|
||||||
else()
|
else()
|
||||||
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib/libndpi.a")
|
set(STATIC_LIBNDPI_LIB "${STATIC_LIBNDPI_INSTALLDIR}/lib/libndpi.a")
|
||||||
@@ -483,8 +487,11 @@ if(STATIC_LIBNDPI_INSTALLDIR)
|
|||||||
message(STATUS "STATIC_LIBNDPI_INSTALLDIR: ${STATIC_LIBNDPI_INSTALLDIR}")
|
message(STATUS "STATIC_LIBNDPI_INSTALLDIR: ${STATIC_LIBNDPI_INSTALLDIR}")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "BUILD_NDPI...............: ${BUILD_NDPI}")
|
message(STATUS "BUILD_NDPI...............: ${BUILD_NDPI}")
|
||||||
|
message(STATUS "BUILD_EXAMPLES...........: ${BUILD_EXAMPLES}")
|
||||||
|
if(BUILD_EXAMPLES)
|
||||||
message(STATUS "ENABLE_DBUS..............: ${ENABLE_DBUS}")
|
message(STATUS "ENABLE_DBUS..............: ${ENABLE_DBUS}")
|
||||||
message(STATUS "ENABLE_CURL..............: ${ENABLE_CURL}")
|
message(STATUS "ENABLE_CURL..............: ${ENABLE_CURL}")
|
||||||
|
endif()
|
||||||
if(BUILD_NDPI)
|
if(BUILD_NDPI)
|
||||||
message(STATUS "NDPI_ADDITIONAL_ARGS.....: ${NDPI_ADDITIONAL_ARGS}")
|
message(STATUS "NDPI_ADDITIONAL_ARGS.....: ${NDPI_ADDITIONAL_ARGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -350,6 +350,29 @@ static struct global_map const severity_map[] = {{"Low", INFLUXD_STATS_GAUGE_PTR
|
|||||||
{"Emergency", INFLUXD_STATS_GAUGE_PTR(flow_severity_emergency)},
|
{"Emergency", INFLUXD_STATS_GAUGE_PTR(flow_severity_emergency)},
|
||||||
{NULL, INFLUXD_STATS_GAUGE_PTR(flow_severity_unknown)}};
|
{NULL, INFLUXD_STATS_GAUGE_PTR(flow_severity_unknown)}};
|
||||||
|
|
||||||
|
#ifdef ENABLE_MEMORY_PROFILING
|
||||||
|
void nDPIsrvd_memprof_log_alloc(size_t alloc_size)
|
||||||
|
{
|
||||||
|
(void)alloc_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nDPIsrvd_memprof_log_free(size_t free_size)
|
||||||
|
{
|
||||||
|
(void)free_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nDPIsrvd_memprof_log(char const * const format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
fprintf(stderr, "%s", "nDPIsrvd MemoryProfiler: ");
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
fprintf(stderr, "%s\n", "");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define INFLUXDB_FORMAT() "%s=%llu,"
|
#define INFLUXDB_FORMAT() "%s=%llu,"
|
||||||
#define INFLUXDB_FORMAT_END() "%s=%llu\n"
|
#define INFLUXDB_FORMAT_END() "%s=%llu\n"
|
||||||
#define INFLUXDB_VALUE_COUNTER(value) #value, (unsigned long long int)influxd_statistics.counters.value
|
#define INFLUXDB_VALUE_COUNTER(value) #value, (unsigned long long int)influxd_statistics.counters.value
|
||||||
|
|||||||
@@ -75,6 +75,29 @@ static int main_thread_shutdown = 0;
|
|||||||
static char * pidfile = NULL;
|
static char * pidfile = NULL;
|
||||||
static char * serv_optarg = NULL;
|
static char * serv_optarg = NULL;
|
||||||
|
|
||||||
|
#ifdef ENABLE_MEMORY_PROFILING
|
||||||
|
void nDPIsrvd_memprof_log_alloc(size_t alloc_size)
|
||||||
|
{
|
||||||
|
(void)alloc_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nDPIsrvd_memprof_log_free(size_t free_size)
|
||||||
|
{
|
||||||
|
(void)free_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nDPIsrvd_memprof_log(char const * const format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
fprintf(stderr, "%s", "nDPIsrvd MemoryProfiler: ");
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
fprintf(stderr, "%s\n", "");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void send_to_dbus(char const * const icon,
|
static void send_to_dbus(char const * const icon,
|
||||||
char const * const urgency,
|
char const * const urgency,
|
||||||
enum dbus_level level,
|
enum dbus_level level,
|
||||||
|
|||||||
Reference in New Issue
Block a user