suricata
output.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2021 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 "output-eve-stream.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-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"
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-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:
165  FatalError("Fatal error encountered in OutputRegisterModule. Exiting...");
166 }
167 
168 /**
169  * \brief Register a packet output module.
170  *
171  * This function will register an output module so it can be
172  * configured with the configuration file.
173  *
174  * \retval Returns 0 on success, -1 on failure.
175  */
176 void OutputRegisterPacketModule(LoggerId id, const char *name,
177  const char *conf_name, OutputInitFunc InitFunc,
178  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
179  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
180  ThreadExitPrintStatsFunc ThreadExitPrintStats)
181 {
182  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
183  goto error;
184  }
185 
186  OutputModule *module = SCCalloc(1, sizeof(*module));
187  if (unlikely(module == NULL)) {
188  goto error;
189  }
190 
191  module->logger_id = id;
192  module->name = name;
193  module->conf_name = conf_name;
194  module->InitFunc = InitFunc;
195  module->PacketLogFunc = PacketLogFunc;
196  module->PacketConditionFunc = PacketConditionFunc;
197  module->ThreadInit = ThreadInit;
198  module->ThreadDeinit = ThreadDeinit;
199  module->ThreadExitPrintStats = ThreadExitPrintStats;
200  TAILQ_INSERT_TAIL(&output_modules, module, entries);
201 
202  SCLogDebug("Packet logger \"%s\" registered.", name);
203  return;
204 error:
205  FatalError("Fatal error encountered. Exiting...");
206 }
207 
208 /**
209  * \brief Register a packet output sub-module.
210  *
211  * This function will register an output module so it can be
212  * configured with the configuration file.
213  *
214  * \retval Returns 0 on success, -1 on failure.
215  */
216 void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name,
217  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
218  PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc,
219  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
220  ThreadExitPrintStatsFunc ThreadExitPrintStats)
221 {
222  if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) {
223  goto error;
224  }
225 
226  OutputModule *module = SCCalloc(1, sizeof(*module));
227  if (unlikely(module == NULL)) {
228  goto error;
229  }
230 
231  module->logger_id = id;
232  module->name = name;
233  module->conf_name = conf_name;
234  module->parent_name = parent_name;
235  module->InitSubFunc = InitFunc;
236  module->PacketLogFunc = PacketLogFunc;
237  module->PacketConditionFunc = PacketConditionFunc;
238  module->ThreadInit = ThreadInit;
239  module->ThreadDeinit = ThreadDeinit;
240  module->ThreadExitPrintStats = ThreadExitPrintStats;
241  TAILQ_INSERT_TAIL(&output_modules, module, entries);
242 
243  SCLogDebug("Packet logger \"%s\" registered.", name);
244  return;
245 error:
246  FatalError("Fatal error encountered. Exiting...");
247 }
248 
249 /**
250  * \brief Wrapper function for tx output modules.
251  *
252  * This function will register an output module so it can be
253  * configured with the configuration file.
254  *
255  * \retval Returns 0 on success, -1 on failure.
256  */
257 static void OutputRegisterTxModuleWrapper(LoggerId id, const char *name,
258  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
259  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
260  TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit,
261  ThreadDeinitFunc ThreadDeinit,
262  ThreadExitPrintStatsFunc ThreadExitPrintStats)
263 {
264  if (unlikely(TxLogFunc == NULL)) {
265  goto error;
266  }
267 
268  OutputModule *module = SCCalloc(1, sizeof(*module));
269  if (unlikely(module == NULL)) {
270  goto error;
271  }
272 
273  module->logger_id = id;
274  module->name = name;
275  module->conf_name = conf_name;
276  module->InitFunc = InitFunc;
277  module->TxLogFunc = TxLogFunc;
278  module->TxLogCondition = TxLogCondition;
279  module->alproto = alproto;
280  module->tc_log_progress = tc_log_progress;
281  module->ts_log_progress = ts_log_progress;
282  module->ThreadInit = ThreadInit;
283  module->ThreadDeinit = ThreadDeinit;
284  module->ThreadExitPrintStats = ThreadExitPrintStats;
285  TAILQ_INSERT_TAIL(&output_modules, module, entries);
286 
287  SCLogDebug("Tx logger \"%s\" registered.", name);
288  return;
289 error:
290  FatalError("Fatal error encountered. Exiting...");
291 }
292 
293 static void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name,
294  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
295  AppProto alproto, TxLogger TxLogFunc, int tc_log_progress,
296  int ts_log_progress, TxLoggerCondition TxLogCondition,
297  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
298  ThreadExitPrintStatsFunc ThreadExitPrintStats)
299 {
300  if (unlikely(TxLogFunc == NULL)) {
301  goto error;
302  }
303 
304  OutputModule *module = SCCalloc(1, sizeof(*module));
305  if (unlikely(module == NULL)) {
306  goto error;
307  }
308 
309  module->logger_id = id;
310  module->name = name;
311  module->conf_name = conf_name;
312  module->parent_name = parent_name;
313  module->InitSubFunc = InitFunc;
314  module->TxLogFunc = TxLogFunc;
315  module->TxLogCondition = TxLogCondition;
316  module->alproto = alproto;
317  module->tc_log_progress = tc_log_progress;
318  module->ts_log_progress = ts_log_progress;
319  module->ThreadInit = ThreadInit;
320  module->ThreadDeinit = ThreadDeinit;
321  module->ThreadExitPrintStats = ThreadExitPrintStats;
322  TAILQ_INSERT_TAIL(&output_modules, module, entries);
323 
324  SCLogDebug("Tx logger for alproto %d \"%s\" registered.", alproto, name);
325  return;
326 error:
327  FatalError("Fatal error encountered. Exiting...");
328 }
329 
330 /**
331  * \brief Register a tx output module with condition.
332  *
333  * This function will register an output module so it can be
334  * configured with the configuration file.
335  *
336  * \retval Returns 0 on success, -1 on failure.
337  */
339  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
340  TxLogger TxLogFunc, TxLoggerCondition TxLogCondition,
341  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
342  ThreadExitPrintStatsFunc ThreadExitPrintStats)
343 {
344  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
345  TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit,
346  ThreadExitPrintStats);
347 }
348 
350  const char *parent_name, const char *name, const char *conf_name,
351  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
352  TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit,
353  ThreadDeinitFunc ThreadDeinit,
354  ThreadExitPrintStatsFunc ThreadExitPrintStats)
355 {
356  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc,
357  alproto, TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit,
358  ThreadExitPrintStats);
359 }
360 
361 /**
362  * \brief Register a tx output module with progress.
363  *
364  * This function will register an output module so it can be
365  * configured with the configuration file.
366  *
367  * \retval Returns 0 on success, -1 on failure.
368  */
370  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
371  TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress,
372  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
373  ThreadExitPrintStatsFunc ThreadExitPrintStats)
374 {
375  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
376  TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit,
377  ThreadDeinit, ThreadExitPrintStats);
378 }
379 
380 void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name,
381  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
382  AppProto alproto, TxLogger TxLogFunc, int tc_log_progress,
383  int ts_log_progress, ThreadInitFunc ThreadInit,
384  ThreadDeinitFunc ThreadDeinit,
385  ThreadExitPrintStatsFunc ThreadExitPrintStats)
386 {
387  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc,
388  alproto, TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit,
389  ThreadDeinit, ThreadExitPrintStats);
390 }
391 
392 /**
393  * \brief Register a tx output module.
394  *
395  * This function will register an output module so it can be
396  * configured with the configuration file.
397  *
398  * \retval Returns 0 on success, -1 on failure.
399  */
400 void OutputRegisterTxModule(LoggerId id, const char *name,
401  const char *conf_name, OutputInitFunc InitFunc, AppProto alproto,
402  TxLogger TxLogFunc, ThreadInitFunc ThreadInit,
403  ThreadDeinitFunc ThreadDeinit,
404  ThreadExitPrintStatsFunc ThreadExitPrintStats)
405 {
406  OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto,
407  TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit,
408  ThreadExitPrintStats);
409 }
410 
411 void OutputRegisterTxSubModule(LoggerId id, const char *parent_name,
412  const char *name, const char *conf_name,
413  OutputInitSubFunc InitFunc, AppProto alproto, TxLogger TxLogFunc,
414  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
415  ThreadExitPrintStatsFunc ThreadExitPrintStats)
416 {
417  OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name,
418  InitFunc, alproto, TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit,
419  ThreadExitPrintStats);
420 }
421 
422 /**
423  * \brief Register a file output module.
424  *
425  * This function will register an output module so it can be
426  * configured with the configuration file.
427  *
428  * \retval Returns 0 on success, -1 on failure.
429  */
430 void OutputRegisterFileModule(LoggerId id, const char *name,
431  const char *conf_name, OutputInitFunc InitFunc, FileLogger FileLogFunc,
432  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
433  ThreadExitPrintStatsFunc ThreadExitPrintStats)
434 {
435  if (unlikely(FileLogFunc == NULL)) {
436  goto error;
437  }
438 
439  OutputModule *module = SCCalloc(1, sizeof(*module));
440  if (unlikely(module == NULL)) {
441  goto error;
442  }
443 
444  module->logger_id = id;
445  module->name = name;
446  module->conf_name = conf_name;
447  module->InitFunc = InitFunc;
448  module->FileLogFunc = FileLogFunc;
449  module->ThreadInit = ThreadInit;
450  module->ThreadDeinit = ThreadDeinit;
451  module->ThreadExitPrintStats = ThreadExitPrintStats;
452  TAILQ_INSERT_TAIL(&output_modules, module, entries);
453 
454  SCLogDebug("File logger \"%s\" registered.", name);
455  return;
456 error:
457  FatalError("Fatal error encountered. Exiting...");
458 }
459 
460 /**
461  * \brief Register a file output sub-module.
462  *
463  * This function will register an output module so it can be
464  * configured with the configuration file.
465  *
466  * \retval Returns 0 on success, -1 on failure.
467  */
468 void OutputRegisterFileSubModule(LoggerId id, const char *parent_name,
469  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
470  FileLogger FileLogFunc, ThreadInitFunc ThreadInit,
471  ThreadDeinitFunc ThreadDeinit,
472  ThreadExitPrintStatsFunc ThreadExitPrintStats)
473 {
474  if (unlikely(FileLogFunc == NULL)) {
475  goto error;
476  }
477 
478  OutputModule *module = SCCalloc(1, sizeof(*module));
479  if (unlikely(module == NULL)) {
480  goto error;
481  }
482 
483  module->logger_id = id;
484  module->name = name;
485  module->conf_name = conf_name;
486  module->parent_name = parent_name;
487  module->InitSubFunc = InitFunc;
488  module->FileLogFunc = FileLogFunc;
489  module->ThreadInit = ThreadInit;
490  module->ThreadDeinit = ThreadDeinit;
491  module->ThreadExitPrintStats = ThreadExitPrintStats;
492  TAILQ_INSERT_TAIL(&output_modules, module, entries);
493 
494  SCLogDebug("File logger \"%s\" registered.", name);
495  return;
496 error:
497  FatalError("Fatal error encountered. Exiting...");
498 }
499 
500 /**
501  * \brief Register a file data output module.
502  *
503  * This function will register an output module so it can be
504  * configured with the configuration file.
505  *
506  * \retval Returns 0 on success, -1 on failure.
507  */
508 void OutputRegisterFiledataModule(LoggerId id, const char *name,
509  const char *conf_name, OutputInitFunc InitFunc,
510  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
511  ThreadDeinitFunc ThreadDeinit,
512  ThreadExitPrintStatsFunc ThreadExitPrintStats)
513 {
514  if (unlikely(FiledataLogFunc == NULL)) {
515  goto error;
516  }
517 
518  OutputModule *module = SCCalloc(1, sizeof(*module));
519  if (unlikely(module == NULL)) {
520  goto error;
521  }
522 
523  module->logger_id = id;
524  module->name = name;
525  module->conf_name = conf_name;
526  module->InitFunc = InitFunc;
527  module->FiledataLogFunc = FiledataLogFunc;
528  module->ThreadInit = ThreadInit;
529  module->ThreadDeinit = ThreadDeinit;
530  module->ThreadExitPrintStats = ThreadExitPrintStats;
531  TAILQ_INSERT_TAIL(&output_modules, module, entries);
532 
533  SCLogDebug("Filedata logger \"%s\" registered.", name);
534  return;
535 error:
536  FatalError("Fatal error encountered. Exiting...");
537 }
538 
539 /**
540  * \brief Register a file data output sub-module.
541  *
542  * This function will register an output module so it can be
543  * configured with the configuration file.
544  *
545  * \retval Returns 0 on success, -1 on failure.
546  */
547 void OutputRegisterFiledataSubModule(LoggerId id, const char *parent_name,
548  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
549  FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit,
550  ThreadDeinitFunc ThreadDeinit,
551  ThreadExitPrintStatsFunc ThreadExitPrintStats)
552 {
553  if (unlikely(FiledataLogFunc == NULL)) {
554  goto error;
555  }
556 
557  OutputModule *module = SCCalloc(1, sizeof(*module));
558  if (unlikely(module == NULL)) {
559  goto error;
560  }
561 
562  module->logger_id = id;
563  module->name = name;
564  module->conf_name = conf_name;
565  module->parent_name = parent_name;
566  module->InitSubFunc = InitFunc;
567  module->FiledataLogFunc = FiledataLogFunc;
568  module->ThreadInit = ThreadInit;
569  module->ThreadDeinit = ThreadDeinit;
570  module->ThreadExitPrintStats = ThreadExitPrintStats;
571  TAILQ_INSERT_TAIL(&output_modules, module, entries);
572 
573  SCLogDebug("Filedata logger \"%s\" registered.", name);
574  return;
575 error:
576  FatalError("Fatal error encountered. Exiting...");
577 }
578 
579 /**
580  * \brief Register a flow output sub-module.
581  *
582  * This function will register an output module so it can be
583  * configured with the configuration file.
584  *
585  * \retval Returns 0 on success, -1 on failure.
586  */
587 void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name,
588  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
589  FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit,
590  ThreadDeinitFunc ThreadDeinit,
591  ThreadExitPrintStatsFunc ThreadExitPrintStats)
592 {
593  if (unlikely(FlowLogFunc == NULL)) {
594  goto error;
595  }
596 
597  OutputModule *module = SCCalloc(1, sizeof(*module));
598  if (unlikely(module == NULL)) {
599  goto error;
600  }
601 
602  module->logger_id = id;
603  module->name = name;
604  module->conf_name = conf_name;
605  module->parent_name = parent_name;
606  module->InitSubFunc = InitFunc;
607  module->FlowLogFunc = FlowLogFunc;
608  module->ThreadInit = ThreadInit;
609  module->ThreadDeinit = ThreadDeinit;
610  module->ThreadExitPrintStats = ThreadExitPrintStats;
611  TAILQ_INSERT_TAIL(&output_modules, module, entries);
612 
613  SCLogDebug("Flow logger \"%s\" registered.", name);
614  return;
615 error:
616  FatalError("Fatal error encountered. Exiting...");
617 }
618 
619 /**
620  * \brief Register a streaming data output module.
621  *
622  * This function will register an output module so it can be
623  * configured with the configuration file.
624  *
625  * \retval Returns 0 on success, -1 on failure.
626  */
627 void OutputRegisterStreamingModule(LoggerId id, const char *name,
628  const char *conf_name, OutputInitFunc InitFunc,
629  StreamingLogger StreamingLogFunc,
630  enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit,
631  ThreadDeinitFunc ThreadDeinit,
632  ThreadExitPrintStatsFunc ThreadExitPrintStats)
633 {
634  if (unlikely(StreamingLogFunc == NULL)) {
635  goto error;
636  }
637 
638  OutputModule *module = SCCalloc(1, sizeof(*module));
639  if (unlikely(module == NULL)) {
640  goto error;
641  }
642 
643  module->logger_id = id;
644  module->name = name;
645  module->conf_name = conf_name;
646  module->InitFunc = InitFunc;
647  module->StreamingLogFunc = StreamingLogFunc;
648  module->stream_type = stream_type;
649  module->ThreadInit = ThreadInit;
650  module->ThreadDeinit = ThreadDeinit;
651  module->ThreadExitPrintStats = ThreadExitPrintStats;
652  TAILQ_INSERT_TAIL(&output_modules, module, entries);
653 
654  SCLogDebug("Streaming logger \"%s\" registered.", name);
655  return;
656 error:
657  FatalError("Fatal error encountered. Exiting...");
658 }
659 
660 /**
661  * \brief Register a streaming data output sub-module.
662  *
663  * This function will register an output module so it can be
664  * configured with the configuration file.
665  *
666  * \retval Returns 0 on success, -1 on failure.
667  */
668 void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name,
669  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
670  StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type,
671  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
672  ThreadExitPrintStatsFunc ThreadExitPrintStats)
673 {
674  if (unlikely(StreamingLogFunc == NULL)) {
675  goto error;
676  }
677 
678  OutputModule *module = SCCalloc(1, sizeof(*module));
679  if (unlikely(module == NULL)) {
680  goto error;
681  }
682 
683  module->logger_id = id;
684  module->name = name;
685  module->conf_name = conf_name;
686  module->parent_name = parent_name;
687  module->InitSubFunc = InitFunc;
688  module->StreamingLogFunc = StreamingLogFunc;
689  module->stream_type = stream_type;
690  module->ThreadInit = ThreadInit;
691  module->ThreadDeinit = ThreadDeinit;
692  module->ThreadExitPrintStats = ThreadExitPrintStats;
693  TAILQ_INSERT_TAIL(&output_modules, module, entries);
694 
695  SCLogDebug("Streaming logger \"%s\" registered.", name);
696  return;
697 error:
698  FatalError("Fatal error encountered. Exiting...");
699 }
700 
701 /**
702  * \brief Register a stats data output module.
703  *
704  * This function will register an output module so it can be
705  * configured with the configuration file.
706  *
707  * \retval Returns 0 on success, -1 on failure.
708  */
709 void OutputRegisterStatsModule(LoggerId id, const char *name,
710  const char *conf_name, OutputInitFunc InitFunc, StatsLogger StatsLogFunc,
711  ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
712  ThreadExitPrintStatsFunc ThreadExitPrintStats)
713 {
714  if (unlikely(StatsLogFunc == NULL)) {
715  goto error;
716  }
717 
718  OutputModule *module = SCCalloc(1, sizeof(*module));
719  if (unlikely(module == NULL)) {
720  goto error;
721  }
722 
723  module->logger_id = id;
724  module->name = name;
725  module->conf_name = conf_name;
726  module->InitFunc = InitFunc;
727  module->StatsLogFunc = StatsLogFunc;
728  module->ThreadInit = ThreadInit;
729  module->ThreadDeinit = ThreadDeinit;
730  module->ThreadExitPrintStats = ThreadExitPrintStats;
731  TAILQ_INSERT_TAIL(&output_modules, module, entries);
732 
733  SCLogDebug("Stats logger \"%s\" registered.", name);
734  return;
735 error:
736  FatalError("Fatal error encountered. Exiting...");
737 }
738 
739 /**
740  * \brief Register a stats data output sub-module.
741  *
742  * This function will register an output module so it can be
743  * configured with the configuration file.
744  *
745  * \retval Returns 0 on success, -1 on failure.
746  */
747 void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name,
748  const char *name, const char *conf_name, OutputInitSubFunc InitFunc,
749  StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit,
750  ThreadDeinitFunc ThreadDeinit,
751  ThreadExitPrintStatsFunc ThreadExitPrintStats)
752 {
753  if (unlikely(StatsLogFunc == NULL)) {
754  goto error;
755  }
756 
757  OutputModule *module = SCCalloc(1, sizeof(*module));
758  if (unlikely(module == NULL)) {
759  goto error;
760  }
761 
762  module->logger_id = id;
763  module->name = name;
764  module->conf_name = conf_name;
765  module->parent_name = parent_name;
766  module->InitSubFunc = InitFunc;
767  module->StatsLogFunc = StatsLogFunc;
768  module->ThreadInit = ThreadInit;
769  module->ThreadDeinit = ThreadDeinit;
770  module->ThreadExitPrintStats = ThreadExitPrintStats;
771  TAILQ_INSERT_TAIL(&output_modules, module, entries);
772 
773  SCLogDebug("Stats logger \"%s\" registered.", name);
774  return;
775 error:
776  FatalError("Fatal error encountered. Exiting...");
777 }
778 
779 /**
780  * \brief Get an output module by name.
781  *
782  * \retval The OutputModule with the given name or NULL if no output module
783  * with the given name is registered.
784  */
786 {
787  OutputModule *module;
788 
789  TAILQ_FOREACH(module, &output_modules, entries) {
790  if (strcmp(module->conf_name, conf_name) == 0)
791  return module;
792  }
793 
794  return NULL;
795 }
796 
797 /**
798  * \brief Deregister all modules. Useful for a memory clean exit.
799  */
801 {
802  OutputModule *module;
803 
804  while ((module = TAILQ_FIRST(&output_modules))) {
805  TAILQ_REMOVE(&output_modules, module, entries);
806  SCFree(module);
807  }
808 }
809 
810 static int drop_loggers = 0;
811 
813 {
814  if (drop_loggers)
815  return -1;
816  drop_loggers++;
817  return 0;
818 }
819 
821 {
822  if (drop_loggers)
823  drop_loggers--;
824 }
825 
826 /**
827  * \brief Register a flag for file rotation notification.
828  *
829  * \param flag A pointer that will be set to 1 when file rotation is
830  * requested.
831  */
833 {
834  OutputFileRolloverFlag *flag_entry = SCCalloc(1, sizeof(*flag_entry));
835  if (unlikely(flag_entry == NULL)) {
836  SCLogError("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  return TM_ECODE_OK;
889 }
890 
891 TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
892 {
893  LoggerThreadStore *thread_store = SCCalloc(1, sizeof(*thread_store));
894  if (thread_store == NULL) {
895  return TM_ECODE_FAILED;
896  }
897  TAILQ_INIT(thread_store);
898  *data = (void *)thread_store;
899 
900  RootLogger *logger;
901  TAILQ_FOREACH(logger, &active_loggers, entries) {
902 
903  void *child_thread_data = NULL;
904  if (logger->ThreadInit != NULL) {
905  if (logger->ThreadInit(tv, initdata, &child_thread_data) == TM_ECODE_OK) {
906  LoggerThreadStoreNode *thread_store_node =
907  SCCalloc(1, sizeof(*thread_store_node));
908  if (thread_store_node == NULL) {
909  /* Undo everything, calling de-init will take care
910  * of that. */
911  OutputLoggerThreadDeinit(tv, thread_store);
912  return TM_ECODE_FAILED;
913  }
914  thread_store_node->thread_data = child_thread_data;
915  TAILQ_INSERT_TAIL(thread_store, thread_store_node, entries);
916  }
917  }
918  }
919  return TM_ECODE_OK;
920 }
921 
923 {
924  if (thread_data == NULL)
925  return TM_ECODE_FAILED;
926 
927  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
928  RootLogger *logger = TAILQ_FIRST(&active_loggers);
929  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
930  while (logger && thread_store_node) {
931  if (logger->ThreadDeinit != NULL) {
932  logger->ThreadDeinit(tv, thread_store_node->thread_data);
933  }
934  logger = TAILQ_NEXT(logger, entries);
935  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
936  }
937 
938  /* Free the thread store. */
939  while ((thread_store_node = TAILQ_FIRST(thread_store)) != NULL) {
940  TAILQ_REMOVE(thread_store, thread_store_node, entries);
941  SCFree(thread_store_node);
942  }
943  SCFree(thread_store);
944 
945  return TM_ECODE_OK;
946 }
947 
948 void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
949 {
950  LoggerThreadStore *thread_store = (LoggerThreadStore *)thread_data;
951  RootLogger *logger = TAILQ_FIRST(&active_loggers);
952  LoggerThreadStoreNode *thread_store_node = TAILQ_FIRST(thread_store);
953  while (logger && thread_store_node) {
954  if (logger->ThreadExitPrintStats != NULL) {
955  logger->ThreadExitPrintStats(tv, thread_store_node->thread_data);
956  }
957  logger = TAILQ_NEXT(logger, entries);
958  thread_store_node = TAILQ_NEXT(thread_store_node, entries);
959  }
960 }
961 
963  ThreadDeinitFunc ThreadDeinit,
964  ThreadExitPrintStatsFunc ThreadExitPrintStats,
965  OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
966 {
967  BUG_ON(LogFunc == NULL);
968 
969  RootLogger *logger = SCCalloc(1, sizeof(*logger));
970  if (logger == NULL) {
971  FatalError("failed to alloc root logger");
972  }
973  logger->ThreadInit = ThreadInit;
974  logger->ThreadDeinit = ThreadDeinit;
975  logger->ThreadExitPrintStats = ThreadExitPrintStats;
976  logger->LogFunc = LogFunc;
977  logger->ActiveCntFunc = ActiveCntFunc;
978  TAILQ_INSERT_TAIL(&registered_loggers, logger, entries);
979 }
980 
981 static void OutputRegisterActiveLogger(RootLogger *reg)
982 {
983  RootLogger *logger = SCCalloc(1, sizeof(*logger));
984  if (logger == NULL) {
985  FatalError("failed to alloc root logger");
986  }
987  logger->ThreadInit = reg->ThreadInit;
988  logger->ThreadDeinit = reg->ThreadDeinit;
990  logger->LogFunc = reg->LogFunc;
991  logger->ActiveCntFunc = reg->ActiveCntFunc;
992  TAILQ_INSERT_TAIL(&active_loggers, logger, entries);
993 }
994 
996 {
997  RootLogger *logger = TAILQ_FIRST(&registered_loggers);
998  while (logger) {
999  uint32_t cnt = logger->ActiveCntFunc();
1000  if (cnt) {
1001  OutputRegisterActiveLogger(logger);
1002  }
1003 
1004  logger = TAILQ_NEXT(logger, entries);
1005  }
1006 }
1007 
1009 {
1010  RootLogger *logger;
1011  while ((logger = TAILQ_FIRST(&active_loggers)) != NULL) {
1012  TAILQ_REMOVE(&active_loggers, logger, entries);
1013  SCFree(logger);
1014  }
1015 }
1016 
1018 {
1021 }
1022 
1023 /**
1024  * \brief Register all root loggers.
1025  */
1027 {
1033 }
1034 
1035 /**
1036  * \brief Register all non-root logging modules.
1037  */
1039 {
1040  /* custom format log*/
1042 
1043  LuaLogRegister();
1044  /* fast log */
1046  /* debug log */
1048  /* syslog log */
1052  /* json log */
1054  /* email logs */
1056  /* http log */
1060  /* tls log */
1064  /* ssh */
1066  /* pcap log */
1067  PcapLogRegister();
1068  /* file log */
1071  /* dns */
1073  /* modbus */
1075  /* tcp streaming data */
1077  /* log stats */
1079 
1082  /* flow/netflow */
1085  /* json stats */
1087 
1088  /* DNP3. */
1091 
1092  /* NFS JSON logger. */
1094  /* TFTP JSON logger. */
1096  /* FTP JSON logger. */
1098  /* SMB JSON logger. */
1100  /* IKE JSON logger. */
1102  /* KRB5 JSON logger. */
1104  /* QUIC JSON logger. */
1106  /* DHCP JSON logger. */
1108  /* SNMP JSON logger. */
1110  /* SIP JSON logger. */
1112  /* RFB JSON logger. */
1114  /* MQTT JSON logger. */
1116  /* Pgsql JSON logger. */
1118  /* Template JSON logger. */
1120  /* RDP JSON logger. */
1122  /* DCERPC JSON logger. */
1124  /* app layer frames */
1126  /* BitTorrent DHT JSON logger */
1128 }
RootLogger_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.c:95
log-stats.h
OutputModule_::parent_name
const char * parent_name
Definition: output.h:60
OutputFileRolloverFlag
OutputFileRolloverFlag
Definition: output.c:132
LogTlsStoreRegister
void LogTlsStoreRegister(void)
Definition: log-tlsstore.c:395
tm-threads.h
output-json-ftp.h
OutputDropLoggerEnable
int OutputDropLoggerEnable(void)
Definition: output.c:812
LoggerThreadStoreNode
LoggerThreadStoreNode
Definition: output.c:116
OutputLogFunc
TmEcode(* OutputLogFunc)(ThreadVars *, Packet *, void *)
Definition: output.h:53
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:747
JsonDCERPCLogRegister
void JsonDCERPCLogRegister(void)
Definition: output-json-dcerpc.c:67
output-json-modbus.h
OutputTxLoggerRegister
void OutputTxLoggerRegister(void)
Definition: output-tx.c:670
alert-debuglog.h
TAILQ_INIT
#define TAILQ_INIT(head)
Definition: queue.h:262
JsonPgsqlLogRegister
void JsonPgsqlLogRegister(void)
Definition: output-json-pgsql.c:180
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
JsonSMBLogRegister
void JsonSMBLogRegister(void)
Definition: output-json-smb.c:79
OutputLoggerExitPrintStats
void OutputLoggerExitPrintStats(ThreadVars *tv, void *thread_data)
Definition: output.c:948
output-json-mqtt.h
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
output-eve-stream.h
OutputFileLoggerRegister
void OutputFileLoggerRegister(void)
Definition: output-file.c:241
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:58
OutputModule_::StreamingLogFunc
StreamingLogger StreamingLogFunc
Definition: output.h:75
LogTlsLogRegister
void LogTlsLogRegister(void)
Definition: log-tlslog.c:527
OutputModule_::FileLogFunc
FileLogger FileLogFunc
Definition: output.h:72
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:42
OutputModule_::logger_id
LoggerId logger_id
Definition: output.h:57
LoggerId
LoggerId
Definition: suricata-common.h:455
AlertFastLogRegister
void AlertFastLogRegister(void)
Definition: alert-fastlog.c:77
output-json-pgsql.h
JsonFileLogRegister
void JsonFileLogRegister(void)
Definition: output-json-file.c:346
JsonRdpLogRegister
void JsonRdpLogRegister(void)
Definition: output-json-rdp.c:71
output-json-frame.h
OutputModule_::ts_log_progress
int ts_log_progress
Definition: output.h:80
JsonSNMPLogRegister
void JsonSNMPLogRegister(void)
Definition: output-json-snmp.c:85
output-json-netflow.h
JsonDNP3LogRegister
void JsonDNP3LogRegister(void)
Definition: output-json-dnp3.c:345
LogCustomFormatRegister
void LogCustomFormatRegister(void)
Definition: log-cf-common.c:271
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:252
output-json-krb5.h
OutputGetModuleByConfName
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
Definition: output.c:785
output-json-tls.h
OutputSetupActiveLoggers
void OutputSetupActiveLoggers(void)
Definition: output.c:995
AlertSyslogRegister
void AlertSyslogRegister(void)
Function to register the AlertSyslog module.
Definition: alert-syslog.c:391
OutputModule_::StatsLogFunc
StatsLogger StatsLogFunc
Definition: output.h:76
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:400
output-json-sip.h
OutputRegisterFileSubModule
void OutputRegisterFileSubModule(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputInitSubFunc InitFunc, FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a file output sub-module.
Definition: output.c:468
JsonDHCPLogRegister
void JsonDHCPLogRegister(void)
Definition: output-json-dhcp.c:146
TxLogger
int(* TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:33
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:30
TAILQ_INSERT_TAIL
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:294
JsonSshLogRegister
void JsonSshLogRegister(void)
Definition: output-json-ssh.c:85
PcapLogRegister
void PcapLogRegister(void)
Definition: log-pcap.c:211
OutputModule_::InitSubFunc
OutputInitSubFunc InitSubFunc
Definition: output.h:62
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:627
OutputModule_::PacketLogFunc
PacketLogger PacketLogFunc
Definition: output.h:68
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:85
JsonStatsLogRegister
void JsonStatsLogRegister(void)
Definition: output-json-stats.c:467
output-json-tftp.h
LogTcpDataLogRegister
void LogTcpDataLogRegister(void)
Definition: log-tcp-data.c:46
OutputRegisterRootLoggers
void OutputRegisterRootLoggers(void)
Register all root loggers.
Definition: output.c:1026
OutputLoggerThreadDeinit
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output.c:922
OutputModule_::alproto
AppProto alproto
Definition: output.h:77
JsonTlsLogRegister
void JsonTlsLogRegister(void)
Definition: output-json-tls.c:649
alert-syslog.h
output-json-bittorrent-dht.h
JsonFlowLogRegister
void JsonFlowLogRegister(void)
Definition: output-json-flow.c:348
TmModuleLoggerRegister
void TmModuleLoggerRegister(void)
Definition: output.c:1017
output-json-rdp.h
output-json-dcerpc.h
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
OutputJsonRegister
void OutputJsonRegister(void)
Definition: output-json.c:91
OutputClearActiveLoggers
void OutputClearActiveLoggers(void)
Definition: output.c:1008
OutputModule_::stream_type
enum OutputStreamingType stream_type
Definition: output.h:78
TAILQ_ENTRY
#define TAILQ_ENTRY(type)
Definition: queue.h:239
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:832
LogHttpLogRegister
void LogHttpLogRegister(void)
Definition: log-httplog.c:65
OutputModule_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.h:64
TAILQ_HEAD_INITIALIZER
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:236
output_modules
OutputModuleList output_modules
OutputInitSubFunc
OutputInitResult(* OutputInitSubFunc)(ConfNode *, OutputCtx *)
Definition: output.h:52
JsonAnomalyLogRegister
void JsonAnomalyLogRegister(void)
Definition: output-json-anomaly.c:452
TAILQ_REMOVE
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:312
OutputModule_::FiledataLogFunc
FiledataLogger FiledataLogFunc
Definition: output.h:73
util-debug.h
output-json-flow.h
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:250
OutputStreamingLoggerRegister
void OutputStreamingLoggerRegister(void)
Definition: output-streaming.c:456
util-error.h
FileLogger
int(* FileLogger)(ThreadVars *, void *thread_data, const Packet *, const File *, void *tx, const uint64_t tx_id, uint8_t direction)
Definition: output-file.h:48
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:547
log-tcp-data.h
output-json-rfb.h
JsonTFTPLogRegister
void JsonTFTPLogRegister(void)
Definition: output-json-tftp.c:84
FiledataLogger
int(* FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, void *tx, const uint64_t tx_id, const uint8_t *, uint32_t, uint8_t, uint8_t dir)
Definition: output-filedata.h:49
OutputModule_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.h:65
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:380
output-json-file.h
OutputRegisterModule
void OutputRegisterModule(const char *, const char *, OutputInitFunc)
JsonIKELogRegister
void JsonIKELogRegister(void)
Definition: output-json-ike.c:182
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
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:668
ThreadInitFunc
TmEcode(* ThreadInitFunc)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:39
log-tlslog.h
OutputLoggerThreadInit
TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
Definition: output.c:891
JsonMQTTLogRegister
void JsonMQTTLogRegister(void)
Definition: output-json-mqtt.c:191
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:295
OutputFilestoreRegister
void OutputFilestoreRegister(void)
Definition: output-filestore.c:509
JsonQuicLogRegister
void JsonQuicLogRegister(void)
Definition: output-json-quic.c:156
OutputRegisterLoggers
void OutputRegisterLoggers(void)
Register all non-root logging modules.
Definition: output.c:1038
OutputModule_::conf_name
const char * conf_name
Definition: output.h:59
output-json-anomaly.h
OutputModule_::FlowLogFunc
FlowLogger FlowLogFunc
Definition: output.h:74
OutputDeregisterAll
void OutputDeregisterAll(void)
Deregister all modules. Useful for a memory clean exit.
Definition: output.c:800
Packet_
Definition: decode.h:430
RootLogger_::ActiveCntFunc
OutputGetActiveCountFunc ActiveCntFunc
Definition: output.c:97
OutputPacketLoggerRegister
void OutputPacketLoggerRegister(void)
Definition: output-packet.c:216
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:118
TmEcode
TmEcode
Definition: tm-threads-common.h:83
EveStreamLogRegister
void EveStreamLogRegister(void)
Definition: output-eve-stream.c:437
OutputModule_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.h:66
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:349
log-pcap.h
alert-fastlog.h
LogStatsLogRegister
void LogStatsLogRegister(void)
Definition: log-stats.c:288
JsonFrameLogRegister
void JsonFrameLogRegister(void)
Definition: output-json-frame.c:509
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:508
OutputModule_::TxLogCondition
TxLoggerCondition TxLogCondition
Definition: output.h:71
JsonBitTorrentDHTLogRegister
void JsonBitTorrentDHTLogRegister(void)
Definition: output-json-bittorrent-dht.c:154
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:216
output-json-nfs.h
ThreadExitPrintStatsFunc
void(* ThreadExitPrintStatsFunc)(ThreadVars *, void *)
Definition: tm-modules.h:41
TAILQ_NEXT
#define TAILQ_NEXT(elm, field)
Definition: queue.h:307
RootLogger_::ThreadExitPrintStats
ThreadExitPrintStatsFunc ThreadExitPrintStats
Definition: output.c:96
output-filestore.h
FatalError
#define FatalError(...)
Definition: util-debug.h:502
LuaLogRegister
void LuaLogRegister(void)
Definition: output-lua.c:898
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:411
JsonSmtpLogRegister
void JsonSmtpLogRegister(void)
Definition: output-json-smtp.c:192
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
log-httplog.h
JsonMetadataLogRegister
void JsonMetadataLogRegister(void)
Definition: output-json-metadata.c:98
output-json-alert.h
OutputModule_::PacketConditionFunc
PacketLogCondition PacketConditionFunc
Definition: output.h:69
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:176
RootLogger
struct RootLogger_ RootLogger
output-json-dns.h
output-json-http2.h
OutputGetActiveCountFunc
uint32_t(* OutputGetActiveCountFunc)(void)
Definition: output.h:54
PacketLogCondition
int(* PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *)
Definition: output-packet.h:35
JsonHttp2LogRegister
void JsonHttp2LogRegister(void)
Definition: output-json-http2.c:178
TxLoggerCondition
int(* TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id)
Definition: output-tx.h:38
log-cf-common.h
output-json-metadata.h
OutputStreamingType
OutputStreamingType
Definition: output-streaming.h:36
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:587
JsonDnsLogRegister
void JsonDnsLogRegister(void)
Definition: output-json-dns.c:577
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
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
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:430
JsonDropLogRegister
void JsonDropLogRegister(void)
Definition: output-json-drop.c:388
output-json-ike.h
StatsLogger
int(* StatsLogger)(ThreadVars *, void *thread_data, const StatsTable *)
Definition: output-stats.h:50
OutputModule_::TxLogFunc
TxLogger TxLogFunc
Definition: output.h:70
OutputModule_::tc_log_progress
int tc_log_progress
Definition: output.h:79
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:369
OutputInitFunc
OutputInitResult(* OutputInitFunc)(ConfNode *)
Definition: output.h:51
JsonFTPLogRegister
void JsonFTPLogRegister(void)
Definition: output-json-ftp.c:202
output-json-ssh.h
output-lua.h
OutputRegisterRootLogger
void OutputRegisterRootLogger(ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats, OutputLogFunc LogFunc, OutputGetActiveCountFunc ActiveCntFunc)
Definition: output.c:962
JsonRFBLogRegister
void JsonRFBLogRegister(void)
Definition: output-json-rfb.c:93
JsonHttpLogRegister
void JsonHttpLogRegister(void)
Definition: output-json-http.c:647
JsonTemplateLogRegister
void JsonTemplateLogRegister(void)
Definition: output-json-template.c:165
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:56
AlertDebugLogRegister
void AlertDebugLogRegister(void)
Definition: alert-debuglog.c:486
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:278
JsonSIPLogRegister
void JsonSIPLogRegister(void)
Definition: output-json-sip.c:94
JsonKRB5LogRegister
void JsonKRB5LogRegister(void)
Definition: output-json-krb5.c:86
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:709
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:338
output-json-snmp.h
output.h
JsonAlertLogRegister
void JsonAlertLogRegister(void)
Definition: output-json-alert.c:1181
JsonNFSLogRegister
void JsonNFSLogRegister(void)
Definition: output-json-nfs.c:110
OutputDropLoggerDisable
void OutputDropLoggerDisable(void)
Definition: output.c:820
JsonNetFlowLogRegister
void JsonNetFlowLogRegister(void)
Definition: output-json-netflow.c:295
ThreadDeinitFunc
TmEcode(* ThreadDeinitFunc)(ThreadVars *, void *)
Definition: tm-modules.h:40
OutputModule_::InitFunc
OutputInitFunc InitFunc
Definition: output.h:61
RootLogger_
Definition: output.c:92
output-json-drop.h