Skip to content

Commit e78d242

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce output TEXT plugin
1 parent 464431e commit e78d242

File tree

6 files changed

+57
-59
lines changed

6 files changed

+57
-59
lines changed

src/plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(input)
2+
add_subdirectory(output)

src/plugins/output/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(text)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
project(ipfixprobe-output-text VERSION 1.0.0 DESCRIPTION "ipfixprobe-output-text plugin")
2+
3+
add_library(ipfixprobe-output-text SHARED
4+
src/text.hpp
5+
src/text.cpp
6+
)
7+
8+
set_target_properties(ipfixprobe-output-text PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-output-text PRIVATE ${CMAKE_SOURCE_DIR}/include/)
14+
15+
install(
16+
TARGETS ipfixprobe-output-text
17+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/output/"
18+
)

src/plugins/output/text/README.md

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

2913
#include "text.hpp"
@@ -34,18 +18,28 @@
3418
#include <ostream>
3519
#include <string>
3620

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

39-
__attribute__((constructor)) static void register_this_plugin()
40-
{
41-
static PluginRecord rec = PluginRecord("text", []() { return new TextExporter(); });
42-
register_plugin(&rec);
43-
}
24+
namespace ipxp {
4425

45-
TextExporter::TextExporter()
26+
static const PluginManifest textPluginManifest = {
27+
.name = "text",
28+
.description = "Output plugin for text export",
29+
.pluginVersion = "1.0.0",
30+
.apiVersion = "1.0.0",
31+
.usage =
32+
[]() {
33+
TextOptParser parser;
34+
parser.usage(std::cout);
35+
},
36+
};
37+
38+
TextExporter::TextExporter(const std::string& params)
4639
: m_out(&std::cout)
4740
, m_hide_mac(false)
4841
{
42+
init(params.c_str());
4943
}
5044

5145
TextExporter::~TextExporter()
@@ -168,4 +162,6 @@ void TextExporter::print_basic_flow(const Flow& flow)
168162
<< static_cast<unsigned>(flow.dst_tcp_flags) << " " << time_begin << "->" << time_end;
169163
}
170164

165+
static const PluginRegistrar<TextExporter, OutputPluginFactory> textRegistrar(textPluginManifest);
166+
171167
} // namespace ipxp
Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,23 @@
11
/**
2-
* \file text.hpp
3-
* \brief Prints exported fields
4-
* \author Jiri Havranek <[email protected]>
5-
* \date 2021
6-
*/
7-
/*
8-
* Copyright (C) 2021 CESNET
9-
*
10-
* LICENSE TERMS
11-
*
12-
* Redistribution and use in source and binary forms, with or without
13-
* modification, are permitted provided that the following conditions
14-
* are met:
15-
* 1. Redistributions of source code must retain the above copyright
16-
* notice, this list of conditions and the following disclaimer.
17-
* 2. Redistributions in binary form must reproduce the above copyright
18-
* notice, this list of conditions and the following disclaimer in
19-
* the documentation and/or other materials provided with the
20-
* distribution.
21-
* 3. Neither the name of the Company nor the names of its contributors
22-
* may be used to endorse or promote products derived from this
23-
* software without specific prior written permission.
24-
*
2+
* @file
3+
* @brief Prints exported fields
4+
* @author Jiri Havranek <[email protected]>
5+
* @author Pavel Siska <[email protected]>
6+
* @date 2025
257
*
8+
* Copyright (c) 2025 CESNET
269
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2711
*/
2812

29-
#ifndef IPXP_OUTPUT_TEXT_HPP
30-
#define IPXP_OUTPUT_TEXT_HPP
13+
#pragma once
3114

3215
#include <string>
3316

3417
#include <ipfixprobe/flowifc.hpp>
3518
#include <ipfixprobe/options.hpp>
36-
#include <ipfixprobe/output.hpp>
37-
#include <ipfixprobe/process.hpp>
19+
#include <ipfixprobe/outputPlugin.hpp>
20+
#include <ipfixprobe/processPlugin.hpp>
3821
#include <ipfixprobe/utils.hpp>
3922

4023
namespace ipxp {
@@ -77,7 +60,7 @@ class TextOptParser : public OptionsParser {
7760

7861
class TextExporter : public OutputPlugin {
7962
public:
80-
TextExporter();
63+
TextExporter(const std::string& params);
8164
~TextExporter();
8265
void init(const char* params);
8366
void init(const char* params, Plugins& plugins);
@@ -94,4 +77,3 @@ class TextExporter : public OutputPlugin {
9477
};
9578

9679
} // namespace ipxp
97-
#endif /* IPXP_OUTPUT_TEXT_HPP */

0 commit comments

Comments
 (0)