/src/suricata7/src/output-eve-null.c
Line | Count | Source |
1 | | /* Copyright (C) 2023 Open Information Security Foundation |
2 | | * |
3 | | * You can copy, redistribute or modify this Program under the terms of |
4 | | * the GNU General Public License version 2 as published by the Free |
5 | | * Software Foundation. |
6 | | * |
7 | | * This program is distributed in the hope that it will be useful, |
8 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | | * GNU General Public License for more details. |
11 | | * |
12 | | * You should have received a copy of the GNU General Public License |
13 | | * version 2 along with this program; if not, write to the Free Software |
14 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
15 | | * 02110-1301, USA. |
16 | | */ |
17 | | |
18 | | /** |
19 | | * \file |
20 | | * |
21 | | * \author Jeff Lucovsky <jlucovsky@oisf.net> |
22 | | * |
23 | | * File-like output for logging: null/discard device |
24 | | */ |
25 | | |
26 | | #include "suricata-common.h" /* errno.h, string.h, etc. */ |
27 | | |
28 | | #include "output.h" /* DEFAULT_LOG_* */ |
29 | | #include "output-eve-null.h" |
30 | | |
31 | | #ifdef OS_WIN32 |
32 | | void NullLogInitialize(void) |
33 | | { |
34 | | } |
35 | | #else /* !OS_WIN32 */ |
36 | | |
37 | 74 | #define OUTPUT_NAME "nullsink" |
38 | | |
39 | | static int NullLogInit(ConfNode *conf, bool threaded, void **init_data) |
40 | 0 | { |
41 | 0 | *init_data = NULL; |
42 | 0 | return 0; |
43 | 0 | } |
44 | | |
45 | | static int NullLogWrite(const char *buffer, int buffer_len, void *init_data, void *thread_data) |
46 | 0 | { |
47 | 0 | return 0; |
48 | 0 | } |
49 | | |
50 | | static int NullLogThreadInit(void *init_data, int thread_id, void **thread_data) |
51 | 0 | { |
52 | 0 | *thread_data = NULL; |
53 | 0 | return 0; |
54 | 0 | } |
55 | | |
56 | | static int NullLogThreadDeInit(void *init_data, void *thread_data) |
57 | 0 | { |
58 | 0 | return 0; |
59 | 0 | } |
60 | | |
61 | | static void NullLogDeInit(void *init_data) |
62 | 0 | { |
63 | 0 | } |
64 | | |
65 | | void NullLogInitialize(void) |
66 | 74 | { |
67 | 74 | SCLogDebug("Registering the %s logger", OUTPUT_NAME); |
68 | | |
69 | 74 | SCEveFileType *file_type = SCCalloc(1, sizeof(SCEveFileType)); |
70 | | |
71 | 74 | if (file_type == NULL) { |
72 | 0 | FatalError("Unable to allocate memory for eve file type %s", OUTPUT_NAME); |
73 | 0 | } |
74 | | |
75 | 74 | file_type->name = OUTPUT_NAME; |
76 | 74 | file_type->Init = NullLogInit; |
77 | 74 | file_type->Deinit = NullLogDeInit; |
78 | 74 | file_type->Write = NullLogWrite; |
79 | 74 | file_type->ThreadInit = NullLogThreadInit; |
80 | 74 | file_type->ThreadDeinit = NullLogThreadDeInit; |
81 | 74 | if (!SCRegisterEveFileType(file_type)) { |
82 | | FatalError("Failed to register EVE file type: %s", OUTPUT_NAME); |
83 | 0 | } |
84 | 74 | } |
85 | | #endif /* !OS_WIN32 */ |