suricata
output.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2016 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 OISF, Jason Ish <jason.ish@oisf.net>
22  * \author Endace Technology Limited, Jason Ish <jason.ish@endace.com>
23  *
24  * The root logging output for all non-application logging.
25  *
26  * The loggers are made up of a hierarchy of loggers. At the top we
27  * have the root logger which is the main entry point to
28  * logging. Under the root there exists parent loggers that are the
29  * entry point for specific types of loggers such as packet logger,
30  * transaction loggers, etc. Each parent logger may have 0 or more
31  * loggers that actual handle the job of producing output to something
32  * like a file.
33  */
34 
35 #include "suricata-common.h"
36 #include "flow.h"
37 #include "conf.h"
38 #include "tm-threads.h"
39 #include "util-error.h"
40 #include "util-debug.h"
41 #include "output.h"
42 
43 #include "alert-fastlog.h"
44 #include "alert-debuglog.h"
45 #include "alert-prelude.h"
46 #include "alert-syslog.h"
47 #include "output-json.h"
48 #include "output-json-alert.h"
49 #include "output-json-anomaly.h"
50 #include "output-json-flow.h"
51 #include "output-json-netflow.h"
52 #include "log-cf-common.h"
53 #include "output-json-drop.h"
54 #include "log-httplog.h"
55 #include "output-json-http.h"
56 #include "output-json-dns.h"
57 #include "log-tlslog.h"
58 #include "log-tlsstore.h"
59 #include "output-json-tls.h"
60 #include "output-json-ssh.h"
61 #include "log-pcap.h"
62 #include "output-json-file.h"
63 #include "output-json-smtp.h"
64 #include "output-json-stats.h"
65 #include "log-tcp-data.h"
66 #include "log-stats.h"
67 #include "output-json.h"
68 #include "output-json-nfs.h"
69 #include "output-json-ftp.h"
70 #include "output-json-tftp.h"
71 #include "output-json-smb.h"
72 #include "output-json-ikev2.h"
73 #include "output-json-krb5.h"
74 #include "output-json-dhcp.h"
75 #include "output-json-snmp.h"
76 #include "output-json-sip.h"
77 #include "output-json-rfb.h"
78 #include "output-json-mqtt.h"
79 #include "output-json-template.h"
81 #include "output-json-rdp.h"
82 #include "output-json-http2.h"
83 #include "output-lua.h"
84 #include "output-json-dnp3.h"
85 #include "output-json-metadata.h"
86 #include "output-json-dcerpc.h"
87 #include "output-filestore.h"
88 
89 typedef struct RootLogger_ {
95 
96  TAILQ_ENTRY(RootLogger_) entries;
98 
99 /* List of registered root loggers. These are registered at start up and
100  * are independent of configuration. Later we will build a list of active
101  * loggers based on configuration. */
102 static TAILQ_HEAD(, RootLogger_) registered_loggers =
103  TAILQ_HEAD_INITIALIZER(registered_loggers);
104 
105 /* List of active root loggers. This means that at least one logger is enabled
106  * for each root logger type in the config. */
107 static TAILQ_HEAD(, RootLogger_) active_loggers =
108  TAILQ_HEAD_INITIALIZER(active_loggers);
109 
110 typedef struct LoggerThreadStoreNode_ {
111  void *thread_data;
112  TAILQ_ENTRY(LoggerThreadStoreNode_) entries;
114 
115 typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_) LoggerThreadStore;
116 
117 /**
118  * The list of all registered (known) output modules.
119  */
121 
122 /**
123  * Registry of flags to be updated on file rotation notification.
124  */
125 typedef struct OutputFileRolloverFlag_ {
126  int *flag;
127 
128  TAILQ_ENTRY(OutputFileRolloverFlag_) entries;
130 
131 TAILQ_HEAD(, OutputFileRolloverFlag_) output_file_rotation_flags =
132  TAILQ_HEAD_INITIALIZER(output_file_rotation_flags);
133 
134 void OutputRegisterRootLoggers(void);
135 void OutputRegisterLoggers(void);
136 
137 /**
138  * \brief Register an output module.
139  *
140  * This function will register an output module so it can be
141  * configured with the configuration file.
142  *
143  * \retval Returns 0 on success, -1 on failure.
144  */
145 void OutputRegisterModule(const char *name, const char *conf_name,
146  OutputInitFunc InitFunc)
147 {
148  OutputModule *module = SCCalloc(1, sizeof(*module));
149  if (unlikely(module == NULL))
150  goto error;
151 
152  module->name = name;
153  module->conf_name = conf_name;
154  module->InitFunc = InitFunc;
155  TAILQ_INSERT_TAIL(&output_modules, module, entries);
156 
157  SCLogDebug("Output module \"%s\" registered.", name);
158 
159  return;
160 
161 error:
163  "Fatal error encountered in OutputRegisterModule. Exiting...");
164 }
165 
166 /**
167  * \brief Register a packet output module.
168  *
169  * This function will register an output module so it can be
170  * configured with the configuration file.
171  *
172  * \retval Returns 0 on success, -1 on failure.
173  */
174 void OutputRegisterPacketModule(LoggerId id, const char *name,
175  const char *conf_name, OutputInitFunc InitFunc,
176  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
177  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
178  ThreadExitPrintStatsFunc ThreadExitPrintStats)
179 {
180  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
181  goto error;
182  }
183 
184  OutputModule *module = SCCalloc(1, sizeof(*module));
185  if (unlikely(module == NULL)) {
186  goto error;
187  }
188 
189  module->logger_id = id;
190  module->name = name;
191  module->conf_name = conf_name;
192  module->InitFunc = InitFunc;
193  module->PacketLogFunc = PacketLogFunc;
194  module->PacketConditionFunc = PacketConditionFunc;
195  module->ThreadInit = ThreadInit;
196  module->ThreadDeinit = ThreadDeinit;
197  module->ThreadExitPrintStats = ThreadExitPrintStats;
198  TAILQ_INSERT_TAIL(&output_modules, module, entries);
199 
200  SCLogDebug("Packet logger \"%s\" registered.", name);
201  return;
202 error:
203  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
204 }
205 
206 /**
207  * \brief Register a packet output sub-module.
208  *
209  * This function will register an output module so it can be
210  * configured with the configuration file.
211  *
212  * \retval Returns 0 on success, -1 on failure.
213  */
214 void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
215  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
216  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
217  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
218  ThreadExitPrintStatsFunc ThreadExitPrintStats)
219 {
220  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
221  goto error;
222  }
223 
224  OutputModule *module = SCCalloc(1, sizeof(*module));
225  if (unlikely(module == NULL)) {
226  goto error;
227  }
228 
229  module->logger_id = id;
230  module->name = name;
231  module->conf_name = conf_name;
232  module->parent_name = parent_name;
233  module->InitSubFunc = InitFunc;
234  module->PacketLogFunc = PacketLogFunc;
235  module->PacketConditionFunc = PacketConditionFunc;
236  module->ThreadInit = ThreadInit;
237  module->ThreadDeinit = ThreadDeinit;
238  module->ThreadExitPrintStats = ThreadExitPrintStats;
239  TAILQ_INSERT_TAIL(&output_modules, module, entries);
240 
241  SCLogDebug("Packet logger \"%s\" registered.", name);
242  return;
243 error:
244  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
245 }
246 
247 /**
248  * \brief Wrapper function for tx output modules.
249  *
250  * This function will register an output module so it can be
251  * configured with the configuration file.
252  *
253  * \retval Returns 0 on success, -1 on failure.
254  */
255 static void OutputRegisterTxModuleWrapper(LoggerId id, const char *name,
256  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
257  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
258  TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit,
259  ThreadDeinitFunc ThreadDeinit,
260  ThreadExitPrintStatsFunc ThreadExitPrintStats)
261 {
262  if (unlikely(TxLogFunc == NULL)) {
263  goto error;
264  }
265 
266  OutputModule *module = SCCalloc(1, sizeof(*module));
267  if (unlikely(module == NULL)) {
268  goto error;
269  }
270 
271  module->logger_id = id;
272  module->name = name;
273  module->conf_name = conf_name;
274  module->InitFunc = InitFunc;
275  module->TxLogFunc = TxLogFunc;
276  module->TxLogCondition = TxLogCondition;
277  module->alproto = alproto;
278  module->tc_log_progress = tc_log_progress;
279  module->ts_log_progress = ts_log_progress;
280  module->ThreadInit = ThreadInit;
281  module->ThreadDeinit = ThreadDeinit;
282  module->ThreadExitPrintStats = ThreadExitPrintStats;
283  TAILQ_INSERT_TAIL(&output_modules, module, entries);
284 
285  SCLogDebug("Tx logger \"%s\" registered.", name);
286  return;
287 error:
288  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
289 }
290 
291 static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name,
292  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
293  AppProto alproto, TxLogger TxLogFunc, int tc_log_progress,
294  int ts_log_progress, TxLoggerCondition TxLogCondition,
295  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
296  ThreadExitPrintStatsFunc ThreadExitPrintStats)
297 {
298  if (unlikely(TxLogFunc == NULL)) {
299  goto error;
300  }
301 
302  OutputModule *module = SCCalloc(1, sizeof(*module));
303  if (unlikely(module == NULL)) {
304  goto error;
305  }
306 
307  module->logger_id = id;
308  module->name = name;
309  module->conf_name = conf_name;
310  module->parent_name = parent_name;
311  module->InitSubFunc = InitFunc;
312  module->TxLogFunc = TxLogFunc;
313  module->TxLogCondition = TxLogCondition;
314  module->alproto = alproto;
315  module->tc_log_progress = tc_log_progress;
316  module->ts_log_progress = ts_log_progress;
317  module->ThreadInit = ThreadInit;
318  module->ThreadDeinit = ThreadDeinit;
319  module->ThreadExitPrintStats = ThreadExitPrintStats;
320  TAILQ_INSERT_TAIL(&output_modules, module, entries);
321 
322  SCLogDebug("Tx logger for alproto %d \"%s\" registered.", alproto, name);
323  return;
324 error:
325  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
326 }
327 
328 /**
329  * \brief Register a tx output module with condition.
330  *
331  * This function will register an output module so it can be
332  * configured with the configuration file.
333  *
334  * \retval Returns 0 on success, -1 on failure.
335  */
337  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
338  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
339  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
340  ThreadExitPrintStatsFunc ThreadExitPrintStats)
341 {
342  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
343  TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit,
344  ThreadExitPrintStats);
345 }
346 
348  const char *parent_name, const char *name, const char *conf_name,
349  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
350  TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit,
351  ThreadDeinitFunc ThreadDeinit,
352  ThreadExitPrintStatsFunc ThreadExitPrintStats)
353 {
354  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc,
355  alproto, TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit,
356  ThreadExitPrintStats);
357 }
358 
359 /**
360  * \brief Register a tx output module with progress.
361  *
362  * This function will register an output module so it can be
363  * configured with the configuration file.
364  *
365  * \retval Returns 0 on success, -1 on failure.
366  */
368  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
369  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
370  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
371  ThreadExitPrintStatsFunc ThreadExitPrintStats)
372 {
373  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
374  TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit,
375  ThreadDeinit, ThreadExitPrintStats);
376 }
377 
378 void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name,
379  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
380  AppProto alproto, TxLogger TxLogFunc, int tc_log_progress,
381  int ts_log_progress, ThreadInitFunc ThreadInit,
382  ThreadDeinitFunc ThreadDeinit,
383  ThreadExitPrintStatsFunc ThreadExitPrintStats)
384 {
385  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc,
386  alproto, TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit,
387  ThreadDeinit, ThreadExitPrintStats);
388 }
389 
390 /**
391  * \brief Register a tx output module.
392  *
393  * This function will register an output module so it can be
394  * configured with the configuration file.
395  *
396  * \retval Returns 0 on success, -1 on failure.
397  */
398 void OutputRegisterTxModule(LoggerId id, const char *name,
399  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
400  TxLogger TxLogFunc, ThreadInitFunc ThreadInit,
401  ThreadDeinitFunc ThreadDeinit,
402  ThreadExitPrintStatsFunc ThreadExitPrintStats)
403 {
404  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
405  TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit,
406  ThreadExitPrintStats);
407 }
408 
409 void OutputRegisterTxSubModule(LoggerId id, const char *parent_name,
410  const char *name, const char *conf_name,
411  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
412  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
413  ThreadExitPrintStatsFunc ThreadExitPrintStats)
414 {
415  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name,
416  InitFunc, alproto, TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit,
417  ThreadExitPrintStats);
418 }
419 
420 /**
421  * \brief Register a file output module.
422  *
423  * This function will register an output module so it can be
424  * configured with the configuration file.
425  *
426  * \retval Returns 0 on success, -1 on failure.
427  */
428 void OutputRegisterFileModule(LoggerId id, const char *name,
429  const char *conf_name, OutputInitFunc InitFunc, FileLogger FileLogFunc,
430  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
431  ThreadExitPrintStatsFunc ThreadExitPrintStats)
432 {
433  if (unlikely(FileLogFunc == NULL)) {
434  goto error;
435  }
436 
437  OutputModule *module = SCCalloc(1, sizeof(*module));
438  if (unlikely(module == NULL)) {
439  goto error;
440  }
441 
442  module->logger_id = id;
443  module->name = name;
444  module->conf_name = conf_name;
445  module->InitFunc = InitFunc;
446  module->FileLogFunc = FileLogFunc;
447  module->ThreadInit = ThreadInit;
448  module->ThreadDeinit = ThreadDeinit;
449  module->ThreadExitPrintStats = ThreadExitPrintStats;
450  TAILQ_INSERT_TAIL(&output_modules, module, entries);
451 
452  SCLogDebug("File logger \"%s\" registered.", name);
453  return;
454 error:
455  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
456 }
457 
458 /**
459  * \brief Register a file output sub-module.
460  *
461  * This function will register an output module so it can be
462  * configured with the configuration file.
463  *
464  * \retval Returns 0 on success, -1 on failure.
465  */
466 void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
467  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
468  FileLogger FileLogFunc, ThreadInitFunc ThreadInit,
469  ThreadDeinitFunc ThreadDeinit,
470  ThreadExitPrintStatsFunc ThreadExitPrintStats)
471 {
472  if (unlikely(FileLogFunc == NULL)) {
473  goto error;
474  }
475 
476  OutputModule *module = SCCalloc(1, sizeof(*module));
477  if (unlikely(module == NULL)) {
478  goto error;
479  }
480 
481  module->logger_id = id;
482  module->name = name;
483  module->conf_name = conf_name;
484  module->parent_name = parent_name;
485  module->InitSubFunc = InitFunc;
486  module->FileLogFunc = FileLogFunc;
487  module->ThreadInit = ThreadInit;
488  module->ThreadDeinit = ThreadDeinit;
489  module->ThreadExitPrintStats = ThreadExitPrintStats;
490  TAILQ_INSERT_TAIL(&output_modules, module, entries);
491 
492  SCLogDebug("File logger \"%s\" registered.", name);
493  return;
494 error:
495  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
496 }
497 
498 /**
499  * \brief Register a file data output module.
500  *
501  * This function will register an output module so it can be
502  * configured with the configuration file.
503  *
504  * \retval Returns 0 on success, -1 on failure.
505  */
506 void OutputRegisterFiledataModule(LoggerId id, const char *name,
507  const char *conf_name, OutputInitFunc InitFunc,
508  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
509  ThreadDeinitFunc ThreadDeinit,
510  ThreadExitPrintStatsFunc ThreadExitPrintStats)
511 {
512  if (unlikely(FiledataLogFunc == NULL)) {
513  goto error;
514  }
515 
516  OutputModule *module = SCCalloc(1, sizeof(*module));
517  if (unlikely(module == NULL)) {
518  goto error;
519  }
520 
521  module->logger_id = id;
522  module->name = name;
523  module->conf_name = conf_name;
524  module->InitFunc = InitFunc;
525  module->FiledataLogFunc = FiledataLogFunc;
526  module->ThreadInit = ThreadInit;
527  module->ThreadDeinit = ThreadDeinit;
528  module->ThreadExitPrintStats = ThreadExitPrintStats;
529  TAILQ_INSERT_TAIL(&output_modules, module, entries);
530 
531  SCLogDebug("Filedata logger \"%s\" registered.", name);
532  return;
533 error:
534  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
535 }
536 
537 /**
538  * \brief Register a file data output sub-module.
539  *
540  * This function will register an output module so it can be
541  * configured with the configuration file.
542  *
543  * \retval Returns 0 on success, -1 on failure.
544  */
545 void OutputRegisterFiledataSubModule(LoggerId id, const char *parent_name,
546  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
547  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
548  ThreadDeinitFunc ThreadDeinit,
549  ThreadExitPrintStatsFunc ThreadExitPrintStats)
550 {
551  if (unlikely(FiledataLogFunc == NULL)) {
552  goto error;
553  }
554 
555  OutputModule *module = SCCalloc(1, sizeof(*module));
556  if (unlikely(module == NULL)) {
557  goto error;
558  }
559 
560  module->logger_id = id;
561  module->name = name;
562  module->conf_name = conf_name;
563  module->parent_name = parent_name;
564  module->InitSubFunc = InitFunc;
565  module->FiledataLogFunc = FiledataLogFunc;
566  module->ThreadInit = ThreadInit;
567  module->ThreadDeinit = ThreadDeinit;
568  module->ThreadExitPrintStats = ThreadExitPrintStats;
569  TAILQ_INSERT_TAIL(&output_modules, module, entries);
570 
571  SCLogDebug("Filedata logger \"%s\" registered.", name);
572  return;
573 error:
574  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
575 }
576 
577 /**
578  * \brief Register a flow output sub-module.
579  *
580  * This function will register an output module so it can be
581  * configured with the configuration file.
582  *
583  * \retval Returns 0 on success, -1 on failure.
584  */
585 void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
586  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
587  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
588  ThreadDeinitFunc ThreadDeinit,
589  ThreadExitPrintStatsFunc ThreadExitPrintStats)
590 {
591  if (unlikely(FlowLogFunc == NULL)) {
592  goto error;
593  }
594 
595  OutputModule *module = SCCalloc(1, sizeof(*module));
596  if (unlikely(module == NULL)) {
597  goto error;
598  }
599 
600  module->logger_id = id;
601  module->name = name;
602  module->conf_name = conf_name;
603  module->parent_name = parent_name;
604  module->InitSubFunc = InitFunc;
605  module->FlowLogFunc = FlowLogFunc;
606  module->ThreadInit = ThreadInit;
607  module->ThreadDeinit = ThreadDeinit;
608  module->ThreadExitPrintStats = ThreadExitPrintStats;
609  TAILQ_INSERT_TAIL(&output_modules, module, entries);
610 
611  SCLogDebug("Flow logger \"%s\" registered.", name);
612  return;
613 error:
614  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
615 }
616 
617 /**
618  * \brief Register a streaming data output module.
619  *
620  * This function will register an output module so it can be
621  * configured with the configuration file.
622  *
623  * \retval Returns 0 on success, -1 on failure.
624  */
625 void OutputRegisterStreamingModule(LoggerId id, const char *name,
626  const char *conf_name, OutputInitFunc InitFunc,
627  StreamingLogger StreamingLogFunc,
628  enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit,
629  ThreadDeinitFunc ThreadDeinit,
630  ThreadExitPrintStatsFunc ThreadExitPrintStats)
631 {
632  if (unlikely(StreamingLogFunc == NULL)) {
633  goto error;
634  }
635 
636  OutputModule *module = SCCalloc(1, sizeof(*module));
637  if (unlikely(module == NULL)) {
638  goto error;
639  }
640 
641  module->logger_id = id;
642  module->name = name;
643  module->conf_name = conf_name;
644  module->InitFunc = InitFunc;
645  module->StreamingLogFunc = StreamingLogFunc;
646  module->stream_type = stream_type;
647  module->ThreadInit = ThreadInit;
648  module->ThreadDeinit = ThreadDeinit;
649  module->ThreadExitPrintStats = ThreadExitPrintStats;
650  TAILQ_INSERT_TAIL(&output_modules, module, entries);
651 
652  SCLogDebug("Streaming logger \"%s\" registered.", name);
653  return;
654 error:
655  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
656 }
657 
658 /**
659  * \brief Register a streaming data output sub-module.
660  *
661  * This function will register an output module so it can be
662  * configured with the configuration file.
663  *
664  * \retval Returns 0 on success, -1 on failure.
665  */
666 void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
667  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
668  StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type,
669  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
670  ThreadExitPrintStatsFunc ThreadExitPrintStats)
671 {
672  if (unlikely(StreamingLogFunc == NULL)) {
673  goto error;
674  }
675 
676  OutputModule *module = SCCalloc(1, sizeof(*module));
677  if (unlikely(module == NULL)) {
678  goto error;
679  }
680 
681  module->logger_id = id;
682  module->name = name;
683  module->conf_name = conf_name;
684  module->parent_name = parent_name;
685  module->InitSubFunc = InitFunc;
686  module->StreamingLogFunc = StreamingLogFunc;
687  module->stream_type = stream_type;
688  module->ThreadInit = ThreadInit;
689  module->ThreadDeinit = ThreadDeinit;
690  module->ThreadExitPrintStats = ThreadExitPrintStats;
691  TAILQ_INSERT_TAIL(&output_modules, module, entries);
692 
693  SCLogDebug("Streaming logger \"%s\" registered.", name);
694  return;
695 error:
696  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
697 }
698 
699 /**
700  * \brief Register a stats data output module.
701  *
702  * This function will register an output module so it can be
703  * configured with the configuration file.
704  *
705  * \retval Returns 0 on success, -1 on failure.
706  */
707 void OutputRegisterStatsModule(LoggerId id, const char *name,
708  const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc,
709  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
710  ThreadExitPrintStatsFunc ThreadExitPrintStats)
711 {
712  if (unlikely(StatsLogFunc == NULL)) {
713  goto error;
714  }
715 
716  OutputModule *module = SCCalloc(1, sizeof(*module));
717  if (unlikely(module == NULL)) {
718  goto error;
719  }
720 
721  module->logger_id = id;
722  module->name = name;
723  module->conf_name = conf_name;
724  module->InitFunc = InitFunc;
725  module->StatsLogFunc = StatsLogFunc;
726  module->ThreadInit = ThreadInit;
727  module->ThreadDeinit = ThreadDeinit;
728  module->ThreadExitPrintStats = ThreadExitPrintStats;
729  TAILQ_INSERT_TAIL(&output_modules, module, entries);
730 
731  SCLogDebug("Stats logger \"%s\" registered.", name);
732  return;
733 error:
734  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
735 }
736 
737 /**
738  * \brief Register a stats data output sub-module.
739  *
740  * This function will register an output module so it can be
741  * configured with the configuration file.
742  *
743  * \retval Returns 0 on success, -1 on failure.
744  */
745 void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
746  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
747  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
748  ThreadDeinitFunc ThreadDeinit,
749  ThreadExitPrintStatsFunc ThreadExitPrintStats)
750 {
751  if (unlikely(StatsLogFunc == NULL)) {
752  goto error;
753  }
754 
755  OutputModule *module = SCCalloc(1, sizeof(*module));
756  if (unlikely(module == NULL)) {
757  goto error;
758  }
759 
760  module->logger_id = id;
761  module->name = name;
762  module->conf_name = conf_name;
763  module->parent_name = parent_name;
764  module->InitSubFunc = InitFunc;
765  module->StatsLogFunc = StatsLogFunc;
766  module->ThreadInit = ThreadInit;
767  module->ThreadDeinit = ThreadDeinit;
768  module->ThreadExitPrintStats = ThreadExitPrintStats;
769  TAILQ_INSERT_TAIL(&output_modules, module, entries);
770 
771  SCLogDebug("Stats logger \"%s\" registered.", name);
772  return;
773 error:
774  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
775 }
776 
777 /**
778  * \brief Get an output module by name.
779  *
780  * \retval The OutputModule with the given name or NULL if no output module
781  * with the given name is registered.
782  */
784 {
785  OutputModule *module;
786 
787  TAILQ_FOREACH(module, &output_modules, entries) {
788  if (strcmp(module->conf_name, conf_name) == 0)
789  return module;
790  }
791 
792  return NULL;
793 }
794 
795 /**
796  * \brief Deregister all modules. Useful for a memory clean exit.
797  */
799 {
800  OutputModule *module;
801 
802  while ((module = TAILQ_FIRST(&output_modules))) {
803  TAILQ_REMOVE(&output_modules, module, entries);
804  SCFree(module);
805  }
806 }
807 
808 static int drop_loggers = 0;
809 
811 {
812  if (drop_loggers)
813  return -1;
814  drop_loggers++;
815  return 0;
816 }
817 
819 {
820  if (drop_loggers)
821  drop_loggers--;
822 }
823 
824 /**
825  * \brief Register a flag for file rotation notification.
826  *
827  * \param flag A pointer that will be set to 1 when file rotation is
828  * requested.
829  */
831 {
832  OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
833  if (unlikely(flag_entry == NULL)) {
835  "Failed to allocate memory to register file rotation flag");
836  return;
837  }
838  flag_entry->flag = flag;
839  TAILQ_INSERT_TAIL(&output_file_rotation_flags, flag_entry, entries);
840 }
841 
842 /**
843  * \brief Unregister a file rotation flag.
844  *
845  * Note that it is safe to call this function with a flag that may not
846  * have been registered, in which case this function won't do
847  * anything.
848  *
849  * \param flag A pointer that has been previously registered for file
850  * rotation notifications.
851  */
853 {
854  OutputFileRolloverFlag *entry, *next;
855  for (entry = TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
856  entry = next) {
857  next = TAILQ_NEXT(entry, entries);
858  if (entry->flag == flag) {
859  TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
860  SCFree(entry);
861  break;
862  }
863  }
864 }
865 
866 /**
867  * \brief Notifies all registered file rotation notification flags.
868  */
871  TAILQ_FOREACH(flag, &output_file_rotation_flags, entries) {
872  *(flag->flag) = 1;
873  }
874 }
875 
876 TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
877 {
878  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
879  RootLogger *logger = TAILQ_FIRST(&active_loggers);
880  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
881  while (logger && thread_store_node) {
882  logger->LogFunc(tv, p, thread_store_node->thread_data);
883 
884  logger = TAILQ_NEXT(logger, entries);
885  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
886  }
887 
888  return TM_ECODE_OK;
889 }
890 
891 TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
892 {
893  LoggerThreadStore *thread_store = SCCalloc(1, sizeof(*thread_store));
894  if (thread_store == NULL) {
895  return TM_ECODE_FAILED;
896  }
897  TAILQ_INIT(thread_store);
898  *data = (void *)thread_store;
899 
900  RootLogger *logger;
901  TAILQ_FOREACH(logger, &active_loggers, entries) {
902 
903  void *child_thread_data = NULL;
904  if (logger->ThreadInit != NULL) {
905  if (logger->ThreadInit(tv, initdata, &child_thread_data) == TM_ECODE_OK) {
906  LoggerThreadStoreNode *thread_store_node =
907  SCCalloc(1, sizeof(*thread_store_node));
908  if (thread_store_node == NULL) {
909  /* Undo everything, calling de-init will take care
910  * of that. */
911  OutputLoggerThreadDeinit(tv, thread_store);
912  return TM_ECODE_FAILED;
913  }
914  thread_store_node->thread_data = child_thread_data;
915  TAILQ_INSERT_TAIL(thread_store, thread_store_node, entries);
916  }
917  }
918  }
919  return TM_ECODE_OK;
920 }
921 
923 {
924  if (thread_data == NULL)
925  return TM_ECODE_FAILED;
926 
927  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
928  RootLogger *logger = TAILQ_FIRST(&active_loggers);
929  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
930  while (logger && thread_store_node) {
931  if (logger->ThreadDeinit != NULL) {
932  logger->ThreadDeinit(tv, thread_store_node->thread_data);
933  }
934  logger = TAILQ_NEXT(logger, entries);
935  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
936  }
937 
938  /* Free the thread store. */
939  while ((thread_store_node = TAILQ_FIRST(thread_store)) != NULL) {
940  TAILQ_REMOVE(thread_store, thread_store_node, entries);
941  SCFree(thread_store_node);
942  }
943  SCFree(thread_store);
944 
945  return TM_ECODE_OK;
946 }
947 
948 void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
949 {
950  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
951  RootLogger *logger = TAILQ_FIRST(&active_loggers);
952  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
953  while (logger && thread_store_node) {
954  if (logger->ThreadExitPrintStats != NULL) {
955  logger->ThreadExitPrintStats(tv, thread_store_node->thread_data);
956  }
957  logger = TAILQ_NEXT(logger, entries);
958  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
959  }
960 }
961 
963  ThreadDeinitFunc ThreadDeinit,
964  ThreadExitPrintStatsFunc ThreadExitPrintStats,
965  OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
966 {
967  BUG_ON(LogFunc == NULL);
968 
969  RootLogger *logger = SCCalloc(1, sizeof(*logger));
970  if (logger == NULL) {
971  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
972  }
973  logger->ThreadInit = ThreadInit;
974  logger->ThreadDeinit = ThreadDeinit;
975  logger->ThreadExitPrintStats = ThreadExitPrintStats;
976  logger->LogFunc = LogFunc;
977  logger->ActiveCntFunc = ActiveCntFunc;
978  TAILQ_INSERT_TAIL(&registered_loggers, logger, entries);
979 }
980 
981 static void OutputRegisterActiveLogger(RootLogger *reg)
982 {
983  RootLogger *logger = SCCalloc(1, sizeof(*logger));
984  if (logger == NULL) {
985  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
986  }
987  logger->ThreadInit = reg->ThreadInit;
988  logger->ThreadDeinit = reg->ThreadDeinit;
990  logger->LogFunc = reg->LogFunc;
991  logger->ActiveCntFunc = reg->ActiveCntFunc;
992  TAILQ_INSERT_TAIL(&active_loggers, logger, entries);
993 }
994 
996 {
997  RootLogger *logger = TAILQ_FIRST(&registered_loggers);
998  while (logger) {
999  uint32_t cnt = logger->ActiveCntFunc();
1000  if (cnt) {
1001  OutputRegisterActiveLogger(logger);
1002  }
1003 
1004  logger = TAILQ_NEXT(logger, entries);
1005  }
1006 }
1007 
1009 {
1010  RootLogger *logger;
1011  while ((logger = TAILQ_FIRST(&active_loggers)) != NULL) {
1012  TAILQ_REMOVE(&active_loggers, logger, entries);
1013  SCFree(logger);
1014  }
1015 }
1016 
1018 {
1021 }
1022 
1023 /**
1024  * \brief Register all root loggers.
1025  */
1027 {
1033 }
1034 
1035 /**
1036  * \brief Register all non-root logging modules.
1037  */
1039 {
1040  /* custom format log*/
1042 
1043  LuaLogRegister();
1044  /* fast log */
1046  /* debug log */
1048  /* prelue log */
1050  /* syslog log */
1053  /* json log */
1055  /* email logs */
1057  /* http log */
1061  /* tls log */
1065  /* ssh */
1067  /* pcap log */
1068  PcapLogRegister();
1069  /* file log */
1072  /* dns */
1074  /* tcp streaming data */
1076  /* log stats */
1078 
1081  /* flow/netflow */
1084  /* json stats */
1086 
1087  /* DNP3. */
1090 
1091  /* NFS JSON logger. */
1093  /* TFTP JSON logger. */
1095  /* FTP JSON logger. */
1097  /* SMB JSON logger. */
1099  /* IKEv2 JSON logger. */
1101  /* KRB5 JSON logger. */
1103  /* DHCP JSON logger. */
1105  /* SNMP JSON logger. */
1107  /* SIP JSON logger. */
1109  /* RFB JSON logger. */
1111  /* MQTT JSON logger. */
1113  /* Template JSON logger. */
1115  /* Template Rust JSON logger. */
1117  /* RDP JSON logger. */
1119  /* DCERPC JSON logger. */
1121 }
RootLogger_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.c:92
log-stats.h
OutputModule_::parent_name
const char * parent_name
Definition: output.h:57
OutputFileRolloverFlag
OutputFileRolloverFlag
Definition: output.c:129
LogTlsStoreRegister
void LogTlsStoreRegister(void)
Definition: log-tlsstore.c:413
tm-threads.h
output-json-ftp.h
OutputDropLoggerEnable
int OutputDropLoggerEnable(void)
Definition: output.c:810
LoggerThreadStoreNode
LoggerThreadStoreNode
Definition: output.c:113
OutputLogFunc
TmEcode(* OutputLogFunc)(ThreadVars *, Packet *, void *)
Definition: output.h:50
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
JsonDCERPCLogRegister
void JsonDCERPCLogRegister(void)
Definition: output-json-dcerpc.c:78
OutputTxLoggerRegister
void OutputTxLoggerRegister(void)
Definition: output-tx.c:448
alert-debuglog.h
TAILQ_INIT
#define TAILQ_INIT(head)
Definition: queue.h:370
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
JsonSMBLogRegister
void JsonSMBLogRegister(void)
Definition: output-json-smb.c:97
OutputLoggerExitPrintStats
void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
Definition: output.c:948
output-json-mqtt.h
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
OutputFileLoggerRegister
void OutputFileLoggerRegister(void)
Definition: output-file.c:289
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:73
OutputModule_::name
const char * name
Definition: output.h:55
OutputModule_::StreamingLogFunc
StreamingLogger StreamingLogFunc
Definition: output.h:72
LogTlsLogRegister
void LogTlsLogRegister(void)
Definition: log-tlslog.c:536
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
AlertFastLogRegister
void AlertFastLogRegister(void)
Definition: alert-fastlog.c:75
JsonFileLogRegister
void JsonFileLogRegister(void)
Definition: output-json-file.c:351
JsonRdpLogRegister
void JsonRdpLogRegister(void)
Definition: output-json-rdp.c:163
OutputModule_::ts_log_progress
int ts_log_progress
Definition: output.h:77
JsonSNMPLogRegister
void JsonSNMPLogRegister(void)
Definition: output-json-snmp.c:178
output-json-netflow.h
JsonDNP3LogRegister
void JsonDNP3LogRegister(void)
Definition: output-json-dnp3.c:357
LogCustomFormatRegister
void LogCustomFormatRegister(void)
Definition: log-cf-common.c:269
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:350
output-json-krb5.h
OutputGetModuleByConfName
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
Definition: output.c:783
output-json-tls.h
OutputSetupActiveLoggers
void OutputSetupActiveLoggers(void)
Definition: output.c:995
AlertSyslogRegister
void AlertSyslogRegister(void)
Function to register the AlertSyslog module.
Definition: alert-syslog.c:394
OutputModule_::StatsLogFunc
StatsLogger StatsLogFunc
Definition: output.h:73
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
output-json-sip.h
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
JsonDHCPLogRegister
void JsonDHCPLogRegister(void)
Definition: output-json-dhcp.c:175
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
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
TAILQ_INSERT_TAIL
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:385
JsonSshLogRegister
void JsonSshLogRegister(void)
Definition: output-json-ssh.c:185
PcapLogRegister
void PcapLogRegister(void)
Definition: log-pcap.c:205
OutputModule_::InitSubFunc
OutputInitSubFunc InitSubFunc
Definition: output.h:59
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
JsonTemplateRustLogRegister
void JsonTemplateRustLogRegister(void)
Definition: output-json-template-rust.c:179
OutputModule_::PacketLogFunc
PacketLogger PacketLogFunc
Definition: output.h:65
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:81
JsonStatsLogRegister
void JsonStatsLogRegister(void)
Definition: output-json-stats.c:454
output-json-tftp.h
LogTcpDataLogRegister
void LogTcpDataLogRegister(void)
Definition: log-tcp-data.c:62
OutputRegisterRootLoggers
void OutputRegisterRootLoggers(void)
Register all root loggers.
Definition: output.c:1026
OutputLoggerThreadDeinit
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output.c:922
OutputModule_::alproto
AppProto alproto
Definition: output.h:74
JsonTlsLogRegister
void JsonTlsLogRegister(void)
Definition: output-json-tls.c:602
alert-syslog.h
JsonFlowLogRegister
void JsonFlowLogRegister(void)
Definition: output-json-flow.c:434
TmModuleLoggerRegister
void TmModuleLoggerRegister(void)
Definition: output.c:1017
output-json-rdp.h
output-json-dcerpc.h
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:80
OutputJsonRegister
void OutputJsonRegister(void)
Definition: output-json.c:91
OutputClearActiveLoggers
void OutputClearActiveLoggers(void)
Definition: output.c:1008
OutputModule_::stream_type
enum OutputStreamingType stream_type
Definition: output.h:75
TAILQ_ENTRY
#define TAILQ_ENTRY(type)
Definition: queue.h:330
RootLogger_::LogFunc
OutputLogFunc LogFunc
Definition: output.c:90
output-json-dnp3.h
OutputRegisterFileRotationFlag
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
Definition: output.c:830
LogHttpLogRegister
void LogHttpLogRegister(void)
Definition: log-httplog.c:66
OutputModule_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.h:61
TAILQ_HEAD_INITIALIZER
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:327
output_modules
OutputModuleList output_modules
OutputInitSubFunc
OutputInitResult(* OutputInitSubFunc)(ConfNode *, OutputCtx *)
Definition: output.h:49
JsonAnomalyLogRegister
void JsonAnomalyLogRegister(void)
Definition: output-json-anomaly.c:474
TAILQ_REMOVE
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:412
OutputModule_::FiledataLogFunc
FiledataLogger FiledataLogFunc
Definition: output.h:70
util-debug.h
output-json-flow.h
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:339
OutputStreamingLoggerRegister
void OutputStreamingLoggerRegister(void)
Definition: output-streaming.c:460
util-error.h
OutputRegisterFiledataSubModule
void OutputRegisterFiledataSubModule(LoggerId id, 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
log-tcp-data.h
output-json-rfb.h
JsonTFTPLogRegister
void JsonTFTPLogRegister(void)
Definition: output-json-tftp.c:177
OutputModule_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.h:62
output-json-template.h
output-json.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-json-file.h
OutputRegisterModule
void OutputRegisterModule(const char *, const char *, OutputInitFunc)
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
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
ThreadInitFunc
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
log-tlslog.h
OutputLoggerThreadInit
TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
Definition: output.c:891
JsonMQTTLogRegister
void JsonMQTTLogRegister(void)
Definition: output-json-mqtt.c:195
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:282
OutputFilestoreRegister
void OutputFilestoreRegister(void)
Definition: output-filestore.c:540
OutputRegisterLoggers
void OutputRegisterLoggers(void)
Register all non-root logging modules.
Definition: output.c:1038
AlertPreludeRegister
void AlertPreludeRegister(void)
Definition: alert-prelude.c:1309
output-json-ikev2.h
OutputModule_::conf_name
const char * conf_name
Definition: output.h:56
output-json-anomaly.h
OutputModule_::FlowLogFunc
FlowLogger FlowLogFunc
Definition: output.h:71
OutputDeregisterAll
void OutputDeregisterAll(void)
Deregister all modules. Useful for a memory clean exit.
Definition: output.c:798
Packet_
Definition: decode.h:414
RootLogger_::ActiveCntFunc
OutputGetActiveCountFunc ActiveCntFunc
Definition: output.c:94
OutputPacketLoggerRegister
void OutputPacketLoggerRegister(void)
Definition: output-packet.c:222
conf.h
OutputNotifyFileRotation
void OutputNotifyFileRotation(void)
Notifies all registered file rotation notification flags.
Definition: output.c:869
TAILQ_HEAD
typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_)
Definition: output.c:115
TmEcode
TmEcode
Definition: tm-threads-common.h:79
OutputModule_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.h:63
RootLogger_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.c:91
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
alert-prelude.h
log-pcap.h
alert-fastlog.h
LogStatsLogRegister
void LogStatsLogRegister(void)
Definition: log-stats.c:290
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
OutputModule_::TxLogCondition
TxLoggerCondition TxLogCondition
Definition: output.h:68
suricata-common.h
output-json-stats.h
OutputRegisterPacketSubModule
void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output sub-module.
Definition: output.c:214
output-json-nfs.h
ThreadExitPrintStatsFunc
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
Definition: tm-modules.h:41
TAILQ_NEXT
#define TAILQ_NEXT(elm, field)
Definition: queue.h:341
RootLogger_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.c:93
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
output-filestore.h
FileLogger
int(* FileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, uint8_t direction)
Definition: output-file.h:33
FatalError
#define FatalError(x,...)
Definition: util-debug.h:532
LuaLogRegister
void LuaLogRegister(void)
Definition: output-lua.c:947
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
JsonSmtpLogRegister
void JsonSmtpLogRegister(void)
Definition: output-json-smtp.c:205
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
log-httplog.h
JsonMetadataLogRegister
void JsonMetadataLogRegister(void)
Definition: output-json-metadata.c:214
output-json-alert.h
OutputModule_::PacketConditionFunc
PacketLogCondition PacketConditionFunc
Definition: output.h:66
OutputRegisterPacketModule
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output module.
Definition: output.c:174
RootLogger
struct RootLogger_ RootLogger
output-json-dns.h
output-json-http2.h
OutputGetActiveCountFunc
uint32_t(* OutputGetActiveCountFunc)(void)
Definition: output.h:51
JsonHttp2LogRegister
void JsonHttp2LogRegister(void)
Definition: output-json-http2.c:236
TxLoggerCondition
int(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:37
log-cf-common.h
output-json-metadata.h
OutputStreamingType
OutputStreamingType
Definition: output-streaming.h:38
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
JsonDnsLogRegister
void JsonDnsLogRegister(void)
Definition: output-json-dns.c:646
OutputLoggerLog
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
Definition: output.c:876
SCFree
#define SCFree(p)
Definition: util-mem.h:61
output-json-dhcp.h
SC_ERR_FATAL
@ SC_ERR_FATAL
Definition: util-error.h:203
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
JsonDropLogRegister
void JsonDropLogRegister(void)
Definition: output-json-drop.c:378
output-json-template-rust.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
JsonIKEv2LogRegister
void JsonIKEv2LogRegister(void)
Definition: output-json-ikev2.c:177
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
OutputInitFunc
OutputInitResult(* OutputInitFunc)(ConfNode *)
Definition: output.h:48
PacketLogCondition
int(* PacketLogCondition)(ThreadVars *, const Packet *)
Definition: output-packet.h:38
JsonFTPLogRegister
void JsonFTPLogRegister(void)
Definition: output-json-ftp.c:279
output-json-ssh.h
output-lua.h
OutputRegisterRootLogger
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
Definition: output.c:962
JsonRFBLogRegister
void JsonRFBLogRegister(void)
Definition: output-json-rfb.c:179
SC_ERR_MEM_ALLOC
@ SC_ERR_MEM_ALLOC
Definition: util-error.h:31
JsonHttpLogRegister
void JsonHttpLogRegister(void)
Definition: output-json-http.c:690
JsonTemplateLogRegister
void JsonTemplateLogRegister(void)
Definition: output-json-template.c:187
output-json-smb.h
output-json-smtp.h
output-json-http.h
flow.h
OutputModule_
Definition: output.h:53
AlertDebugLogRegister
void AlertDebugLogRegister(void)
Definition: alert-debuglog.c:484
OutputUnregisterFileRotationFlag
void OutputUnregisterFileRotationFlag(int *flag)
Unregister a file rotation flag.
Definition: output.c:852
log-tlsstore.h
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
OutputFiledataLoggerRegister
void OutputFiledataLoggerRegister(void)
Definition: output-filedata.c:461
JsonSIPLogRegister
void JsonSIPLogRegister(void)
Definition: output-json-sip.c:188
JsonKRB5LogRegister
void JsonKRB5LogRegister(void)
Definition: output-json-krb5.c:178
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
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
output-json-snmp.h
output.h
JsonAlertLogRegister
void JsonAlertLogRegister(void)
Definition: output-json-alert.c:1016
JsonNFSLogRegister
void JsonNFSLogRegister(void)
Definition: output-json-nfs.c:112
OutputDropLoggerDisable
void OutputDropLoggerDisable(void)
Definition: output.c:818
JsonNetFlowLogRegister
void JsonNetFlowLogRegister(void)
Definition: output-json-netflow.c:392
ThreadDeinitFunc
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
OutputModule_::InitFunc
OutputInitFunc InitFunc
Definition: output.h:58
RootLogger_
Definition: output.c:89
output-json-drop.h