suricata
output-file.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2024 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 Victor Julien <victor@inliniac.net>
22  *
23  * AppLayer File Logger Output registration functions
24  */
25 
26 #ifndef SURICATA_OUTPUT_FILE_H
27 #define SURICATA_OUTPUT_FILE_H
28 
29 #include "rust.h"
30 
31 /** per thread data for this module, contains a list of per thread
32  * data for the packet loggers. */
35 #ifdef HAVE_MAGIC
36  magic_t magic_ctx;
37 #endif
39 
42 
44  FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd,
45  const bool file_close, const bool file_trunc, uint8_t dir);
46 
47 /** file logger function pointer type */
48 typedef int (*SCFileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, void *tx,
49  const uint64_t tx_id, uint8_t direction);
50 
51 /** \brief Register a file logger.
52  *
53  * \param logger_id An ID used to distinguish this logger from others
54  * while profiling.
55  *
56  * \param name An informational name for this logger. Used only for
57  * debugging.
58  *
59  * \param LogFunc A function that will be called to log each file to be logged.
60  *
61  * \param initdata Initialization data that will pass to the
62  * ThreadInitFunc.
63  *
64  * \param ThreadInitFunc Thread initialization function.
65  *
66  * \param ThreadDeinitFunc Thread de-initialization function.
67  *
68  * \retval 0 on success, -1 on failure.
69  */
70 int SCOutputRegisterFileLogger(LoggerId id, const char *name, SCFileLogger LogFunc, void *initdata,
71  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit);
72 
73 /** Internal function: private API. */
74 void OutputFileLoggerRegister(void);
75 
76 /** Internal function: private API. */
77 void OutputFileShutdown(void);
78 
79 #endif /* SURICATA_OUTPUT_FILE_H */
FileContainer_
Definition: util-file.h:113
OutputLoggerThreadStore_
Definition: output.h:33
OutputFileLoggerThreadData_
Definition: output-file.h:33
SCFileLogger
int(* SCFileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, void *tx, const uint64_t tx_id, uint8_t direction)
Definition: output-file.h:48
LoggerId
LoggerId
Definition: suricata-common.h:460
rust.h
OutputFileLogThreadDeinit
TmEcode OutputFileLogThreadDeinit(ThreadVars *tv, OutputFileLoggerThreadData *thread_data)
Definition: output-file.c:211
OutputFileShutdown
void OutputFileShutdown(void)
Definition: output-file.c:239
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
ThreadInitFunc
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
OutputFileLoggerThreadData
struct OutputFileLoggerThreadData_ OutputFileLoggerThreadData
Packet_
Definition: decode.h:473
TmEcode
TmEcode
Definition: tm-threads-common.h:79
File_
Definition: util-file.h:79
AppLayerTxData
struct AppLayerTxData AppLayerTxData
Definition: detect.h:1367
OutputFileLogThreadInit
TmEcode OutputFileLogThreadInit(ThreadVars *tv, OutputFileLoggerThreadData **data)
thread init for the file logger This will run the thread init functions for the individual registered...
Definition: output-file.c:164
OutputFileLoggerRegister
void OutputFileLoggerRegister(void)
Definition: output-file.c:235
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
SCOutputRegisterFileLogger
int SCOutputRegisterFileLogger(LoggerId id, const char *name, SCFileLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a file logger.
Definition: output-file.c:56
OutputFileLogFfc
void OutputFileLogFfc(ThreadVars *tv, OutputFileLoggerThreadData *op_thread_data, Packet *p, FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd, const bool file_close, const bool file_trunc, uint8_t dir)
Definition: output-file.c:96
OutputFileLoggerThreadData_::store
OutputLoggerThreadStore * store
Definition: output-file.h:34
ThreadDeinitFunc
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40