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 "output-json-modbus.h"
58 #include "log-tlslog.h"
59 #include "log-tlsstore.h"
60 #include "output-json-tls.h"
61 #include "output-json-ssh.h"
62 #include "log-pcap.h"
63 #include "output-json-file.h"
64 #include "output-json-smtp.h"
65 #include "output-json-stats.h"
66 #include "log-tcp-data.h"
67 #include "log-stats.h"
68 #include "output-json.h"
69 #include "output-json-nfs.h"
70 #include "output-json-ftp.h"
71 #include "output-json-tftp.h"
72 #include "output-json-smb.h"
73 #include "output-json-ike.h"
74 #include "output-json-krb5.h"
75 #include "output-json-dhcp.h"
76 #include "output-json-snmp.h"
77 #include "output-json-sip.h"
78 #include "output-json-rfb.h"
79 #include "output-json-mqtt.h"
80 #include "output-json-template.h"
82 #include "output-json-rdp.h"
83 #include "output-json-http2.h"
84 #include "output-lua.h"
85 #include "output-json-dnp3.h"
86 #include "output-json-metadata.h"
87 #include "output-json-dcerpc.h"
88 #include "output-filestore.h"
89 
90 typedef struct RootLogger_ {
96 
97  TAILQ_ENTRY(RootLogger_) entries;
99 
100 /* List of registered root loggers. These are registered at start up and
101  * are independent of configuration. Later we will build a list of active
102  * loggers based on configuration. */
103 static TAILQ_HEAD(, RootLogger_) registered_loggers =
104  TAILQ_HEAD_INITIALIZER(registered_loggers);
105 
106 /* List of active root loggers. This means that at least one logger is enabled
107  * for each root logger type in the config. */
108 static TAILQ_HEAD(, RootLogger_) active_loggers =
109  TAILQ_HEAD_INITIALIZER(active_loggers);
110 
111 typedef struct LoggerThreadStoreNode_ {
112  void *thread_data;
113  TAILQ_ENTRY(LoggerThreadStoreNode_) entries;
115 
116 typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_) LoggerThreadStore;
117 
118 /**
119  * The list of all registered (known) output modules.
120  */
122 
123 /**
124  * Registry of flags to be updated on file rotation notification.
125  */
126 typedef struct OutputFileRolloverFlag_ {
127  int *flag;
128 
129  TAILQ_ENTRY(OutputFileRolloverFlag_) entries;
131 
132 TAILQ_HEAD(, OutputFileRolloverFlag_) output_file_rotation_flags =
133  TAILQ_HEAD_INITIALIZER(output_file_rotation_flags);
134 
135 void OutputRegisterRootLoggers(void);
136 void OutputRegisterLoggers(void);
137 
138 /**
139  * \brief Register an output module.
140  *
141  * This function will register an output module so it can be
142  * configured with the configuration file.
143  *
144  * \retval Returns 0 on success, -1 on failure.
145  */
146 void OutputRegisterModule(const char *name, const char *conf_name,
147  OutputInitFunc InitFunc)
148 {
149  OutputModule *module = SCCalloc(1, sizeof(*module));
150  if (unlikely(module == NULL))
151  goto error;
152 
153  module->name = name;
154  module->conf_name = conf_name;
155  module->InitFunc = InitFunc;
156  TAILQ_INSERT_TAIL(&output_modules, module, entries);
157 
158  SCLogDebug("Output module \"%s\" registered.", name);
159 
160  return;
161 
162 error:
164  "Fatal error encountered in OutputRegisterModule. Exiting...");
165 }
166 
167 /**
168  * \brief Register a packet output module.
169  *
170  * This function will register an output module so it can be
171  * configured with the configuration file.
172  *
173  * \retval Returns 0 on success, -1 on failure.
174  */
175 void OutputRegisterPacketModule(LoggerId id, const char *name,
176  const char *conf_name, OutputInitFunc InitFunc,
177  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
178  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
179  ThreadExitPrintStatsFunc ThreadExitPrintStats)
180 {
181  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
182  goto error;
183  }
184 
185  OutputModule *module = SCCalloc(1, sizeof(*module));
186  if (unlikely(module == NULL)) {
187  goto error;
188  }
189 
190  module->logger_id = id;
191  module->name = name;
192  module->conf_name = conf_name;
193  module->InitFunc = InitFunc;
194  module->PacketLogFunc = PacketLogFunc;
195  module->PacketConditionFunc = PacketConditionFunc;
196  module->ThreadInit = ThreadInit;
197  module->ThreadDeinit = ThreadDeinit;
198  module->ThreadExitPrintStats = ThreadExitPrintStats;
199  TAILQ_INSERT_TAIL(&output_modules, module, entries);
200 
201  SCLogDebug("Packet logger \"%s\" registered.", name);
202  return;
203 error:
204  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
205 }
206 
207 /**
208  * \brief Register a packet output sub-module.
209  *
210  * This function will register an output module so it can be
211  * configured with the configuration file.
212  *
213  * \retval Returns 0 on success, -1 on failure.
214  */
215 void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
216  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
217  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
218  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
219  ThreadExitPrintStatsFunc ThreadExitPrintStats)
220 {
221  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
222  goto error;
223  }
224 
225  OutputModule *module = SCCalloc(1, sizeof(*module));
226  if (unlikely(module == NULL)) {
227  goto error;
228  }
229 
230  module->logger_id = id;
231  module->name = name;
232  module->conf_name = conf_name;
233  module->parent_name = parent_name;
234  module->InitSubFunc = InitFunc;
235  module->PacketLogFunc = PacketLogFunc;
236  module->PacketConditionFunc = PacketConditionFunc;
237  module->ThreadInit = ThreadInit;
238  module->ThreadDeinit = ThreadDeinit;
239  module->ThreadExitPrintStats = ThreadExitPrintStats;
240  TAILQ_INSERT_TAIL(&output_modules, module, entries);
241 
242  SCLogDebug("Packet logger \"%s\" registered.", name);
243  return;
244 error:
245  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
246 }
247 
248 /**
249  * \brief Wrapper function for tx output modules.
250  *
251  * This function will register an output module so it can be
252  * configured with the configuration file.
253  *
254  * \retval Returns 0 on success, -1 on failure.
255  */
256 static void OutputRegisterTxModuleWrapper(LoggerId id, const char *name,
257  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
258  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
259  TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit,
260  ThreadDeinitFunc ThreadDeinit,
261  ThreadExitPrintStatsFunc ThreadExitPrintStats)
262 {
263  if (unlikely(TxLogFunc == NULL)) {
264  goto error;
265  }
266 
267  OutputModule *module = SCCalloc(1, sizeof(*module));
268  if (unlikely(module == NULL)) {
269  goto error;
270  }
271 
272  module->logger_id = id;
273  module->name = name;
274  module->conf_name = conf_name;
275  module->InitFunc = InitFunc;
276  module->TxLogFunc = TxLogFunc;
277  module->TxLogCondition = TxLogCondition;
278  module->alproto = alproto;
279  module->tc_log_progress = tc_log_progress;
280  module->ts_log_progress = ts_log_progress;
281  module->ThreadInit = ThreadInit;
282  module->ThreadDeinit = ThreadDeinit;
283  module->ThreadExitPrintStats = ThreadExitPrintStats;
284  TAILQ_INSERT_TAIL(&output_modules, module, entries);
285 
286  SCLogDebug("Tx logger \"%s\" registered.", name);
287  return;
288 error:
289  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
290 }
291 
292 static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name,
293  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
294  AppProto alproto, TxLogger TxLogFunc, int tc_log_progress,
295  int ts_log_progress, TxLoggerCondition TxLogCondition,
296  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
297  ThreadExitPrintStatsFunc ThreadExitPrintStats)
298 {
299  if (unlikely(TxLogFunc == NULL)) {
300  goto error;
301  }
302 
303  OutputModule *module = SCCalloc(1, sizeof(*module));
304  if (unlikely(module == NULL)) {
305  goto error;
306  }
307 
308  module->logger_id = id;
309  module->name = name;
310  module->conf_name = conf_name;
311  module->parent_name = parent_name;
312  module->InitSubFunc = InitFunc;
313  module->TxLogFunc = TxLogFunc;
314  module->TxLogCondition = TxLogCondition;
315  module->alproto = alproto;
316  module->tc_log_progress = tc_log_progress;
317  module->ts_log_progress = ts_log_progress;
318  module->ThreadInit = ThreadInit;
319  module->ThreadDeinit = ThreadDeinit;
320  module->ThreadExitPrintStats = ThreadExitPrintStats;
321  TAILQ_INSERT_TAIL(&output_modules, module, entries);
322 
323  SCLogDebug("Tx logger for alproto %d \"%s\" registered.", alproto, name);
324  return;
325 error:
326  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
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  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
457 }
458 
459 /**
460  * \brief Register a file output sub-module.
461  *
462  * This function will register an output module so it can be
463  * configured with the configuration file.
464  *
465  * \retval Returns 0 on success, -1 on failure.
466  */
467 void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
468  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
469  FileLogger FileLogFunc, ThreadInitFunc ThreadInit,
470  ThreadDeinitFunc ThreadDeinit,
471  ThreadExitPrintStatsFunc ThreadExitPrintStats)
472 {
473  if (unlikely(FileLogFunc == NULL)) {
474  goto error;
475  }
476 
477  OutputModule *module = SCCalloc(1, sizeof(*module));
478  if (unlikely(module == NULL)) {
479  goto error;
480  }
481 
482  module->logger_id = id;
483  module->name = name;
484  module->conf_name = conf_name;
485  module->parent_name = parent_name;
486  module->InitSubFunc = InitFunc;
487  module->FileLogFunc = FileLogFunc;
488  module->ThreadInit = ThreadInit;
489  module->ThreadDeinit = ThreadDeinit;
490  module->ThreadExitPrintStats = ThreadExitPrintStats;
491  TAILQ_INSERT_TAIL(&output_modules, module, entries);
492 
493  SCLogDebug("File logger \"%s\" registered.", name);
494  return;
495 error:
496  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
497 }
498 
499 /**
500  * \brief Register a file data output module.
501  *
502  * This function will register an output module so it can be
503  * configured with the configuration file.
504  *
505  * \retval Returns 0 on success, -1 on failure.
506  */
507 void OutputRegisterFiledataModule(LoggerId id, const char *name,
508  const char *conf_name, OutputInitFunc InitFunc,
509  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
510  ThreadDeinitFunc ThreadDeinit,
511  ThreadExitPrintStatsFunc ThreadExitPrintStats)
512 {
513  if (unlikely(FiledataLogFunc == NULL)) {
514  goto error;
515  }
516 
517  OutputModule *module = SCCalloc(1, sizeof(*module));
518  if (unlikely(module == NULL)) {
519  goto error;
520  }
521 
522  module->logger_id = id;
523  module->name = name;
524  module->conf_name = conf_name;
525  module->InitFunc = InitFunc;
526  module->FiledataLogFunc = FiledataLogFunc;
527  module->ThreadInit = ThreadInit;
528  module->ThreadDeinit = ThreadDeinit;
529  module->ThreadExitPrintStats = ThreadExitPrintStats;
530  TAILQ_INSERT_TAIL(&output_modules, module, entries);
531 
532  SCLogDebug("Filedata logger \"%s\" registered.", name);
533  return;
534 error:
535  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
536 }
537 
538 /**
539  * \brief Register a file data output sub-module.
540  *
541  * This function will register an output module so it can be
542  * configured with the configuration file.
543  *
544  * \retval Returns 0 on success, -1 on failure.
545  */
546 void OutputRegisterFiledataSubModule(LoggerId id, const char *parent_name,
547  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
548  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
549  ThreadDeinitFunc ThreadDeinit,
550  ThreadExitPrintStatsFunc ThreadExitPrintStats)
551 {
552  if (unlikely(FiledataLogFunc == NULL)) {
553  goto error;
554  }
555 
556  OutputModule *module = SCCalloc(1, sizeof(*module));
557  if (unlikely(module == NULL)) {
558  goto error;
559  }
560 
561  module->logger_id = id;
562  module->name = name;
563  module->conf_name = conf_name;
564  module->parent_name = parent_name;
565  module->InitSubFunc = InitFunc;
566  module->FiledataLogFunc = FiledataLogFunc;
567  module->ThreadInit = ThreadInit;
568  module->ThreadDeinit = ThreadDeinit;
569  module->ThreadExitPrintStats = ThreadExitPrintStats;
570  TAILQ_INSERT_TAIL(&output_modules, module, entries);
571 
572  SCLogDebug("Filedata logger \"%s\" registered.", name);
573  return;
574 error:
575  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
576 }
577 
578 /**
579  * \brief Register a flow output sub-module.
580  *
581  * This function will register an output module so it can be
582  * configured with the configuration file.
583  *
584  * \retval Returns 0 on success, -1 on failure.
585  */
586 void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
587  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
588  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
589  ThreadDeinitFunc ThreadDeinit,
590  ThreadExitPrintStatsFunc ThreadExitPrintStats)
591 {
592  if (unlikely(FlowLogFunc == NULL)) {
593  goto error;
594  }
595 
596  OutputModule *module = SCCalloc(1, sizeof(*module));
597  if (unlikely(module == NULL)) {
598  goto error;
599  }
600 
601  module->logger_id = id;
602  module->name = name;
603  module->conf_name = conf_name;
604  module->parent_name = parent_name;
605  module->InitSubFunc = InitFunc;
606  module->FlowLogFunc = FlowLogFunc;
607  module->ThreadInit = ThreadInit;
608  module->ThreadDeinit = ThreadDeinit;
609  module->ThreadExitPrintStats = ThreadExitPrintStats;
610  TAILQ_INSERT_TAIL(&output_modules, module, entries);
611 
612  SCLogDebug("Flow logger \"%s\" registered.", name);
613  return;
614 error:
615  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
616 }
617 
618 /**
619  * \brief Register a streaming data output module.
620  *
621  * This function will register an output module so it can be
622  * configured with the configuration file.
623  *
624  * \retval Returns 0 on success, -1 on failure.
625  */
626 void OutputRegisterStreamingModule(LoggerId id, const char *name,
627  const char *conf_name, OutputInitFunc InitFunc,
628  StreamingLogger StreamingLogFunc,
629  enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit,
630  ThreadDeinitFunc ThreadDeinit,
631  ThreadExitPrintStatsFunc ThreadExitPrintStats)
632 {
633  if (unlikely(StreamingLogFunc == NULL)) {
634  goto error;
635  }
636 
637  OutputModule *module = SCCalloc(1, sizeof(*module));
638  if (unlikely(module == NULL)) {
639  goto error;
640  }
641 
642  module->logger_id = id;
643  module->name = name;
644  module->conf_name = conf_name;
645  module->InitFunc = InitFunc;
646  module->StreamingLogFunc = StreamingLogFunc;
647  module->stream_type = stream_type;
648  module->ThreadInit = ThreadInit;
649  module->ThreadDeinit = ThreadDeinit;
650  module->ThreadExitPrintStats = ThreadExitPrintStats;
651  TAILQ_INSERT_TAIL(&output_modules, module, entries);
652 
653  SCLogDebug("Streaming logger \"%s\" registered.", name);
654  return;
655 error:
656  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
657 }
658 
659 /**
660  * \brief Register a streaming data output sub-module.
661  *
662  * This function will register an output module so it can be
663  * configured with the configuration file.
664  *
665  * \retval Returns 0 on success, -1 on failure.
666  */
667 void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
668  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
669  StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type,
670  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
671  ThreadExitPrintStatsFunc ThreadExitPrintStats)
672 {
673  if (unlikely(StreamingLogFunc == NULL)) {
674  goto error;
675  }
676 
677  OutputModule *module = SCCalloc(1, sizeof(*module));
678  if (unlikely(module == NULL)) {
679  goto error;
680  }
681 
682  module->logger_id = id;
683  module->name = name;
684  module->conf_name = conf_name;
685  module->parent_name = parent_name;
686  module->InitSubFunc = InitFunc;
687  module->StreamingLogFunc = StreamingLogFunc;
688  module->stream_type = stream_type;
689  module->ThreadInit = ThreadInit;
690  module->ThreadDeinit = ThreadDeinit;
691  module->ThreadExitPrintStats = ThreadExitPrintStats;
692  TAILQ_INSERT_TAIL(&output_modules, module, entries);
693 
694  SCLogDebug("Streaming logger \"%s\" registered.", name);
695  return;
696 error:
697  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
698 }
699 
700 /**
701  * \brief Register a stats data output module.
702  *
703  * This function will register an output module so it can be
704  * configured with the configuration file.
705  *
706  * \retval Returns 0 on success, -1 on failure.
707  */
708 void OutputRegisterStatsModule(LoggerId id, const char *name,
709  const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc,
710  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
711  ThreadExitPrintStatsFunc ThreadExitPrintStats)
712 {
713  if (unlikely(StatsLogFunc == NULL)) {
714  goto error;
715  }
716 
717  OutputModule *module = SCCalloc(1, sizeof(*module));
718  if (unlikely(module == NULL)) {
719  goto error;
720  }
721 
722  module->logger_id = id;
723  module->name = name;
724  module->conf_name = conf_name;
725  module->InitFunc = InitFunc;
726  module->StatsLogFunc = StatsLogFunc;
727  module->ThreadInit = ThreadInit;
728  module->ThreadDeinit = ThreadDeinit;
729  module->ThreadExitPrintStats = ThreadExitPrintStats;
730  TAILQ_INSERT_TAIL(&output_modules, module, entries);
731 
732  SCLogDebug("Stats logger \"%s\" registered.", name);
733  return;
734 error:
735  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
736 }
737 
738 /**
739  * \brief Register a stats data output sub-module.
740  *
741  * This function will register an output module so it can be
742  * configured with the configuration file.
743  *
744  * \retval Returns 0 on success, -1 on failure.
745  */
746 void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
747  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
748  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
749  ThreadDeinitFunc ThreadDeinit,
750  ThreadExitPrintStatsFunc ThreadExitPrintStats)
751 {
752  if (unlikely(StatsLogFunc == NULL)) {
753  goto error;
754  }
755 
756  OutputModule *module = SCCalloc(1, sizeof(*module));
757  if (unlikely(module == NULL)) {
758  goto error;
759  }
760 
761  module->logger_id = id;
762  module->name = name;
763  module->conf_name = conf_name;
764  module->parent_name = parent_name;
765  module->InitSubFunc = InitFunc;
766  module->StatsLogFunc = StatsLogFunc;
767  module->ThreadInit = ThreadInit;
768  module->ThreadDeinit = ThreadDeinit;
769  module->ThreadExitPrintStats = ThreadExitPrintStats;
770  TAILQ_INSERT_TAIL(&output_modules, module, entries);
771 
772  SCLogDebug("Stats logger \"%s\" registered.", name);
773  return;
774 error:
775  FatalError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
776 }
777 
778 /**
779  * \brief Get an output module by name.
780  *
781  * \retval The OutputModule with the given name or NULL if no output module
782  * with the given name is registered.
783  */
785 {
786  OutputModule *module;
787 
788  TAILQ_FOREACH(module, &output_modules, entries) {
789  if (strcmp(module->conf_name, conf_name) == 0)
790  return module;
791  }
792 
793  return NULL;
794 }
795 
796 /**
797  * \brief Deregister all modules. Useful for a memory clean exit.
798  */
800 {
801  OutputModule *module;
802 
803  while ((module = TAILQ_FIRST(&output_modules))) {
804  TAILQ_REMOVE(&output_modules, module, entries);
805  SCFree(module);
806  }
807 }
808 
809 static int drop_loggers = 0;
810 
812 {
813  if (drop_loggers)
814  return -1;
815  drop_loggers++;
816  return 0;
817 }
818 
820 {
821  if (drop_loggers)
822  drop_loggers--;
823 }
824 
825 /**
826  * \brief Register a flag for file rotation notification.
827  *
828  * \param flag A pointer that will be set to 1 when file rotation is
829  * requested.
830  */
832 {
833  OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
834  if (unlikely(flag_entry == NULL)) {
836  "Failed to allocate memory to register file rotation flag");
837  return;
838  }
839  flag_entry->flag = flag;
840  TAILQ_INSERT_TAIL(&output_file_rotation_flags, flag_entry, entries);
841 }
842 
843 /**
844  * \brief Unregister a file rotation flag.
845  *
846  * Note that it is safe to call this function with a flag that may not
847  * have been registered, in which case this function won't do
848  * anything.
849  *
850  * \param flag A pointer that has been previously registered for file
851  * rotation notifications.
852  */
854 {
855  OutputFileRolloverFlag *entry, *next;
856  for (entry = TAILQ_FIRST(&output_file_rotation_flags); entry != NULL;
857  entry = next) {
858  next = TAILQ_NEXT(entry, entries);
859  if (entry->flag == flag) {
860  TAILQ_REMOVE(&output_file_rotation_flags, entry, entries);
861  SCFree(entry);
862  break;
863  }
864  }
865 }
866 
867 /**
868  * \brief Notifies all registered file rotation notification flags.
869  */
872  TAILQ_FOREACH(flag, &output_file_rotation_flags, entries) {
873  *(flag->flag) = 1;
874  }
875 }
876 
877 TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
878 {
879  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
880  RootLogger *logger = TAILQ_FIRST(&active_loggers);
881  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
882  while (logger && thread_store_node) {
883  logger->LogFunc(tv, p, thread_store_node->thread_data);
884 
885  logger = TAILQ_NEXT(logger, entries);
886  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
887  }
888 
889  return TM_ECODE_OK;
890 }
891 
892 TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
893 {
894  LoggerThreadStore *thread_store = SCCalloc(1, sizeof(*thread_store));
895  if (thread_store == NULL) {
896  return TM_ECODE_FAILED;
897  }
898  TAILQ_INIT(thread_store);
899  *data = (void *)thread_store;
900 
901  RootLogger *logger;
902  TAILQ_FOREACH(logger, &active_loggers, entries) {
903 
904  void *child_thread_data = NULL;
905  if (logger->ThreadInit != NULL) {
906  if (logger->ThreadInit(tv, initdata, &child_thread_data) == TM_ECODE_OK) {
907  LoggerThreadStoreNode *thread_store_node =
908  SCCalloc(1, sizeof(*thread_store_node));
909  if (thread_store_node == NULL) {
910  /* Undo everything, calling de-init will take care
911  * of that. */
912  OutputLoggerThreadDeinit(tv, thread_store);
913  return TM_ECODE_FAILED;
914  }
915  thread_store_node->thread_data = child_thread_data;
916  TAILQ_INSERT_TAIL(thread_store, thread_store_node, entries);
917  }
918  }
919  }
920  return TM_ECODE_OK;
921 }
922 
924 {
925  if (thread_data == NULL)
926  return TM_ECODE_FAILED;
927 
928  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
929  RootLogger *logger = TAILQ_FIRST(&active_loggers);
930  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
931  while (logger && thread_store_node) {
932  if (logger->ThreadDeinit != NULL) {
933  logger->ThreadDeinit(tv, thread_store_node->thread_data);
934  }
935  logger = TAILQ_NEXT(logger, entries);
936  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
937  }
938 
939  /* Free the thread store. */
940  while ((thread_store_node = TAILQ_FIRST(thread_store)) != NULL) {
941  TAILQ_REMOVE(thread_store, thread_store_node, entries);
942  SCFree(thread_store_node);
943  }
944  SCFree(thread_store);
945 
946  return TM_ECODE_OK;
947 }
948 
949 void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
950 {
951  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
952  RootLogger *logger = TAILQ_FIRST(&active_loggers);
953  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
954  while (logger && thread_store_node) {
955  if (logger->ThreadExitPrintStats != NULL) {
956  logger->ThreadExitPrintStats(tv, thread_store_node->thread_data);
957  }
958  logger = TAILQ_NEXT(logger, entries);
959  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
960  }
961 }
962 
964  ThreadDeinitFunc ThreadDeinit,
965  ThreadExitPrintStatsFunc ThreadExitPrintStats,
966  OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
967 {
968  BUG_ON(LogFunc == NULL);
969 
970  RootLogger *logger = SCCalloc(1, sizeof(*logger));
971  if (logger == NULL) {
972  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
973  }
974  logger->ThreadInit = ThreadInit;
975  logger->ThreadDeinit = ThreadDeinit;
976  logger->ThreadExitPrintStats = ThreadExitPrintStats;
977  logger->LogFunc = LogFunc;
978  logger->ActiveCntFunc = ActiveCntFunc;
979  TAILQ_INSERT_TAIL(&registered_loggers, logger, entries);
980 }
981 
982 static void OutputRegisterActiveLogger(RootLogger *reg)
983 {
984  RootLogger *logger = SCCalloc(1, sizeof(*logger));
985  if (logger == NULL) {
986  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc root logger");
987  }
988  logger->ThreadInit = reg->ThreadInit;
989  logger->ThreadDeinit = reg->ThreadDeinit;
991  logger->LogFunc = reg->LogFunc;
992  logger->ActiveCntFunc = reg->ActiveCntFunc;
993  TAILQ_INSERT_TAIL(&active_loggers, logger, entries);
994 }
995 
997 {
998  RootLogger *logger = TAILQ_FIRST(&registered_loggers);
999  while (logger) {
1000  uint32_t cnt = logger->ActiveCntFunc();
1001  if (cnt) {
1002  OutputRegisterActiveLogger(logger);
1003  }
1004 
1005  logger = TAILQ_NEXT(logger, entries);
1006  }
1007 }
1008 
1010 {
1011  RootLogger *logger;
1012  while ((logger = TAILQ_FIRST(&active_loggers)) != NULL) {
1013  TAILQ_REMOVE(&active_loggers, logger, entries);
1014  SCFree(logger);
1015  }
1016 }
1017 
1019 {
1022 }
1023 
1024 /**
1025  * \brief Register all root loggers.
1026  */
1028 {
1034 }
1035 
1036 /**
1037  * \brief Register all non-root logging modules.
1038  */
1040 {
1041  /* custom format log*/
1043 
1044  LuaLogRegister();
1045  /* fast log */
1047  /* debug log */
1049  /* prelue log */
1051  /* syslog log */
1054  /* json log */
1056  /* email logs */
1058  /* http log */
1062  /* tls log */
1066  /* ssh */
1068  /* pcap log */
1069  PcapLogRegister();
1070  /* file log */
1073  /* dns */
1075  /* modbus */
1077  /* tcp streaming data */
1079  /* log stats */
1081 
1084  /* flow/netflow */
1087  /* json stats */
1089 
1090  /* DNP3. */
1093 
1094  /* NFS JSON logger. */
1096  /* TFTP JSON logger. */
1098  /* FTP JSON logger. */
1100  /* SMB JSON logger. */
1102  /* IKE JSON logger. */
1104  /* KRB5 JSON logger. */
1106  /* DHCP JSON logger. */
1108  /* SNMP JSON logger. */
1110  /* SIP JSON logger. */
1112  /* RFB JSON logger. */
1114  /* MQTT JSON logger. */
1116  /* Template JSON logger. */
1118  /* Template Rust JSON logger. */
1120  /* RDP JSON logger. */
1122  /* DCERPC JSON logger. */
1124 }
RootLogger_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.c:93
log-stats.h
OutputModule_::parent_name
const char * parent_name
Definition: output.h:57
OutputFileRolloverFlag
OutputFileRolloverFlag
Definition: output.c:130
LogTlsStoreRegister
void LogTlsStoreRegister(void)
Definition: log-tlsstore.c:413
tm-threads.h
output-json-ftp.h
OutputDropLoggerEnable
int OutputDropLoggerEnable(void)
Definition: output.c:811
LoggerThreadStoreNode
LoggerThreadStoreNode
Definition: output.c:114
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:746
JsonDCERPCLogRegister
void JsonDCERPCLogRegister(void)
Definition: output-json-dcerpc.c:84
output-json-modbus.h
OutputTxLoggerRegister
void OutputTxLoggerRegister(void)
Definition: output-tx.c:446
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:95
OutputLoggerExitPrintStats
void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
Definition: output.c:949
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:77
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:436
AlertFastLogRegister
void AlertFastLogRegister(void)
Definition: alert-fastlog.c:75
JsonFileLogRegister
void JsonFileLogRegister(void)
Definition: output-json-file.c:341
JsonRdpLogRegister
void JsonRdpLogRegister(void)
Definition: output-json-rdp.c:72
OutputModule_::ts_log_progress
int ts_log_progress
Definition: output.h:77
JsonSNMPLogRegister
void JsonSNMPLogRegister(void)
Definition: output-json-snmp.c:86
output-json-netflow.h
JsonDNP3LogRegister
void JsonDNP3LogRegister(void)
Definition: output-json-dnp3.c:337
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:784
output-json-tls.h
OutputSetupActiveLoggers
void OutputSetupActiveLoggers(void)
Definition: output.c:996
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: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:467
JsonDHCPLogRegister
void JsonDHCPLogRegister(void)
Definition: output-json-dhcp.c:147
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:87
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:626
JsonTemplateRustLogRegister
void JsonTemplateRustLogRegister(void)
Definition: output-json-template-rust.c:168
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:1027
OutputLoggerThreadDeinit
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output.c:923
OutputModule_::alproto
AppProto alproto
Definition: output.h:74
JsonTlsLogRegister
void JsonTlsLogRegister(void)
Definition: output-json-tls.c:594
alert-syslog.h
JsonFlowLogRegister
void JsonFlowLogRegister(void)
Definition: output-json-flow.c:334
TmModuleLoggerRegister
void TmModuleLoggerRegister(void)
Definition: output.c:1018
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:1009
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:91
output-json-dnp3.h
OutputRegisterFileRotationFlag
void OutputRegisterFileRotationFlag(int *flag)
Register a flag for file rotation notification.
Definition: output.c:831
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:454
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:458
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:546
log-tcp-data.h
output-json-rfb.h
JsonTFTPLogRegister
void JsonTFTPLogRegister(void)
Definition: output-json-tftp.c:86
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:379
output-json-file.h
OutputRegisterModule
void OutputRegisterModule(const char *, const char *, OutputInitFunc)
JsonIKELogRegister
void JsonIKELogRegister(void)
Definition: output-json-ike.c:183
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:667
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:892
JsonMQTTLogRegister
void JsonMQTTLogRegister(void)
Definition: output-json-mqtt.c:192
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:277
OutputFilestoreRegister
void OutputFilestoreRegister(void)
Definition: output-filestore.c:533
OutputRegisterLoggers
void OutputRegisterLoggers(void)
Register all non-root logging modules.
Definition: output.c:1039
AlertPreludeRegister
void AlertPreludeRegister(void)
Definition: alert-prelude.c:1309
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:799
Packet_
Definition: decode.h:416
RootLogger_::ActiveCntFunc
OutputGetActiveCountFunc ActiveCntFunc
Definition: output.c:95
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:870
TAILQ_HEAD
typedef TAILQ_HEAD(LoggerThreadStore_, LoggerThreadStoreNode_)
Definition: output.c:116
TmEcode
TmEcode
Definition: tm-threads-common.h:79
OutputModule_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.h:63
RootLogger_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.c:92
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:507
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:215
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:94
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:410
JsonSmtpLogRegister
void JsonSmtpLogRegister(void)
Definition: output-json-smtp.c:194
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
log-httplog.h
JsonMetadataLogRegister
void JsonMetadataLogRegister(void)
Definition: output-json-metadata.c:100
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:175
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:180
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:586
JsonDnsLogRegister
void JsonDnsLogRegister(void)
Definition: output-json-dns.c:647
OutputLoggerLog
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
Definition: output.c:877
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:361
output-json-ike.h
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
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:48
PacketLogCondition
int(* PacketLogCondition)(ThreadVars *, const Packet *)
Definition: output-packet.h:38
JsonFTPLogRegister
void JsonFTPLogRegister(void)
Definition: output-json-ftp.c:185
output-json-ssh.h
output-lua.h
OutputRegisterRootLogger
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
Definition: output.c:963
JsonRFBLogRegister
void JsonRFBLogRegister(void)
Definition: output-json-rfb.c:93
SC_ERR_MEM_ALLOC
@ SC_ERR_MEM_ALLOC
Definition: util-error.h:31
JsonHttpLogRegister
void JsonHttpLogRegister(void)
Definition: output-json-http.c:675
JsonTemplateLogRegister
void JsonTemplateLogRegister(void)
Definition: output-json-template.c:176
output-json-smb.h
JsonModbusLogRegister
void JsonModbusLogRegister(void)
Definition: output-json-modbus.c:152
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:853
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:95
JsonKRB5LogRegister
void JsonKRB5LogRegister(void)
Definition: output-json-krb5.c:87
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:708
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
JsonAlertLogRegister
void JsonAlertLogRegister(void)
Definition: output-json-alert.c:1019
JsonNFSLogRegister
void JsonNFSLogRegister(void)
Definition: output-json-nfs.c:111
OutputDropLoggerDisable
void OutputDropLoggerDisable(void)
Definition: output.c:819
JsonNetFlowLogRegister
void JsonNetFlowLogRegister(void)
Definition: output-json-netflow.c:294
ThreadDeinitFunc
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
OutputModule_::InitFunc
OutputInitFunc InitFunc
Definition: output.h:58
RootLogger_
Definition: output.c:90
output-json-drop.h