Skip to content

Commit 3cb500c

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process FLOW HASH plugin
1 parent 4a6a510 commit 3cb500c

File tree

6 files changed

+91
-96
lines changed

6 files changed

+91
-96
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ add_subdirectory(mpls)
55
add_subdirectory(ntp)
66
add_subdirectory(nettisa)
77
add_subdirectory(vlan)
8+
add_subdirectory(flowHash)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project(ipfixprobe-process-flowhash VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-flowhash plugin")
2+
3+
add_library(ipfixprobe-process-flowhash MODULE
4+
src/flow_hash.cpp
5+
src/flow_hash.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-flowhash PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-flowhash PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
)
16+
17+
install(TARGETS ipfixprobe-process-flowhash
18+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
19+
)

src/plugins/process/flowHash/README.md

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @file
3+
* @brief Plugin for processing flow_hash value.
4+
* @author Jakub Antonín Štigler [email protected]
5+
* @author Pavel Siska <[email protected]>
6+
* @date 2025
7+
*
8+
* Copyright (c) 2025 CESNET
9+
*
10+
* SPDX-License-Identifier: BSD-3-Clause
11+
*/
12+
13+
#include "flow_hash.hpp"
14+
15+
#include <iostream>
16+
17+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
18+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
19+
20+
namespace ipxp {
21+
22+
int RecordExtFLOW_HASH::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
23+
24+
static const PluginManifest flowhashPluginManifest = {
25+
.name = "flow_hash",
26+
.description = "flow_hash process plugin for parsing flow_hash value.",
27+
.pluginVersion = "1.0.0",
28+
.apiVersion = "1.0.0",
29+
};
30+
31+
FLOW_HASHPlugin::FLOW_HASHPlugin(const std::string& params)
32+
{
33+
(void) params;
34+
}
35+
36+
FLOW_HASHPlugin::~FLOW_HASHPlugin() {}
37+
38+
void FLOW_HASHPlugin::init(const char* params) {}
39+
40+
void FLOW_HASHPlugin::close() {}
41+
42+
ProcessPlugin* FLOW_HASHPlugin::copy()
43+
{
44+
return new FLOW_HASHPlugin(*this);
45+
}
46+
47+
int FLOW_HASHPlugin::post_create(Flow& rec, const Packet& pkt)
48+
{
49+
auto ext = new RecordExtFLOW_HASH();
50+
51+
ext->flow_hash = rec.flow_hash;
52+
53+
rec.add_extension(ext);
54+
55+
return 0;
56+
}
57+
58+
static const PluginRegistrar<FLOW_HASHPlugin, ProcessPluginFactory>
59+
flowhashRegistrar(flowhashPluginManifest);
60+
61+
} // namespace ipxp

src/plugins/process/flow_hash.hpp renamed to src/plugins/process/flowHash/src/flow_hash.hpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file flow_hash.hpp
3-
* \brief Plugin for parsing flow_hash traffic.
4-
* \author Jakub Antonín Štigler [email protected]
5-
* \date 2023
6-
*/
7-
/*
8-
* Copyright (C) 2023 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 processing flow_hash value.
4+
* @author Jakub Antonín Štigler [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_FLOW_HASH_HPP
30-
#define IPXP_PROCESS_FLOW_HASH_HPP
13+
#pragma once
3114

3215
#include <cstring>
3316

@@ -42,7 +25,7 @@
4225
#include <ipfixprobe/flowifc.hpp>
4326
#include <ipfixprobe/ipfix-elements.hpp>
4427
#include <ipfixprobe/packet.hpp>
45-
#include <ipfixprobe/process.hpp>
28+
#include <ipfixprobe/processPlugin.hpp>
4629

4730
namespace ipxp {
4831

@@ -108,7 +91,7 @@ struct RecordExtFLOW_HASH : public RecordExt {
10891
*/
10992
class FLOW_HASHPlugin : public ProcessPlugin {
11093
public:
111-
FLOW_HASHPlugin();
94+
FLOW_HASHPlugin(const std::string& params);
11295
~FLOW_HASHPlugin();
11396
void init(const char* params);
11497
void close();
@@ -124,4 +107,3 @@ class FLOW_HASHPlugin : public ProcessPlugin {
124107
};
125108

126109
} // namespace ipxp
127-
#endif /* IPXP_PROCESS_FLOW_HASH_HPP */

src/plugins/process/flow_hash.cpp

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)