Skip to content

Commit ed73093

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process NTP plugin
1 parent e2c6956 commit ed73093

File tree

5 files changed

+57
-61
lines changed

5 files changed

+57
-61
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ if (ENABLE_PROCESS_EXPERIMENTAL)
2626
add_subdirectory(sip)
2727
add_subdirectory(rtsp)
2828
add_subdirectory(mpls)
29+
add_subdirectory(ntp)
2930
endif()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
project(ipfixprobe-process-ntp VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-ntp plugin")
2+
3+
add_library(ipfixprobe-process-ntp MODULE
4+
src/ntp.cpp
5+
src/ntp.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-ntp PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-ntp PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
)
16+
17+
install(
18+
TARGETS ipfixprobe-process-ntp
19+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
20+
)

src/plugins/process/ntp/README.md

Whitespace-only changes.
Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
11
/**
2-
* \file ntp.cpp
3-
* \author Alejandro Robledo <[email protected]>
4-
* \date 2016
5-
*/
6-
/*
7-
* Copyright (C) 2016 CESNET
8-
*
9-
* LICENSE TERMS
10-
*
11-
* Redistribution and use in source and binary forms, with or without
12-
* modification, are permitted provided that the following conditions
13-
* are met:
14-
* 1. Redistributions of source code must retain the above copyright
15-
* notice, this list of conditions and the following disclaimer.
16-
* 2. Redistributions in binary form must reproduce the above copyright
17-
* notice, this list of conditions and the following disclaimer in
18-
* the documentation and/or other materials provided with the
19-
* distribution.
20-
* 3. Neither the name of the Company nor the names of its contributors
21-
* may be used to endorse or promote products derived from this
22-
* software without specific prior written permission.
23-
*
2+
* @file
3+
* @brief Plugin for parsing ntp traffic.
4+
* @author Alejandro Robledo <[email protected]>
5+
* @date 2025
246
*
7+
* Copyright (c) 2025 CESNET
258
*
9+
* SPDX-License-Identifier: BSD-3-Clause
2610
*/
11+
12+
#include "ntp.hpp"
13+
2714
#include <cstdlib>
2815
#include <cstring>
2916
#include <iomanip>
3017
#include <iostream>
3118
#include <sstream>
3219

33-
#include <stdlib.h>
34-
3520
#ifdef WITH_NEMEA
3621
#include <unirec/unirec.h>
3722
#endif
3823

39-
#include "ntp.hpp"
24+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
25+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
4026

4127
namespace ipxp {
4228

43-
int RecordExtNTP::REGISTERED_ID = -1;
29+
int RecordExtNTP::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4430

45-
__attribute__((constructor)) static void register_this_plugin()
46-
{
47-
static PluginRecord rec = PluginRecord("ntp", []() { return new NTPPlugin(); });
48-
register_plugin(&rec);
49-
RecordExtNTP::REGISTERED_ID = register_extension();
50-
}
31+
static const PluginManifest ntpPluginManifest = {
32+
.name = "ntp",
33+
.description = "Ntp process plugin for parsing ntp traffic.",
34+
.pluginVersion = "1.0.0",
35+
.apiVersion = "1.0.0",
36+
.usage = nullptr,
37+
};
5138

5239
// #define DEBUG_NTP
5340

@@ -58,19 +45,23 @@ __attribute__((constructor)) static void register_this_plugin()
5845
#define DEBUG_MSG(format, ...)
5946
#endif
6047

61-
NTPPlugin::NTPPlugin()
48+
NTPPlugin::NTPPlugin(const std::string& params)
6249
: requests(0)
6350
, responses(0)
6451
, total(0)
6552
{
53+
(void) params;
6654
}
6755

6856
NTPPlugin::~NTPPlugin()
6957
{
7058
close();
7159
}
7260

73-
void NTPPlugin::init(const char* params) {}
61+
void NTPPlugin::init(const char* params)
62+
{
63+
(void) params;
64+
}
7465

7566
void NTPPlugin::close() {}
7667

@@ -448,4 +439,6 @@ NTPPlugin::parse_timestamp(const Packet& pkt, uint16_t p1, uint16_t p4, uint16_t
448439
return result2;
449440
}
450441

442+
static const PluginRegistrar<NTPPlugin, ProcessPluginFactory> ntpRegistrar(ntpPluginManifest);
443+
451444
} // namespace ipxp
Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
/**
2-
* \file ntp.hpp
3-
* \author Alejandro Robledo <[email protected]>
4-
* \date 2016
5-
*/
6-
/*
7-
* Copyright (C) 2016 CESNET
8-
*
9-
* LICENSE TERMS
10-
*
11-
* Redistribution and use in source and binary forms, with or without
12-
* modification, are permitted provided that the following conditions
13-
* are met:
14-
* 1. Redistributions of source code must retain the above copyright
15-
* notice, this list of conditions and the following disclaimer.
16-
* 2. Redistributions in binary form must reproduce the above copyright
17-
* notice, this list of conditions and the following disclaimer in
18-
* the documentation and/or other materials provided with the
19-
* distribution.
20-
* 3. Neither the name of the Company nor the names of its contributors
21-
* may be used to endorse or promote products derived from this
22-
* software without specific prior written permission.
23-
*
2+
* @file
3+
* @brief Plugin for parsing ntp traffic.
4+
* @author Alejandro Robledo <[email protected]>
5+
* @date 2025
246
*
7+
* Copyright (c) 2025 CESNET
258
*
9+
* SPDX-License-Identifier: BSD-3-Clause
2610
*/
2711

28-
#ifndef IPXP_PROCESS_NTP_HPP
29-
#define IPXP_PROCESS_NTP_HPP
12+
#pragma once
3013

3114
#include <cstdlib>
3215
#include <cstring>
@@ -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
#include <stdio.h>
4528

4629
namespace ipxp {
@@ -225,7 +208,7 @@ struct RecordExtNTP : public RecordExt {
225208
*/
226209
class NTPPlugin : public ProcessPlugin {
227210
public:
228-
NTPPlugin();
211+
NTPPlugin(const std::string& params);
229212
~NTPPlugin();
230213
void init(const char* params);
231214
void close();
@@ -249,4 +232,3 @@ class NTPPlugin : public ProcessPlugin {
249232
};
250233

251234
} // namespace ipxp
252-
#endif /* IPXP_PROCESS_NTP_HPP */

0 commit comments

Comments
 (0)