2014-11-28 15:22:27 +01:00
|
|
|
cmake_minimum_required (VERSION 2.8)
|
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# cmake versions:
|
2014-11-28 15:22:27 +01:00
|
|
|
# Debian 6 - 2.8.2
|
|
|
|
# Debian 7 - 2.8.9
|
|
|
|
# CentOS 6 - 2.8.12
|
|
|
|
|
|
|
|
project(FastNetMon)
|
|
|
|
|
2015-06-04 22:54:29 +02:00
|
|
|
# Unfortunately, Debian Squeeze haven't support for this feature
|
|
|
|
# It added in 2.8.5 release: http://www.cmake.org/cmake/help/v2.8.5/cmake.html
|
2015-06-04 15:13:22 +02:00
|
|
|
# Get convinient paths for all system folders: http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a262fe09
|
2015-06-04 22:54:29 +02:00
|
|
|
# include(GNUInstallDirs)
|
2015-06-04 15:13:22 +02:00
|
|
|
|
2018-02-05 23:21:12 +01:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
|
2015-03-22 22:30:51 +01:00
|
|
|
# Enable it and fix all warnigns!
|
|
|
|
# add_definitions ("-Wall")
|
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
set (FASTNETMON_VERSION_MAJOR 1)
|
|
|
|
set (FASTNETMON_VERSION_MINOR 1)
|
|
|
|
|
2017-05-29 16:50:23 +02:00
|
|
|
set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "/lib/systemd/system"
|
|
|
|
CACHE PATH "Location for systemd service files")
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
# With this flag we can enable GoBGP build via console: cmake .. -DENABLE_GOBGP_SUPPORT=ON
|
|
|
|
option(ENABLE_GOBGP_SUPPORT "Enable GoBGP support build" OFF)
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
|
|
|
# We could not compile gRPC without C++ 11
|
2015-10-06 18:59:54 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
2015-10-03 21:17:58 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
|
|
|
endif()
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
# cmake -DENABLE_CUSTOM_BOOST_BUILD=ON ..
|
|
|
|
if (ENABLE_CUSTOM_BOOST_BUILD)
|
|
|
|
message(STATUS "Build with custom Boost")
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
set(Boost_NO_SYSTEM_PATHS ON)
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
set(BOOST_INCLUDEDIR "/opt/boost_1_72_0")
|
|
|
|
set(BOOST_LIBRARYDIR "/opt/boost_1_72_0/stage/lib/")
|
2015-08-12 17:24:13 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
SET(Boost_DIR "/opt/boost_1_72_0/stage/lib/cmake/Boost-1.72.0/")
|
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
2015-10-06 18:59:54 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
2015-08-13 17:34:28 +02:00
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-deprecated-declarations")
|
2015-10-08 16:58:39 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
set(ICU_CUSTOM_INSTALL_PATH "/opt/libicu_65_1")
|
|
|
|
|
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};/opt/boost_1_72_0/stage/lib;${ICU_CUSTOM_INSTALL_PATH}/lib")
|
|
|
|
|
|
|
|
# For custom Boost we need to build libicu library
|
|
|
|
find_library(ICU_LIBRARY_UC_PATH NAMES icuuc PATHS "${ICU_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
find_library(ICU_LIBRARY_DATA_PATH NAMES icudata PATHS "${ICU_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
find_library(ICU_LIBRARY_I18N_PATH NAMES icui18n PATHS "${ICU_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (ICU_LIBRARY_UC_PATH AND ICU_LIBRARY_DATA_PATH AND ICU_LIBRARY_I18N_PATH)
|
|
|
|
message(STATUS "Found libicu")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Could not find icu libraries ${ICU_LIBRARY_UC_PATH} ${ICU_LIBRARY_DATA_PATH} ${ICU_LIBRARY_I18N_PATH}")
|
|
|
|
endif()
|
|
|
|
|
2015-10-08 16:58:39 +02:00
|
|
|
endif()
|
2015-08-13 17:34:28 +02:00
|
|
|
|
2015-10-08 16:58:39 +02:00
|
|
|
# Specify full RPATH for build tree
|
|
|
|
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
2015-08-13 17:34:28 +02:00
|
|
|
|
2015-10-08 16:58:39 +02:00
|
|
|
# Create builds in current folder with install RPATH
|
|
|
|
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
2015-08-13 17:34:28 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};/opt/libhiredis_0_13/lib;/opt/log4cpp1.1.1/lib;/opt/luajit_2.0.4/lib;/opt/ndpi/lib;/opt/pf_ring_6.0.3/lib;/opt/json-c-0.13/lib;/opt/mongo_c_driver_1_1_9/lib;/opt/grpc_1_27_3_e73882dc0fcedab1ffe789e44ed6254819639ce3/lib;/opt/protobuf_3.11.4/lib")
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
message(STATUS "C++ compilation flags: ${CMAKE_CXX_FLAGS_RELEASE}")
|
2014-12-18 11:23:56 +01:00
|
|
|
|
2015-08-11 08:18:17 +02:00
|
|
|
set(HIREDIS_CUSTOM_INSTALL_PATH "/opt/libhiredis_0_13")
|
2015-08-11 10:24:08 +02:00
|
|
|
set(LOG4CPP_CUSTOM_INSTALL_PATH "/opt/log4cpp1.1.1")
|
2022-01-22 17:09:21 +01:00
|
|
|
set(JSONC_CUSTOM_INSTALL_PATH "/opt/json-c-0.13")
|
2015-08-17 15:02:19 +02:00
|
|
|
set(PFRING_CUSTOM_INSTALL_PATH "/opt/pf_ring_6.0.3")
|
2015-08-30 19:34:13 +02:00
|
|
|
set(LIBPCAP_CUSTOM_INSTALL_PATH "/opt/libpcap_1.7.4")
|
2015-09-30 16:54:57 +02:00
|
|
|
set(MONGO_C_CUSTOM_INSTALL_PATH "/opt/mongo_c_driver_1_1_9")
|
2015-08-11 08:18:17 +02:00
|
|
|
|
2014-12-19 09:42:10 +01:00
|
|
|
set(FASTNETMON_PROFILER OFF)
|
|
|
|
|
|
|
|
set(FASTNETMON_PROFILE_FLAGS "-g -pg")
|
|
|
|
|
2015-06-03 11:27:17 +02:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "Setting build type to Release as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2014-12-19 09:42:10 +01:00
|
|
|
if (FASTNETMON_PROFILER)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
2017-05-30 11:11:39 +02:00
|
|
|
execute_process(COMMAND sh -c ". /etc/os-release; echo $ID" OUTPUT_VARIABLE OS_ID ERROR_QUIET)
|
|
|
|
|
2015-10-16 11:34:48 +02:00
|
|
|
### Executables definition
|
|
|
|
|
|
|
|
# Main tool
|
|
|
|
add_executable(fastnetmon fastnetmon.cpp)
|
|
|
|
|
2015-09-30 13:00:09 +02:00
|
|
|
# Get last commit hash
|
|
|
|
execute_process(COMMAND git rev-list HEAD COMMAND head -n 1 OUTPUT_VARIABLE GIT_LAST_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2022-01-22 18:21:57 +01:00
|
|
|
set(FASTNETMON_APPLICATION_VERSION "1.1.5 master git-${GIT_LAST_COMMIT_HASH}")
|
2015-06-04 13:08:25 +02:00
|
|
|
configure_file(fast_platform.h.template "${PROJECT_SOURCE_DIR}/fast_platform.h")
|
|
|
|
|
2018-02-04 14:19:44 +01:00
|
|
|
# Use new Memory Model Aware Atomic Operations
|
|
|
|
# You could enable it using: cmake .. -DUSE_NEW_ATOMIC_BUILTINS=ON
|
|
|
|
if (USE_NEW_ATOMIC_BUILTINS)
|
|
|
|
message(STATUS "Will use new memory model aware atomic builtins")
|
|
|
|
add_definitions(-DUSE_NEW_ATOMIC_BUILTINS)
|
|
|
|
endif()
|
|
|
|
|
2018-02-05 23:21:12 +01:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#include <cstdint>
|
|
|
|
int main() {
|
|
|
|
uint64_t x = 1;
|
|
|
|
__atomic_add_fetch(&x, 0, __ATOMIC_RELAXED);
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
" HAVE__ATOMIC_ADD_FETCH)
|
|
|
|
|
|
|
|
if (NOT HAVE__ATOMIC_ADD_FETCH)
|
|
|
|
check_library_exists(atomic __atomic_add_fetch_8 "" HAVE_LIBATOMIC)
|
|
|
|
if (HAVE_LIBATOMIC)
|
|
|
|
target_link_libraries(fastnetmon atomic)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-01-22 14:31:28 +01:00
|
|
|
# With this flag we can enable PF_RING build via console: cmake .. -DENABLE_PF_RING_SUPPORT=ON
|
|
|
|
option(ENABLE_PF_RING_SUPPORT "Enable PF_RING build" OFF)
|
2014-11-28 15:58:12 +01:00
|
|
|
|
2018-07-14 18:13:07 +02:00
|
|
|
option(ENABLE_NETMAP_SUPPORT "Enable Netmap support" ON)
|
2017-07-28 00:19:33 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
int main() {
|
|
|
|
__atomic_thread_fence(__ATOMIC_RELEASE);
|
|
|
|
__atomic_thread_fence(__ATOMIC_ACQUIRE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_ATOMIC_THREAD_FENCE)
|
|
|
|
|
|
|
|
# If we do not have it then we need to disable it
|
|
|
|
if (NOT HAVE_ATOMIC_THREAD_FENCE)
|
|
|
|
set(ENABLE_NETMAP_SUPPORT OFF)
|
|
|
|
message(STATUS "Your system does not support __atomic_thread_fence, disabled Netmap plugin support")
|
|
|
|
endif()
|
|
|
|
|
2017-07-28 00:19:33 +02:00
|
|
|
if (ENABLE_NETMAP_SUPPORT)
|
|
|
|
message(STATUS "We will build Netmap support for you")
|
|
|
|
add_definitions(-DNETMAP_PLUGIN)
|
|
|
|
endif()
|
|
|
|
|
2022-01-22 14:31:28 +01:00
|
|
|
if (ENABLE_PF_RING_SUPPORT)
|
2015-10-16 00:24:03 +02:00
|
|
|
# Set path to manually compiled PF_RING
|
|
|
|
set(PFRING_INCLUDE_DIRS "${PFRING_CUSTOM_INSTALL_PATH}/include")
|
|
|
|
|
|
|
|
find_library(PFRING_LIBRARIES NAMES pfring PATHS "${PFRING_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-03-24 12:04:18 +01:00
|
|
|
|
2015-10-16 00:24:03 +02:00
|
|
|
if (NOT PFRING_LIBRARIES)
|
|
|
|
message(FATAL_ERROR "Could not find PF_RING")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
link_directories("${PFRING_CUSTOM_INSTALL_PATH}/lib")
|
2015-01-09 23:43:23 +01:00
|
|
|
add_definitions(-DPF_RING)
|
2015-02-03 20:55:44 +01:00
|
|
|
|
2015-08-17 15:02:19 +02:00
|
|
|
if (EXISTS "${PFRING_CUSTOM_INSTALL_PATH}/include/pfring_zc.h" OR EXISTS "/usr/local/include/pfring_zc.h")
|
2015-06-03 11:27:17 +02:00
|
|
|
message(STATUS "We found PF_RING ZC headers and will build PF_RING ZC support")
|
2015-02-24 17:53:41 +01:00
|
|
|
# Enable ZC support
|
|
|
|
add_definitions(-DPF_RING_ZC)
|
|
|
|
else()
|
2022-02-09 15:27:32 +01:00
|
|
|
message(WARNING "We can't find PF_RING ZC header pfring_zc.h. Will not compile ZC support")
|
2015-02-24 17:53:41 +01:00
|
|
|
endif()
|
|
|
|
|
2015-02-03 20:55:44 +01:00
|
|
|
include_directories(${PFRING_INCLUDE_DIRS})
|
2015-01-09 23:43:23 +01:00
|
|
|
|
2015-09-03 13:09:16 +02:00
|
|
|
message(STATUS "We have enabled PF_RING's hardware filtering option")
|
|
|
|
endif()
|
2014-12-03 15:56:08 +01:00
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# Our LPM library
|
2014-12-16 09:01:07 +01:00
|
|
|
add_library(patricia STATIC libpatricia/patricia.c)
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-07-22 14:16:13 +02:00
|
|
|
add_library(fastnetmon_pcap_format STATIC fastnetmon_pcap_format.cpp)
|
|
|
|
|
2015-03-21 11:47:25 +01:00
|
|
|
# Our tools library
|
|
|
|
add_library(fast_library STATIC fast_library.cpp)
|
|
|
|
|
2017-07-28 01:09:58 +02:00
|
|
|
# Our parser
|
|
|
|
add_library(unified_parser STATIC unified_parser.cpp)
|
|
|
|
target_link_libraries(unified_parser fastnetmon_packet_parser)
|
|
|
|
|
2015-03-22 17:00:16 +01:00
|
|
|
# Our ipfix database library
|
|
|
|
add_library(ipfix_rfc STATIC ipfix_rfc.cpp)
|
|
|
|
|
2015-03-10 15:18:52 +01:00
|
|
|
# Our packet parser
|
2015-03-21 12:56:44 +01:00
|
|
|
add_library(fastnetmon_packet_parser STATIC fastnetmon_packet_parser.c)
|
2015-03-10 15:18:52 +01:00
|
|
|
|
2015-08-31 12:25:57 +02:00
|
|
|
# -DENABLE_SNABBSWITCH_SUPPORT=ON ..
|
2015-08-31 14:15:16 +02:00
|
|
|
# Please also comment out line: set(ENABLE_LUA_SUPPORT yes) if you want SnabbSwitch support
|
2015-08-31 12:25:57 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
add_definitions(-DSNABB_SWITCH)
|
|
|
|
add_library(snabbswitch_plugin STATIC snabbswitch_plugin/snabbswitch_collector.cpp)
|
|
|
|
|
|
|
|
link_directories(/usr/src/snabbswitch/src)
|
|
|
|
target_link_libraries(snabbswitch_plugin snabb)
|
|
|
|
endif()
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
2022-02-09 15:27:32 +01:00
|
|
|
#include <linux/if_packet.h>
|
|
|
|
int main() {
|
|
|
|
return TPACKET_V3;
|
|
|
|
}
|
|
|
|
" HAVE_TPACKET_V3)
|
|
|
|
|
|
|
|
|
|
|
|
if (${HAVE_TPACKET_V3})
|
|
|
|
message(STATUS "Your system has support for AF_PACKET v3")
|
|
|
|
set (ENABLE_AFPACKET_SUPPORT ON)
|
|
|
|
else()
|
|
|
|
message(STATUS "Your system does not support AF_PACKET v3, disabled it")
|
2015-09-01 14:37:50 +02:00
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
# -DENABLE_AFPACKET_SUPPORT=ON ..
|
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
add_definitions(-DFASTNETMON_ENABLE_AFPACKET)
|
2015-10-03 18:09:37 +02:00
|
|
|
add_library(afpacket_plugin STATIC afpacket_plugin/afpacket_collector.cpp)
|
2017-07-28 01:09:58 +02:00
|
|
|
target_link_libraries(afpacket_plugin unified_parser)
|
2015-09-01 10:41:55 +02:00
|
|
|
endif()
|
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# sFLOW plugin
|
2014-12-01 22:08:38 +01:00
|
|
|
add_library(sflow_plugin STATIC sflow_plugin/sflow_collector.cpp)
|
2014-12-01 21:26:08 +01:00
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# netflow plugin
|
2015-01-23 17:49:37 +01:00
|
|
|
add_library(netflow_plugin STATIC netflow_plugin/netflow_collector.cpp)
|
2015-03-22 17:00:16 +01:00
|
|
|
target_link_libraries(netflow_plugin ipfix_rfc)
|
2015-01-23 17:49:37 +01:00
|
|
|
|
2018-07-14 18:13:07 +02:00
|
|
|
option(ENABLE_DPI_SUPPORT "Enable Deep Packet Inspection support" ON)
|
2015-07-24 14:45:15 +02:00
|
|
|
if (ENABLE_DPI_SUPPORT)
|
2015-08-02 23:27:22 +02:00
|
|
|
message(STATUS "We will enable nDPI support")
|
|
|
|
|
2015-07-24 14:45:15 +02:00
|
|
|
add_library(fast_dpi STATIC fast_dpi.cpp)
|
|
|
|
|
2016-01-04 16:26:54 +01:00
|
|
|
set(NDPI_INCLUDE_DIRS "/opt/ndpi/include/libndpi-1.7.1")
|
2015-10-16 00:24:03 +02:00
|
|
|
|
|
|
|
find_library(NDPI_LIBRARIES NAMES ndpi PATHS "/opt/ndpi/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (NOT NDPI_LIBRARIES)
|
|
|
|
message(FATAL_ERROR "Could not find nDPI library")
|
|
|
|
endif()
|
2015-07-24 14:45:15 +02:00
|
|
|
|
|
|
|
link_directories("/opt/ndpi/lib")
|
|
|
|
include_directories(${NDPI_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
add_definitions(-DENABLE_DPI)
|
|
|
|
|
|
|
|
target_link_libraries(fast_dpi ${NDPI_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2015-06-22 10:19:04 +02:00
|
|
|
# We do not enable it by default, it's testing feature
|
|
|
|
# If you want it please build with:
|
|
|
|
# cmake -DENABLE_LUA_SUPPORT=ON ..
|
2022-01-21 18:17:09 +01:00
|
|
|
option(ENABLE_LUA_SUPPORT "Enable Lua support" OFF)
|
2015-06-22 10:19:04 +02:00
|
|
|
if (ENABLE_LUA_SUPPORT)
|
2015-07-03 17:01:18 +02:00
|
|
|
message(STATUS "We will enable LuaJIT support")
|
|
|
|
|
2015-06-22 10:19:04 +02:00
|
|
|
add_definitions(-DENABLE_LUA_HOOKS)
|
2015-08-02 22:38:37 +02:00
|
|
|
|
2015-10-16 00:24:03 +02:00
|
|
|
set(LUAJIT_CUSTOM_INSTALL_PATH "/opt/luajit_2.0.4")
|
|
|
|
|
|
|
|
link_directories("${LUAJIT_CUSTOM_INSTALL_PATH}/lib")
|
|
|
|
include_directories("${LUAJIT_CUSTOM_INSTALL_PATH}/include")
|
|
|
|
|
|
|
|
find_library(LUAJIT_LIBRARY_PATH NAMES luajit-5.1 PATHS "${LUAJIT_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (NOT LUAJIT_LIBRARY_PATH)
|
|
|
|
message(FATAL_ERROR "Could not find luajit library")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(netflow_plugin ${LUAJIT_LIBRARY_PATH})
|
|
|
|
target_link_libraries(sflow_plugin ${LUAJIT_LIBRARY_PATH})
|
|
|
|
target_link_libraries(fast_library ${LUAJIT_LIBRARY_PATH})
|
2015-06-22 10:19:04 +02:00
|
|
|
endif()
|
|
|
|
|
2015-01-26 14:37:12 +01:00
|
|
|
# pcap plugin
|
|
|
|
add_library(pcap_plugin STATIC pcap_plugin/pcap_collector.cpp)
|
2015-02-01 14:02:16 +01:00
|
|
|
target_link_libraries(pcap_plugin pcap)
|
2015-01-26 14:37:12 +01:00
|
|
|
|
2015-06-02 22:27:49 +02:00
|
|
|
find_package(Threads)
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
if (ENABLE_PF_RING_SUPPORT)
|
2015-02-03 20:55:44 +01:00
|
|
|
add_library(pfring_plugin STATIC pfring_plugin/pfring_collector.cpp)
|
|
|
|
target_link_libraries(pfring_plugin ${PFRING_LIBRARIES})
|
|
|
|
target_link_libraries(pfring_plugin numa)
|
2015-06-02 22:27:49 +02:00
|
|
|
target_link_libraries(pfring_plugin ${CMAKE_THREAD_LIBS_INIT})
|
2015-09-03 13:09:16 +02:00
|
|
|
|
|
|
|
# Add action for hardware filetring
|
|
|
|
add_library(pfring_hardware_filter_action STATIC actions/pfring_hardware_filter_action.cpp)
|
2015-02-03 20:55:44 +01:00
|
|
|
endif()
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
2022-02-09 15:27:32 +01:00
|
|
|
set(GRPC_CUSTOM_INSTALL_PATH "/opt/grpc_1_27_3_e73882dc0fcedab1ffe789e44ed6254819639ce3")
|
2022-02-09 15:27:32 +01:00
|
|
|
set(PROTOCOL_BUFFERS_CUSTOM_INSTALL_PATH "/opt/protobuf_3.11.4")
|
2015-10-05 12:00:47 +02:00
|
|
|
|
|
|
|
add_definitions(-DENABLE_GOBGP)
|
|
|
|
add_library(gobgp_action STATIC actions/gobgp_action.cpp)
|
2015-10-03 21:17:58 +02:00
|
|
|
|
|
|
|
find_path(GRPC_INCLUDES_FOLDER NAMES grpc/grpc.h PATHS "${GRPC_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(GRPC_LIBRARY_GRPC_PATH NAMES grpc PATHS "${GRPC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
find_library(GRPC_LIBRARY_GPR_PATH NAMES gpr PATHS "${GRPC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2022-02-09 15:27:32 +01:00
|
|
|
find_library(GRPC_LIBRARY_GRPC_CPP_PATH NAMES grpc++ PATHS "${GRPC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
if (GRPC_INCLUDES_FOLDER AND GRPC_LIBRARY_GRPC_PATH AND GRPC_LIBRARY_GPR_PATH AND GRPC_LIBRARY_GRPC_CPP_PATH)
|
2015-10-03 21:17:58 +02:00
|
|
|
include_directories(${GRPC_INCLUDES_FOLDER})
|
2015-10-05 12:00:47 +02:00
|
|
|
target_link_libraries(gobgp_action ${GRPC_LIBRARY_GRPC_PATH})
|
|
|
|
target_link_libraries(gobgp_action ${GRPC_LIBRARY_GPR_PATH})
|
2022-02-09 15:27:32 +01:00
|
|
|
target_link_libraries(gobgp_action ${GRPC_LIBRARY_GRPC_CPP__PATH})
|
2022-02-09 15:27:32 +01:00
|
|
|
|
|
|
|
message(STATUS "Found gRPC library")
|
2015-10-04 12:53:06 +02:00
|
|
|
else()
|
2015-10-05 12:00:47 +02:00
|
|
|
message(FATAL_ERROR "Could not find gRPC library")
|
2015-10-04 12:53:06 +02:00
|
|
|
endif()
|
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
find_path(PROTOCOL_BUFFERS_INCLUDE_FOLDER NAMES "google/protobuf/stubs/common.h" PATHS "${PROTOCOL_BUFFERS_CUSTOM_INSTALL_PATH}/include")
|
2015-10-03 21:17:58 +02:00
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
find_library(PROTOCOL_BUFFERS_LIBRARY_PATH NAMES protobuf PATHS "${PROTOCOL_BUFFERS_CUSTOM_INSTALL_PATH}/lib")
|
|
|
|
|
|
|
|
if (PROTOCOL_BUFFERS_INCLUDE_FOLDER AND PROTOCOL_BUFFERS_LIBRARY_PATH)
|
|
|
|
include_directories(${PROTOCOL_BUFFERS_INCLUDE_FOLDER})
|
|
|
|
target_link_libraries(gobgp_action ${PROTOCOL_BUFFERS_LIBRARY_PATH})
|
2022-02-09 15:27:32 +01:00
|
|
|
|
|
|
|
message(STATUS "Found protobuf library")
|
2015-10-05 12:00:47 +02:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Could not find protocol buffers")
|
|
|
|
endif()
|
2015-10-04 12:53:06 +02:00
|
|
|
|
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
# message(STATUS "grpc: ${GRPC_INCLUDES_FOLDER} ${GRPC_LIBRARY_GRPC_PATH} ${GRPC_LIBRARY_GPR_PATH}")
|
|
|
|
# message(STATUS ${PROJECT_BINARY_DIR})
|
2015-10-04 12:53:06 +02:00
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
find_program(PROTOC_BINARY protoc PATHS "${PROTOCOL_BUFFERS_CUSTOM_INSTALL_PATH}/bin" NO_DEFAULT_PATH)
|
2015-10-04 12:53:06 +02:00
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
if (PROTOC_BINARY)
|
|
|
|
message(STATUS "Found protoc protobuf compiler: ${PROTOC_BINARY}")
|
2015-10-03 21:17:58 +02:00
|
|
|
else()
|
2015-10-05 12:00:47 +02:00
|
|
|
message(FATAL_ERROR "Can't find protoc compiler")
|
2015-10-03 21:17:58 +02:00
|
|
|
endif()
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
message(STATUS "Building protobuf and gRPC mappings for C++")
|
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
set(GRPC_CPP_PLUGIN "${GRPC_CUSTOM_INSTALL_PATH}/bin/grpc_cpp_plugin")
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
execute_process(COMMAND ${PROTOC_BINARY} -I ${PROJECT_BINARY_DIR}/../actions --grpc_out=${PROJECT_BINARY_DIR}/../actions --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} ${PROJECT_BINARY_DIR}/../actions/gobgp.proto ERROR_VARIABLE PROTOC_STDERR RESULT_VARIABLE PROTOC_RETURN_CODE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
message(STATUS "Protoc return code for gobgp.proto gRPC: ${PROTOC_RETURN_CODE} std err: ${PROTOC_STDERR}")
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
execute_process(COMMAND ${PROTOC_BINARY} -I ${PROJECT_BINARY_DIR}/../actions --cpp_out=${PROJECT_BINARY_DIR}/../actions ${PROJECT_BINARY_DIR}/../actions/gobgp.proto ${PROJECT_BINARY_DIR}/../actions/attribute.proto ERROR_VARIABLE PROTOC_STDERR RESULT_VARIABLE PROTOC_RETURN_CODE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
message(STATUS "Protoc return code for gobgp.proto and attribute.proto Protobuf: ${PROTOC_RETURN_CODE} std err: ${PROTOC_STDERR}")
|
2015-10-05 12:00:47 +02:00
|
|
|
|
|
|
|
# Build gRPC and protocol bufffers libraries and link they to gobgp_action
|
2022-02-09 15:27:32 +01:00
|
|
|
add_library(gobgp_api_client_pb_cc STATIC actions/gobgp.pb.cc)
|
|
|
|
add_library(gobgp_api_client_grpc_pb_cc STATIC actions/gobgp.grpc.pb.cc)
|
2015-10-05 12:00:47 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
# Disable annoying warnings
|
|
|
|
set_source_files_properties(actions/gobgp.pb.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
set_source_files_properties(actions/gobgp.grpc.pb.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
|
|
|
|
set_source_files_properties(actions/gobgp.pb.h PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
set_source_files_properties(actions/gobgp.grpc.pb.h PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
|
2015-10-05 12:00:47 +02:00
|
|
|
target_link_libraries(gobgp_action gobgp_api_client_pb_cc)
|
|
|
|
target_link_libraries(gobgp_action gobgp_api_client_grpc_pb_cc)
|
2015-10-13 18:45:27 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
# Add attributes
|
|
|
|
add_library(attribute_pb_cc STATIC actions/attribute.pb.cc)
|
|
|
|
target_link_libraries(gobgp_action attribute_pb_cc)
|
|
|
|
|
2015-10-13 18:45:27 +02:00
|
|
|
# FastNetMon API
|
2015-10-16 00:24:03 +02:00
|
|
|
add_definitions(-DFASTNETMON_API)
|
|
|
|
|
2015-10-13 18:45:27 +02:00
|
|
|
execute_process(COMMAND ${PROTOC_BINARY} -I ${PROJECT_BINARY_DIR}/.. --grpc_out=${PROJECT_BINARY_DIR}/.. --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} ${PROJECT_BINARY_DIR}/../fastnetmon.proto ERROR_VARIABLE PROTOC_STDERR RESULT_VARIABLE PROTOC_RETURN_CODE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
message(STATUS "Protoc return code for gRPC fastnetmon.proto: ${PROTOC_RETURN_CODE} std err: ${PROTOC_STDERR}")
|
2015-10-15 20:50:21 +02:00
|
|
|
|
2015-10-13 18:45:27 +02:00
|
|
|
execute_process(COMMAND ${PROTOC_BINARY} -I ${PROJECT_BINARY_DIR}/.. --cpp_out=${PROJECT_BINARY_DIR}/.. ${PROJECT_BINARY_DIR}/../fastnetmon.proto ERROR_VARIABLE PROTOC_STDERR RESULT_VARIABLE PROTOC_RETURN_CODE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
message(STATUS "Protoc return code for protobuf fastnetmon.proto: ${PROTOC_RETURN_CODE} std err: ${PROTOC_STDERR}")
|
2015-10-15 20:50:21 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
# Disable annoying warnings
|
|
|
|
set_source_files_properties(fastnetmon.grpc.pb.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
set_source_files_properties(fastnetmon.pb.cc PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
set_source_files_properties(fastnetmon.grpc.pb.h PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
set_source_files_properties(fastnetmon.pb.h PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
|
|
|
|
|
2015-10-13 18:45:27 +02:00
|
|
|
add_library(fastnetmon_grpc_pb_cc STATIC fastnetmon.grpc.pb.cc)
|
|
|
|
add_library(fastnetmon_pb_cc STATIC fastnetmon.pb.cc)
|
|
|
|
|
2015-10-15 22:39:16 +02:00
|
|
|
add_executable(fastnetmon_api_client fastnetmon_api_client.cpp)
|
2015-10-15 22:30:11 +02:00
|
|
|
|
|
|
|
target_link_libraries(fastnetmon_api_client ${GRPC_LIBRARY_GPR_PATH})
|
2022-02-09 15:27:32 +01:00
|
|
|
target_link_libraries(fastnetmon_api_client ${GRPC_LIBRARY_GRPC_CPP_PATH})
|
2015-10-15 22:30:11 +02:00
|
|
|
target_link_libraries(fastnetmon_api_client ${GRPC_LIBRARY_GRPC_PATH})
|
|
|
|
target_link_libraries(fastnetmon_api_client fastnetmon_grpc_pb_cc)
|
|
|
|
target_link_libraries(fastnetmon_api_client fastnetmon_pb_cc)
|
|
|
|
target_link_libraries(fastnetmon_api_client ${PROTOCOL_BUFFERS_LIBRARY_PATH})
|
2015-10-13 18:45:27 +02:00
|
|
|
|
2015-10-16 00:24:03 +02:00
|
|
|
target_link_libraries(fastnetmon ${GRPC_LIBRARY_GPR_PATH})
|
2022-02-09 15:27:32 +01:00
|
|
|
target_link_libraries(fastnetmon ${GRPC_LIBRARY_GRPC_CPP_PATH})
|
2015-10-16 00:24:03 +02:00
|
|
|
target_link_libraries(fastnetmon ${GRPC_LIBRARY_GRPC_PATH})
|
|
|
|
target_link_libraries(fastnetmon fastnetmon_grpc_pb_cc)
|
|
|
|
target_link_libraries(fastnetmon fastnetmon_pb_cc)
|
|
|
|
target_link_libraries(fastnetmon ${PROTOCOL_BUFFERS_LIBRARY_PATH})
|
2015-10-03 21:17:58 +02:00
|
|
|
endif()
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
if (ENABLE_CUSTOM_BOOST_BUILD)
|
|
|
|
target_link_libraries(fastnetmon ${ICU_LIBRARY_UC_PATH})
|
|
|
|
target_link_libraries(fastnetmon ${ICU_LIBRARY_DATA_PATH})
|
|
|
|
target_link_libraries(fastnetmon ${ICU_LIBRARY_I18N_PATH})
|
|
|
|
endif()
|
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# example plugin
|
|
|
|
add_library(example_plugin STATIC example_plugin/example_collector.cpp)
|
|
|
|
|
2017-07-28 00:19:33 +02:00
|
|
|
if (ENABLE_NETMAP_SUPPORT)
|
|
|
|
# Netmap plugin
|
|
|
|
set(NETMAP_INCLUDE_DIRS "netmap_plugin/netmap_includes")
|
|
|
|
include_directories(${NETMAP_INCLUDE_DIRS})
|
|
|
|
add_library(netmap_plugin STATIC netmap_plugin/netmap_collector.cpp)
|
|
|
|
target_link_libraries(netmap_plugin fastnetmon_packet_parser)
|
2019-07-14 20:57:22 +02:00
|
|
|
target_link_libraries(netmap_plugin unified_parser)
|
2017-07-28 00:19:33 +02:00
|
|
|
endif()
|
2015-03-10 15:18:52 +01:00
|
|
|
|
2014-12-22 16:39:46 +01:00
|
|
|
# Client tool
|
|
|
|
add_executable(fastnetmon_client fastnetmon_client.cpp)
|
|
|
|
|
2014-11-28 15:22:27 +01:00
|
|
|
# Find boost: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html
|
2014-12-01 09:09:37 +01:00
|
|
|
|
|
|
|
# Enable detailed errors
|
2014-11-28 15:58:12 +01:00
|
|
|
set(Boost_DETAILED_FAILURE_MSG ON)
|
2022-02-09 15:27:32 +01:00
|
|
|
# set(Boost_DEBUG ON)
|
2014-12-01 09:09:37 +01:00
|
|
|
|
2015-09-29 15:40:57 +02:00
|
|
|
find_package(Boost COMPONENTS thread regex program_options system REQUIRED)
|
2014-11-28 15:58:12 +01:00
|
|
|
|
2014-11-28 15:22:27 +01:00
|
|
|
if(Boost_FOUND)
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(fastnetmon ${Boost_LIBRARIES})
|
2015-03-21 13:15:35 +01:00
|
|
|
target_link_libraries(fast_library ${Boost_LIBRARIES})
|
2014-11-28 15:22:27 +01:00
|
|
|
endif()
|
|
|
|
|
2015-05-29 14:45:02 +02:00
|
|
|
target_link_libraries(fast_library patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fast_library fastnetmon_pcap_format)
|
2015-05-29 14:45:02 +02:00
|
|
|
|
2015-05-07 09:13:05 +02:00
|
|
|
# Try to find ncurses librreary
|
2014-11-28 15:58:12 +01:00
|
|
|
find_package(Curses REQUIRED)
|
|
|
|
|
|
|
|
if(CURSES_FOUND)
|
|
|
|
include_directories(${CURSES_INCLUDE_DIRS})
|
2014-12-22 16:39:46 +01:00
|
|
|
target_link_libraries(fastnetmon_client ${CURSES_LIBRARIES})
|
2014-11-28 15:58:12 +01:00
|
|
|
endif()
|
|
|
|
|
2015-08-11 08:18:17 +02:00
|
|
|
### Move this code to cmake module
|
|
|
|
|
|
|
|
# Try to find hiredis in a specific folder
|
|
|
|
find_path(HIREDIS_INCLUDES_FOLDER NAMES hiredis/hiredis.h PATHS "${HIREDIS_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
# Try to find hiredis library path
|
|
|
|
find_library(HIREDIS_LIBRARY_PATH NAMES hiredis PATHS "${HIREDIS_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (HIREDIS_INCLUDES_FOLDER AND HIREDIS_LIBRARY_PATH)
|
|
|
|
message(STATUS "We found hiredis library and will build Redis support ${HIREDIS_INCLUDES_FOLDER} ${HIREDIS_LIBRARY_PATH}")
|
|
|
|
|
|
|
|
add_definitions(-DREDIS)
|
|
|
|
include_directories(${HIREDIS_INCLUDES_FOLDER})
|
|
|
|
target_link_libraries (fastnetmon ${HIREDIS_LIBRARY_PATH})
|
|
|
|
else()
|
|
|
|
message(STATUS "We can't find hiredis library and will disable Redis support")
|
|
|
|
endif()
|
2015-03-19 10:40:58 +01:00
|
|
|
|
2015-09-30 16:54:57 +02:00
|
|
|
### Find mongo-c
|
|
|
|
find_path(MONGOC_INCLUDES_FOLDER NAMES libmongoc-1.0/mongoc.h PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(MONGOC_LIBRARY_PATH NAMES mongoc-1.0 PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
### find bson
|
|
|
|
find_path(BSON_INCLUDES_FOLDER NAMES libbson-1.0/bson.h PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(BSON_LIBRARY_PATH NAMES bson-1.0 PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (MONGOC_INCLUDES_FOLDER AND MONGOC_LIBRARY_PATH AND BSON_INCLUDES_FOLDER AND BSON_LIBRARY_PATH)
|
|
|
|
message(STATUS "We found mongo-c library ${MONGOC_INCLUDES_FOLDER} ${MONGOC_LIBRARY_PATH} ${BSON_INCLUDES_FOLDER} ${BSON_LIBRARY_PATH}")
|
|
|
|
add_definitions(-DMONGO)
|
|
|
|
|
|
|
|
# We add suffix name because cmake could not detect it correctly...
|
|
|
|
include_directories("${MONGOC_INCLUDES_FOLDER}/libmongoc-1.0")
|
|
|
|
include_directories("${BSON_INCLUDES_FOLDER}/libbson-1.0")
|
|
|
|
|
|
|
|
target_link_libraries(fastnetmon ${MONGOC_LIBRARY_PATH} ${BSON_LIBRARY_PATH})
|
|
|
|
else()
|
|
|
|
message(WARNING "We can't find Mongo C library")
|
|
|
|
endif()
|
|
|
|
|
2015-08-17 18:36:35 +02:00
|
|
|
### Look for libpcap
|
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#find_path(LIBPCAP_INCLUDES_FOLDER NAMES pcap.h PATHS "${LIBPCAP_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#find_library(LIBPCAP_LIBRARY_PATH NAMES pcap PATHS "${LIBPCAP_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#if (LIBPCAP_INCLUDES_FOLDER AND LIBPCAP_LIBRARY_PATH)
|
|
|
|
# message(STATUS "We found pcap library ${LIBPCAP_LIBRARY_PATH}")
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
# include_directories(${LIBPCAP_INCLUDES_FOLDER})
|
|
|
|
#else()
|
|
|
|
# message(FATAL_ERROR "We can't find pcap library")
|
|
|
|
#endif()
|
2015-08-17 18:36:35 +02:00
|
|
|
|
2015-08-12 19:27:29 +02:00
|
|
|
### Look for log4cpp
|
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
# Try to find log4cpp includes path
|
|
|
|
find_path(LOG4CPP_INCLUDES_FOLDER NAMES log4cpp/Appender.hh PATHS "${LOG4CPP_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
2015-02-10 11:42:48 +01:00
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
# Try to find log4cpp library path
|
|
|
|
find_library(LOG4CPP_LIBRARY_PATH NAMES log4cpp PATHS "${LOG4CPP_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-01-29 11:27:55 +01:00
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
if (LOG4CPP_INCLUDES_FOLDER AND LOG4CPP_LIBRARY_PATH)
|
|
|
|
include_directories(${LOG4CPP_INCLUDES_FOLDER})
|
|
|
|
message(STATUS "We have found log4cpp and will build project")
|
|
|
|
else()
|
2015-08-17 18:36:35 +02:00
|
|
|
message(FATAL_ERROR "We can't find log4cpp. We can't build project")
|
2015-02-10 14:07:53 +01:00
|
|
|
endif()
|
|
|
|
|
2015-08-12 19:27:29 +02:00
|
|
|
### Look for jsonc
|
|
|
|
|
|
|
|
find_path(JSONC_INCLUDES_FOLDER NAMES json-c/json.h PATHS "${JSONC_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(JSONC_LIBRARY_PATH NAMES json-c PATHS "${JSONC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (JSONC_INCLUDES_FOLDER AND JSONC_LIBRARY_PATH)
|
|
|
|
include_directories(${JSONC_INCLUDES_FOLDER})
|
|
|
|
message(STATUS "We have found json-c library correctly: ${JSONC_LIBRARY_PATH}")
|
|
|
|
else()
|
2015-08-17 18:36:35 +02:00
|
|
|
message(FATAL_ERROR "We can't find json-c library! Can't build project")
|
2015-08-12 19:27:29 +02:00
|
|
|
endif()
|
|
|
|
|
2015-08-13 15:59:06 +02:00
|
|
|
target_link_libraries(fast_library ${JSONC_LIBRARY_PATH})
|
|
|
|
|
2015-07-29 15:49:34 +02:00
|
|
|
if (ENABLE_DPI_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon fast_dpi)
|
|
|
|
endif()
|
|
|
|
|
2015-02-10 11:42:48 +01:00
|
|
|
target_link_libraries(fastnetmon ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
|
2015-06-02 22:27:49 +02:00
|
|
|
target_link_libraries(fastnetmon ${CMAKE_THREAD_LIBS_INIT})
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-07-03 17:01:18 +02:00
|
|
|
if (ENABLE_LUA_SUPPORT)
|
2015-10-16 00:24:03 +02:00
|
|
|
target_link_libraries(fast_library ${LUAJIT_LIBRARY_PATH})
|
|
|
|
target_link_libraries(fastnetmon ${LUAJIT_LIBRARY_PATH})
|
2015-07-03 17:01:18 +02:00
|
|
|
endif()
|
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# Our libs
|
2014-12-16 09:01:07 +01:00
|
|
|
target_link_libraries(fastnetmon patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon fastnetmon_pcap_format)
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-03-22 17:00:16 +01:00
|
|
|
target_link_libraries(fastnetmon ipfix_rfc)
|
|
|
|
|
2015-03-21 11:47:25 +01:00
|
|
|
# Link to our functions
|
|
|
|
target_link_libraries(fastnetmon fast_library)
|
|
|
|
|
2017-07-28 01:09:58 +02:00
|
|
|
# link to our unified parser
|
|
|
|
target_link_libraries(fastnetmon unified_parser)
|
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
if (ENABLE_PF_RING_SUPPORT)
|
2015-08-31 14:15:16 +02:00
|
|
|
target_link_libraries(fastnetmon pfring_plugin)
|
2015-09-03 13:09:16 +02:00
|
|
|
target_link_libraries(fastnetmon pfring_hardware_filter_action)
|
2015-08-31 14:15:16 +02:00
|
|
|
endif()
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon gobgp_action)
|
|
|
|
endif()
|
|
|
|
|
2015-08-31 14:15:16 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon snabbswitch_plugin)
|
2015-02-03 20:55:44 +01:00
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon afpacket_plugin)
|
|
|
|
endif()
|
|
|
|
|
2017-07-28 00:19:33 +02:00
|
|
|
target_link_libraries(fastnetmon sflow_plugin netflow_plugin pcap_plugin example_plugin)
|
|
|
|
|
|
|
|
if (ENABLE_NETMAP_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon netmap_plugin)
|
|
|
|
endif()
|
2015-05-29 13:42:01 +02:00
|
|
|
|
|
|
|
# cmake .. -DBUILD_PLUGIN_RUNNER=ON
|
|
|
|
if (BUILD_PLUGIN_RUNNER)
|
|
|
|
add_executable(fastnetmon_plugin_runner plugin_runner.cpp)
|
|
|
|
|
2015-08-31 12:25:57 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner snabbswitch_plugin)
|
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner afpacket_plugin)
|
|
|
|
endif()
|
|
|
|
|
2015-06-16 17:00:10 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${CMAKE_THREAD_LIBS_INIT})
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner fastnetmon_pcap_format)
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner fast_library)
|
|
|
|
|
|
|
|
# Add all plugins
|
2017-07-28 00:19:33 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner sflow_plugin netflow_plugin pcap_plugin example_plugin)
|
|
|
|
|
|
|
|
if (ENABLE_NETMAP_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner netmap_plugin)
|
|
|
|
endif()
|
2015-05-29 13:42:01 +02:00
|
|
|
|
2022-02-09 15:27:32 +01:00
|
|
|
if (ENABLE_PF_RING_SUPPORT)
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${PFRING_LIBRARIES})
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner pfring_plugin)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-03-23 17:39:44 +01:00
|
|
|
|
2015-05-29 14:08:12 +02:00
|
|
|
# cmake .. -DBUILD_PCAP_READER=ON
|
|
|
|
if (BUILD_PCAP_READER)
|
|
|
|
add_executable(fastnetmon_pcap_reader pcap_reader.cpp)
|
|
|
|
|
2015-05-29 14:45:02 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fastnetmon_packet_parser)
|
2015-05-29 14:08:12 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fastnetmon_pcap_format)
|
|
|
|
|
2015-05-29 14:08:12 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fast_library)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader ${LOG4CPP_LIBRARY_PATH})
|
2015-06-17 12:35:42 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader netflow_plugin)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader sflow_plugin)
|
2017-07-28 00:19:33 +02:00
|
|
|
|
|
|
|
if (ENABLE_NETMAP_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader netmap_plugin)
|
|
|
|
endif()
|
2015-07-24 14:45:15 +02:00
|
|
|
|
|
|
|
if (ENABLE_DPI_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader fast_dpi)
|
|
|
|
endif()
|
2015-05-29 14:08:12 +02:00
|
|
|
endif()
|
2015-03-23 17:39:44 +01:00
|
|
|
|
2015-07-12 17:34:00 +02:00
|
|
|
# cmake -DBUILD_TESTS=ON ..
|
|
|
|
if (BUILD_TESTS)
|
|
|
|
add_executable(fastnetmon_tests fastnetmon_tests.cpp)
|
|
|
|
target_link_libraries(fastnetmon_tests fast_library)
|
|
|
|
target_link_libraries(fastnetmon_tests ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
target_link_libraries(fastnetmon_tests ${Boost_LIBRARIES})
|
2015-07-13 10:05:26 +02:00
|
|
|
target_link_libraries(fastnetmon_tests ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
|
|
|
|
set(GOOGLE_TEST_INCLUDE_DIRS /opt/gtest/include)
|
|
|
|
set(GOOGLE_TEST_LIBRARIES /opt/gtest/lib/libgtest.a /opt/gtest/lib/libgtest_main.a)
|
2015-07-12 17:34:00 +02:00
|
|
|
|
|
|
|
# Compiled Google Library
|
2015-07-13 10:05:26 +02:00
|
|
|
include_directories(${GOOGLE_TEST_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(fastnetmon_tests ${GOOGLE_TEST_LIBRARIES})
|
2015-07-12 17:34:00 +02:00
|
|
|
endif()
|
|
|
|
|
2015-06-04 17:13:43 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
|
2017-05-29 16:45:36 +02:00
|
|
|
set(CMAKE_INSTALL_BINDIR "bin")
|
|
|
|
set(CMAKE_INSTALL_SBINDIR "bin")
|
|
|
|
set(CMAKE_INSTALL_SYSCONFDIR "etc")
|
2015-06-04 17:13:43 +02:00
|
|
|
else()
|
2017-05-29 16:45:36 +02:00
|
|
|
set(CMAKE_INSTALL_BINDIR "/usr/bin")
|
|
|
|
set(CMAKE_INSTALL_SBINDIR "/usr/sbin")
|
|
|
|
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
|
|
|
|
endif()
|
2015-06-02 22:26:04 +02:00
|
|
|
|
2017-05-29 16:45:36 +02:00
|
|
|
install(TARGETS fastnetmon DESTINATION "${CMAKE_INSTALL_SBINDIR}")
|
|
|
|
install(TARGETS fastnetmon_client DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2015-06-04 17:13:43 +02:00
|
|
|
|
2017-05-29 16:45:36 +02:00
|
|
|
install(FILES fastnetmon.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}")
|
|
|
|
|
|
|
|
# Install blank files for networks list and whitelist
|
|
|
|
install(FILES networks_list DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}")
|
|
|
|
install(FILES networks_whitelist DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}")
|
2015-06-04 10:15:32 +02:00
|
|
|
|
2015-06-04 15:13:22 +02:00
|
|
|
# man pages
|
2015-06-04 22:54:29 +02:00
|
|
|
install(FILES man/fastnetmon.1 DESTINATION /usr/share/man/man1)
|
|
|
|
install(FILES man/fastnetmon_client.1 DESTINATION /usr/share/man/man1)
|
2015-06-04 15:13:22 +02:00
|
|
|
|
2017-05-29 16:50:23 +02:00
|
|
|
# service files
|
2019-04-01 11:15:36 +02:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
configure_file(fastnetmon.service.in "${CMAKE_CURRENT_BINARY_DIR}/fastnetmon.service" @ONLY)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fastnetmon.service" DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR})
|
|
|
|
endif()
|
2017-05-29 16:50:23 +02:00
|
|
|
|
2017-05-30 11:11:39 +02:00
|
|
|
if (${OS_ID} MATCHES debian|ubuntu)
|
|
|
|
install(FILES fastnetmon_init_script_debian_6_7 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d RENAME fastnetmon)
|
|
|
|
endif()
|
|
|
|
|
2015-05-30 20:45:28 +02:00
|
|
|
# Configure cpack package builder
|
|
|
|
# Run it with: cd build; cpack -G DEB ..
|
|
|
|
set(CPACK_PACKAGE_NAME "fastnetmon")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "vps2fast.com")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "pavel.odintsov@gmail.com")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FastNetMon - very fast DDoS analyzer with sflow/netflow/mirror support")
|
|
|
|
set(CPACK_PACKAGE_VERSION "1.1.2")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "2")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
|
|
|
|
# set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
|
|
|
|
|
|
|
|
# Specify config for deb package
|
|
|
|
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-thread-dev, libboost-system-dev, libboost-regex-dev, libpcap-dev, libnuma-dev, liblog4cpp5-dev")
|
|
|
|
|
|
|
|
# This must always be last!
|
|
|
|
include(CPack)
|