Skip to content

Commit 295100e

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process PHISTS plugin
1 parent 6179207 commit 295100e

File tree

5 files changed

+60
-59
lines changed

5 files changed

+60
-59
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ add_subdirectory(vlan)
88
add_subdirectory(flowHash)
99
add_subdirectory(osquery)
1010
add_subdirectory(idpContent)
11+
add_subdirectory(phists)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
project(ipfixprobe-process-phists VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-phists plugin")
2+
3+
add_library(ipfixprobe-process-phists MODULE
4+
src/phists.cpp
5+
src/phists.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-phists PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-phists PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
)
16+
17+
target_link_libraries(ipfixprobe-process-phists PRIVATE
18+
ipfixprobe-output-ipfix
19+
)
20+
21+
install(TARGETS ipfixprobe-process-phists
22+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
23+
)

src/plugins/process/phists/README.md

Whitespace-only changes.
Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
/**
2-
* \file phists.cpp
3-
* \brief Plugin for parsing phists traffic.
4-
* \author Karel Hynek <[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 Plugin for parsing phists traffic.
4+
* @author Karel Hynek <[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 "phists.hpp"
@@ -35,18 +19,25 @@
3519
#include <string>
3620
#include <vector>
3721

22+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
23+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3824
#include <math.h>
3925

4026
namespace ipxp {
4127

42-
int RecordExtPHISTS::REGISTERED_ID = -1;
28+
int RecordExtPHISTS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4329

44-
__attribute__((constructor)) static void register_this_plugin()
45-
{
46-
static PluginRecord rec = PluginRecord("phists", []() { return new PHISTSPlugin(); });
47-
register_plugin(&rec);
48-
RecordExtPHISTS::REGISTERED_ID = register_extension();
49-
}
30+
static const PluginManifest phistsPluginManifest = {
31+
.name = "phists",
32+
.description = "Phists process plugin for parsing phists traffic.",
33+
.pluginVersion = "1.0.0",
34+
.apiVersion = "1.0.0",
35+
.usage =
36+
[]() {
37+
PHISTSOptParser parser;
38+
parser.usage(std::cout);
39+
},
40+
};
5041

5142
#define PHISTS_INCLUDE_ZEROS_OPT "includezeros"
5243

@@ -60,9 +51,10 @@ const uint32_t PHISTSPlugin::log2_lookup32[32]
6051
= {0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
6152
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31};
6253

63-
PHISTSPlugin::PHISTSPlugin()
54+
PHISTSPlugin::PHISTSPlugin(const std::string& params)
6455
: use_zeros(false)
6556
{
57+
init(params.c_str());
6658
}
6759

6860
PHISTSPlugin::~PHISTSPlugin()
@@ -175,4 +167,7 @@ int PHISTSPlugin::post_update(Flow& rec, const Packet& pkt)
175167
return 0;
176168
}
177169

170+
static const PluginRegistrar<PHISTSPlugin, ProcessPluginFactory>
171+
phistsRegistrar(phistsPluginManifest);
172+
178173
} // namespace ipxp
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file phists.hpp
3-
* \brief Plugin for parsing phists traffic.
4-
* \author Karel Hynek <[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 Plugin for parsing phists traffic.
4+
* @author Karel Hynek <[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_PROCESS_PHISTS_HPP
30-
#define IPXP_PROCESS_PHISTS_HPP
13+
#pragma once
3114

3215
#include <limits>
3316
#include <sstream>
@@ -41,7 +24,7 @@
4124
#include <ipfixprobe/ipfix-basiclist.hpp>
4225
#include <ipfixprobe/ipfix-elements.hpp>
4326
#include <ipfixprobe/packet.hpp>
44-
#include <ipfixprobe/process.hpp>
27+
#include <ipfixprobe/processPlugin.hpp>
4528

4629
namespace ipxp {
4730

@@ -200,7 +183,7 @@ struct RecordExtPHISTS : public RecordExt {
200183
*/
201184
class PHISTSPlugin : public ProcessPlugin {
202185
public:
203-
PHISTSPlugin();
186+
PHISTSPlugin(const std::string& params);
204187
~PHISTSPlugin();
205188
void init(const char* params);
206189
void close();
@@ -242,4 +225,3 @@ class PHISTSPlugin : public ProcessPlugin {
242225
};
243226

244227
} // namespace ipxp
245-
#endif /* IPXP_PROCESS_PHISTS_HPP */

0 commit comments

Comments
 (0)