Skip to content

Commit f65da1d

Browse files
committed
lnfstore output: initial version
1 parent 32ab16c commit f65da1d

21 files changed

+3726
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
cmake_minimum_required(VERSION 2.8.8)
2+
project(lnfstore)
3+
4+
# Description of the project
5+
set(LNFSTORE_DESCRIPTION
6+
"Output plugin for IPFIXcol2 that stores flow records into nfdump compatible files."
7+
)
8+
9+
set(LNFSTORE_VERSION_MAJOR 2)
10+
set(LNFSTORE_VERSION_MINOR 0)
11+
set(LNFSTORE_VERSION_PATCH 0)
12+
set(LNFSTORE_VERSION
13+
${LNFSTORE_VERSION_MAJOR}.${LNFSTORE_VERSION_MINOR}.${LNFSTORE_VERSION_PATCH})
14+
15+
include(CheckCCompilerFlag)
16+
include(CheckCXXCompilerFlag)
17+
include(GNUInstallDirs)
18+
# Include custom FindXXX modules
19+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
20+
21+
# Find IPFIXcol and libnf
22+
find_package(IPFIXcol 2.0.0 REQUIRED)
23+
find_package(LibFds REQUIRED)
24+
find_package(LibNf REQUIRED)
25+
find_package(LibBFI REQUIRED)
26+
27+
# Check capabilities of a compiler
28+
CHECK_C_COMPILER_FLAG(-std=gnu11 COMPILER_SUPPORT_GNU11)
29+
if (NOT COMPILER_SUPPORT_GNU11)
30+
message(FATAL_ERROR "Compiler does NOT support C11 with GNU extension")
31+
endif()
32+
33+
CHECK_CXX_COMPILER_FLAG(-std=gnu++11 COMPILER_SUPPORT_GNUXX11)
34+
if (NOT COMPILER_SUPPORT_GNUXX11)
35+
message(FATAL_ERROR "Compiler does NOT support C++11 with GNU extension")
36+
endif()
37+
38+
# Set default build type if not specified by user
39+
if (NOT CMAKE_BUILD_TYPE)
40+
set (CMAKE_BUILD_TYPE Release
41+
CACHE STRING "Choose type of build (Release/Debug/Coverage)." FORCE)
42+
endif()
43+
44+
# Hard coded definitions
45+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -std=gnu11")
46+
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
47+
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
48+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -std=gnu++11")
49+
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
50+
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
51+
52+
# Header files for source code building
53+
include_directories(
54+
"${IPFIXCOL2_INCLUDE_DIRS}" # IPFIXcol2 header files
55+
"${FDS_INCLUDE_DIRS}" # libfds header files
56+
"${NF_INCLUDE_DIRS}" # libnf header files
57+
"${BFI_INCLUDE_DIRS}" # libbfindex header files
58+
)
59+
60+
# Create a linkable module
61+
add_library(lnfstore-output MODULE
62+
configuration.c
63+
configuration.h
64+
files_manager.c
65+
files_manager.h
66+
idx_manager.c
67+
idx_manager.h
68+
lnfstore.c
69+
lnfstore.h
70+
storage_basic.c
71+
storage_basic.h
72+
storage_common.c
73+
storage_common.h
74+
translator.c
75+
translator.h
76+
utils.c
77+
utils.h
78+
)
79+
80+
target_link_libraries(lnfstore-output
81+
${NF_LIBRARIES} # libnf
82+
${BFI_LIBRARIES} # libbfindex
83+
${FDS_LIBRARIES} # libfds
84+
)
85+
86+
install(
87+
TARGETS lnfstore-output
88+
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/ipfixcol2/"
89+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# IPFIXCOL2_FOUND - System has IPFIXcol
2+
# IPFIXCOL2_INCLUDE_DIRS - The IPFIXcol include directories
3+
# IPFIXCOL2_DEFINITIONS - Compiler switches required for using IPFIXcol
4+
5+
# use pkg-config to get the directories and then use these values
6+
# in the find_path() and find_library() calls
7+
find_package(PkgConfig)
8+
pkg_check_modules(PC_IPFIXCOL QUIET ipfixcol2)
9+
set(IPFIXCOL2_DEFINITIONS ${PC_IPFIXCOL_CFLAGS_OTHER})
10+
11+
find_path(
12+
IPFIXCOL2_INCLUDE_DIR ipfixcol2.h
13+
HINTS ${PC_IPFIXCOL_INCLUDEDIR} ${PC_IPFIXCOL_INCLUDE_DIRS}
14+
PATH_SUFFIXES include
15+
)
16+
17+
if (PC_IPFIXCOL_VERSION)
18+
# Version extracted from pkg-config
19+
set(IPFIXCOL_VERSION_STRING ${PC_IPFIXCOL_VERSION})
20+
elseif(IPFIXCOL2_INCLUDE_DIR AND EXISTS "${IPFIXCOL2_INCLUDE_DIR}/ipfixcol2/api.h")
21+
# Try to extract library version from a header file
22+
file(STRINGS "${IPFIXCOL2_INCLUDE_DIR}/ipfixcol2/api.h" ipfixcol_version_str
23+
REGEX "^#define[\t ]+IPX_API_VERSION_STR[\t ]+\".*\"")
24+
25+
string(REGEX REPLACE "^#define[\t ]+IPX_API_VERSION_STR[\t ]+\"([^\"]*)\".*" "\\1"
26+
IPFIXCOL_VERSION_STRING "${ipfixcol_version_str}")
27+
unset(ipfixcol_version_str)
28+
endif()
29+
30+
# handle the QUIETLY and REQUIRED arguments and set IPFIXCOL2_FOUND to TRUE
31+
# if all listed variables are TRUE
32+
include(FindPackageHandleStandardArgs)
33+
find_package_handle_standard_args(IPFIXcol2
34+
REQUIRED_VARS IPFIXCOL2_INCLUDE_DIR
35+
VERSION_VAR IPFIXCOL_VERSION_STRING
36+
)
37+
38+
set(IPFIXCOL2_INCLUDE_DIRS ${IPFIXCOL2_INCLUDE_DIR})
39+
mark_as_advanced(IPFIXCOL2_INCLUDE_DIR)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# BFI_FOUND - System has bloom filter index
2+
# BFI_INCLUDE_DIRS - Include directories
3+
# BFI_LIBRARIES - The libraries needed to use it
4+
5+
find_path(
6+
BFI_INCLUDE_DIR bf_index.h
7+
PATH_SUFFIXES include
8+
)
9+
10+
find_library(
11+
BFI_LIBRARY NAMES bfindex libbfindex
12+
PATH_SUFFIXES lib lib64
13+
)
14+
15+
# handle the QUIETLY and REQUIRED arguments and set BFI_FOUND to TRUE
16+
# if all listed variables are TRUE
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(LibBFI
19+
REQUIRED_VARS BFI_LIBRARY BFI_INCLUDE_DIR
20+
)
21+
22+
set(BFI_LIBRARIES ${BFI_LIBRARY})
23+
set(BFI_INCLUDE_DIRS ${BFI_INCLUDE_DIR})
24+
mark_as_advanced(BFI_INCLUDE_DIR BFI_LIBRARY)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# FDS_FOUND - System has libfds
2+
# FDS_INCLUDE_DIRS - The libfds include directories
3+
# FDS_LIBRARIES - The libraries needed to use libfds
4+
# FDS_DEFINITIONS - Compiler switches required for using libfds
5+
6+
# use pkg-config to get the directories and then use these values
7+
# in the find_path() and find_library() calls
8+
find_package(PkgConfig)
9+
pkg_check_modules(PC_FDS QUIET libfds)
10+
set(FDS_DEFINITIONS ${PC_FDS_CFLAGS_OTHER})
11+
12+
find_path(
13+
FDS_INCLUDE_DIR libfds.h
14+
HINTS ${PC_FDS_INCLUDEDIR} ${PC_FDS_INCLUDE_DIRS}
15+
PATH_SUFFIXES include
16+
)
17+
18+
find_library(
19+
FDS_LIBRARY NAMES fds libfds
20+
HINTS ${PC_FDS_LIBDIR} ${PC_FDS_LIBRARY_DIRS}
21+
PATH_SUFFIXES lib lib64
22+
)
23+
24+
if (PC_FDS_VERSION)
25+
# Version extracted from pkg-config
26+
set(FDS_VERSION_STRING ${PC_FDS_VERSION})
27+
elseif(FDS_INCLUDE_DIR AND EXISTS "${FDS_INCLUDE_DIR}/libfds/api.h")
28+
# Try to extract library version from a header file
29+
file(STRINGS "${FDS_INCLUDE_DIR}/libfds/api.h" libfds_version_str
30+
REGEX "^#define[\t ]+FDS_VERSION_STR[\t ]+\".*\"")
31+
32+
string(REGEX REPLACE "^#define[\t ]+FDS_VERSION_STR[\t ]+\"([^\"]*)\".*" "\\1"
33+
FDS_VERSION_STRING "${libfds_version_str}")
34+
unset(libfds_version_str)
35+
endif()
36+
37+
# handle the QUIETLY and REQUIRED arguments and set LIBFDS_FOUND to TRUE
38+
# if all listed variables are TRUE
39+
include(FindPackageHandleStandardArgs)
40+
find_package_handle_standard_args(LibFds
41+
REQUIRED_VARS FDS_LIBRARY FDS_INCLUDE_DIR
42+
VERSION_VAR FDS_VERSION_STRING
43+
)
44+
45+
set(FDS_LIBRARIES ${FDS_LIBRARY})
46+
set(FDS_INCLUDE_DIRS ${FDS_INCLUDE_DIR})
47+
mark_as_advanced(FDS_INCLUDE_DIR FDS_LIBRARY)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NF_FOUND - System has libnf
2+
# NF_INCLUDE_DIRS - The libnf include directories
3+
# NF_LIBRARIES - The libraries needed to use libnf
4+
5+
find_path(
6+
NF_INCLUDE_DIR libnf.h
7+
PATH_SUFFIXES include
8+
)
9+
10+
find_library(
11+
NF_LIBRARY NAMES nf libnf
12+
PATH_SUFFIXES lib lib64
13+
)
14+
15+
# handle the QUIETLY and REQUIRED arguments and set NF_FOUND to TRUE
16+
# if all listed variables are TRUE
17+
include(FindPackageHandleStandardArgs)
18+
find_package_handle_standard_args(LibNf
19+
REQUIRED_VARS NF_LIBRARY NF_INCLUDE_DIR
20+
)
21+
22+
set(NF_LIBRARIES ${NF_LIBRARY})
23+
set(NF_INCLUDE_DIRS ${NF_INCLUDE_DIR})
24+
mark_as_advanced(NF_INCLUDE_DIR NF_LIBRARY)

0 commit comments

Comments
 (0)