Skip to content

Commit f4b56ab

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process DNSSD plugin
1 parent 984db05 commit f4b56ab

File tree

5 files changed

+60
-66
lines changed

5 files changed

+60
-66
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ add_subdirectory(ssdp)
1717
add_subdirectory(ssaDetector)
1818
add_subdirectory(mqtt)
1919
add_subdirectory(dns)
20+
add_subdirectory(dnssd)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
project(ipfixprobe-process-dnssd VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-dnssd plugin")
2+
3+
add_library(ipfixprobe-process-dnssd MODULE
4+
src/dnssd.cpp
5+
src/dnssd.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-dnssd PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-dnssd PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
${CMAKE_SOURCE_DIR}/src/plugins/process/common
16+
)
17+
18+
install(TARGETS ipfixprobe-process-dnssd
19+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
20+
)

src/plugins/process/dnssd/README.md

Whitespace-only changes.
Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,46 @@
11
/**
2-
* \file dnssd.cpp
3-
* \brief Plugin for parsing DNS-SD traffic.
4-
* \author Ondrej Sedlacek [email protected]
5-
* \author Jiri Havranek <[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 dnssd traffic.
4+
* @author Ondrej Sedlacek [email protected]
5+
* @author Pavel Siska <[email protected]>
6+
* @date 2025
267
*
8+
* Copyright (c) 2025 CESNET
279
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2811
*/
2912

13+
#include "dnssd.hpp"
14+
3015
#include <iostream>
3116
#include <sstream>
3217

3318
#include <arpa/inet.h>
19+
#include <errno.h>
20+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
21+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3422
#include <stdio.h>
3523
#include <stdlib.h>
3624

3725
#ifdef WITH_NEMEA
3826
#include <unirec/unirec.h>
3927
#endif
4028

41-
#include "dnssd.hpp"
42-
43-
#include <errno.h>
44-
4529
namespace ipxp {
4630

47-
int RecordExtDNSSD::REGISTERED_ID = -1;
31+
int RecordExtDNSSD::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4832

49-
__attribute__((constructor)) static void register_this_plugin()
50-
{
51-
static PluginRecord rec = PluginRecord("dnssd", []() { return new DNSSDPlugin(); });
52-
register_plugin(&rec);
53-
RecordExtDNSSD::REGISTERED_ID = register_extension();
54-
}
33+
static const PluginManifest dnssdPluginManifest = {
34+
.name = "dnssd",
35+
.description = "Dnssd process plugin for parsing dnssd traffic.",
36+
.pluginVersion = "1.0.0",
37+
.apiVersion = "1.0.0",
38+
.usage =
39+
[]() {
40+
DNSSDOptParser parser;
41+
parser.usage(std::cout);
42+
},
43+
};
5544

5645
// #define DEBUG_DNSSD
5746

@@ -81,14 +70,15 @@ __attribute__((constructor)) static void register_this_plugin()
8170
*/
8271
#define GET_OFFSET(half1, half2) ((((uint8_t) (half1) & 0x3F) << 8) | (uint8_t) (half2))
8372

84-
DNSSDPlugin::DNSSDPlugin()
73+
DNSSDPlugin::DNSSDPlugin(const std::string& params)
8574
: txt_all_records(false)
8675
, queries(0)
8776
, responses(0)
8877
, total(0)
8978
, data_begin(nullptr)
9079
, data_len(0)
9180
{
81+
init(params.c_str());
9282
}
9383

9484
DNSSDPlugin::~DNSSDPlugin()
@@ -734,4 +724,6 @@ int DNSSDPlugin::add_ext_dnssd(const char* data, unsigned int payload_len, bool
734724
return 0;
735725
}
736726

727+
static const PluginRegistrar<DNSSDPlugin, ProcessPluginFactory> dnssdRegistrar(dnssdPluginManifest);
728+
737729
} // namespace ipxp
Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file dnssd.hpp
3-
* \brief Plugin for parsing dnssd traffic.
4-
* \author Ondrej Sedlacek [email protected]
5-
* \date 2020
6-
*/
7-
/*
8-
* Copyright (C) 2020 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 dnssd traffic.
4+
* @author Ondrej Sedlacek [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_DNSSD_HPP
30-
#define IPXP_PROCESS_DNSSD_HPP
13+
#pragma once
3114

3215
#include <algorithm>
3316
#include <cstring>
@@ -40,13 +23,12 @@
4023
#include "fields.h"
4124
#endif
4225

43-
#include "dns-utils.hpp"
44-
26+
#include <dns-utils.hpp>
4527
#include <ipfixprobe/flowifc.hpp>
4628
#include <ipfixprobe/ipfix-elements.hpp>
4729
#include <ipfixprobe/options.hpp>
4830
#include <ipfixprobe/packet.hpp>
49-
#include <ipfixprobe/process.hpp>
31+
#include <ipfixprobe/processPlugin.hpp>
5032

5133
namespace ipxp {
5234

@@ -260,7 +242,7 @@ struct RecordExtDNSSD : public RecordExt {
260242
*/
261243
class DNSSDPlugin : public ProcessPlugin {
262244
public:
263-
DNSSDPlugin();
245+
DNSSDPlugin(const std::string& params);
264246
~DNSSDPlugin();
265247
void init(const char* params);
266248
void close();
@@ -308,4 +290,3 @@ class DNSSDPlugin : public ProcessPlugin {
308290
};
309291

310292
} // namespace ipxp
311-
#endif /* IPXP_PROCESS_DNSSD_HPP */

0 commit comments

Comments
 (0)