Skip to content

Commit 9e25a75

Browse files
committed
++
1 parent 8269526 commit 9e25a75

29 files changed

+563
-240
lines changed

new-process-api/process/ovpn/src/openvpn.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
namespace ipxp {
2929

30+
/**
31+
* @class OpenVPNPlugin
32+
* @brief A plugin for detecting OpenVPN traffic.
33+
*/
3034
class OpenVPNPlugin : public ProcessPlugin {
3135
public:
3236

new-process-api/process/passiveDns/src/passivedns.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ static const PluginManifest passiveDNSPluginManifest = {
3939
},
4040
};
4141

42-
const inline std::vector<FieldPair<PassiveDNSFields>> fields = {
43-
{PassiveDNSFields::DNS_ID, "DNS_ID"},
44-
{PassiveDNSFields::DNS_ATYPE, "DNS_ATYPE"},
45-
{PassiveDNSFields::DNS_NAME, "DNS_NAME"},
46-
{PassiveDNSFields::DNS_RR_TTL, "DNS_RR_TTL"},
47-
{PassiveDNSFields::DNS_IP, "DNS_IP"},
48-
};
49-
5042
static FieldSchema createPassiveDNSSchema(FieldManager& manager, FieldHandlers<PassiveDNSFields>& handlers) noexcept
5143
{
5244
FieldSchema schema = fieldManager.createFieldSchema("passivedns");
@@ -259,11 +251,6 @@ PluginDataMemoryLayout DNSSDPlugin::getDataMemoryLayout() const noexcept
259251
};
260252
}
261253

262-
std::string PassiveDNSPlugin::getName() const noexcept
263-
{
264-
return passiveDNSPluginManifest.name;
265-
}
266-
267254
static const PluginRegistrar<PassiveDNSPlugin, PluginFactory<ProcessPlugin, const std::string&, FieldManager&>>
268255
passiveDNSRegistrar(passiveDNSPluginManifest);
269256

new-process-api/process/passiveDns/src/passivedns.hpp

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* @file
3-
* @brief Plugin for parsing basicplus traffic.
3+
* @brief Plugin for parsing DNS responses.
44
* @author Jiri Havranek <[email protected]>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
8-
* Copyright (c) 2025 CESNET
9-
*
10-
* SPDX-License-Identifier: BSD-3-Clause
9+
* Provides a plugin that parses DNS A, AAAA, PTR responses,
10+
* stores them in per-flow plugin data, and exposes fields via FieldManager.
11+
*
12+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1113
*/
1214

1315
#pragma once
@@ -23,18 +25,55 @@
2325

2426
namespace ipxp {
2527

28+
/**
29+
* @class PassiveDNSPlugin
30+
* @brief A plugin for parsing DNS responses.
31+
*/
2632
class PassiveDNSPlugin : public ProcessPlugin {
2733
public:
34+
35+
/**
36+
* @brief Constructs the PassiveDNS plugin.
37+
*
38+
* @param parameters Plugin parameters as a string (currently unused).
39+
* @param fieldManager Reference to the FieldManager for field registration.
40+
*/
2841
PassiveDNSPlugin(const std::string& params, FieldManager& manager);
2942

43+
/**
44+
* @brief Initializes plugin data for a new flow.
45+
*
46+
* Removes plugin if neither source nor destination port is 53.
47+
* Constructs `PassiveDNSData` in `pluginContext`.
48+
* Tries to parse DNS if its a response and updates `PassiveDNSData` with parsed values.
49+
*
50+
* @param flowContext Contextual information about the flow to fill new record.
51+
* @param pluginContext Pointer to pre-allocated memory to create record.
52+
* @return Result of the initialization process.
53+
*/
3054
PluginInitResult onInit(const FlowContext& flowContext, void* pluginContext) override;
3155

56+
/**
57+
* @brief Updates plugin data with values from new packet.
58+
*
59+
* Parses DNS responses to fill `PassiveDNSData`.
60+
*
61+
* @param flowContext Contextual information about the flow to be updated.
62+
* @param pluginContext Pointer to `PassiveDNSData`.
63+
* @return Result of the update, may not require new packets if burst storage is full.
64+
*/
3265
PluginUpdateResult onUpdate(const FlowContext& flowContext, void* pluginContext) override;
3366

67+
/**
68+
* @brief Cleans up and destroys `PassiveDNSData`.
69+
* @param pluginContext Pointer to `PassiveDNSData`.
70+
*/
3471
void onDestroy(void* pluginContext) override;
3572

36-
std::string getName() const noexcept override;
37-
73+
/**
74+
* @brief Provides the memory layout of `PassiveDNSData`.
75+
* @return Memory layout description for the plugin data.
76+
*/
3877
PluginDataMemoryLayout getDataMemoryLayout() const noexcept override;
3978

4079
private:

new-process-api/process/passiveDns/src/passivednsData.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Export data of passive DNS plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <boost/static_string.hpp>
@@ -8,6 +17,10 @@
817
namespace ipxp
918
{
1019

20+
/**
21+
* @struct PassiveDNSData
22+
* @brief Struct representing passive DNS export data.
23+
*/
1124
struct PassiveDNSData {
1225
DNSQueryType type;
1326
uint16_t id;

new-process-api/process/passiveDns/src/passivednsFields.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
/**
2+
* @file
3+
* @brief Export fields of bstats plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <cstddef>
413

514
namespace ipxp
615
{
716

17+
/**
18+
* @enum PassiveDNSFields
19+
* @brief Enumerates the fields exported by the PassiveDNS plugin.
20+
*
21+
* These enum values are used to index field handlers for this plugin.
22+
*/
823
enum class PassiveDNSFields : std::size_t {
924
DNS_ID = 0,
1025
DNS_ATYPE,

new-process-api/process/phists/src/packetHistogram.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* @file
3-
* @brief Plugin for parsing basicplus traffic.
4-
* @author Jiri Havranek <havranek@cesnet.cz>
3+
* @brief Plugin for parsing phists traffic.
4+
* @author Karel Hynek <[email protected].cz>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
8-
* Copyright (c) 2025 CESNET
9-
*
10-
* SPDX-License-Identifier: BSD-3-Clause
9+
* Provides a plugin that creates histograms based on packet sizes and inter-arrival times,
10+
* stores them in per-flow plugin data, and exposes fields via FieldManager.
11+
*
12+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1113
*/
1214

1315
#include "packetHistogram.hpp"
@@ -201,11 +203,6 @@ PluginDataMemoryLayout DNSSDPlugin::getDataMemoryLayout() const noexcept
201203
};
202204
}
203205

204-
std::string PacketHistogramPlugin::getName() const noexcept
205-
{
206-
return packetHistogramPluginManifest.name;
207-
}
208-
209206
static const PluginRegistrar<PacketHistogramPlugin, PluginFactory<ProcessPlugin, const std::string&, FieldManager&>>
210207
packetHistogramRegistrar(packetHistogramPluginManifest);
211208

new-process-api/process/phists/src/packetHistogram.hpp

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* @file
3-
* @brief Plugin for parsing basicplus traffic.
4-
* @author Jiri Havranek <havranek@cesnet.cz>
3+
* @brief Plugin for parsing phists traffic.
4+
* @author Karel Hynek <[email protected].cz>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
8-
* Copyright (c) 2025 CESNET
9-
*
10-
* SPDX-License-Identifier: BSD-3-Clause
9+
* Provides a plugin that creates histograms based on packet sizes and inter-arrival times,
10+
* stores them in per-flow plugin data, and exposes fields via FieldManager.
11+
*
12+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1113
*/
1214

1315
#pragma once
@@ -23,26 +25,76 @@
2325

2426
namespace ipxp {
2527

28+
/**
29+
* @class PacketHistogramPlugin
30+
* @brief A plugin for collecting and exporting packet histogram statistics.
31+
*
32+
* Empty packets can optionally be omitted from statistics.
33+
*/
2634
class PacketHistogramPlugin : public ProcessPlugin {
2735
public:
36+
37+
/**
38+
* @brief Constructs the PacketHistogram plugin.
39+
*
40+
* @param parameters Plugin parameters as a string (currently unused).
41+
* @param fieldManager Reference to the FieldManager for field registration.
42+
*/
2843
PacketHistogramPlugin(const std::string& params, FieldManager& manager);
2944

45+
/**
46+
* @brief Initializes plugin data for a new flow.
47+
*
48+
* Constructs `PacketHistogramData` in `pluginContext` and initializes histograms
49+
* with values from the first packet.
50+
*
51+
* @param flowContext Contextual information about the flow to fill new record.
52+
* @param pluginContext Pointer to pre-allocated memory to create record.
53+
* @return Result of the initialization process, always requires new packets.
54+
*/
3055
PluginInitResult onInit(const FlowContext& flowContext, void* pluginContext) override;
3156

57+
/**
58+
* @brief Updates plugin data with values from new packet.
59+
*
60+
* Updates histograms of `PacketHistogramData` with length and inter-arrival time.
61+
*
62+
* @param flowContext Contextual information about the flow to be updated.
63+
* @param pluginContext Pointer to `PacketHistogramData`.
64+
* @return Result of the update, always requires new packets.
65+
*/
3266
PluginUpdateResult onUpdate(const FlowContext& flowContext, void* pluginContext) override;
3367

68+
/**
69+
* @brief Prepare the export data.
70+
*
71+
* Removes record if it seems to be TCP scan.
72+
* Sets all fields as available otherwise.
73+
*
74+
* @param flowRecord The flow record containing aggregated flow data.
75+
* @param pluginContext Pointer to `PacketHistogramData`.
76+
* @return Remove plugin if it is TCP scan.
77+
*/
3478
PluginExportResult onExport(const FlowRecord& flowRecord, void* pluginContext) override;
3579

80+
/**
81+
* @brief Cleans up and destroys `PacketHistogramData`.
82+
* @param pluginContext Pointer to `PacketHistogramData`.
83+
*/
3684
void onDestroy(void* pluginContext) override;
3785

38-
std::string getName() const noexcept override;
39-
86+
/**
87+
* @brief Provides the memory layout of `PacketHistogramData`.
88+
* @return Memory layout description for the plugin data.
89+
*/
4090
PluginDataMemoryLayout getDataMemoryLayout() const noexcept override;
4191

4292
private:
4393
void updateExportData(
4494
const std::size_t realPacketLength, const uint64_t packetTimestamp, const Direction direction, PacketHistogramData& pluginData) noexcept;
4595

96+
bool m_countEmptyPackets{false};
97+
4698
FieldHandlers<PacketHistogramFields> m_fieldHandlers;
4799
};
48100

new-process-api/process/phists/src/packetHistogramData.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Export data of packet histogram plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <array>
@@ -7,14 +16,17 @@
716
namespace ipxp
817
{
918

19+
/**
20+
* @struct PacketHistogramData
21+
* @brief Struct representing flow packet histogram statistics based on lengths and inter-arrival times.
22+
*/
1023
struct PacketHistogramData {
1124
constexpr static std::size_t HISTOGRAM_SIZE = 8;
1225
DirectionalField<std::array<uint32_t, HISTOGRAM_SIZE>> packetLengths;
1326
DirectionalField<std::array<uint32_t, HISTOGRAM_SIZE>> packetTimediffs;
1427

1528
struct {
16-
DirectionalField<std::optional<uint64_t>> m_lastTimestamps;
17-
bool m_countEmptyPackets{false};
29+
DirectionalField<std::optional<uint64_t>> lastTimestamps;
1830
} processingState;
1931

2032
};

new-process-api/process/phists/src/packetHistogramFields.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
/**
2+
* @file
3+
* @brief Export fields of packet histogram plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <cstddef>
413

514
namespace ipxp
615
{
716

17+
/**
18+
* @enum PacketHistogramFields
19+
* @brief Enumerates the fields exported by the PacketHistogram plugin.
20+
*
21+
* These enum values are used to index field handlers for this plugin.
22+
*/
823
enum class PacketHistogramFields : std::size_t {
924
S_PHISTS_SIZES = 0,
1025
S_PHISTS_IPT,

new-process-api/process/pstats/src/packetStats.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* @author Damir Zainullin <[email protected]>
88
* @date 2025
99
*
10-
* Copyright (c) 2025 CESNET
11-
*
12-
* SPDX-License-Identifier: BSD-3-Clause
10+
* Provides a plugin that calculates packet statistics as flags, acknowledgments, and sequences within flows,
11+
* stores it in per-flow plugin data, and exposes that field via FieldManager.
12+
*
13+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1314
*/
1415

1516
#include "packetStats.hpp"

0 commit comments

Comments
 (0)