Skip to content

Commit b3e6de5

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

File tree

5 files changed

+63
-61
lines changed

5 files changed

+63
-61
lines changed

src/plugins/process/CMakeLists.txt

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

src/plugins/process/pstats/README.md

Whitespace-only changes.
Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
/**
2-
* \file pstats.cpp
3-
* \brief Plugin for parsing pstats traffic.
4-
* \author Tomas Cejka <[email protected]>
5-
* \author Karel Hynek <[email protected]>
6-
* \date 2020
7-
*/
8-
/*
9-
* Copyright (C) 2020 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 Plugin for parsing pstats traffic.
4+
* @author Tomas Cejka <[email protected]>
5+
* @author Karel Hynek <[email protected]>
6+
* @author Pavel Siska <[email protected]>
7+
* @date 2025
268
*
9+
* Copyright (c) 2025 CESNET
2710
*
11+
* SPDX-License-Identifier: BSD-3-Clause
2812
*/
2913

3014
#include "pstats.hpp"
@@ -36,16 +20,24 @@
3620
#include <string>
3721
#include <vector>
3822

23+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
24+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
25+
3926
namespace ipxp {
4027

41-
int RecordExtPSTATS::REGISTERED_ID = -1;
28+
int RecordExtPSTATS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4229

43-
__attribute__((constructor)) static void register_this_plugin()
44-
{
45-
static PluginRecord rec = PluginRecord("pstats", []() { return new PSTATSPlugin(); });
46-
register_plugin(&rec);
47-
RecordExtPSTATS::REGISTERED_ID = register_extension();
48-
}
30+
static const PluginManifest pstatsPluginManifest = {
31+
.name = "pstats",
32+
.description = "Pstats process plugin for computing packet bursts stats.",
33+
.pluginVersion = "1.0.0",
34+
.apiVersion = "1.0.0",
35+
.usage =
36+
[]() {
37+
PSTATSOptParser parser;
38+
parser.usage(std::cout);
39+
},
40+
};
4941

5042
// #define DEBUG_PSTATS
5143

@@ -56,10 +48,11 @@ __attribute__((constructor)) static void register_this_plugin()
5648
#define DEBUG_MSG(format, ...)
5749
#endif
5850

59-
PSTATSPlugin::PSTATSPlugin()
51+
PSTATSPlugin::PSTATSPlugin(const std::string& params)
6052
: use_zeros(false)
6153
, skip_dup_pkts(false)
6254
{
55+
init(params.c_str());
6356
}
6457

6558
PSTATSPlugin::~PSTATSPlugin()
@@ -177,4 +170,7 @@ int PSTATSPlugin::post_update(Flow& rec, const Packet& pkt)
177170
return 0;
178171
}
179172

173+
static const PluginRegistrar<PSTATSPlugin, ProcessPluginFactory>
174+
pstatsRegistrar(pstatsPluginManifest);
175+
180176
} // namespace ipxp
Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
/**
2-
* \file pstats.h
3-
* \brief Plugin for parsing pstats traffic.
4-
* \author Tomas Cejka <[email protected]>
5-
* \author Karel Hynek <[email protected]>
6-
* \date 2020
7-
*/
8-
/*
9-
* Copyright (C) 2020 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 Plugin for parsing pstats traffic.
4+
* @author Tomas Cejka <[email protected]>
5+
* @author Karel Hynek <[email protected]>
6+
* @author Pavel Siska <[email protected]>
7+
* @date 2025
268
*
9+
* Copyright (c) 2025 CESNET
2710
*
11+
* SPDX-License-Identifier: BSD-3-Clause
2812
*/
2913

30-
#ifndef IPXP_PROCESS_PSTATS_HPP
31-
#define IPXP_PROCESS_PSTATS_HPP
14+
#pragma once
3215

3316
#include <cstring>
3417
#include <sstream>
@@ -44,7 +27,7 @@
4427
#include <ipfixprobe/ipfix-elements.hpp>
4528
#include <ipfixprobe/options.hpp>
4629
#include <ipfixprobe/packet.hpp>
47-
#include <ipfixprobe/process.hpp>
30+
#include <ipfixprobe/processPlugin.hpp>
4831

4932
namespace ipxp {
5033

@@ -230,7 +213,7 @@ struct RecordExtPSTATS : public RecordExt {
230213
*/
231214
class PSTATSPlugin : public ProcessPlugin {
232215
public:
233-
PSTATSPlugin();
216+
PSTATSPlugin(const std::string& params);
234217
~PSTATSPlugin();
235218
void init(const char* params);
236219
void close();
@@ -249,4 +232,3 @@ class PSTATSPlugin : public ProcessPlugin {
249232
};
250233

251234
} // namespace ipxp
252-
#endif /* IPXP_PROCESS_PSTATS_HPP */

0 commit comments

Comments
 (0)