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