Skip to content

Commit ddc2994

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process OVPN plugin
1 parent b8111db commit ddc2994

File tree

6 files changed

+88
-99
lines changed

6 files changed

+88
-99
lines changed

include/ipfixprobe/rtp.hpp

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

src/plugins/process/CMakeLists.txt

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

src/plugins/process/ovpn/README.md

Whitespace-only changes.
Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,73 @@
11
/**
2-
* \file ovpn.cpp
3-
* \brief Plugin for parsing ovpn traffic.
4-
* \author Karel Hynek <[email protected]>
5-
* \author Martin Ctrnacty <[email protected]>
6-
* \date 2020
7-
*/
8-
/*
9-
* Copyright (C) 2020 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Plugin for parsing ovpn traffic.
4+
* @author Karel Hynek <[email protected]>
5+
* @author Martin Ctrnacty <[email protected]>
6+
* @author Pavel Siska <[email protected]>
7+
* @date 2025
268
*
9+
* Copyright (c) 2025 CESNET
2710
*
11+
* SPDX-License-Identifier: BSD-3-Clause
2812
*/
2913

3014
#include "ovpn.hpp"
3115

32-
#include "ipfixprobe/rtp.hpp"
33-
16+
#include <cstdint>
3417
#include <cstring>
3518
#include <iostream>
3619

37-
namespace ipxp {
20+
#include <endian.h>
21+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
22+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3823

39-
int RecordExtOVPN::REGISTERED_ID = -1;
24+
namespace ipxp {
4025

41-
__attribute__((constructor)) static void register_this_plugin()
26+
struct __attribute__((packed)) rtp_header {
27+
union {
28+
struct {
29+
#if defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
30+
uint16_t csrc_count : 4;
31+
uint16_t extension : 1;
32+
uint16_t padding : 1;
33+
uint16_t version : 2;
34+
// next byte
35+
uint16_t payload_type : 7;
36+
uint16_t marker : 1;
37+
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
38+
uint16_t version : 2;
39+
uint16_t padding : 1;
40+
uint16_t extension : 1;
41+
uint16_t csrc_count : 4;
42+
// next byte
43+
uint16_t marker : 1;
44+
uint16_t payload_type : 7;
45+
46+
#else // if defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
47+
#error "Please fix <endian.h>"
48+
#endif // if defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
49+
};
50+
uint16_t flags;
51+
};
52+
uint16_t sequence_number;
53+
uint32_t timestamp;
54+
uint32_t ssrc;
55+
};
56+
57+
int RecordExtOVPN::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
58+
59+
static const PluginManifest ovpnPluginManifest = {
60+
.name = "ovpn",
61+
.description = "Ovpn process plugin for parsing ovpn traffic.",
62+
.pluginVersion = "1.0.0",
63+
.apiVersion = "1.0.0",
64+
};
65+
66+
OVPNPlugin::OVPNPlugin(const std::string& params)
4267
{
43-
static PluginRecord rec = PluginRecord("ovpn", []() { return new OVPNPlugin(); });
44-
register_plugin(&rec);
45-
RecordExtOVPN::REGISTERED_ID = register_extension();
68+
(void) params;
4669
}
4770

48-
OVPNPlugin::OVPNPlugin() {}
49-
5071
OVPNPlugin::~OVPNPlugin()
5172
{
5273
close();
@@ -274,4 +295,6 @@ bool OVPNPlugin::check_valid_rtp_header(const Packet& pkt)
274295
return true;
275296
}
276297

298+
static const PluginRegistrar<OVPNPlugin, ProcessPluginFactory> ovpnRegistrar(ovpnPluginManifest);
299+
277300
} // namespace ipxp
Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
/**
2-
* \file ovpn.hpp
3-
* \brief Plugin for parsing ovpn traffic.
4-
* \author Karel Hynek <[email protected]>
5-
* \author Martin Ctrnacty <[email protected]>
6-
* \date 2020
7-
*/
8-
/*
9-
* Copyright (C) 2020 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Plugin for parsing ovpn traffic.
4+
* @author Karel Hynek <[email protected]>
5+
* @author Martin Ctrnacty <[email protected]>
6+
* @author Pavel Siska <[email protected]>
7+
* @date 2025
268
*
9+
* Copyright (c) 2025 CESNET
2710
*
11+
* SPDX-License-Identifier: BSD-3-Clause
2812
*/
2913

30-
#ifndef IPXP_PROCESS_OVPN_HPP
31-
#define IPXP_PROCESS_OVPN_HPP
14+
#pragma once
3215

3316
#include <sstream>
3417
#include <string>
@@ -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

@@ -109,7 +92,7 @@ struct RecordExtOVPN : RecordExt {
10992
*/
11093
class OVPNPlugin : public ProcessPlugin {
11194
public:
112-
OVPNPlugin();
95+
OVPNPlugin(const std::string& params);
11396
~OVPNPlugin();
11497
void init(const char* params);
11598
void close();
@@ -171,4 +154,3 @@ class OVPNPlugin : public ProcessPlugin {
171154
};
172155

173156
} // namespace ipxp
174-
#endif /* IPXP_PROCESS_OVPN_HPP */

0 commit comments

Comments
 (0)