Skip to content

Commit 150d6b3

Browse files
committed
Merge remote-tracking branch 'origin/hutak-unirec-array' into devel
2 parents 4f03dd9 + b058cd3 commit 150d6b3

File tree

9 files changed

+738
-201
lines changed

9 files changed

+738
-201
lines changed

extra_plugins/output/unirec/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(UNIREC_DESCRIPTION
77
)
88

99
set(UNIREC_VERSION_MAJOR 2)
10-
set(UNIREC_VERSION_MINOR 0)
10+
set(UNIREC_VERSION_MINOR 2)
1111
set(UNIREC_VERSION_PATCH 0)
1212
set(UNIREC_VERSION
1313
${UNIREC_VERSION_MAJOR}.${UNIREC_VERSION_MINOR}.${UNIREC_VERSION_PATCH})
@@ -19,9 +19,9 @@ include(CheckCXXCompilerFlag)
1919
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
2020

2121
# Find IPFIXcol and libnf
22-
find_package(IPFIXcol2 2.0.0 REQUIRED)
23-
find_package(LibTrap REQUIRED)
24-
find_package(Unirec REQUIRED)
22+
find_package(IPFIXcol2 2.1.0 REQUIRED) # support for basicList is required
23+
find_package(LibTrap 1.13.1 REQUIRED)
24+
find_package(LibUnirec 2.8.0 REQUIRED)
2525

2626
# Set default build type if not specified by user
2727
if (NOT CMAKE_BUILD_TYPE)
@@ -49,7 +49,7 @@ configure_file(
4949
include_directories(
5050
"${IPFIXCOL2_INCLUDE_DIRS}" # IPFIXcol2 header files
5151
"${LIBTRAP_INCLUDE_DIRS}" # libtrap header files
52-
"${UNIREC_INCLUDE_DIRS}" # unirec header files
52+
"${LIBUNIREC_INCLUDE_DIRS}" # unirec header files
5353
)
5454

5555
# Create a linkable module
@@ -67,7 +67,7 @@ add_library(unirec-output MODULE
6767

6868
target_link_libraries(unirec-output
6969
${LIBTRAP_LIBRARIES} # libtrap
70-
${UNIREC_LIBRARIES} # unirec
70+
${LIBUNIREC_LIBRARIES} # unirec
7171
m # standard math library
7272
)
7373

extra_plugins/output/unirec/CMakeModules/FindLibTrap.cmake

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,53 @@
55

66
# use pkg-config to get the directories and then use these values
77
# in the find_path() and find_library() calls
8-
find_package(PkgConfig)
9-
pkg_check_modules(PC_LIBTRAP QUIET LibTrap)
8+
find_package(PkgConfig QUIET)
9+
if (PKG_CONFIG_FOUND)
10+
pkg_check_modules(PC_LIBTRAP QUIET "libtrap")
11+
endif()
1012
set(LIBTRAP_DEFINITIONS ${PC_LIBTRAP_CFLAGS_OTHER})
1113

1214
find_path(
13-
LIBTRAP_INCLUDE_DIR trap.h
15+
LIBTRAP_INCLUDE_DIR libtrap/trap.h
1416
HINTS ${PC_LIBTRAP_INCLUDEDIR} ${PC_LIBTRAP_INCLUDE_DIRS}
15-
PATH_SUFFIXES include/libtrap
17+
PATH_SUFFIX include
1618
)
1719

1820
find_library(
19-
LIBTRAP_LIBRARY NAMES trap
21+
LIBTRAP_LIBRARY NAMES trap libtrap
2022
HINTS ${PC_LIBTRAP_LIBDIR} ${PC_LIBTRAP_LIBRARY_DIRS}
2123
PATH_SUFFIXES lib lib64
2224
)
2325

24-
# handle the QUIETLY and REQUIRED arguments and set LIBLIBTRAP_FOUND to TRUE
26+
if (PC_LIBTRAP_VERSION)
27+
# Version extracted from pkg-config
28+
set(LIBTRAP_VERSION_STRING ${PC_LIBTRAP_VERSION})
29+
elseif (LIBTRAP_INCLUDE_DIR AND LIBTRAP_LIBRARY)
30+
# Try to get the version of the installed library
31+
try_run(
32+
TRAP_RES_RUN TRAP_RES_COMP
33+
${CMAKE_CURRENT_BINARY_DIR}/try_run/trap_version_test/
34+
${PROJECT_SOURCE_DIR}/CMakeModules/try_run/trap_version.c
35+
CMAKE_FLAGS
36+
-DLINK_LIBRARIES=${LIBTRAP_LIBRARY}
37+
-DINCLUDE_DIRECTORIES=${LIBTRAP_INCLUDE_DIR}
38+
RUN_OUTPUT_VARIABLE LIBTRAP_VERSION_VAR
39+
)
40+
41+
if (TRAP_RES_COMP AND TRAP_RES_RUN EQUAL 0)
42+
# Successfully compiled and executed with return code 0
43+
set(LIBTRAP_VERSION_STRING ${LIBTRAP_VERSION_VAR})
44+
endif()
45+
endif()
46+
47+
# handle the QUIETLY and REQUIRED arguments and set LIBTRAP_FOUND to TRUE
2548
# if all listed variables are TRUE
2649
include(FindPackageHandleStandardArgs)
27-
find_package_handle_standard_args(libtrap
50+
find_package_handle_standard_args(LibTrap
2851
REQUIRED_VARS LIBTRAP_LIBRARY LIBTRAP_INCLUDE_DIR
2952
VERSION_VAR LIBTRAP_VERSION_STRING
3053
)
3154

3255
set(LIBTRAP_LIBRARIES ${LIBTRAP_LIBRARY})
3356
set(LIBTRAP_INCLUDE_DIRS ${LIBTRAP_INCLUDE_DIR})
34-
mark_as_advanced(LIBTRAP_INCLUDE_DIR LIBTRAP_LIBRARIES)
57+
mark_as_advanced(LIBTRAP_INCLUDE_DIR LIBTRAP_LIBRARY)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# LIBUNIREC_FOUND - System has libfds
2+
# LIBUNIREC_INCLUDE_DIRS - The libfds include directories
3+
# LIBUNIREC_LIBRARIES - The libraries needed to use libfds
4+
# LIBUNIREC_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 QUIET)
9+
if (PKG_CONFIG_FOUND)
10+
pkg_check_modules(PC_UNIREC QUIET "unirec")
11+
endif()
12+
set(LIBUNIREC_DEFINITIONS ${PC_UNIREC_CFLAGS_OTHER})
13+
14+
find_path(
15+
UNIREC_INCLUDE_DIR unirec/unirec.h
16+
HINTS ${PC_UNIREC_INCLUDEDIR} ${PC_UNIREC_INCLUDE_DIRS}
17+
PATH_SUFFIXES include
18+
)
19+
20+
find_library(
21+
UNIREC_LIBRARY NAMES unirec libunirec
22+
HINTS ${PC_UNIREC_LIBDIR} ${PC_UNIREC_LIBRARY_DIRS}
23+
PATH_SUFFIXES lib lib64
24+
)
25+
26+
if (PC_UNIREC_VERSION)
27+
# Version extracted from pkg-config
28+
set(UNIREC_VERSION_STRING ${PC_UNIREC_VERSION})
29+
endif()
30+
31+
32+
# handle the QUIETLY and REQUIRED arguments and set LIBUNIREC_FOUND to TRUE
33+
# if all listed variables are TRUE
34+
include(FindPackageHandleStandardArgs)
35+
find_package_handle_standard_args(LibUnirec
36+
REQUIRED_VARS UNIREC_LIBRARY UNIREC_INCLUDE_DIR
37+
VERSION_VAR UNIREC_VERSION_STRING
38+
)
39+
40+
set(LIBUNIREC_LIBRARIES ${UNIREC_LIBRARY})
41+
set(LIBUNIREC_INCLUDE_DIRS ${UNIREC_INCLUDE_DIR})
42+
mark_as_advanced(UNIREC_INCLUDE_DIR UNIREC_LIBRARY)

extra_plugins/output/unirec/CMakeModules/FindUnirec.cmake

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <libtrap/trap.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
5+
int
6+
main(int argc, char *argv[])
7+
{
8+
printf("%s", trap_version);
9+
return EXIT_SUCCESS;
10+
}

extra_plugins/output/unirec/config/unirec-elements.txt

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
# fields. You can change setting by editing this file. Each entry consists
55
# of the following parameters:
66
# - UniRec field name
7-
# - UniRec data type (int{8,16,32,64}, uint{8,16,32,64}, float, double, time,
8-
# ipaddr, macaddr, char, string, bytes)
7+
# - UniRec data type - one of the following:
8+
# int{8,16,32,64}, uint{8,16,32,64},
9+
# float, double, time, ipaddr, macaddr, char, string, bytes
10+
# int{8,16,32,64}*, uint{8,16,32,64}*, // "array of" types
11+
# float*, double*, time*, ipaddr*, macaddr* // "array of" types
12+
# string_trimmed // trimmed string (i.e. no tailing '\0')
913
# - Comma separated list of IPFIX Information Elements identifiers
1014
# ("eXXidYY" where XX is Private Enterprise Number and YY is field ID)
1115
#
@@ -31,6 +35,13 @@ TIME_FIRST time e0id150,e0id152,e0id154,e0id156 # T
3135
TIME_LAST time e0id151,e0id153,e0id155,e0id157 # Time of the last packet of a flow
3236
DIR_BIT_FIELD uint8 _internal_dbf_ # Bit field used for determining incoming/outgoing flow (1 => Incoming, 0 => Outgoing)
3337
LINK_BIT_FIELD uint64 _internal_lbf_ # Bit field of links on which was flow seen
38+
SRC_MAC macaddr e0id56
39+
DST_MAC macaddr e0id80
40+
41+
# --- Additional biflow fields ---
42+
BYTES_REV uint64 e29305id1
43+
PACKETS_REV uint32 e29305id2
44+
TCP_FLAGS_REV uint8 e29305id6
3445

3546
# --- DNS specific fields ---
3647
DNS_ID uint16 e39499id110 # DNS transaction id
@@ -123,32 +134,40 @@ IPV6_TUN_TYPE uint8 e16982id405 # IPv6 tunnel type
123134
APP_ID bytes e0id95 # Application ID from libprotoident / NBAR2 / Flowmon's NBAR plugin
124135

125136
# --- Flowmon TLS fields
126-
TLS_CONTENT_TYPE uint8 flowmon:tlsContentType # tlsContentType
127-
TLS_HANDSHAKE_TYPE uint32 flowmon:tlsHandshakeType # https://tools.ietf.org/html/rfc5246#appendix-A.4
128-
TLS_SETUP_TIME uint64 flowmon:tlsSetupTime # tlsSetupTime
129-
TLS_SERVER_VERSION uint16 flowmon:tlsServerVersion # 8b major and 8b minor, 0x0303 ~ TLS1.2
130-
TLS_SERVER_RANDOM bytes flowmon:tlsServerRandom # tlsServerRandom
131-
TLS_SERVER_SESSIONID bytes flowmon:tlsServerSessionId # tlsServerSessionId
132-
TLS_CIPHER_SUITE uint16 flowmon:tlsCipherSuite # https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
133-
TLS_ALPN string flowmon:tlsAlpn # TLS Application-Layer Protocol Negotiation https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
134-
TLS_SNI string flowmon:tlsSni # Server Name Indication https://en.wikipedia.org/wiki/Server_Name_Indication
135-
TLS_SNI_LENGTH uint16 flowmon:tlsSniLength # Length of TLS_SNI field
136-
TLS_CLIENT_VERSION uint16 flowmon:tlsClientVersion # tlsClientVersion
137-
TLS_CIPHER_SUITES bytes flowmon:tlsCipherSuites # List of 2B ciphers, beware of network byte order. See https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
138-
TLS_CLIENT_RANDOM bytes flowmon:tlsClientRandom # tlsClientRandom
139-
TLS_CLIENT_SESSIONID bytes flowmon:tlsClientSessionId # tlsClientSessionId
140-
TLS_EXTENSION_TYPES bytes flowmon:tlsExtensionTypes # tlsExtensionTypes
141-
TLS_EXTENSION_LENGTHS bytes flowmon:tlsExtensionLengths # tlsExtensionLengths
142-
TLS_ELLIPTIC_CURVES bytes flowmon:tlsEllipticCurves # tlsEllipticCurves
143-
TLS_EC_POINTFORMATS bytes flowmon:tlsEcPointFormats # tlsEcPointFormats
144-
TLS_CLIENT_KEYLENGTH int32 flowmon:tlsClientKeyLength # Length of client's key
145-
TLS_ISSUER_CN string flowmon:tlsIssuerCn # Common name of certificate issuer
146-
TLS_SUBJECT_CN string flowmon:tlsSubjectCn # Certificate Common Name
147-
TLS_SUBJECT_ON string flowmon:tlsSubjectOn # Certificate Organization Name
148-
TLS_VALIDITY_NOTBEFORE int64 flowmon:tlsValidityNotBefore # UNIX timestamp of certificate creation
149-
TLS_VALIDITY_NOTAFTER int64 flowmon:tlsValidityNotAfter # UNIX timestamp of certificate expiration
150-
TLS_SIGNATURE_ALG uint16 flowmon:tlsSignatureAlg # tlsSignatureAlg
151-
TLS_PUBLIC_KEYALG uint16 flowmon:tlsPublicKeyAlg # tlsPublicKeyAlg
152-
TLS_PUBLIC_KEYLENGTH int32 flowmon:tlsPublicKeyLength # tlsPublicKeyLength
153-
TLS_JA_3FINGERPRINT bytes flowmon:tlsJa3Fingerprint # tlsJa3Fingerprint
137+
TLS_CONTENT_TYPE uint8 flowmon:tlsContentType # tlsContentType
138+
TLS_HANDSHAKE_TYPE uint32 flowmon:tlsHandshakeType # https://tools.ietf.org/html/rfc5246#appendix-A.4
139+
TLS_SETUP_TIME uint64 flowmon:tlsSetupTime # tlsSetupTime
140+
TLS_SERVER_VERSION uint16 flowmon:tlsServerVersion # 8b major and 8b minor, 0x0303 ~ TLS1.2
141+
TLS_SERVER_RANDOM bytes flowmon:tlsServerRandom # tlsServerRandom
142+
TLS_SERVER_SESSIONID bytes flowmon:tlsServerSessionId # tlsServerSessionId
143+
TLS_CIPHER_SUITE uint16 flowmon:tlsCipherSuite # https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
144+
TLS_ALPN string flowmon:tlsAlpn # TLS Application-Layer Protocol Negotiation https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids
145+
TLS_SNI string flowmon:tlsSni # Server Name Indication https://en.wikipedia.org/wiki/Server_Name_Indication
146+
TLS_SNI_LENGTH uint16 flowmon:tlsSniLength # Length of TLS_SNI field
147+
TLS_CLIENT_VERSION uint16 flowmon:tlsClientVersion # tlsClientVersion
148+
TLS_CIPHER_SUITES bytes flowmon:tlsCipherSuites # List of 2B ciphers, beware of network byte order. See https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
149+
TLS_CLIENT_RANDOM bytes flowmon:tlsClientRandom # tlsClientRandom
150+
TLS_CLIENT_SESSIONID bytes flowmon:tlsClientSessionId # tlsClientSessionId
151+
TLS_EXTENSION_TYPES bytes flowmon:tlsExtensionTypes # tlsExtensionTypes
152+
TLS_EXTENSION_LENGTHS bytes flowmon:tlsExtensionLengths # tlsExtensionLengths
153+
TLS_ELLIPTIC_CURVES bytes flowmon:tlsEllipticCurves # tlsEllipticCurves
154+
TLS_EC_POINTFORMATS bytes flowmon:tlsEcPointFormats # tlsEcPointFormats
155+
TLS_CLIENT_KEYLENGTH int32 flowmon:tlsClientKeyLength # Length of client's key
156+
TLS_ISSUER_CN string flowmon:tlsIssuerCn # Common name of certificate issuer
157+
TLS_SUBJECT_CN string flowmon:tlsSubjectCn # Certificate Common Name
158+
TLS_SUBJECT_ON string flowmon:tlsSubjectOn # Certificate Organization Name
159+
TLS_VALIDITY_NOTBEFORE int64 flowmon:tlsValidityNotBefore # UNIX timestamp of certificate creation
160+
TLS_VALIDITY_NOTAFTER int64 flowmon:tlsValidityNotAfter # UNIX timestamp of certificate expiration
161+
TLS_SIGNATURE_ALG uint16 flowmon:tlsSignatureAlg # tlsSignatureAlg
162+
TLS_PUBLIC_KEYALG uint16 flowmon:tlsPublicKeyAlg # tlsPublicKeyAlg
163+
TLS_PUBLIC_KEYLENGTH int32 flowmon:tlsPublicKeyLength # tlsPublicKeyLength
164+
TLS_JA_3FINGERPRINT bytes flowmon:tlsJa3Fingerprint # tlsJa3Fingerprint
154165

166+
# --- Per-Packet Information elements ---
167+
PPI_TLS_REC_LENGTHS int16* e0id291/e8057id1010 # basicList of TLS record lengths
168+
PPI_TLS_REC_TIMES uint16* e0id291/e8057id1011 # basicList of TLS record timestamps
169+
PPI_TLS_CONTENT_TYPES uint8* e0id291/e8057id1012 # basicList of TLS record content types
170+
PPI_PKT_LENGTHS int16* e0id291/e8057id1013 # basicList of packet lengths
171+
PPI_PKT_TIMES time* e0id291/e8057id1014 # basicList of packet timestamps
172+
PPI_PKT_FLAGS int8* e0id291/e8057id1015 # basicList of packet TCP flags
173+
PPI_PKT_DIRECTIONS int8* e0id291/e8057id1016 # basicList of packet directions

0 commit comments

Comments
 (0)