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 typedef struct OutputInitResult_ {
43  bool ok;
45 
48 typedef TmEcode (*OutputLogFunc)(ThreadVars *, Packet *, void *);
49 
50 typedef struct OutputModule_ {
52  const char *name;
53  const char *conf_name;
54  const char *parent_name;
57 
61 
72  enum OutputStreamingType stream_type;
75 
76  TAILQ_ENTRY(OutputModule_) entries;
77 } OutputModule;
78 
79 typedef TAILQ_HEAD(OutputModuleList_, OutputModule_) OutputModuleList;
80 extern OutputModuleList output_modules;
81 
82 void OutputRegisterModule(const char *, const char *, OutputInitFunc);
83 
84 void OutputRegisterPacketModule(LoggerId id, const char *name,
85  const char *conf_name, OutputInitFunc InitFunc, PacketLogger LogFunc,
88 void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
89  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
90  PacketLogger LogFunc, PacketLogCondition ConditionFunc,
91  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
92  ThreadExitPrintStatsFunc ThreadExitPrintStats);
93 
94 void OutputRegisterTxModule(LoggerId id, const char *name,
95  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
96  TxLogger TxLogFunc, ThreadInitFunc ThreadInit,
97  ThreadDeinitFunc ThreadDeinit,
98  ThreadExitPrintStatsFunc ThreadExitPrintStats);
99 void OutputRegisterTxSubModule(LoggerId id, const char *parent_name,
100  const char *name, const char *conf_name,
101  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
102  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
103  ThreadExitPrintStatsFunc ThreadExitPrintStats);
104 
105 void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name,
106  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
107  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
108  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
109  ThreadExitPrintStatsFunc ThreadExitPrintStats);
111  const char *parent_name, const char *name, const char *conf_name,
112  OutputInitSubFunc InitFunc, AppProto alproto,
113  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
114  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
115  ThreadExitPrintStatsFunc ThreadExitPrintStats);
116 
117 void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name,
118  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
119  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
120  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
121  ThreadExitPrintStatsFunc ThreadExitPrintStats);
122 void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name,
123  const char *name, const char *conf_name,
124  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
125  int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit,
126  ThreadDeinitFunc ThreadDeinit,
127  ThreadExitPrintStatsFunc ThreadExitPrintStats);
128 
129 void OutputRegisterFileModule(LoggerId id, const char *name,
130  const char *conf_name, OutputInitFunc InitFunc,
131  FileLogger FileLogFunc, ThreadInitFunc ThreadInit,
132  ThreadDeinitFunc ThreadDeinit,
133  ThreadExitPrintStatsFunc ThreadExitPrintStats);
134 void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
135  const char *name, const char *conf_name,
136  OutputInitSubFunc InitFunc, FileLogger FileLogFunc,
137  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
138  ThreadExitPrintStatsFunc ThreadExitPrintStats);
139 
140 void OutputRegisterFiledataModule(LoggerId id, const char *name,
141  const char *conf_name, OutputInitFunc InitFunc,
142  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
143  ThreadDeinitFunc ThreadDeinit,
144  ThreadExitPrintStatsFunc ThreadExitPrintStats);
145 void OutputRegisterFiledataSubModule(LoggerId, const char *parent_name,
146  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
147  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
148  ThreadDeinitFunc ThreadDeinit,
149  ThreadExitPrintStatsFunc ThreadExitPrintStats);
150 
151 void OutputRegisterFlowModule(LoggerId id, const char *name,
152  const char *conf_name, OutputInitFunc InitFunc,
153  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
154  ThreadDeinitFunc ThreadDeinit,
155  ThreadExitPrintStatsFunc ThreadExitPrintStats);
156 void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
157  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
158  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
159  ThreadDeinitFunc ThreadDeinit,
160  ThreadExitPrintStatsFunc ThreadExitPrintStats);
161 
162 void OutputRegisterStreamingModule(LoggerId id, const char *name,
163  const char *conf_name, OutputInitFunc InitFunc,
164  StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type,
165  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
166  ThreadExitPrintStatsFunc ThreadExitPrintStats);
167 void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
168  const char *name, const char *conf_name,
169  OutputInitSubFunc InitFunc, StreamingLogger StreamingLogFunc,
170  enum OutputStreamingType stream_type,
171  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
172  ThreadExitPrintStatsFunc ThreadExitPrintStats);
173 
174 void OutputRegisterStatsModule(LoggerId id, const char *name,
175  const char *conf_name, OutputInitFunc InitFunc,
176  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
177  ThreadDeinitFunc ThreadDeinit,
178  ThreadExitPrintStatsFunc ThreadExitPrintStats);
179 void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
180  const char *name, const char *conf_name,
181  OutputInitSubFunc InitFunc,
182  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
183  ThreadDeinitFunc ThreadDeinit,
184  ThreadExitPrintStatsFunc ThreadExitPrintStats);
185 
186 OutputModule *OutputGetModuleByConfName(const char *name);
187 void OutputDeregisterAll(void);
188 
189 int OutputDropLoggerEnable(void);
190 void OutputDropLoggerDisable(void);
191 
192 void OutputRegisterFileRotationFlag(int *flag);
193 void OutputUnregisterFileRotationFlag(int *flag);
194 void OutputNotifyFileRotation(void);
195 
196 void OutputRegisterRootLogger(ThreadInitFunc ThreadInit,
197  ThreadDeinitFunc ThreadDeinit,
198  ThreadExitPrintStatsFunc ThreadExitPrintStats,
199  OutputLogFunc LogFunc);
200 void TmModuleLoggerRegister(void);
201 
203 TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **);
204 TmEcode OutputLoggerThreadDeinit(ThreadVars *, void *);
205 void OutputLoggerExitPrintStats(ThreadVars *, void *);
206 
207 #endif /* ! __OUTPUT_H__ */
TmEcode(* OutputLogFunc)(ThreadVars *, Packet *, void *)
Definition: output.h:48
StreamingLogger StreamingLogFunc
Definition: output.h:69
int ts_log_progress
Definition: output.h:74
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:355
void OutputUnregisterFileRotationFlag(int *flag)
Unregister a file rotation flag.
Definition: output.c:888
LoggerId
OutputInitFunc InitFunc
Definition: output.h:55
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:536
ThreadDeinitFunc ThreadDeinit
Definition: output.h:59
PacketLogger PacketLogFunc
Definition: output.h:62
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:366
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
Definition: tm-modules.h:41
void OutputDropLoggerDisable(void)
Definition: output.c:854
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:455
TmEcode OutputLoggerThreadDeinit(ThreadVars *, void *)
Definition: output.c:959
OutputModule * OutputGetModuleByConfName(const char *name)
Get an output module by name.
Definition: output.c:819
int tc_log_progress
Definition: output.h:73
OutputInitSubFunc InitSubFunc
Definition: output.h:56
void OutputNotifyFileRotation(void)
Notifies all registered file rotation notification flags.
Definition: output.c:905
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:699
uint16_t AppProto
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
Definition: output-stats.h:47
OutputStreamingType
LoggerId logger_id
Definition: output.h:51
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:496
OutputInitResult(* OutputInitSubFunc)(ConfNode *, OutputCtx *)
Definition: output.h:47
ThreadInitFunc ThreadInit
Definition: output.h:58
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
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:780
TxLoggerCondition TxLogCondition
Definition: output.h:65
TmEcode OutputLoggerLog(ThreadVars *, Packet *, void *)
Definition: output.c:912
void OutputDeregisterAll(void)
Deregister all modules. Useful for a memory clean exit.
Definition: output.c:834
int(* FlowLogger)(ThreadVars *, void *thread_data, Flow *f)
Definition: output-flow.h:32
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:335
int(* PacketLogger)(ThreadVars *, void *thread_data, const Packet *)
Definition: output-packet.h:33
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:616
void OutputLoggerExitPrintStats(ThreadVars *, void *)
Definition: output.c:985
TxLogger TxLogFunc
Definition: output.h:64
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:657
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:158
AppProto alproto
Definition: output.h:71
OutputInitResult(* OutputInitFunc)(ConfNode *)
Definition: output.h:46
const char * name
Definition: output.h:52
int(* TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:32
typedef TAILQ_HEAD(OutputModuleList_, OutputModule_) OutputModuleList
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:741
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:386
int(* FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, const uint8_t *, uint32_t, uint8_t, uint8_t dir)
FlowLogger FlowLogFunc
Definition: output.h:68
TmEcode OutputLoggerThreadInit(ThreadVars *, const void *, void **)
Definition: output.c:928
int(* StreamingLogger)(ThreadVars *, void *thread_data, const Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags)
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.h:60
Definition: conf.h:32
OutputCtx * ctx
Definition: output.h:42
FiledataLogger FiledataLogFunc
Definition: output.h:67
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:324
struct OutputInitResult_ OutputInitResult
#define TAILQ_ENTRY(type)
Definition: queue.h:330
const char * parent_name
Definition: output.h:54
int(* FileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, uint8_t direction)
Definition: output-file.h:33
OutputModuleList output_modules
void TmModuleLoggerRegister(void)
Definition: output.c:1015
FileLogger FileLogFunc
Definition: output.h:66
int(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:37
int OutputDropLoggerEnable(void)
Definition: output.c:846
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
Definition: output.c:866
const char * conf_name
Definition: output.h:53
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:397
StatsLogger StatsLogFunc
Definition: output.h:70
PacketLogCondition PacketConditionFunc
Definition: output.h:63
int(* PacketLogCondition)(ThreadVars *, const Packet *)
Definition: output-packet.h:38
Per thread variable structure.
Definition: threadvars.h:57
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc)
Definition: output.c:999
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:199
void OutputRegisterFlowModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a flow output module.
Definition: output.c:577
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:416
void OutputRegisterModule(const char *, const char *, OutputInitFunc)