Skip to content

Commit 5baf892

Browse files
Pavel SiskaPavel Šiška
authored andcommitted
ipfixprobe - introduce process MPLS plugin
1 parent c487704 commit 5baf892

File tree

6 files changed

+87
-89
lines changed

6 files changed

+87
-89
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ add_subdirectory(tls)
2424
if (ENABLE_PROCESS_EXPERIMENTAL)
2525
add_subdirectory(sip)
2626
add_subdirectory(rtsp)
27+
add_subdirectory(mpls)
2728
endif()

src/plugins/process/mpls.cpp

Lines changed: 0 additions & 62 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-mpls VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-mpls plugin")
2+
3+
add_library(ipfixprobe-process-mpls MODULE
4+
src/mpls.cpp
5+
src/mpls.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-mpls PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-mpls PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
)
16+
17+
install(TARGETS ipfixprobe-process-mpls
18+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
19+
)

src/plugins/process/mpls/README.md

Whitespace-only changes.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @file
3+
* @brief Plugin for parsing mpls traffic.
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 "mpls.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 RecordExtMPLS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
23+
24+
static const PluginManifest mplsPluginManifest = {
25+
.name = "mpls",
26+
.description = "Mpls process plugin for parsing mpls traffic.",
27+
.pluginVersion = "1.0.0",
28+
.apiVersion = "1.0.0",
29+
.usage = nullptr,
30+
};
31+
32+
MPLSPlugin::MPLSPlugin(const std::string& params)
33+
{
34+
(void) params;
35+
}
36+
37+
ProcessPlugin* MPLSPlugin::copy()
38+
{
39+
return new MPLSPlugin(*this);
40+
}
41+
42+
int MPLSPlugin::post_create(Flow& rec, const Packet& pkt)
43+
{
44+
if (pkt.mplsTop == 0) {
45+
return 0;
46+
}
47+
48+
auto ext = new RecordExtMPLS();
49+
ext->mpls = pkt.mplsTop;
50+
51+
rec.add_extension(ext);
52+
return 0;
53+
}
54+
55+
static const PluginRegistrar<MPLSPlugin, ProcessPluginFactory> mplsRegistrar(mplsPluginManifest);
56+
57+
} // namespace ipxp
Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file mpls.hpp
3-
* \brief Plugin for parsing mpls 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 parsing mpls traffic.
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_MPLS_HPP
30-
#define IPXP_PROCESS_MPLS_HPP
13+
#pragma once
3114

3215
#include <cstring>
3316
#include <sstream>
@@ -40,7 +23,7 @@
4023
#include <ipfixprobe/flowifc.hpp>
4124
#include <ipfixprobe/ipfix-elements.hpp>
4225
#include <ipfixprobe/packet.hpp>
43-
#include <ipfixprobe/process.hpp>
26+
#include <ipfixprobe/processPlugin.hpp>
4427

4528
namespace ipxp {
4629

@@ -113,6 +96,7 @@ struct RecordExtMPLS : public RecordExt {
11396
*/
11497
class MPLSPlugin : public ProcessPlugin {
11598
public:
99+
MPLSPlugin(const std::string& params);
116100
OptionsParser* get_parser() const { return new OptionsParser("mpls", "Parse MPLS traffic"); }
117101
std::string get_name() const { return "mpls"; }
118102
RecordExt* get_ext() const { return new RecordExtMPLS(); }
@@ -122,4 +106,3 @@ class MPLSPlugin : public ProcessPlugin {
122106
};
123107

124108
} // namespace ipxp
125-
#endif /* IPXP_PROCESS_MPLS_HPP */

0 commit comments

Comments
 (0)