Skip to content

Commit 8b031f8

Browse files
Zainullin DamirZainullin Damir
authored andcommitted
++ misc
1 parent 5b86270 commit 8b031f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4853
-417
lines changed

include/ipfixprobe/flowifc.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
#include <sys/time.h>
4040

4141
#ifdef WITH_NEMEA
42-
#include <unirec/unirec.h>
42+
//#include <unirec/unirec.h>
4343
#else
44-
#define UR_FIELDS(...)
44+
//#define UR_FIELDS(...)
4545
#endif
4646

4747
#include "ipaddr.hpp"
4848

4949
#include <string>
5050

51-
#include <arpa/inet.h>
51+
//#include <arpa/inet.h>
5252

5353
namespace ipxp {
5454

@@ -80,17 +80,17 @@ struct RecordExt {
8080
* \param [in] tmplt Unirec template.
8181
* \param [out] record Pointer to the unirec record.
8282
*/
83-
virtual void fill_unirec(ur_template_t* tmplt, void* record)
83+
/*virtual void fill_unirec(ur_template_t* tmplt, void* record)
8484
{
8585
(void) tmplt;
8686
(void) record;
87-
}
87+
}*/
8888

8989
/**
9090
* \brief Get unirec template string.
9191
* \return Unirec template string.
9292
*/
93-
virtual const char* get_unirec_tmplt() const { return ""; }
93+
//virtual const char* get_unirec_tmplt() const { return ""; }
9494
#endif
9595

9696
/**
@@ -233,11 +233,11 @@ struct Record {
233233
virtual ~Record() { remove_extensions(); }
234234
};
235235

236-
#define FLOW_END_INACTIVE 0x01
237-
#define FLOW_END_ACTIVE 0x02
238-
#define FLOW_END_EOF 0x03
239-
#define FLOW_END_FORCED 0x04
240-
#define FLOW_END_NO_RES 0x05
236+
//#define FLOW_END_INACTIVE 0x01
237+
//#define FLOW_END_ACTIVE 0x02
238+
//#define FLOW_END_EOF 0x03
239+
//#define FLOW_END_FORCED 0x04
240+
//#define FLOW_END_NO_RES 0x05
241241

242242
/**
243243
* \brief Flow record struct constaining basic flow record data and extension headers.

include/ipfixprobe/ipProtocol.hpp

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+
namespace ipxp
6+
{
7+
8+
enum IPProtocol : uint8_t {
9+
TCP = 6,
10+
UDP = 17,
11+
};
12+
13+
} // namespace ipxp
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#pragma once
2+
3+
#include "../api.hpp"
4+
#include "fieldManager.hpp"
5+
#include "flowRecord.hpp"
6+
#include "processPluginEntry.hpp"
7+
8+
#include <cstddef>
9+
#include <cstdint>
10+
#include <string>
11+
#include <vector>
12+
13+
// #include "../pluginFactory/pluginFactory.hpp"
14+
15+
namespace ipxp {
16+
17+
using namespace process;
18+
19+
class IPXP_API OutputPlugin {
20+
public:
21+
OutputPlugin(const FieldManager& fieldManager, const std::vector<ProcessPluginEntry>& plugins)
22+
: m_fieldManager(fieldManager)
23+
, m_plugins(plugins)
24+
{
25+
}
26+
27+
virtual void processRecord(FlowRecordUniquePtr& flowRecord) = 0;
28+
29+
std::size_t getDroppedCount() const noexcept { return m_dropped; }
30+
31+
virtual ~OutputPlugin() = default;
32+
33+
constexpr static std::size_t DEFAULT_EXPORTER_ID = 1;
34+
35+
protected:
36+
const FieldManager& m_fieldManager;
37+
const std::vector<ProcessPluginEntry>& m_plugins;
38+
std::size_t m_dropped = 0;
39+
std::size_t m_seen = 0;
40+
};
41+
42+
template<typename Base, typename... Args>
43+
class IPXP_API PluginFactory;
44+
45+
/**
46+
* @brief Type alias for the OutputPlugin factory.
47+
*
48+
* Provides a factory for creating OutputPlugin instances using a string-based constructor.
49+
*/
50+
using OutputPluginFactory = PluginFactory<
51+
OutputPlugin,
52+
const std::string&,
53+
const FieldManager&,
54+
const std::vector<ProcessPluginEntry>&>;
55+
56+
} // namespace ipxp

include/ipfixprobe/parser-stats.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <ipfixprobe/packet.hpp>
3333
#include <telemetry.hpp>
3434

35+
#include "ipProtocol.hpp"
36+
3537
namespace ipxp {
3638

3739
static constexpr std::size_t MAX_VLAN_ID = 4096;
@@ -132,9 +134,9 @@ struct VlanStats {
132134
ipv6_bytes += pkt.packet_len;
133135
}
134136

135-
if (pkt.ip_proto == IPPROTO_TCP) {
137+
if (pkt.ip_proto == IPProtocol::TCP) {
136138
tcp_packets++;
137-
} else if (pkt.ip_proto == IPPROTO_UDP) {
139+
} else if (pkt.ip_proto == IPProtocol::UDP) {
138140
udp_packets++;
139141
}
140142

include/ipfixprobe/pluginFactory/pluginFactory.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <string_view>
2222
#include <type_traits>
2323

24+
#include "../api.hpp"
25+
2426
namespace ipxp {
2527

2628
/**
@@ -62,7 +64,7 @@ class PluginFactory {
6264
void registerPlugin(const PluginManifest& manifest)
6365
{
6466
static_assert(std::is_base_of<Base, Derived>::value, "Derived must be a subclass of Base");
65-
67+
6668
m_registeredPlugins[manifest] = createGenerators<Base, Derived, Args...>();
6769
}
6870

0 commit comments

Comments
 (0)