diff options
-rw-r--r-- | .github/workflows/build.yml | 42 | ||||
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | nDPId-test.c | 29 | ||||
-rwxr-xr-x | scripts/get-and-build-libndpi.sh | 2 | ||||
-rw-r--r-- | sonar-project.properites | 12 |
5 files changed, 90 insertions, 5 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4e235b261 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build +on: + push: + branches: + - master + pull_request: + branches: + - master + types: [opened, synchronize, reopened] + release: + types: [created] +jobs: + test: + name: ${{ matrix.os }} ${{ matrix.gcrypt }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: ["ubuntu-latest", "ubuntu-18.04"] + ndpid_gcrypt: ["-DNDPI_WITH_GCRYPT=OFF", ""] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Install Ubuntu Prerequisites + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev + sudo apt-get install gcc-arm-linux-gnueabihf gcc-mingw-w64 libc6-dev + - name: Install Ubuntu Prerequisites (libgcrypt) + if: startsWith(matrix.os, 'ubuntu') && !startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') + run: | + sudo apt-get install libgcrypt20-dev + - name: Configure nDPI + run: | + mkdir build && cd build + env CMAKE_C_FLAGS='-Werror' cmake .. -DBUILD_EXAMPLES=ON -DBUILD_NDPI=ON -DENABLE_SANITIZER=ON ${{ matrix.ndpid_gcrypt }} + - name: Build nDPI + run: | + make -C build all diff --git a/CMakeLists.txt b/CMakeLists.txt index b929ba87b..1a61af0a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,10 @@ if(ENABLE_SANITIZER_THREAD) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize=alignment -fsanitize=enum -fsanitize=thread") endif() +if(NOT NDPI_WITH_GCRYPT) + set(NDPI_ADDITIONAL_ARGS "--disable-gcrypt") +endif() + if(STATIC_LIBNDPI_INSTALLDIR STREQUAL "" AND BUILD_NDPI) include(ExternalProject) ExternalProject_Add( @@ -117,6 +121,7 @@ if(STATIC_LIBNDPI_INSTALLDIR STREQUAL "" AND BUILD_NDPI) CFLAGS=${CMAKE_C_FLAGS} LDFLAGS=${CMAKE_MODULE_LINKER_FLAGS} CROSS_COMPILE_TRIPLET=${CROSS_COMPILE_TRIPLET} + ADDITIONAL_ARGS=${NDPI_ADDITIONAL_ARGS} MAKE_PROGRAM=make DEST_INSTALL=${CMAKE_BINARY_DIR}/libnDPI ${CMAKE_CURRENT_SOURCE_DIR}/scripts/get-and-build-libndpi.sh @@ -139,10 +144,6 @@ if(NOT STATIC_LIBNDPI_INSTALLDIR STREQUAL "" OR BUILD_NDPI OR NDPI_NO_PKGCONFIG) option(NDPI_WITH_PCRE "Link static libndpi library against libpcre." OFF) option(NDPI_WITH_MAXMINDDB "Link static libndpi library against libmaxminddb." OFF) - if(BUILD_NDPI AND NOT NDPI_WITH_GCRYPT) - message(FATAL_ERROR "BUILD_NDPI enabled, but NDPI_WITH_GCRYPT not. This will lead to unexpected test results.") - endif() - if(NDPI_WITH_GCRYPT) find_package(GCRYPT "1.4.2" REQUIRED) endif() @@ -176,6 +177,7 @@ else() endif() find_package(PCAP "1.8.1" REQUIRED) + target_compile_options(nDPId PRIVATE "-pthread") target_compile_definitions(nDPId PRIVATE -DGIT_VERSION=\"${GIT_VERSION}\" ${NDPID_DEFS} ${ZLIB_DEFS}) target_include_directories(nDPId PRIVATE diff --git a/nDPId-test.c b/nDPId-test.c index 3beaf6298..543ddb91f 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -32,6 +32,8 @@ struct nDPId_return_value unsigned long long int detected_flow_protocols; unsigned long long int total_active_flows; unsigned long long int total_idle_flows; + unsigned long long int cur_active_flows; + unsigned long long int cur_idle_flows; }; struct distributor_return_value @@ -316,6 +318,8 @@ static void * nDPId_mainloop_thread(void * const arg) nrv->detected_flow_protocols = reader_threads[i].workflow->detected_flow_protocols; nrv->total_active_flows = reader_threads[i].workflow->total_active_flows; nrv->total_idle_flows = reader_threads[i].workflow->total_idle_flows; + nrv->cur_active_flows = reader_threads[i].workflow->cur_active_flows; + nrv->cur_idle_flows = reader_threads[i].workflow->cur_idle_flows; } error: @@ -500,5 +504,30 @@ int main(int argc, char ** argv) return 1; } + if (nDPId_return.cur_active_flows != 0 || nDPId_return.cur_idle_flows != 0) + { + fprintf(stderr, "%s: %s\n", argv[0], "Active / Idle inconsistency detected."); + return 1; + } + + if (nDPId_return.total_skipped_flows != 0) + { + fprintf(stderr, "%s: %s\n", argv[0], "Skipped flow detected, that should not happen."); + return 1; + } + +#ifdef ENABLE_ZLIB + if (zlib_compressions != zlib_decompressions) + { + fprintf(stderr, + "%s: %s (%llu != %llu)\n", + argv[0], + "ZLib compression / decompression inconsistency detected.", + zlib_compressions, + zlib_decompressions); + return 1; + } +#endif + return THREADS_RETURNED_ERROR(); } diff --git a/scripts/get-and-build-libndpi.sh b/scripts/get-and-build-libndpi.sh index 573b68d2c..215c7b9b0 100755 --- a/scripts/get-and-build-libndpi.sh +++ b/scripts/get-and-build-libndpi.sh @@ -25,7 +25,7 @@ if [ ! -z "${CROSS_COMPILE_TRIPLET}" ]; then else HOST_ARG="" fi -./autogen.sh --prefix="${DEST_INSTALL}" --with-only-libndpi ${HOST_ARG} +./autogen.sh --prefix="${DEST_INSTALL}" --with-only-libndpi ${HOST_ARG} ${ADDITIONAL_ARGS} ${MAKE_PROGRAM} install rm -f "${LOCKFILE}" diff --git a/sonar-project.properites b/sonar-project.properites new file mode 100644 index 000000000..09631cb2d --- /dev/null +++ b/sonar-project.properites @@ -0,0 +1,12 @@ +sonar.projectKey=lnslbrty_nDPId +sonar.organization=lnslbrty + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=nDPId +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 |