|
1 | 1 | /** |
2 | | - * \file passivedns.cpp |
3 | | - * \brief Plugin for exporting DNS A and AAAA records. |
4 | | - * \author Jiri Havranek <[email protected]> |
5 | | - * \date 2017 |
6 | | - */ |
7 | | -/* |
8 | | - * Copyright (C) 2017 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 DNS A and AAAA records. |
| 4 | + * @author Jiri Havranek <[email protected]> |
| 5 | + * @author Pavel Siska <[email protected]> |
| 6 | + * @date 2025 |
25 | 7 | * |
| 8 | + * Copyright (c) 2025 CESNET |
26 | 9 | * |
| 10 | + * SPDX-License-Identifier: BSD-3-Clause |
27 | 11 | */ |
28 | 12 |
|
29 | | -#include <cstring> |
30 | | -#include <iostream> |
31 | | -#include <sstream> |
32 | | -#include <type_traits> |
33 | | - |
34 | | -#include <arpa/inet.h> |
35 | | -#include <stdio.h> |
36 | | -#include <stdlib.h> |
| 13 | +#include "passivedns.hpp" |
37 | 14 |
|
38 | 15 | #ifdef WITH_NEMEA |
39 | 16 | #include <unirec/unirec.h> |
40 | 17 | #endif |
41 | 18 |
|
42 | | -#include "passivedns.hpp" |
43 | | - |
| 19 | +#include <cstdlib> |
| 20 | +#include <cstring> |
| 21 | +#include <iostream> |
44 | 22 | #include <limits> |
| 23 | +#include <sstream> |
| 24 | +#include <type_traits> |
45 | 25 |
|
| 26 | +#include <arpa/inet.h> |
46 | 27 | #include <errno.h> |
| 28 | +#include <ipfixprobe/pluginFactory/pluginManifest.hpp> |
| 29 | +#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp> |
47 | 30 | #include <ipfixprobe/utils.hpp> |
48 | 31 | #include <stdint.h> |
49 | | -#include <stdlib.h> |
| 32 | +#include <stdio.h> |
50 | 33 |
|
51 | 34 | namespace ipxp { |
52 | 35 |
|
53 | | -int RecordExtPassiveDNS::REGISTERED_ID = -1; |
| 36 | +int RecordExtPassiveDNS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID(); |
54 | 37 |
|
55 | | -__attribute__((constructor)) static void register_this_plugin() |
56 | | -{ |
57 | | - static PluginRecord rec = PluginRecord("passivedns", []() { return new PassiveDNSPlugin(); }); |
58 | | - register_plugin(&rec); |
59 | | - RecordExtPassiveDNS::REGISTERED_ID = register_extension(); |
60 | | -} |
| 38 | +static const PluginManifest passivednsPluginManifest = { |
| 39 | + .name = "passivedns", |
| 40 | + .description = "Passivedns process plugin for parsing DNS A and AAAA records.", |
| 41 | + .pluginVersion = "1.0.0", |
| 42 | + .apiVersion = "1.0.0", |
| 43 | + .usage = nullptr, |
| 44 | +}; |
61 | 45 |
|
62 | 46 | // #define DEBUG_PASSIVEDNS |
63 | 47 |
|
@@ -87,14 +71,15 @@ __attribute__((constructor)) static void register_this_plugin() |
87 | 71 | */ |
88 | 72 | #define GET_OFFSET(half1, half2) ((((uint8_t) (half1) & 0x3F) << 8) | (uint8_t) (half2)) |
89 | 73 |
|
90 | | -PassiveDNSPlugin::PassiveDNSPlugin() |
| 74 | +PassiveDNSPlugin::PassiveDNSPlugin(const std::string& params) |
91 | 75 | : total(0) |
92 | 76 | , parsed_a(0) |
93 | 77 | , parsed_aaaa(0) |
94 | 78 | , parsed_ptr(0) |
95 | 79 | , data_begin(nullptr) |
96 | 80 | , data_len(0) |
97 | 81 | { |
| 82 | + init(params.c_str()); |
98 | 83 | } |
99 | 84 |
|
100 | 85 | PassiveDNSPlugin::~PassiveDNSPlugin() |
@@ -526,4 +511,7 @@ int PassiveDNSPlugin::add_ext_dns(const char* data, unsigned int payload_len, bo |
526 | 511 | return FLOW_FLUSH; |
527 | 512 | } |
528 | 513 |
|
| 514 | +static const PluginRegistrar<PassiveDNSPlugin, ProcessPluginFactory> |
| 515 | + passivednsRegistrar(passivednsPluginManifest); |
| 516 | + |
529 | 517 | } // namespace ipxp |
0 commit comments