Skip to content

Commit 3c924b6

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process WIREGUARD plugin
1 parent 315993f commit 3c924b6

File tree

4 files changed

+51
-59
lines changed

4 files changed

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

src/plugins/process/wg/README.md

Whitespace-only changes.
Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,43 @@
11
/**
2-
* \file wg.cpp
3-
* \brief Plugin for parsing wg traffic.
4-
* \author Pavel Valach <[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 wg traffic.
4+
* @author Pavel Valach <[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 "wg.hpp"
3014

3115
#include <cstring>
3216
#include <iostream>
3317

18+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
19+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3420
#include <ipfixprobe/utils.hpp>
3521

3622
namespace ipxp {
3723

38-
int RecordExtWG::REGISTERED_ID = -1;
24+
int RecordExtWG::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
3925

40-
__attribute__((constructor)) static void register_this_plugin()
41-
{
42-
static PluginRecord rec = PluginRecord("wg", []() { return new WGPlugin(); });
43-
register_plugin(&rec);
44-
RecordExtWG::REGISTERED_ID = register_extension();
45-
}
26+
static const PluginManifest wgPluginManifest = {
27+
.name = "wg",
28+
.description = "Wg process plugin for parsing wg traffic.",
29+
.pluginVersion = "1.0.0",
30+
.apiVersion = "1.0.0",
31+
.usage = nullptr,
32+
};
4633

47-
WGPlugin::WGPlugin()
34+
WGPlugin::WGPlugin(const std::string& params)
4835
: preallocated_record(nullptr)
4936
, flow_flush(false)
5037
, total(0)
5138
, identified(0)
5239
{
40+
(void) params;
5341
}
5442

5543
WGPlugin::~WGPlugin()
@@ -235,4 +223,6 @@ int WGPlugin::add_ext_wg(const char* data, unsigned int payload_len, bool source
235223
return 0;
236224
}
237225

226+
static const PluginRegistrar<WGPlugin, ProcessPluginFactory> wgRegistrar(wgPluginManifest);
227+
238228
} // namespace ipxp
Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,18 @@
11
/**
2-
* \file wg.hpp
3-
* \brief Plugin for parsing wg traffic.
4-
* \author Pavel Valach <[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 wg traffic.
4+
* @author Pavel Valach <[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_WG_HPP
30-
#define IPXP_PROCESS_WG_HPP
13+
#pragma once
3114

15+
#include <cstring>
3216
#include <sstream>
3317
#include <string>
3418

@@ -41,7 +25,7 @@
4125
#include <ipfixprobe/flowifc.hpp>
4226
#include <ipfixprobe/ipfix-elements.hpp>
4327
#include <ipfixprobe/packet.hpp>
44-
#include <ipfixprobe/process.hpp>
28+
#include <ipfixprobe/processPlugin.hpp>
4529

4630
namespace ipxp {
4731

@@ -139,7 +123,7 @@ struct RecordExtWG : public RecordExt {
139123
*/
140124
class WGPlugin : public ProcessPlugin {
141125
public:
142-
WGPlugin();
126+
WGPlugin(const std::string& params);
143127
~WGPlugin();
144128
void init(const char* params);
145129
void close();
@@ -164,4 +148,3 @@ class WGPlugin : public ProcessPlugin {
164148
};
165149

166150
} // namespace ipxp
167-
#endif /* IPXP_PROCESS_WG_HPP */

0 commit comments

Comments
 (0)