Skip to content

Commit 047988c

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process SMTP plugin
1 parent d4ab52a commit 047988c

File tree

5 files changed

+53
-61
lines changed

5 files changed

+53
-61
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ add_subdirectory(dns)
2020
add_subdirectory(dnssd)
2121
add_subdirectory(netbios)
2222
add_subdirectory(passiveDns)
23+
add_subdirectory(smtp)
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: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,44 @@
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

29-
#include "smtp.hpp"
30-
3113
#include "common.hpp"
14+
#include "smtp.hpp"
3215

3316
#include <cstring>
3417
#include <iostream>
3518

3619
#include <ctype.h>
20+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
21+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3722

3823
namespace ipxp {
3924

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

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-
}
27+
static const PluginManifest smtpPluginManifest = {
28+
.name = "smtp",
29+
.description = "Smtp process plugin for parsing smtp traffic.",
30+
.pluginVersion = "1.0.0",
31+
.apiVersion = "1.0.0",
32+
.usage = nullptr,
33+
};
4834

49-
SMTPPlugin::SMTPPlugin()
35+
SMTPPlugin::SMTPPlugin(const std::string& params)
5036
: ext_ptr(nullptr)
5137
, total(0)
5238
, replies_cnt(0)
5339
, commands_cnt(0)
5440
{
41+
init(params.c_str());
5542
}
5643

5744
SMTPPlugin::~SMTPPlugin()
@@ -416,4 +403,6 @@ void SMTPPlugin::finish(bool print_stats)
416403
}
417404
}
418405

406+
static const PluginRegistrar<SMTPPlugin, ProcessPluginFactory> smtpRegistrar(smtpPluginManifest);
407+
419408
} // 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)