11/* *
2- * \file http.cpp
3- * \brief Plugin for parsing HTTP traffic
4- * \author Jiri Havranek <[email protected] > 5- * \date 2015
6- * \date 2016
7- */
8- /*
9- * Copyright (C) 2014-2016 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 HTTP traffic.
4+ * @author Jiri Havranek <[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 " common.hpp"
14+ #include " http.hpp"
15+
3016#include < cstdlib>
3117#include < cstring>
3218#include < iostream>
3319
20+ #include < ipfixprobe/pluginFactory/pluginManifest.hpp>
21+ #include < ipfixprobe/pluginFactory/pluginRegistrar.hpp>
22+
3423#ifdef WITH_NEMEA
3524#include < unirec/unirec.h>
3625#endif
3726
38- #include " common.hpp"
39- #include " http.hpp"
40-
4127namespace ipxp {
4228
43- int RecordExtHTTP::REGISTERED_ID = - 1 ;
29+ int RecordExtHTTP::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID() ;
4430
45- __attribute__ ((constructor)) static void register_this_plugin ()
46- {
47- static PluginRecord rec = PluginRecord (" http" , []() { return new HTTPPlugin (); });
48- register_plugin (&rec);
49- RecordExtHTTP::REGISTERED_ID = register_extension ();
50- }
31+ static const PluginManifest httpPluginManifest = {
32+ .name = " http" ,
33+ .description = " http process plugin for parsing http traffic." ,
34+ .pluginVersion = " 1.0.0" ,
35+ .apiVersion = " 1.0.0" ,
36+ .usage = nullptr ,
37+ };
5138
5239// #define DEBUG_HTTP
5340
@@ -70,21 +57,25 @@ __attribute__((constructor)) static void register_this_plugin()
7057#define HTTP_SETCOOKIE_NAME_DELIMITER " ="
7158#define STRING_DELIMITER " ;"
7259
73- HTTPPlugin::HTTPPlugin ()
60+ HTTPPlugin::HTTPPlugin (const std::string& params )
7461 : recPrealloc(nullptr )
7562 , flow_flush(false )
7663 , requests(0 )
7764 , responses(0 )
7865 , total(0 )
7966{
67+ init (params.c_str ());
8068}
8169
8270HTTPPlugin::~HTTPPlugin ()
8371{
8472 close ();
8573}
8674
87- void HTTPPlugin::init (const char * params) {}
75+ void HTTPPlugin::init (const char * params)
76+ {
77+ (void ) params;
78+ }
8879
8980void HTTPPlugin::close ()
9081{
@@ -154,34 +145,6 @@ void HTTPPlugin::finish(bool print_stats)
154145 }
155146}
156147
157- /* *
158- * \brief Copy string and append \0 character.
159- * NOTE: function removes any CR chars at the end of string.
160- * \param [in] dst Destination buffer.
161- * \param [in] size Size of destination buffer.
162- * \param [in] begin Ptr to begin of source string.
163- * \param [in] end Ptr to end of source string.
164- */
165- void copy_str (char * dst, ssize_t size, const char * begin, const char * end)
166- {
167- ssize_t len = end - begin;
168- if (len >= size) {
169- len = size - 1 ;
170- }
171-
172- memcpy (dst, begin, len);
173-
174- if (len >= 1 && dst[len - 1 ] == ' \n ' ) {
175- len--;
176- }
177-
178- if (len >= 1 && dst[len - 1 ] == ' \r ' ) {
179- len--;
180- }
181-
182- dst[len] = 0 ;
183- }
184-
185148/* *
186149 * \brief Add delimiter and string at the end of destination buffer if is it empty add only string
187150 * and append \0 character. NOTE: function removes any CR chars at the end of string. \param [in]
@@ -650,4 +613,6 @@ void HTTPPlugin::add_ext_http_response(const char* data, int payload_len, Flow&
650613 }
651614}
652615
616+ static const PluginRegistrar<HTTPPlugin, ProcessPluginFactory> httpRegistrar (httpPluginManifest);
617+
653618} // namespace ipxp
0 commit comments