|
1 | 1 | /** |
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 |
26 | 8 | * |
| 9 | + * Copyright (c) 2025 CESNET |
27 | 10 | * |
| 11 | + * SPDX-License-Identifier: BSD-3-Clause |
28 | 12 | */ |
29 | 13 |
|
30 | 14 | #include "ovpn.hpp" |
31 | 15 |
|
32 | | -#include "ipfixprobe/rtp.hpp" |
33 | | - |
| 16 | +#include <cstdint> |
34 | 17 | #include <cstring> |
35 | 18 | #include <iostream> |
36 | 19 |
|
37 | | -namespace ipxp { |
| 20 | +#include <endian.h> |
| 21 | +#include <ipfixprobe/pluginFactory/pluginManifest.hpp> |
| 22 | +#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp> |
38 | 23 |
|
39 | | -int RecordExtOVPN::REGISTERED_ID = -1; |
| 24 | +namespace ipxp { |
40 | 25 |
|
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) |
42 | 67 | { |
43 | | - static PluginRecord rec = PluginRecord("ovpn", []() { return new OVPNPlugin(); }); |
44 | | - register_plugin(&rec); |
45 | | - RecordExtOVPN::REGISTERED_ID = register_extension(); |
| 68 | + (void) params; |
46 | 69 | } |
47 | 70 |
|
48 | | -OVPNPlugin::OVPNPlugin() {} |
49 | | - |
50 | 71 | OVPNPlugin::~OVPNPlugin() |
51 | 72 | { |
52 | 73 | close(); |
@@ -274,4 +295,6 @@ bool OVPNPlugin::check_valid_rtp_header(const Packet& pkt) |
274 | 295 | return true; |
275 | 296 | } |
276 | 297 |
|
| 298 | +static const PluginRegistrar<OVPNPlugin, ProcessPluginFactory> ovpnRegistrar(ovpnPluginManifest); |
| 299 | + |
277 | 300 | } // namespace ipxp |
0 commit comments