suricata
output.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 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 Endace Technology Limited, Jason Ish <jason.ish@endace.com>
22  */
23 
24 #ifndef __OUTPUT_H__
25 #define __OUTPUT_H__
26 
27 #include "suricata.h"
28 #include "tm-threads.h"
29 
30 #define DEFAULT_LOG_MODE_APPEND "yes"
31 #define DEFAULT_LOG_FILETYPE "regular"
32 
33 #include "output-packet.h"
34 #include "output-tx.h"
35 #include "output-file.h"
36 #include "output-filedata.h"
37 #include "output-flow.h"
38 #include "output-streaming.h"
39 #include "output-stats.h"
40 
41 #include "util-config.h"
42 
43 typedef struct OutputInitResult_ {
45  bool ok;
47 
50 typedef TmEcode (*OutputLogFunc)(ThreadVars *, Packet *, void *);
51 typedef uint32_t (*OutputGetActiveCountFunc)(void);
52 
53 typedef struct OutputModule_ {
55  const char *name;
56  const char *conf_name;
57  const char *parent_name;
60 
64 
78 
81 
82 typedef TAILQ_HEAD(OutputModuleList_, OutputModule_) OutputModuleList;
83 extern OutputModuleList output_modules;
84 
85 void OutputRegisterModule(const char *, const char *, OutputInitFunc);
86 
87 void OutputRegisterPacketModule(LoggerId id, const char *name,
88  const char *conf_name, OutputInitFunc InitFunc, PacketLogger LogFunc,
91 void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
92  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
93  PacketLogger LogFunc, PacketLogCondition ConditionFunc,
94  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
95  ThreadExitPrintStatsFunc ThreadExitPrintStats);
96 
97 void OutputRegisterTxModule(LoggerId id, const char *name,
98  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
99  TxLogger TxLogFunc, ThreadInitFunc ThreadInit,
100  ThreadDeinitFunc ThreadDeinit,
101  ThreadExitPrintStatsFunc ThreadExitPrintStats);
102 void OutputRegisterTxSubModule(LoggerId id, const char *parent_name,
103  const char *name, const char *conf_name,
104  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
105  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
106  ThreadExitPrintStatsFunc ThreadExitPrintStats);
107 
108 void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name,
109  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
110  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
111  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
112  ThreadExitPrintStatsFunc ThreadExitPrintStats);
114  const char *parent_name, const char *name, const char *conf_name,
115  OutputInitSubFunc InitFunc, AppProto alproto,
116  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
117  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
118  ThreadExitPrintStatsFunc ThreadExitPrintStats);
119 
120 void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name,
121  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
122  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
123  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
124  ThreadExitPrintStatsFunc ThreadExitPrintStats);
125 void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name,
126  const char *name, const char *conf_name,
127  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
128  int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit,
129  ThreadDeinitFunc ThreadDeinit,
130  ThreadExitPrintStatsFunc ThreadExitPrintStats);
131 
132 void OutputRegisterFileModule(LoggerId id, const char *name,
133  const char *conf_name, OutputInitFunc InitFunc,
134  FileLogger FileLogFunc, ThreadInitFunc ThreadInit,
135  ThreadDeinitFunc ThreadDeinit,
136  ThreadExitPrintStatsFunc ThreadExitPrintStats);
137 void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
138  const char *name, const char *conf_name,
139  OutputInitSubFunc InitFunc, FileLogger FileLogFunc,
140  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
141  ThreadExitPrintStatsFunc ThreadExitPrintStats);
142 
143 void OutputRegisterFiledataModule(LoggerId id, const char *name,
144  const char *conf_name, OutputInitFunc InitFunc,
145  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
146  ThreadDeinitFunc ThreadDeinit,
147  ThreadExitPrintStatsFunc ThreadExitPrintStats);
148 void OutputRegisterFiledataSubModule(LoggerId, const char *parent_name,
149  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
150  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
151  ThreadDeinitFunc ThreadDeinit,
152  ThreadExitPrintStatsFunc ThreadExitPrintStats);
153 
154 void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
155  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
156  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
157  ThreadDeinitFunc ThreadDeinit,
158  ThreadExitPrintStatsFunc ThreadExitPrintStats);
159 
160 void OutputRegisterStreamingModule(LoggerId id, const char *name,
161  const char *conf_name, OutputInitFunc InitFunc,
162  StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type,
163  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
164  ThreadExitPrintStatsFunc ThreadExitPrintStats);
165 void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
166  const char *name, const char *conf_name,
167  OutputInitSubFunc InitFunc, StreamingLogger StreamingLogFunc,
168  enum OutputStreamingType stream_type,
169  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
170  ThreadExitPrintStatsFunc ThreadExitPrintStats);
171 
172 void OutputRegisterStatsModule(LoggerId id, const char *name,
173  const char *conf_name, OutputInitFunc InitFunc,
174  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
175  ThreadDeinitFunc ThreadDeinit,
176  ThreadExitPrintStatsFunc ThreadExitPrintStats);
177 void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
178  const char *name, const char *conf_name,
179  OutputInitSubFunc InitFunc,
180  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
181  ThreadDeinitFunc ThreadDeinit,
182  ThreadExitPrintStatsFunc ThreadExitPrintStats);
183 
184 OutputModule *OutputGetModuleByConfName(const char *name);
185 void OutputDeregisterAll(void);
186 
187 int OutputDropLoggerEnable(void);
188 void OutputDropLoggerDisable(void);
189 
190 void OutputRegisterFileRotationFlag(int *flag);
191 void OutputUnregisterFileRotationFlag(int *flag);
192 void OutputNotifyFileRotation(void);
193 
195  ThreadDeinitFunc ThreadDeinit,
196  ThreadExitPrintStatsFunc ThreadExitPrintStats,
197  OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc);
198 void TmModuleLoggerRegister(void);
199 
201 TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **);
203 void OutputLoggerExitPrintStats(ThreadVars *, void *);
204 
205 void OutputSetupActiveLoggers(void);
206 void OutputClearActiveLoggers(void);
207 
208 #endif /* ! __OUTPUT_H__ */
OutputRegisterTxModule
void OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a tx output module.
Definition: output.c:398
OutputRegisterFileSubModule
void OutputRegisterFileSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a file output sub-module.
Definition: output.c:466
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger LogFunc, PacketLogCondition ConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output sub-module.
Definition: output.c:214
OutputModule_::parent_name
const char * parent_name
Definition: output.h:57
tm-threads.h
OutputRegisterTxSubModuleWithProgress
void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:378
output-tx.h
OutputLogFunc
TmEcode(* OutputLogFunc)(ThreadVars *, Packet *, void *)
Definition: output.h:50
OutputLoggerThreadInit
TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **)
Definition: output.c:891
TAILQ_HEAD
typedef TAILQ_HEAD(OutputModuleList_, OutputModule_) OutputModuleList
OutputRegisterRootLogger
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
Definition: output.c:962
output-filedata.h
OutputModule
struct OutputModule_ OutputModule
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:73
output-streaming.h
OutputInitResult
struct OutputInitResult_ OutputInitResult
OutputModule_::name
const char * name
Definition: output.h:55
OutputModule_::StreamingLogFunc
StreamingLogger StreamingLogFunc
Definition: output.h:72
OutputModule_::FileLogFunc
FileLogger FileLogFunc
Definition: output.h:69
StreamingLogger
int(* StreamingLogger)(ThreadVars *, void *thread_data, const Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags)
Definition: output-streaming.h:44
OutputModule_::logger_id
LoggerId logger_id
Definition: output.h:54
LoggerId
LoggerId
Definition: suricata-common.h:439
OutputModule_::ts_log_progress
int ts_log_progress
Definition: output.h:77
OutputRegisterFileModule
void OutputRegisterFileModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a file output module.
Definition: output.c:428
OutputModule_::StatsLogFunc
StatsLogger StatsLogFunc
Definition: output.h:73
OutputModule_::TAILQ_ENTRY
TAILQ_ENTRY(OutputModule_) entries
TxLogger
int(* TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:32
FlowLogger
int(* FlowLogger)(ThreadVars *, void *thread_data, Flow *f)
Definition: output-flow.h:32
output-packet.h
OutputRegisterFiledataModule
void OutputRegisterFiledataModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a file data output module.
Definition: output.c:506
PacketLogger
int(* PacketLogger)(ThreadVars *, void *thread_data, const Packet *)
Definition: output-packet.h:33
FiledataLogger
int(* FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, const uint8_t *, uint32_t, uint8_t, uint8_t dir)
Definition: output-filedata.h:36
OutputModule_::InitSubFunc
OutputInitSubFunc InitSubFunc
Definition: output.h:59
OutputGetModuleByConfName
OutputModule * OutputGetModuleByConfName(const char *name)
Get an output module by name.
Definition: output.c:783
OutputRegisterPacketModule
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger LogFunc, PacketLogCondition ConditionFunc, ThreadInitFunc, ThreadDeinitFunc, ThreadExitPrintStatsFunc)
Register a packet output module.
Definition: output.c:174
OutputRegisterStatsSubModule
void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a stats data output sub-module.
Definition: output.c:745
OutputModule_::PacketLogFunc
PacketLogger PacketLogFunc
Definition: output.h:65
OutputLoggerLog
TmEcode OutputLoggerLog(ThreadVars *, Packet *, void *)
Definition: output.c:876
OutputModule_::alproto
AppProto alproto
Definition: output.h:74
OutputDeregisterAll
void OutputDeregisterAll(void)
Deregister all modules. Useful for a memory clean exit.
Definition: output.c:798
OutputCtx_
Definition: tm-modules.h:78
OutputModule_::stream_type
enum OutputStreamingType stream_type
Definition: output.h:75
OutputRegisterStatsModule
void OutputRegisterStatsModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a stats data output module.
Definition: output.c:707
OutputRegisterTxSubModuleWithCondition
void OutputRegisterTxSubModuleWithCondition(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:347
OutputModule_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.h:61
output_modules
OutputModuleList output_modules
OutputInitSubFunc
OutputInitResult(* OutputInitSubFunc)(ConfNode *, OutputCtx *)
Definition: output.h:49
OutputDropLoggerDisable
void OutputDropLoggerDisable(void)
Definition: output.c:818
OutputModule_::FiledataLogFunc
FiledataLogger FiledataLogFunc
Definition: output.h:70
OutputRegisterTxModuleWithProgress
void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a tx output module with progress.
Definition: output.c:367
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:44
OutputModule_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.h:62
output-file.h
OutputRegisterModule
void OutputRegisterModule(const char *, const char *, OutputInitFunc)
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
ThreadInitFunc
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
OutputInitResult_::ok
bool ok
Definition: output.h:45
OutputRegisterStreamingModule
void OutputRegisterStreamingModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a streaming data output module.
Definition: output.c:625
OutputUnregisterFileRotationFlag
void OutputUnregisterFileRotationFlag(int *flag)
Unregister a file rotation flag.
Definition: output.c:852
OutputModule_::conf_name
const char * conf_name
Definition: output.h:56
OutputModule_::FlowLogFunc
FlowLogger FlowLogFunc
Definition: output.h:71
Packet_
Definition: decode.h:414
OutputRegisterFlowSubModule
void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a flow output sub-module.
Definition: output.c:585
TmModuleLoggerRegister
void TmModuleLoggerRegister(void)
Definition: output.c:1017
OutputClearActiveLoggers
void OutputClearActiveLoggers(void)
Definition: output.c:1008
TmEcode
TmEcode
Definition: tm-threads-common.h:79
output-flow.h
OutputModule_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.h:63
OutputDropLoggerEnable
int OutputDropLoggerEnable(void)
Definition: output.c:810
OutputInitResult_
Definition: output.h:43
OutputModule_::TxLogCondition
TxLoggerCondition TxLogCondition
Definition: output.h:68
ThreadExitPrintStatsFunc
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
Definition: tm-modules.h:41
FileLogger
int(* FileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, uint8_t direction)
Definition: output-file.h:33
OutputRegisterTxModuleWithCondition
void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a tx output module with condition.
Definition: output.c:336
OutputLoggerThreadDeinit
TmEcode OutputLoggerThreadDeinit(ThreadVars *, void *)
Definition: output.c:922
OutputModule_::PacketConditionFunc
PacketLogCondition PacketConditionFunc
Definition: output.h:66
OutputGetActiveCountFunc
uint32_t(* OutputGetActiveCountFunc)(void)
Definition: output.h:51
TxLoggerCondition
int(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:37
OutputRegisterFileRotationFlag
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
Definition: output.c:830
OutputStreamingType
OutputStreamingType
Definition: output-streaming.h:38
OutputNotifyFileRotation
void OutputNotifyFileRotation(void)
Notifies all registered file rotation notification flags.
Definition: output.c:869
ConfNode_
Definition: conf.h:32
util-config.h
StatsLogger
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
Definition: output-stats.h:47
OutputModule_::TxLogFunc
TxLogger TxLogFunc
Definition: output.h:67
OutputModule_::tc_log_progress
int tc_log_progress
Definition: output.h:76
OutputInitFunc
OutputInitResult(* OutputInitFunc)(ConfNode *)
Definition: output.h:48
PacketLogCondition
int(* PacketLogCondition)(ThreadVars *, const Packet *)
Definition: output-packet.h:38
suricata.h
OutputRegisterStreamingSubModule
void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a streaming data output sub-module.
Definition: output.c:666
output-stats.h
OutputLoggerExitPrintStats
void OutputLoggerExitPrintStats(ThreadVars *, void *)
Definition: output.c:948
OutputModule_
Definition: output.h:53
OutputRegisterFiledataSubModule
void OutputRegisterFiledataSubModule(LoggerId, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a file data output sub-module.
Definition: output.c:545
OutputRegisterTxSubModule
void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Definition: output.c:409
ThreadDeinitFunc
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
OutputModule_::InitFunc
OutputInitFunc InitFunc
Definition: output.h:58
OutputSetupActiveLoggers
void OutputSetupActiveLoggers(void)
Definition: output.c:995