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