Skip to content

Commit d3e4ce8

Browse files
author
Damir Zainullin
committed
++
1 parent bb30bc1 commit d3e4ce8

27 files changed

+443
-23
lines changed

process-plugin-api/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
CXX := g++
22
CXXFLAGS := -std=c++20 -Wall -Wextra -pedantic -Wunused -Wconversion -Wsign-conversion -g -fsanitize=address
33
TARGET := ipx
4-
SRC := main.cpp
4+
SRC := main.cpp $(wildcard process/*/src/*.cpp)
55

66
.PHONY: all clean
77

88
all: $(TARGET)
99

1010
$(TARGET): $(SRC)
11-
$(CXX) $(CXXFLAGS) $^ -o $@
11+
$(CXX) $(CXXFLAGS) $^ -I. -I../include/ipfixprobe/pluginFactory -o $@
1212

1313
clean:
1414
rm -f $(TARGET)

process-plugin-api/biflowPair.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <string>
44
#include <utility>
55

6+
namespace ipxp {
7+
68
/**
79
* @brief Represents a pair of field names that are semantically linked in a bidirectional flow.
810
*
@@ -46,3 +48,5 @@ struct BiflowPair {
4648
*/
4749
bool operator!=(const BiflowPair& other) const { return !(*this == other); }
4850
};
51+
52+
} // namespace ipxp
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
5+
enum Direction : std::size_t { Forward = 0, Reverse = 1 };
6+
7+
template<typename T>
8+
struct DirectionalField {
9+
T values[2]{};
10+
11+
T& operator[](Direction d) { return values[static_cast<std::size_t>(d)]; }
12+
const T& operator[](Direction d) const { return values[static_cast<std::size_t>(d)]; }
13+
};

process-plugin-api/dummyProcessPlugin.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,8 @@
55
#include "fieldSchema.hpp"
66
#include "processPlugin.hpp"
77
#include "flowRecord.hpp"
8+
#include "directionalField.hpp"
89

9-
enum Direction : std::size_t { Forward = 0, Reverse = 1 };
10-
11-
template<typename T>
12-
struct DirectionalField {
13-
T values[2];
14-
15-
T& operator[](Direction d) { return values[static_cast<std::size_t>(d)]; }
16-
const T& operator[](Direction d) const { return values[static_cast<std::size_t>(d)]; }
17-
};
1810

1911
/*
2012
struct DummyExport {
@@ -34,6 +26,8 @@ struct DummyExport {
3426
};
3527
*/
3628

29+
namespace ipxp {
30+
3731
struct DummyExport {
3832
DirectionalField<uint8_t> ipTtl;
3933
DirectionalField<uint8_t> ipFlag;
@@ -170,10 +164,11 @@ class DummyPlugin
170164
return FlowAction::RequestNoData;
171165
}
172166

173-
FlowAction onFlowUpdate(FlowRecord& flowRecord, const Packet& packet) override
167+
FlowAction onFlowUpdate(FlowRecord& flowRecord, const Packet& packet, const PacketOfFlowData& data) override
174168
{
175169
(void) flowRecord;
176170
(void) packet;
171+
(void) data;
177172

178173
m_exportData.packets[Direction::Forward] = {1, 2, 3, 4, 5, 6};
179174
m_fieldHandlers[DummyFields::PACKETS].setAsAvailable(flowRecord);
@@ -200,3 +195,5 @@ class DummyPlugin
200195
private:
201196
DummyExport m_exportData;
202197
};
198+
199+
} // namespace ipxp

process-plugin-api/fieldAccessor.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <string>
77
#include <variant>
88

9+
namespace ipxp {
10+
911
/**
1012
* @brief Accessor for reading a scalar field of type T from a binary structure using offset.
1113
*
@@ -95,3 +97,5 @@ using VectorValueGetter = std::variant<
9597
* Used in output fields to provide unified access to underlying data.
9698
*/
9799
using GenericValueGetter = std::variant<ScalarValueGetter, VectorValueGetter>;
100+
101+
} // namespace ipxp

process-plugin-api/fieldDescription.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <string>
88
#include <variant>
99

10+
namespace ipxp {
11+
1012
/**
1113
* @brief Describes a field in a flow record schema.
1214
*
@@ -27,3 +29,5 @@ struct FieldDescription {
2729
/// Value getter that allows access to the field's value in a record.
2830
GenericValueGetter getter;
2931
};
32+
33+
} // namespace ipxp

process-plugin-api/fieldDirection.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include <cstdint>
44
#include <stdexcept>
55

6-
/**
6+
namespace ipxp {
7+
8+
/**
79
* @brief Enum representing the direction of a flow field.
810
*
911
* FieldDirection enum is used to represent the possible directions for a field.
@@ -87,3 +89,5 @@ inline const char* toString(FieldDirection dir)
8789
throw std::invalid_argument("Unknown FieldDirection value.");
8890
}
8991
}
92+
93+
} // namespace ipxp

process-plugin-api/fieldHandler.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <limits>
77
#include <stdexcept>
88

9+
namespace ipxp {
10+
911
/**
1012
* @brief Represents a handle to a single field within a FlowRecord.
1113
*
@@ -90,3 +92,5 @@ class FieldHandler {
9092
static constexpr std::size_t s_invalidIndex = std::numeric_limits<std::size_t>::max();
9193
std::size_t m_bitIndex;
9294
};
95+
96+
} // namespace ipxp

process-plugin-api/fieldManager.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <string_view>
2121
#include <vector>
2222

23+
namespace ipxp {
24+
2325
/**
2426
* @brief Manages field handlers and schema registrations.
2527
*
@@ -54,3 +56,5 @@ class FieldManager {
5456
std::vector<FieldSchema> m_schemas;
5557
std::atomic<std::size_t> m_fieldIndex = 0;
5658
};
59+
60+
} // namespace ipxp

process-plugin-api/fieldSchema.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <string_view>
1313
#include <vector>
1414

15+
namespace ipxp {
16+
1517
/**
1618
* @brief Represents the schema of a flow record, including field definitions and biflow mappings.
1719
*
@@ -144,3 +146,5 @@ class FieldSchema {
144146
std::vector<FieldDescription> m_fields;
145147
std::vector<BiflowPair> m_biflowPairs;
146148
};
149+
150+
} // namespace ipxp

0 commit comments

Comments
 (0)