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