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