Skip to content

Commit 1e357a2

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process QUIC plugin
1 parent 4c05772 commit 1e357a2

File tree

7 files changed

+94
-39
lines changed

7 files changed

+94
-39
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ add_subdirectory(dnssd)
1818
add_subdirectory(netbios)
1919
add_subdirectory(passiveDns)
2020
add_subdirectory(smtp)
21+
add_subdirectory(quic)
2122

2223
if (ENABLE_PROCESS_EXPERIMENTAL)
2324
add_subdirectory(sip)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
project(ipfixprobe-process-quic VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-quic plugin")
2+
3+
add_library(ipfixprobe-process-quic MODULE
4+
src/quic.cpp
5+
src/quic.hpp
6+
src/quic_parser.cpp
7+
src/quic_parser.hpp
8+
)
9+
10+
set_target_properties(ipfixprobe-process-quic PROPERTIES
11+
CXX_VISIBILITY_PRESET hidden
12+
VISIBILITY_INLINES_HIDDEN YES
13+
)
14+
15+
target_include_directories(ipfixprobe-process-quic PRIVATE
16+
${CMAKE_SOURCE_DIR}/include/
17+
${CMAKE_SOURCE_DIR}/src/plugins/process/common
18+
)
19+
20+
target_link_libraries(ipfixprobe-process-quic PRIVATE
21+
crypto # TODO
22+
ipfixprobe-process-tls-parser
23+
)
24+
25+
install(
26+
TARGETS ipfixprobe-process-quic
27+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
28+
)

src/plugins/process/quic/README.md

Whitespace-only changes.
Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
1-
/* SPDX-License-Identifier: BSD-3-Clause
2-
* Copyright (C) 2021-2022, CESNET z.s.p.o.
3-
*/
4-
51
/**
6-
* \file quic.cpp
7-
* \brief Plugin for enriching flows for quic data.
8-
* \author Andrej Lukacovic [email protected]
9-
* \author Karel Hynek <[email protected]>
10-
* \author Jonas Mücke <[email protected]>
11-
* \date 2023
2+
* @file
3+
* @brief Plugin for parsing basicplus traffic.
4+
* @author Andrej Lukacovic [email protected]
5+
* @author Karel Hynek <[email protected]>
6+
* @author Jonas Mücke <[email protected]>
7+
* @author Pavel Siska <[email protected]>
8+
*
9+
* Copyright (c) 2025 CESNET
10+
*
11+
* SPDX-License-Identifier: BSD-3-Clause
1212
*/
1313

14+
#include "quic.hpp"
15+
1416
#ifdef WITH_NEMEA
1517
#include <unirec/unirec.h>
1618
#endif
1719

18-
#include "quic.hpp"
20+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
21+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
1922

2023
namespace ipxp {
21-
int RecordExtQUIC::REGISTERED_ID = -1;
24+
int RecordExtQUIC::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
2225

23-
__attribute__((constructor)) static void register_this_plugin()
24-
{
25-
static PluginRecord rec = PluginRecord("quic", []() { return new QUICPlugin(); });
26+
static const PluginManifest quicPluginManifest = {
27+
.name = "quic",
28+
.description = "Quic process plugin for parsing quic traffic.",
29+
.pluginVersion = "1.0.0",
30+
.apiVersion = "1.0.0",
31+
.usage = nullptr,
32+
};
2633

27-
register_plugin(&rec);
28-
RecordExtQUIC::REGISTERED_ID = register_extension();
34+
QUICPlugin::QUICPlugin(const std::string& params)
35+
{
36+
(void) params;
2937
}
3038

31-
QUICPlugin::QUICPlugin() {}
32-
3339
QUICPlugin::~QUICPlugin()
3440
{
3541
close();
3642
}
3743

38-
void QUICPlugin::init(const char* params) {}
44+
void QUICPlugin::init(const char* params)
45+
{
46+
(void) params;
47+
}
3948

4049
void QUICPlugin::close() {}
4150

@@ -251,6 +260,9 @@ void QUICPlugin::set_client_hello_fields(
251260
const Packet& pkt,
252261
bool new_quic_flow)
253262
{
263+
(void) rec;
264+
(void) pkt;
265+
254266
process_quic->quic_get_token_length(quic_data->quic_token_length);
255267
char dcid[MAX_CID_LEN] = {0};
256268
uint8_t dcid_len = 0;
@@ -262,7 +274,7 @@ void QUICPlugin::set_client_hello_fields(
262274
!= QUICParser::QUIC_CONSTANTS::QUIC_UNUSED_VARIABLE_LENGTH_INT)
263275
&& (quic_data->quic_token_length > 0)
264276
&& ((quic_data->retry_scid_length == dcid_len)
265-
|| (!new_quic_flow) && (quic_data->retry_scid_length == dcid_len))
277+
|| ((!new_quic_flow) && (quic_data->retry_scid_length == dcid_len)))
266278
&& ((strncmp(quic_data->retry_scid, dcid, std::min(quic_data->retry_scid_length, dcid_len))
267279
== 0)
268280
|| ((!new_quic_flow)
@@ -433,6 +445,7 @@ int QUICPlugin::process_quic(
433445
pkt,
434446
new_quic_flow);
435447
// fallthrough to set cids
448+
[[fallthrough]];
436449
case QUICParser::PACKET_TYPE::HANDSHAKE:
437450
// -1 sets stores intermediately.
438451
set_cid_fields(quic_data, rec, &process_quic, toServer, new_quic_flow, pkt);
@@ -485,6 +498,7 @@ int QUICPlugin::process_quic(
485498

486499
int QUICPlugin::pre_create(Packet& pkt)
487500
{
501+
(void) pkt;
488502
return 0;
489503
}
490504

@@ -495,6 +509,8 @@ int QUICPlugin::post_create(Flow& rec, const Packet& pkt)
495509

496510
int QUICPlugin::pre_update(Flow& rec, Packet& pkt)
497511
{
512+
(void) rec;
513+
(void) pkt;
498514
return 0;
499515
}
500516

@@ -535,4 +551,7 @@ void QUICPlugin::finish(bool print_stats)
535551
std::cout << " Parsed SNI: " << parsed_initial << std::endl;
536552
}
537553
}
554+
555+
static const PluginRegistrar<QUICPlugin, ProcessPluginFactory> quicRegistrar(quicPluginManifest);
556+
538557
} // namespace ipxp
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
/* SPDX-License-Identifier: BSD-3-Clause
2-
* Copyright (C) 2021-2022, CESNET z.s.p.o.
3-
*/
4-
51
/**
6-
* \file quic.hpp
7-
* \brief Plugin for enriching flows for quic data.
8-
* \author Andrej Lukacovic [email protected]
9-
* \author Karel Hynek <[email protected]>
10-
* \author Jonas Mücke <[email protected]>
11-
* \date 2023
2+
* @file
3+
* @brief Plugin for parsing basicplus traffic.
4+
* @author Andrej Lukacovic [email protected]
5+
* @author Karel Hynek <[email protected]>
6+
* @author Jonas Mücke <[email protected]>
7+
* @author Pavel Siska <[email protected]>
8+
*
9+
* Copyright (c) 2025 CESNET
10+
*
11+
* SPDX-License-Identifier: BSD-3-Clause
1212
*/
1313

14-
#ifndef IPXP_PROCESS_QUIC_HPP
15-
#define IPXP_PROCESS_QUIC_HPP
14+
#pragma once
1615

1716
#ifdef WITH_NEMEA
1817
#include "fields.h"
@@ -364,7 +363,7 @@ struct RecordExtQUIC : public RecordExt {
364363
*/
365364
class QUICPlugin : public ProcessPlugin {
366365
public:
367-
QUICPlugin();
366+
QUICPlugin(const std::string& params);
368367
~QUICPlugin();
369368
void init(const char* params);
370369
void close();
@@ -424,5 +423,3 @@ class QUICPlugin : public ProcessPlugin {
424423
};
425424

426425
} // namespace ipxp
427-
428-
#endif /* IPXP_PROCESS_QUIC_HPP */

src/plugins/process/quic_parser.cpp renamed to src/plugins/process/quic/src/quic_parser.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ bool expand_label(
498498
* "... the actual length precedes the vector's contents in the byte stream ... "
499499
* */
500500

501+
(void) context_hash;
502+
501503
const unsigned int label_prefix_length = (unsigned int) strlen(label_prefix);
502504
const unsigned int label_length = (unsigned int) strlen(label);
503505

@@ -772,6 +774,8 @@ bool QUICParser::quic_encrypt_sample(uint8_t* plaintext)
772774

773775
bool QUICParser::quic_decrypt_initial_header(const uint8_t* payload_pointer, uint64_t offset)
774776
{
777+
(void) offset;
778+
775779
uint8_t plaintext[SAMPLE_LENGTH];
776780
uint8_t mask[5] = {0};
777781
uint8_t full_pkn[4] = {0};
@@ -1116,6 +1120,8 @@ bool QUICParser::quic_parse_initial_header(
11161120
const uint8_t* payload_end,
11171121
uint64_t& offset)
11181122
{
1123+
(void) pkt;
1124+
11191125
token_length = quic_get_variable_length(payload_pointer, offset);
11201126
if (!quic_check_pointer_pos((payload_pointer + offset), payload_end)) {
11211127
return false;
@@ -1211,6 +1217,8 @@ bool QUICParser::quic_parse_header(
12111217
uint8_t* payload_pointer,
12121218
uint8_t* payload_end)
12131219
{
1220+
(void) pkt;
1221+
12141222
if (!quic_check_pointer_pos((payload_pointer + offset), payload_end)) {
12151223
return false;
12161224
}
@@ -1276,6 +1284,9 @@ bool QUICParser::quic_parse_header(
12761284

12771285
bool QUICParser::quic_parse_headers(const Packet& pkt, bool forceInitialParsing)
12781286
{
1287+
(void) pkt;
1288+
(void) forceInitialParsing;
1289+
12791290
uint8_t* pkt_payload_pointer = (uint8_t*) pkt.payload;
12801291
uint8_t* payload_pointer = pkt_payload_pointer;
12811292
uint64_t offset = 0;

src/plugins/process/quic_parser.hpp renamed to src/plugins/process/quic/src/quic_parser.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
* \date 2023
1212
*/
1313

14-
#include "tls_parser.hpp"
15-
1614
#include <ipfixprobe/byte-utils.hpp>
17-
#include <ipfixprobe/process.hpp>
15+
#include <ipfixprobe/processPlugin.hpp>
1816
#include <openssl/evp.h>
1917
#include <openssl/kdf.h>
18+
#include <tlsParser/tls_parser.hpp>
2019

2120
#define HASH_SHA2_256_LENGTH 32
2221
#define TLS13_AEAD_NONCE_LENGTH 12

0 commit comments

Comments
 (0)