Skip to content

Commit 4a6a510

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process VLAN plugin
1 parent 191e087 commit 4a6a510

File tree

6 files changed

+82
-84
lines changed

6 files changed

+82
-84
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ add_subdirectory(icmp)
44
add_subdirectory(mpls)
55
add_subdirectory(ntp)
66
add_subdirectory(nettisa)
7+
add_subdirectory(vlan)

src/plugins/process/vlan.cpp

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

src/plugins/process/vlan/README.md

Whitespace-only changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* @file
3+
* @brief Plugin for parsing basicplus traffic.
4+
* @author Jakub Antonín Štigler xstigl00@[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 "vlan.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 RecordExtVLAN::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
23+
24+
static const PluginManifest vlanPluginManifest = {
25+
.name = "vlan",
26+
.description = "Vlan process plugin for parsing vlan traffic.",
27+
.pluginVersion = "1.0.0",
28+
.apiVersion = "1.0.0",
29+
.usage = nullptr,
30+
};
31+
32+
VLANPlugin::VLANPlugin(const std::string& params)
33+
{
34+
(void) params;
35+
}
36+
37+
ProcessPlugin* VLANPlugin::copy()
38+
{
39+
return new VLANPlugin(*this);
40+
}
41+
42+
int VLANPlugin::post_create(Flow& rec, const Packet& pkt)
43+
{
44+
auto ext = new RecordExtVLAN();
45+
ext->vlan_id = pkt.vlan_id;
46+
rec.add_extension(ext);
47+
return 0;
48+
}
49+
50+
static const PluginRegistrar<VLANPlugin, ProcessPluginFactory> vlanRegistrar(vlanPluginManifest);
51+
52+
} // namespace ipxp
Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file vlan.hpp
3-
* \brief Plugin for parsing vlan traffic.
4-
* \author Jakub Antonín Štigler xstigl00@[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 parsing basicplus traffic.
4+
* @author Jakub Antonín Štigler xstigl00@[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_VLAN_HPP
30-
#define IPXP_PROCESS_VLAN_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

@@ -105,6 +88,7 @@ struct RecordExtVLAN : public RecordExt {
10588
*/
10689
class VLANPlugin : public ProcessPlugin {
10790
public:
91+
VLANPlugin(const std::string& params);
10892
OptionsParser* get_parser() const { return new OptionsParser("vlan", "Parse VLAN traffic"); }
10993
std::string get_name() const { return "vlan"; }
11094
RecordExt* get_ext() const { return new RecordExtVLAN(); }
@@ -114,4 +98,3 @@ class VLANPlugin : public ProcessPlugin {
11498
};
11599

116100
} // namespace ipxp
117-
#endif /* IPXP_PROCESS_VLAN_HPP */

0 commit comments

Comments
 (0)