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