Skip to content

Commit 4aef79f

Browse files
Pavel SiskaPavel Šiška
authored andcommitted
ipfixprobe - introduce process SMTP plugin
1 parent e98fdc7 commit 4aef79f

File tree

5 files changed

+56
-60
lines changed

5 files changed

+56
-60
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_subdirectory(dns)
1616
add_subdirectory(dnssd)
1717
add_subdirectory(netbios)
1818
add_subdirectory(passiveDns)
19+
add_subdirectory(smtp)
1920

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

src/plugins/process/smtp/README.md

Whitespace-only changes.
Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
/**
2-
* \file smtp.cpp
3-
* \brief Plugin for parsing smtp traffic.
4-
* \author Jiri Havranek <[email protected]>
5-
* \date 2018
6-
*/
7-
/*
8-
* Copyright (C) 2018 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 smtp traffic.
4+
* @author Jiri Havranek <[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

2913
#include "smtp.hpp"
@@ -34,32 +18,39 @@
3418
#include <iostream>
3519

3620
#include <ctype.h>
21+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
22+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3723

3824
namespace ipxp {
3925

40-
int RecordExtSMTP::REGISTERED_ID = -1;
26+
int RecordExtSMTP::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4127

42-
__attribute__((constructor)) static void register_this_plugin()
43-
{
44-
static PluginRecord rec = PluginRecord("smtp", []() { return new SMTPPlugin(); });
45-
register_plugin(&rec);
46-
RecordExtSMTP::REGISTERED_ID = register_extension();
47-
}
28+
static const PluginManifest smtpPluginManifest = {
29+
.name = "smtp",
30+
.description = "Smtp process plugin for parsing smtp traffic.",
31+
.pluginVersion = "1.0.0",
32+
.apiVersion = "1.0.0",
33+
.usage = nullptr,
34+
};
4835

49-
SMTPPlugin::SMTPPlugin()
36+
SMTPPlugin::SMTPPlugin(const std::string& params)
5037
: ext_ptr(nullptr)
5138
, total(0)
5239
, replies_cnt(0)
5340
, commands_cnt(0)
5441
{
42+
init(params.c_str());
5543
}
5644

5745
SMTPPlugin::~SMTPPlugin()
5846
{
5947
close();
6048
}
6149

62-
void SMTPPlugin::init(const char* params) {}
50+
void SMTPPlugin::init(const char* params)
51+
{
52+
(void) params;
53+
}
6354

6455
void SMTPPlugin::close() {}
6556

@@ -416,4 +407,6 @@ void SMTPPlugin::finish(bool print_stats)
416407
}
417408
}
418409

410+
static const PluginRegistrar<SMTPPlugin, ProcessPluginFactory> smtpRegistrar(smtpPluginManifest);
411+
419412
} // namespace ipxp
Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
/**
2-
* \file smtp.hpp
3-
* \brief Plugin for parsing smtp traffic.
4-
* \author Jiri Havranek <[email protected]>
5-
* \date 2018
6-
*/
7-
/*
8-
* Copyright (C) 2018 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 smtp traffic.
4+
* @author Jiri Havranek <[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_SMTP_HPP
30-
#define IPXP_PROCESS_SMTP_HPP
13+
#pragma once
3114

3215
#include <cstring>
3316
#include <sstream>
@@ -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

4528
namespace ipxp {
4629

@@ -223,7 +206,7 @@ struct RecordExtSMTP : public RecordExt {
223206
*/
224207
class SMTPPlugin : public ProcessPlugin {
225208
public:
226-
SMTPPlugin();
209+
SMTPPlugin(const std::string& params);
227210
~SMTPPlugin();
228211
void init(const char* params);
229212
void close();
@@ -250,4 +233,3 @@ class SMTPPlugin : public ProcessPlugin {
250233
};
251234

252235
} // namespace ipxp
253-
#endif /* IPXP_PROCESS_SMTP_HPP */

0 commit comments

Comments
 (0)