Skip to content

Commit 9f5a0f1

Browse files
Pavel SiskaPavel Šiška
authored andcommitted
CMake: add option to build with NEMEA
1 parent 67b8873 commit 9f5a0f1

File tree

36 files changed

+292
-93
lines changed

36 files changed

+292
-93
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ option(ENABLE_PROCESS_EXPERIMENTAL "Enable build of experimental process plugins
2222
option(ENABLE_RPMBUILD "Enable build of RPM package" ON)
2323

2424
option(ENABLE_MILISECONDS_TIMESTAMP "Compile ipfixprobe with miliseconds timestamp precesion" OFF)
25+
option(ENABLE_NEMEA "Enable build of NEMEA plugins" OFF)
2526

2627
if(ENABLE_MILISECONDS_TIMESTAMP)
2728
add_compile_definitions(IPXP_TS_MSEC)
2829
endif()
2930

31+
if(ENABLE_NEMEA)
32+
add_compile_definitions(WITH_NEMEA)
33+
endif()
34+
3035
set(CMAKE_C_STANDARD 11)
3136
set(CMAKE_C_STANDARD_REQUIRED ON)
3237
set(CMAKE_C_EXTENSIONS ON)

cmake/dependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (ENABLE_INPUT_NFB)
1919
find_package(NUMA REQUIRED)
2020
endif()
2121

22-
if (ENABLE_OUTPUT_UNIREC)
22+
if (ENABLE_OUTPUT_UNIREC OR ENABLE_NEMEA)
2323
find_package(LIBTRAP REQUIRED)
2424
find_package(UNIREC REQUIRED)
2525
endif()

include/ipfixprobe/flowifc.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#include <sys/time.h>
4040

4141
#ifdef WITH_NEMEA
42-
#include "fields.h"
43-
4442
#include <unirec/unirec.h>
4543
#else
4644
#define UR_FIELDS(...)

src/plugins/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,36 @@ add_subdirectory(input)
22
add_subdirectory(output)
33
add_subdirectory(process)
44
add_subdirectory(storage)
5+
6+
7+
if(ENABLE_NEMEA)
8+
message(STATUS "Running ur_processor script for process plugins")
9+
10+
set(OUTPUT_DIR ${CMAKE_BINARY_DIR}/src/plugins/nemea-fields/)
11+
file(MAKE_DIRECTORY ${OUTPUT_DIR})
12+
13+
set(GENERATED_SOURCES
14+
${OUTPUT_DIR}/fields.c
15+
${OUTPUT_DIR}/fields.h
16+
)
17+
18+
execute_process(
19+
COMMAND /usr/bin/nemea/ur_processor.sh -i ${CMAKE_CURRENT_SOURCE_DIR} -o ${OUTPUT_DIR}
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
21+
RESULT_VARIABLE SCRIPT_RESULT
22+
)
23+
24+
if(NOT SCRIPT_RESULT EQUAL 0)
25+
message(FATAL_ERROR "Script ur_processor failed")
26+
endif()
27+
28+
add_custom_target(generate_nemea_files DEPENDS ${GENERATED_SOURCES})
29+
30+
add_library(ipfixprobe-nemea-fields STATIC
31+
${GENERATED_SOURCES}
32+
)
33+
34+
add_dependencies(ipfixprobe-nemea-fields generate_nemea_files)
35+
target_include_directories(ipfixprobe-nemea-fields PUBLIC ${OUTPUT_DIR})
36+
37+
endif()

src/plugins/input/nfb/src/ndp.cpp

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
11
/**
2-
* \file ndp.cpp
3-
* \brief Packet reader using NDP library for high speed capture.
4-
* \author Tomas Benes <[email protected]>
5-
* \author Jiri Havranek <[email protected]>
6-
* \date 2021
7-
*/
8-
/*
9-
* Copyright (C) 2020-2021 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Packet reader using NDP library for high speed capture.
4+
* @author Jiri Havranek <[email protected]>
5+
* @author Tomas Benes <[email protected]>
6+
* @author Pavel Siska <[email protected]>
267
*
8+
* Copyright (c) 2025 CESNET
279
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2811
*/
2912

3013
#include "ndp.hpp"
31-
3214
#include "parser.hpp"
3315

3416
#include <cstdio>
3517
#include <cstring>
3618
#include <iostream>
3719

20+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
21+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
22+
3823
namespace ipxp {
3924

4025
telemetry::Content NdpPacketReader::get_queue_telemetry()
@@ -45,14 +30,23 @@ telemetry::Content NdpPacketReader::get_queue_telemetry()
4530
return dict;
4631
}
4732

48-
__attribute__((constructor)) static void register_this_plugin()
33+
static const PluginManifest ndpPluginManifest = {
34+
.name = "ndp",
35+
.description = "Ndp input plugin for reading packets from network interface or ndp file.",
36+
.pluginVersion = "1.0.0",
37+
.apiVersion = "1.0.0",
38+
.usage =
39+
[]() {
40+
NdpOptParser parser;
41+
parser.usage(std::cout);
42+
},
43+
};
44+
45+
NdpPacketReader::NdpPacketReader(const std::string& params)
4946
{
50-
static PluginRecord rec = PluginRecord("ndp", []() { return new NdpPacketReader(); });
51-
register_plugin(&rec);
47+
init(params.c_str());
5248
}
5349

54-
NdpPacketReader::NdpPacketReader() {}
55-
5650
NdpPacketReader::~NdpPacketReader()
5751
{
5852
close();
@@ -134,4 +128,6 @@ void NdpPacketReader::configure_telemetry_dirs(
134128
register_file(queues_dir, "input-stats", statsOps);
135129
}
136130

131+
static const PluginRegistrar<NdpPacketReader, InputPluginFactory> ndpRegistrar(ndpPluginManifest);
132+
137133
} // namespace ipxp

src/plugins/input/nfb/src/ndp.hpp

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
/**
2-
* \file ndp.hpp
3-
* \brief Packet reader using NDP library for high speed capture.
4-
* \author Tomas Benes <[email protected]>
5-
* \author Jiri Havranek <[email protected]>
6-
* \date 2021
7-
*/
8-
/*
9-
* Copyright (C) 2020-2021 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Packet reader using NDP library for high speed capture.
4+
* @author Jiri Havranek <[email protected]>
5+
* @author Tomas Benes <[email protected]>
6+
* @author Pavel Siska <[email protected]>
267
*
8+
* Copyright (c) 2025 CESNET
279
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2811
*/
2912

30-
#ifndef IPXP_INPUT_NDP_HPP
31-
#define IPXP_INPUT_NDP_HPP
13+
#pragma once
3214

3315
#include "ndpReader.hpp"
3416

@@ -78,7 +60,7 @@ class NdpOptParser : public OptionsParser {
7860

7961
class NdpPacketReader : public InputPlugin {
8062
public:
81-
NdpPacketReader();
63+
NdpPacketReader(const std::string& params);
8264
~NdpPacketReader();
8365

8466
void init(const char* params);
@@ -106,5 +88,3 @@ class NdpPacketReader : public InputPlugin {
10688
};
10789

10890
} // namespace ipxp
109-
110-
#endif /* IPXP_INPUT_NDP_HPP */

src/plugins/output/unirec/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ target_include_directories(ipfixprobe-output-unirec PRIVATE
1515
)
1616

1717
target_link_libraries(ipfixprobe-output-unirec PRIVATE
18+
-Wl,--whole-archive ipfixprobe-nemea-fields -Wl,--no-whole-archive
1819
unirec::unirec
1920
trap::trap
2021
)

src/plugins/process/basicplus/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ target_include_directories(ipfixprobe-process-basicplus PRIVATE
1818
${CMAKE_SOURCE_DIR}/include/
1919
)
2020

21+
if(ENABLE_NEMEA)
22+
target_link_libraries(ipfixprobe-process-basicplus PRIVATE
23+
-Wl,--whole-archive ipfixprobe-nemea-fields -Wl,--no-whole-archive
24+
unirec::unirec
25+
)
26+
endif()
27+
2128
install(TARGETS ipfixprobe-process-basicplus
2229
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
23-
)
30+
)

src/plugins/process/bstats/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ target_link_libraries(ipfixprobe-process-bstats PRIVATE
1818
ipfixprobe-output-ipfix
1919
)
2020

21+
if(ENABLE_NEMEA)
22+
target_link_libraries(ipfixprobe-process-bstats PRIVATE
23+
-Wl,--whole-archive ipfixprobe-nemea-fields -Wl,--no-whole-archive
24+
unirec::unirec
25+
)
26+
endif()
27+
2128
install(TARGETS ipfixprobe-process-bstats
2229
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
23-
)
30+
)

src/plugins/process/dns/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ target_include_directories(ipfixprobe-process-dns PRIVATE
1515
${CMAKE_SOURCE_DIR}/src/plugins/process/common
1616
)
1717

18+
if(ENABLE_NEMEA)
19+
target_link_libraries(ipfixprobe-process-dns PRIVATE
20+
-Wl,--whole-archive -Wl,--whole-archive ipfixprobe-nemea-fields -Wl,--no-whole-archive -Wl,--no-whole-archive
21+
unirec::unirec
22+
)
23+
endif()
24+
1825
install(TARGETS ipfixprobe-process-dns
1926
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
20-
)
27+
)

0 commit comments

Comments
 (0)