mirror of
https://github.com/optim-enterprises-bv/nDPId-2.git
synced 2025-10-29 09:22:27 +00:00
Switched to CMake build system.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
@@ -5,9 +5,9 @@ before_install:
|
||||
script:
|
||||
- git clone https://github.com/ntop/nDPI.git
|
||||
- cd nDPI && ./autogen.sh --prefix=$(realpath ./_install) --with-sanitizer --with-only-libndpi && make install -j4 && cd ..
|
||||
- make NDPI_WITH_GCRYPT=yes CUSTOM_LIBNDPI=./nDPI/_install/lib/libndpi.a ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all examples
|
||||
- make -f Makefile.old NDPI_WITH_GCRYPT=yes CUSTOM_LIBNDPI=./nDPI/_install/lib/libndpi.a ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all examples
|
||||
# RUNTIME TESTS (disabled, needs further testing..)
|
||||
#- ./tests/do.sh ./nDPI
|
||||
# EoF RUNTIME TESTS
|
||||
- make clean
|
||||
- PKG_CONFIG_PATH="$(realpath ./nDPI/_install/lib/pkgconfig)" make PKG_CONFIG_BIN=pkg-config ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all examples
|
||||
- make -f Makefile.old clean
|
||||
- PKG_CONFIG_PATH="$(realpath ./nDPI/_install/lib/pkgconfig)" make -f Makefile.old PKG_CONFIG_BIN=pkg-config ENABLE_DEBUG=yes ENABLE_SANITIZER=yes all examples
|
||||
|
||||
102
CMakeLists.txt
Normal file
102
CMakeLists.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(nDPId C)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
option(ENABLE_SANITIZER "Enable ASAN/LSAN/UBSAN." OFF)
|
||||
option(ENABLE_SANITIZER_THREAD "Enable TSAN (does not work together with ASAN)." OFF)
|
||||
option(ENABLE_MEMORY_PROFILING "Enable dynamic memory tracking." OFF)
|
||||
option(BUILD_EXAMPLES "Build C examples." ON)
|
||||
|
||||
set(STATIC_LIBNDPI_INSTALLDIR "" CACHE STRING "Path to a installation directory of libnDPI e.g. /opt/libnDPI/usr")
|
||||
|
||||
add_executable(nDPId nDPId.c utils.c)
|
||||
add_executable(nDPIsrvd nDPIsrvd.c utils.c)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -DJSMN_STATIC=1 -DJSMN_STRICT=1")
|
||||
|
||||
if(ENABLE_MEMORY_PROFILING)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_MEMORY_PROFILING=1 -Duthash_malloc=nDPIsrvd_uthash_malloc -Duthash_free=nDPIsrvd_uthash_free")
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g3 -fno-omit-frame-pointer -fno-inline")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SANITIZER AND ENABLE_SANITIZER_THREAD)
|
||||
message(STATUS_FATAL "ENABLE_SANITIZER and ENABLE_SANITIZER_THREAD can not be used together!")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SANITIZER)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined -fsanitize=enum -fsanitize=leak")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SANITIZER_THREAD)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fsanitize=enum -fsanitize=thread")
|
||||
endif()
|
||||
|
||||
if(NOT STATIC_LIBNDPI_INSTALLDIR STREQUAL "")
|
||||
option(NDPI_WITH_GCRYPT "Link static libndpi library against libgcrypt." ON)
|
||||
option(NDPI_WITH_PCRE "Link static libndpi library against libpcre." OFF)
|
||||
option(NDPI_WITH_MAXMINDDB "Link static libndpi library against libmaxminddb." ON)
|
||||
|
||||
if(NDPI_WITH_GCRYPT)
|
||||
find_package(GCRYPT "1.4.2" REQUIRED)
|
||||
endif()
|
||||
|
||||
if(NDPI_WITH_PCRE)
|
||||
pkg_check_modules(PCRE REQUIRED libpcre)
|
||||
endif()
|
||||
if(NDPI_WITH_MAXMINDDB)
|
||||
pkg_check_modules(MAXMINDDB REQUIRED libmaxminddb)
|
||||
endif()
|
||||
|
||||
find_package(PCAP "1.8.1" REQUIRED)
|
||||
target_compile_options(nDPId PRIVATE "-pthread")
|
||||
target_include_directories(nDPId PRIVATE "${STATIC_LIBNDPI_INSTALLDIR}/include/ndpi")
|
||||
target_link_libraries(nDPId "${STATIC_LIBNDPI_INSTALLDIR}/lib/libndpi.a"
|
||||
"${GCRYPT_LIBRARY}" "${PCAP_LIBRARY}"
|
||||
"${pkgcfg_lib_MAXMINDDB_maxminddb}" "-pthread")
|
||||
target_include_directories(nDPIsrvd PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/jsmn"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/uthash/src")
|
||||
else()
|
||||
pkg_check_modules(NDPI "3.6.0" REQUIRED)
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_executable(nDPIsrvd-collectd examples/c-collectd/c-collectd.c)
|
||||
target_include_directories(nDPIsrvd-collectd PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/jsmn"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/uthash/src")
|
||||
add_executable(nDPIsrvd-captured examples/c-captured/c-captured.c utils.c)
|
||||
target_include_directories(nDPIsrvd-captured PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/jsmn"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/uthash/src")
|
||||
target_link_libraries(nDPIsrvd-captured "${PCAP_LIBRARY}")
|
||||
add_executable(nDPIsrvd-json-dump examples/c-json-stdout/c-json-stdout.c)
|
||||
target_include_directories(nDPIsrvd-json-dump PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies"
|
||||
"${CMAKE_SOURCE_DIR}/dependencies/jsmn")
|
||||
endif()
|
||||
|
||||
message(STATUS "--------------------------")
|
||||
message(STATUS "CMAKE_BUILD_TYPE.........: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "CMAKE_C_FLAGS............: ${CMAKE_C_FLAGS}")
|
||||
message(STATUS "ENABLE_SANITIZER.........: ${ENABLE_SANITIZER}")
|
||||
message(STATUS "ENABLE_SANITIZER_THREAD..: ${ENABLE_SANITIZER_THREAD}")
|
||||
message(STATUS "ENABLE_MEMORY_PROFILING..: ${ENABLE_MEMORY_PROFILING}")
|
||||
message(STATUS "STATIC_LIBNDPI_INSTALLDIR: ${STATIC_LIBNDPI_INSTALLDIR}")
|
||||
if(NOT STATIC_LIBNDPI_INSTALLDIR STREQUAL "")
|
||||
message(STATUS "`- NDPI_WITH_GCRYPT......: ${NDPI_WITH_GCRYPT}")
|
||||
message(STATUS "`- NDPI_WITH_PCRE........: ${NDPI_WITH_PCRE}")
|
||||
message(STATUS "`- NDPI_WITH_MAXMINDDB...: ${NDPI_WITH_MAXMINDDB}")
|
||||
endif()
|
||||
message(STATUS "--------------------------")
|
||||
@@ -1,6 +1,6 @@
|
||||
CC = gcc
|
||||
PROJECT_CFLAGS += -Wall -Wextra $(EXTRA_CFLAGS) -I.
|
||||
DEPS_CFLAGS := -DJSMN_STATIC=1 -DJSMN_STRICT=1 -Idependencies -Idependencies/uthash/src
|
||||
DEPS_CFLAGS := -DJSMN_STATIC=1 -DJSMN_STRICT=1 -Idependencies -Idependencies/jsmn -Idependencies/uthash/src
|
||||
LIBS += -pthread -lpcap -lm -lmaxminddb
|
||||
|
||||
GOCC =
|
||||
@@ -156,6 +156,10 @@ else
|
||||
@echo 'ENABLE_SANITIZER_THREAD = no'
|
||||
endif
|
||||
@echo '------------------------------------'
|
||||
@echo 'Example:'
|
||||
@echo ' make ENABLE_DEBUG=yes ENABLE_SANITIZER=yes GOCC=go-1.14.1 \\'
|
||||
@echo ' CUSTOM_LIBNDPI="~/git/libnDPI/_install/lib/libndpi.a)" \\'
|
||||
@echo ' NDPI_WITH_GCRYPT=yes ENABLE_MEMORY_PROFILING=no all'
|
||||
|
||||
run-mocksrvd:
|
||||
nc -k -l -U $(UNIX_SOCK_COLLECTOR)
|
||||
69
cmake/FindGCRYPT.cmake
Normal file
69
cmake/FindGCRYPT.cmake
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# - Find gcrypt
|
||||
# Find the native GCRYPT includes and library
|
||||
#
|
||||
# GCRYPT_INCLUDE_DIRS - where to find gcrypt.h, etc.
|
||||
# GCRYPT_LIBRARIES - List of libraries when using gcrypt.
|
||||
# GCRYPT_FOUND - True if gcrypt found.
|
||||
# GCRYPT_DLL_DIR - (Windows) Path to the Libgcrypt DLLs.
|
||||
# GCRYPT_DLLS - (Windows) List of required Libgcrypt DLLs.
|
||||
|
||||
|
||||
if(GCRYPT_INCLUDE_DIRS)
|
||||
# Already in cache, be silent
|
||||
set(GCRYPT_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
find_path(GCRYPT_INCLUDE_DIR gcrypt.h
|
||||
HINTS
|
||||
"${GCRYPT_HINTS}/include"
|
||||
)
|
||||
|
||||
find_library(GCRYPT_LIBRARY
|
||||
NAMES gcrypt libgcrypt-20
|
||||
HINTS "${GCRYPT_HINTS}/bin")
|
||||
|
||||
# libgpg-error6-0 is used in libgcrypt-1.7.6-win??ws (built from source).
|
||||
# libgpg-error-0 is used in libgcrypt-1.8.3-win??ws (from Debian).
|
||||
find_library(GCRYPT_ERROR_LIBRARY
|
||||
NAMES gpg-error libgpg-error-0 libgpg-error6-0
|
||||
HINTS "${GCRYPT_HINTS}/bin")
|
||||
|
||||
# Try to retrieve version from header if found (available since libgcrypt 1.3.0)
|
||||
if(GCRYPT_INCLUDE_DIR)
|
||||
set(_version_regex "^#define[ \t]+GCRYPT_VERSION[ \t]+\"([^\"]+)\".*")
|
||||
file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" GCRYPT_VERSION REGEX "${_version_regex}")
|
||||
string(REGEX REPLACE "${_version_regex}" "\\1" GCRYPT_VERSION "${GCRYPT_VERSION}")
|
||||
unset(_version_regex)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GCRYPT
|
||||
REQUIRED_VARS GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR
|
||||
VERSION_VAR GCRYPT_VERSION)
|
||||
|
||||
if(GCRYPT_FOUND)
|
||||
set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
|
||||
set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
|
||||
if(WIN32)
|
||||
set(GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
|
||||
CACHE PATH "Path to the Libgcrypt DLLs"
|
||||
)
|
||||
file(GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
|
||||
"${GCRYPT_DLL_DIR}/libgcrypt-*.dll"
|
||||
"${GCRYPT_DLL_DIR}/libgpg-error*.dll"
|
||||
)
|
||||
set(GCRYPT_DLLS ${_gcrypt_dlls}
|
||||
# We're storing filenames only. Should we use STRING instead?
|
||||
CACHE FILEPATH "Libgcrypt DLL list"
|
||||
)
|
||||
mark_as_advanced(GCRYPT_DLL_DIR GCRYPT_DLLS)
|
||||
endif()
|
||||
else()
|
||||
set(GCRYPT_LIBRARIES)
|
||||
set(GCRYPT_INCLUDE_DIRS)
|
||||
set(GCRYPT_DLL_DIR)
|
||||
set(GCRYPT_DLLS)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)
|
||||
273
cmake/FindPCAP.cmake
Normal file
273
cmake/FindPCAP.cmake
Normal file
@@ -0,0 +1,273 @@
|
||||
#
|
||||
# - Find libpcap
|
||||
# Find the native PCAP includes and library
|
||||
#
|
||||
# PCAP_INCLUDE_DIRS - where to find pcap.h, etc.
|
||||
# PCAP_LIBRARIES - List of libraries when using pcap.
|
||||
# PCAP_FOUND - True if pcap found.
|
||||
|
||||
#
|
||||
# First, try pkg-config on platforms other than Windows.
|
||||
#
|
||||
if(NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
pkg_search_module(PC_PCAP libpcap)
|
||||
endif()
|
||||
|
||||
if(NOT PC_PCAP_FOUND AND NOT WIN32)
|
||||
#
|
||||
# That didn't work. Try to retrieve hints from pcap-config.
|
||||
# Do not use it on Windows as pcap-config is a shell script.
|
||||
#
|
||||
find_program(PCAP_CONFIG pcap-config)
|
||||
if(PCAP_CONFIG)
|
||||
#
|
||||
# We have pcap-config; use it.
|
||||
#
|
||||
# First, get the include directory.
|
||||
#
|
||||
execute_process(COMMAND "${PCAP_CONFIG}" "--cflags"
|
||||
RESULT_VARIABLE PCAP_CONFIG_RESULT
|
||||
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "pcap-config --cflags failed")
|
||||
endif()
|
||||
#
|
||||
# Assumes there's exactly one -I flag in the output
|
||||
# of pcap-config --cflags. That *should* be the case.
|
||||
# Note that the hint might be bogus, on macOS it could be
|
||||
# -I/usr/local/include even though the header isn't
|
||||
# there (it may be under /usr/include or it may be
|
||||
# buried in the Xcode app bundle).
|
||||
#
|
||||
string(REGEX REPLACE "^-I" "" PCAP_CONFIG_INCLUDE_DIRS "${PCAP_CONFIG_OUTPUT}")
|
||||
|
||||
# Now, get the library search path.
|
||||
execute_process(COMMAND "${PCAP_CONFIG}" "--libs"
|
||||
RESULT_VARIABLE PCAP_CONFIG_RESULT
|
||||
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "pcap-config --libs failed")
|
||||
endif()
|
||||
separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT})
|
||||
set(PCAP_CONFIG_LIBRARY_DIRS "")
|
||||
foreach(_arg IN LISTS LIBS_LIST)
|
||||
# At most one -L path is expected for -lpcap.
|
||||
if(_arg MATCHES "^-L")
|
||||
string(REGEX REPLACE "^-L" "" _dir ${_arg})
|
||||
list(APPEND PCAP_CONFIG_LIBRARY_DIRS ${_dir})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES STREQUAL ".a")
|
||||
# Now, get the library directories and libraries for static linking.
|
||||
# (XXX - what about AIX?)
|
||||
execute_process(COMMAND "${PCAP_CONFIG}" "--libs" "--static"
|
||||
RESULT_VARIABLE PCAP_CONFIG_RESULT
|
||||
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
|
||||
)
|
||||
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "pcap-config --libs --static failed")
|
||||
endif()
|
||||
separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT})
|
||||
set(PCAP_CONFIG_STATIC_LIBRARY_DIRS "")
|
||||
set(PCAP_CONFIG_STATIC_LIBRARIES "")
|
||||
foreach(_arg IN LISTS LIBS_LIST)
|
||||
if(_arg MATCHES "^-L")
|
||||
# Add this directory to the library directory hints.
|
||||
string(REGEX REPLACE "^-L" "" _dir ${_arg})
|
||||
list(APPEND PCAP_CONFIG_STATIC_LIBRARY_DIRS ${_dir})
|
||||
elseif(_arg MATCHES "^-l")
|
||||
# Add this library to the requirements for static linking.
|
||||
string(REGEX REPLACE "^-l" "" _lib ${_arg})
|
||||
list(APPEND PCAP_CONFIG_STATIC_LIBRARIES ${_lib})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Locate the actual include directory. For pkg-config the
|
||||
# PC_PCAP_INCLUDE_DIRS variable could be empty if the default
|
||||
# header search path is sufficient to locate the header file.
|
||||
# For macOS, the directory returned by pcap-config is wrong, so
|
||||
# this will make sure to find a valid path.
|
||||
#
|
||||
find_path(PCAP_INCLUDE_DIR
|
||||
NAMES
|
||||
pcap/pcap.h
|
||||
pcap.h
|
||||
HINTS
|
||||
${PC_PCAP_INCLUDE_DIRS}
|
||||
${PCAP_CONFIG_INCLUDE_DIRS}
|
||||
"${PCAP_HINTS}/Include"
|
||||
)
|
||||
|
||||
# On Windows we load wpcap.dll explicitly and probe its functions in
|
||||
# caputils\capture-wpcap.c. We don't want to link with pcap.lib since
|
||||
# that would bring in the non-capturing (null) pcap.dll from the vcpkg
|
||||
# library.
|
||||
if(WIN32)
|
||||
set(_pkg_required_vars PCAP_INCLUDE_DIR)
|
||||
else()
|
||||
find_library(PCAP_LIBRARY
|
||||
NAMES
|
||||
pcap
|
||||
HINTS
|
||||
${PC_PCAP_LIBRARY_DIRS}
|
||||
${PCAP_CONFIG_LIBRARY_DIRS}
|
||||
)
|
||||
set(_pkg_required_vars PCAP_LIBRARY PCAP_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES STREQUAL ".a")
|
||||
# Try to find the static library (XXX - what about AIX?)
|
||||
if(PC_PCAP_FOUND)
|
||||
set(_pcap_static_libraries ${PC_PCAP_STATIC_LIBRARIES})
|
||||
elseif(PCAP_CONFIG)
|
||||
set(_pcap_static_libraries ${PCAP_CONFIG_STATIC_LIBRARIES})
|
||||
else()
|
||||
#
|
||||
# No pkg-config nor pcap-config found, hope that this single library is
|
||||
# sufficient for static linking.
|
||||
#
|
||||
set(_pcap_static_libraries pcap)
|
||||
endif()
|
||||
|
||||
set(PCAP_STATIC_LIBRARIES "")
|
||||
foreach(_lib IN LISTS _pcap_static_libraries)
|
||||
#
|
||||
# Try to find that library, so we get its full path, as
|
||||
# we do with dynamic libraries.
|
||||
#
|
||||
string(MAKE_C_IDENTIFIER "PCAP_STATIC_${_lib}_LIBRARY" _libvar)
|
||||
find_library(${_libvar} ${_lib}
|
||||
HINTS
|
||||
${PC_PCAP_STATIC_LIBRARY_DIRS}
|
||||
${PCAP_CONFIG_STATIC_LIBRARY_DIRS}
|
||||
)
|
||||
set(_libpath ${${_libvar}})
|
||||
if(_libpath)
|
||||
list(APPEND PCAP_STATIC_LIBRARIES ${_libpath})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PCAP DEFAULT_MSG ${_pkg_required_vars})
|
||||
mark_as_advanced(${_pkg_required_vars})
|
||||
|
||||
if(PCAP_FOUND)
|
||||
set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
|
||||
if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES STREQUAL ".a")
|
||||
# Link with static libpcap and its transitive dependencies.
|
||||
set(PCAP_LIBRARIES ${PCAP_STATIC_LIBRARIES})
|
||||
else()
|
||||
set(PCAP_LIBRARIES ${PCAP_LIBRARY})
|
||||
endif()
|
||||
|
||||
#Functions
|
||||
include( CMakePushCheckState )
|
||||
include( CheckFunctionExists )
|
||||
include( CheckVariableExists )
|
||||
|
||||
cmake_push_check_state()
|
||||
set( CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS} )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES} )
|
||||
|
||||
include(CheckSymbolExists)
|
||||
|
||||
if(WIN32)
|
||||
#
|
||||
# Prepopulate some values. WinPcap 3.1 and later, and Npcap, have these
|
||||
# in their SDK, and compilation checks on Windows can be slow. We check
|
||||
# whether they're present at run time, when we load wpcap.dll, and work
|
||||
# around their absence or report an error.
|
||||
#
|
||||
set(HAVE_PCAP_FREECODE TRUE)
|
||||
set(HAVE_PCAP_CREATE TRUE)
|
||||
set(HAVE_PCAP_FREE_DATALINKS TRUE)
|
||||
set(HAVE_PCAP_OPEN TRUE)
|
||||
set(HAVE_PCAP_SETSAMPLING TRUE)
|
||||
set(HAVE_PCAP_SET_TSTAMP_PRECISION TRUE)
|
||||
set(HAVE_PCAP_SET_TSTAMP_TYPE TRUE)
|
||||
else(WIN32)
|
||||
#
|
||||
# Make sure we have at least libpcap 0.8, because we we require at
|
||||
# least libpcap 0.8's APIs.
|
||||
#
|
||||
# We check whether pcap_lib_version is defined in the pcap header,
|
||||
# using it as a proxy for all the 0.8 API's. if not, we fail.
|
||||
#
|
||||
check_symbol_exists( pcap_lib_version ${PCAP_INCLUDE_DIR}/pcap.h HAVE_PCAP_LIB_VERSION )
|
||||
if( NOT HAVE_PCAP_LIB_VERSION )
|
||||
message(FATAL_ERROR "You need libpcap 0.8 or later")
|
||||
endif( NOT HAVE_PCAP_LIB_VERSION )
|
||||
|
||||
check_function_exists( "pcap_freecode" HAVE_PCAP_FREECODE )
|
||||
check_function_exists( "pcap_create" HAVE_PCAP_CREATE )
|
||||
check_function_exists( "pcap_free_datalinks" HAVE_PCAP_FREE_DATALINKS )
|
||||
check_function_exists( "pcap_open" HAVE_PCAP_OPEN )
|
||||
if( HAVE_PCAP_OPEN )
|
||||
#
|
||||
# XXX - this *should* be checked for independently of checking
|
||||
# for pcap_open(), as you might have pcap_setsampling() without
|
||||
# remote capture support.
|
||||
#
|
||||
# However, 1) the sampling options are treated as remote options
|
||||
# in the GUI and and 2) having pcap_setsampling() doesn't mean
|
||||
# you have sampling support. libpcap needs a way to indicate
|
||||
# whether a given device supports sampling, and the GUI should
|
||||
# be changed to decouple them.
|
||||
#
|
||||
# (Actually, libpcap needs a general mechanism to offer options
|
||||
# for particular devices, and Wireshark needs to use that
|
||||
# mechanism. The former is a work in progress.)
|
||||
#
|
||||
# (Note: another work in progress is support for remote
|
||||
# capturing using pcap_create()/pcap_activate(), which we
|
||||
# also need to support once it's available.)
|
||||
#
|
||||
check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
|
||||
endif( HAVE_PCAP_OPEN )
|
||||
endif(WIN32)
|
||||
|
||||
if( HAVE_PCAP_CREATE )
|
||||
#
|
||||
# If we have pcap_create(), we have pcap_set_buffer_size(), and
|
||||
# can set the capture buffer size.
|
||||
#
|
||||
# Otherwise, if this is Windows, we have pcap_setbuff(), and can
|
||||
# set the capture buffer size.
|
||||
#
|
||||
set( CAN_SET_CAPTURE_BUFFER_SIZE TRUE )
|
||||
endif()
|
||||
check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
|
||||
check_function_exists( "pcap_set_tstamp_type" HAVE_PCAP_SET_TSTAMP_TYPE )
|
||||
# Remote pcap checks
|
||||
if( HAVE_PCAP_OPEN )
|
||||
set( HAVE_PCAP_REMOTE 1 )
|
||||
endif()
|
||||
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
if(PCAP_FOUND AND NOT TARGET pcap::pcap)
|
||||
if(WIN32)
|
||||
add_library(pcap::pcap INTERFACE IMPORTED)
|
||||
set_target_properties(pcap::pcap PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PCAP_INCLUDE_DIRS}"
|
||||
)
|
||||
else()
|
||||
add_library(pcap::pcap UNKNOWN IMPORTED)
|
||||
set_target_properties(pcap::pcap PROPERTIES
|
||||
IMPORTED_LOCATION "${PCAP_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PCAP_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
2
dependencies/nDPIsrvd.h
vendored
2
dependencies/nDPIsrvd.h
vendored
@@ -13,7 +13,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "jsmn/jsmn.h"
|
||||
#include "jsmn.h"
|
||||
#include "utarray.h"
|
||||
#include "uthash.h"
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "jsmn/jsmn.h"
|
||||
#include "jsmn.h"
|
||||
|
||||
static char serv_listen_addr[INET_ADDRSTRLEN] = DISTRIBUTOR_HOST;
|
||||
static uint16_t serv_listen_port = DISTRIBUTOR_PORT;
|
||||
|
||||
Reference in New Issue
Block a user