"Fossies" - the Fresh Open Source Software Archive 
Member "snort3_extra-3.1.51.0/src/inspectors/null_trace_logger/null_trace_logger.cc" (20 Dec 2022, 3934 Bytes) of package /linux/misc/snort3_extra-3.1.51.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "null_trace_logger.cc" see the
Fossies "Dox" file reference documentation.
1 //--------------------------------------------------------------------------
2 // Copyright (C) 2020-2022 Cisco and/or its affiliates. All rights reserved.
3 //
4 // This program is free software; you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License Version 2 as published
6 // by the Free Software Foundation. You may not use, modify or distribute
7 // this program under any other version of the GNU General Public License.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 //--------------------------------------------------------------------------
18 // null_trace_logger.cc author Oleksandr Serhiienko <oserhiie@cisco.com>
19 // author Oleksii Shumeiko <oshumeik@cisco.com>
20
21 #include "framework/decode_data.h" // for PROTO_BIT__NONE
22 #include "framework/inspector.h"
23 #include "framework/module.h"
24 #include "trace/trace_api.h"
25 #include "trace/trace_logger.h"
26
27 static const char* s_name = "null_trace_logger";
28 static const char* s_help = "trace logger with a null printout";
29
30 using namespace snort;
31
32 //-------------------------------------------------------------------------
33 // logger
34 //-------------------------------------------------------------------------
35
36 class NullTraceLogger : public TraceLogger
37 {
38 public:
39 void log(const char*, const char*, uint8_t, const char*, const Packet*) override
40 { }
41 };
42
43 //-------------------------------------------------------------------------
44 // logger factory
45 //-------------------------------------------------------------------------
46
47 class NullLoggerFactory : public TraceLoggerFactory
48 {
49 public:
50 NullLoggerFactory() = default;
51 NullLoggerFactory(const NullLoggerFactory&) = delete;
52 NullLoggerFactory& operator=(const NullLoggerFactory&) = delete;
53
54 TraceLogger* instantiate() override
55 { return new NullTraceLogger(); }
56 };
57
58 //-------------------------------------------------------------------------
59 // module
60 //-------------------------------------------------------------------------
61
62 class NullLoggerModule : public Module
63 {
64 public:
65 NullLoggerModule() : Module(s_name, s_help) { }
66
67 Usage get_usage() const override
68 { return GLOBAL; }
69 };
70
71 //-------------------------------------------------------------------------
72 // inspector
73 //-------------------------------------------------------------------------
74
75 class NullLoggerInspector : public Inspector
76 {
77 public:
78 void eval(Packet*) override { }
79 bool configure(SnortConfig* sc) override
80 { return TraceApi::override_logger_factory(sc, new NullLoggerFactory()); }
81 };
82
83 //-------------------------------------------------------------------------
84 // API
85 //-------------------------------------------------------------------------
86
87 static Module* mod_ctor()
88 { return new NullLoggerModule; }
89
90 static void mod_dtor(Module* m)
91 { delete m; }
92
93 static Inspector* ntl_ctor(Module*)
94 { return new NullLoggerInspector; }
95
96 static void ntl_dtor(Inspector* p)
97 { delete p; }
98
99 static const InspectApi ntl_api
100 {
101 {
102 PT_INSPECTOR,
103 sizeof(InspectApi),
104 INSAPI_VERSION,
105 0,
106 API_RESERVED,
107 API_OPTIONS,
108 s_name,
109 s_help,
110 mod_ctor,
111 mod_dtor
112 },
113 IT_PASSIVE,
114 PROTO_BIT__NONE,
115 nullptr, // buffers
116 nullptr, // service
117 nullptr, // pinit
118 nullptr, // pterm
119 nullptr, // tinit,
120 nullptr, // tterm,
121 ntl_ctor,
122 ntl_dtor,
123 nullptr, // ssn
124 nullptr // reset
125 };
126
127 SO_PUBLIC const BaseApi* snort_plugins[] =
128 {
129 &ntl_api.base,
130 nullptr
131 };
132