Skip to content

Commit 8113f18

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process NETBIOS plugin
1 parent f4b56ab commit 8113f18

File tree

5 files changed

+57
-64
lines changed

5 files changed

+57
-64
lines changed

src/plugins/process/CMakeLists.txt

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

src/plugins/process/netbios/README.md

Whitespace-only changes.

src/plugins/process/netbios.cpp renamed to src/plugins/process/netbios/src/netbios.cpp

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
11
/**
2-
* \file netbios.cpp
3-
* \brief Plugin for parsing netbios 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 netbios 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-
#include <iostream>
13+
#include "netbios.hpp"
3014

3115
#ifdef WITH_NEMEA
3216
#include <unirec/unirec.h>
3317
#endif
3418

35-
#include "netbios.hpp"
19+
#include <iostream>
3620

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

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

41-
__attribute__((constructor)) static void register_this_plugin()
42-
{
43-
static PluginRecord rec = PluginRecord("netbios", []() { return new NETBIOSPlugin(); });
44-
register_plugin(&rec);
45-
RecordExtNETBIOS::REGISTERED_ID = register_extension();
46-
}
26+
int RecordExtNETBIOS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4727

48-
NETBIOSPlugin::NETBIOSPlugin()
28+
static const PluginManifest netbiosPluginManifest = {
29+
.name = "netbios",
30+
.description = "Netbios process plugin for parsing netbios traffic.",
31+
.pluginVersion = "1.0.0",
32+
.apiVersion = "1.0.0",
33+
.usage = nullptr,
34+
};
35+
NETBIOSPlugin::NETBIOSPlugin(const std::string& params)
4936
: total_netbios_packets(0)
5037
{
38+
init(params.c_str());
5139
}
5240

5341
NETBIOSPlugin::~NETBIOSPlugin()
@@ -154,4 +142,7 @@ void NETBIOSPlugin::finish(bool print_stats)
154142
}
155143
}
156144

145+
static const PluginRegistrar<NETBIOSPlugin, ProcessPluginFactory>
146+
netbiosRegistrar(netbiosPluginManifest);
147+
157148
} // namespace ipxp

src/plugins/process/netbios.hpp renamed to src/plugins/process/netbios/src/netbios.hpp

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file netbios.h
3-
* \brief Plugin for parsing netbios 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 netbios 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_NETBIOS_HPP
30-
#define IPXP_PROCESS_NETBIOS_HPP
13+
#pragma once
3114

3215
#include <cstring>
3316
#include <sstream>
@@ -37,12 +20,11 @@
3720
#include "fields.h"
3821
#endif
3922

40-
#include "dns-utils.hpp"
41-
23+
#include <dns-utils.hpp>
4224
#include <ipfixprobe/flowifc.hpp>
4325
#include <ipfixprobe/ipfix-elements.hpp>
4426
#include <ipfixprobe/packet.hpp>
45-
#include <ipfixprobe/process.hpp>
27+
#include <ipfixprobe/processPlugin.hpp>
4628

4729
namespace ipxp {
4830

@@ -110,7 +92,7 @@ struct RecordExtNETBIOS : public RecordExt {
11092
*/
11193
class NETBIOSPlugin : public ProcessPlugin {
11294
public:
113-
NETBIOSPlugin();
95+
NETBIOSPlugin(const std::string& params);
11496
~NETBIOSPlugin();
11597
void init(const char* params);
11698
void close();
@@ -138,4 +120,3 @@ class NETBIOSPlugin : public ProcessPlugin {
138120
};
139121

140122
} // namespace ipxp
141-
#endif /* IPXP_PROCESS_NETBIOS_HPP */

0 commit comments

Comments
 (0)