suricata
runmodes.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2024 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 /** \file
19  *
20  * \author Victor Julien <victor@inliniac.net>
21  *
22  * Pre-cooked threading runmodes.
23  */
24 
25 #include "suricata-common.h"
26 #include "detect-engine.h"
27 #include "app-layer-parser.h"
28 #include "util-debug.h"
29 #include "util-affinity.h"
30 #include "conf.h"
31 #include "runmodes.h"
32 #include "runmode-af-packet.h"
33 #include "runmode-af-xdp.h"
34 #include "runmode-dpdk.h"
35 #include "runmode-erf-dag.h"
36 #include "runmode-erf-file.h"
37 #include "runmode-ipfw.h"
38 #include "runmode-netmap.h"
39 #include "runmode-nflog.h"
40 #include "runmode-nfq.h"
41 #include "runmode-pcap.h"
42 #include "runmode-pcap-file.h"
43 #include "runmode-unix-socket.h"
44 #include "runmode-windivert.h"
45 #include "util-unittest.h"
46 #include "util-misc.h"
47 #include "util-plugin.h"
48 
49 #include "output.h"
50 
51 #include "tmqh-flow.h"
52 #include "flow-manager.h"
53 #include "flow-bypass.h"
54 #include "counters.h"
55 
56 #include "suricata-plugin.h"
57 #include "util-device.h"
58 
62 
63 /* Runmode Global Thread Names */
64 const char *thread_name_autofp = "RX";
65 const char *thread_name_single = "W";
66 const char *thread_name_workers = "W";
67 const char *thread_name_verdict = "TX";
68 const char *thread_name_flow_mgr = "FM";
69 const char *thread_name_flow_rec = "FR";
70 const char *thread_name_flow_bypass = "FB";
71 const char *thread_name_unix_socket = "US";
72 const char *thread_name_detect_loader = "DL";
73 const char *thread_name_counter_stats = "CS";
74 const char *thread_name_counter_wakeup = "CW";
75 
76 /**
77  * \brief Holds description for a runmode.
78  */
79 typedef struct RunMode_ {
80  /* the runmode type */
81  enum RunModes runmode;
82  const char *name;
83  const char *description;
84  /* runmode function */
85  int (*RunModeFunc)(void);
86  int (*RunModeIsIPSEnabled)(void);
88 
89 typedef struct RunModes_ {
90  int cnt;
93 
94 static RunModes runmodes[RUNMODE_USER_MAX];
95 
96 static char *active_runmode;
97 
98 /* free list for our outputs */
99 typedef struct OutputFreeList_ {
102 
103  TAILQ_ENTRY(OutputFreeList_) entries;
105 static TAILQ_HEAD(, OutputFreeList_) output_free_list =
106  TAILQ_HEAD_INITIALIZER(output_free_list);
107 
108 /**
109  * \internal
110  * \brief Translate a runmode mode to a printable string.
111  *
112  * \param runmode Runmode to be converted into a printable string.
113  *
114  * \retval string Printable string.
115  */
116 static const char *RunModeTranslateModeToName(int runmode)
117 {
118  switch (runmode) {
119  case RUNMODE_PCAP_DEV:
120  return "PCAP_DEV";
121  case RUNMODE_PCAP_FILE:
122  return "PCAP_FILE";
123  case RUNMODE_PLUGIN:
124  return "PLUGIN";
125  case RUNMODE_NFQ:
126  return "NFQ";
127  case RUNMODE_NFLOG:
128  return "NFLOG";
129  case RUNMODE_IPFW:
130  return "IPFW";
131  case RUNMODE_ERF_FILE:
132  return "ERF_FILE";
133  case RUNMODE_DAG:
134  return "ERF_DAG";
135  case RUNMODE_UNITTEST:
136  return "UNITTEST";
137  case RUNMODE_AFP_DEV:
138  return "AF_PACKET_DEV";
139  case RUNMODE_AFXDP_DEV:
140  return "AF_XDP_DEV";
141  case RUNMODE_NETMAP:
142 #ifdef HAVE_NETMAP
143  return "NETMAP";
144 #else
145  return "NETMAP(DISABLED)";
146 #endif
147  case RUNMODE_UNIX_SOCKET:
148  return "UNIX_SOCKET";
149  case RUNMODE_WINDIVERT:
150 #ifdef WINDIVERT
151  return "WINDIVERT";
152 #else
153  return "WINDIVERT(DISABLED)";
154 #endif
155  case RUNMODE_DPDK:
156 #ifdef HAVE_DPDK
157  return "DPDK";
158 #else
159  return "DPDK(DISABLED)";
160 #endif
161 
162  default:
163  FatalError("Unknown runtime mode. Aborting");
164  }
165 }
166 
167 /**
168  * \internal
169  * \brief Dispatcher function for runmodes. Calls the required runmode function
170  * based on runmode + runmode_custom_id.
171  *
172  * \param runmode The runmode type.
173  * \param runmode_custom_id The runmode custom id.
174  */
175 static RunMode *RunModeGetCustomMode(enum RunModes runmode, const char *custom_mode)
176 {
177  if (runmode < RUNMODE_USER_MAX) {
178  for (int i = 0; i < runmodes[runmode].cnt; i++) {
179  if (strcmp(runmodes[runmode].runmodes[i].name, custom_mode) == 0)
180  return &runmodes[runmode].runmodes[i];
181  }
182  }
183  return NULL;
184 }
185 
186 
187 /**
188  * Return the running mode
189  *
190  * The returned string must not be freed.
191  *
192  * \return a string containing the current running mode
193  */
194 char *RunmodeGetActive(void)
195 {
196  return active_runmode;
197 }
198 
199 /**
200  * Return the running mode
201  *
202  * The returned string must not be freed.
203  *
204  * \return a string containing the current running mode
205  */
206 const char *RunModeGetMainMode(void)
207 {
208  int mainmode = SCRunmodeGet();
209 
210  return RunModeTranslateModeToName(mainmode);
211 }
212 
213 /**
214  * \brief Register all runmodes in the engine.
215  */
217 {
218  memset(runmodes, 0, sizeof(runmodes));
219 
233 #ifdef UNITTESTS
235 #endif
236 }
237 
238 /**
239  * \brief Lists all registered runmodes.
240  */
242 {
243  printf("------------------------------------- Runmodes -------------------"
244  "-----------------------\n");
245 
246  printf("| %-17s | %-17s | %-10s \n",
247  "RunMode Type", "Custom Mode ", "Description");
248  printf("|-----------------------------------------------------------------"
249  "-----------------------\n");
250  int i = RUNMODE_UNKNOWN + 1;
251  int j = 0;
252  for ( ; i < RUNMODE_USER_MAX; i++) {
253  int mode_displayed = 0;
254  for (j = 0; j < runmodes[i].cnt; j++) {
255  if (mode_displayed == 1) {
256  printf("| ----------------------------------------------"
257  "-----------------------\n");
258  RunMode *runmode = &runmodes[i].runmodes[j];
259  printf("| %-17s | %-17s | %-27s \n",
260  "",
261  runmode->name,
262  runmode->description);
263  } else {
264  RunMode *runmode = &runmodes[i].runmodes[j];
265  printf("| %-17s | %-17s | %-27s \n",
266  RunModeTranslateModeToName(runmode->runmode),
267  runmode->name,
268  runmode->description);
269  }
270  if (mode_displayed == 0)
271  mode_displayed = 1;
272  }
273  if (mode_displayed == 1) {
274  printf("|-----------------------------------------------------------------"
275  "-----------------------\n");
276  }
277  }
278 }
279 
280 static const char *RunModeGetConfOrDefault(int capture_mode, const char *capture_plugin_name)
281 {
282  const char *custom_mode = NULL;
283  const char *val = NULL;
284  if (ConfGet("runmode", &val) != 1) {
285  custom_mode = NULL;
286  } else {
287  custom_mode = val;
288  }
289 
290  if ((custom_mode == NULL) || (strcmp(custom_mode, "auto") == 0)) {
291  switch (capture_mode) {
292  case RUNMODE_PCAP_DEV:
293  custom_mode = RunModeIdsGetDefaultMode();
294  break;
295  case RUNMODE_PCAP_FILE:
296  custom_mode = RunModeFilePcapGetDefaultMode();
297  break;
298  case RUNMODE_PLUGIN: {
299 #ifdef HAVE_PLUGINS
300  SCCapturePlugin *plugin = SCPluginFindCaptureByName(capture_plugin_name);
301  if (plugin == NULL) {
302  FatalError("No capture plugin found with name %s", capture_plugin_name);
303  }
304  custom_mode = (const char *)plugin->GetDefaultMode();
305 #endif
306  break;
307  }
308  case RUNMODE_NFQ:
309  custom_mode = RunModeIpsNFQGetDefaultMode();
310  break;
311  case RUNMODE_IPFW:
312  custom_mode = RunModeIpsIPFWGetDefaultMode();
313  break;
314  case RUNMODE_ERF_FILE:
315  custom_mode = RunModeErfFileGetDefaultMode();
316  break;
317  case RUNMODE_DAG:
318  custom_mode = RunModeErfDagGetDefaultMode();
319  break;
320  case RUNMODE_AFP_DEV:
321  custom_mode = RunModeAFPGetDefaultMode();
322  break;
323  case RUNMODE_AFXDP_DEV:
324  custom_mode = RunModeAFXDPGetDefaultMode();
325  break;
326  case RUNMODE_NETMAP:
327  custom_mode = RunModeNetmapGetDefaultMode();
328  break;
329  case RUNMODE_UNIX_SOCKET:
330  custom_mode = RunModeUnixSocketGetDefaultMode();
331  break;
332  case RUNMODE_NFLOG:
333  custom_mode = RunModeIdsNflogGetDefaultMode();
334  break;
335 #ifdef WINDIVERT
336  case RUNMODE_WINDIVERT:
337  custom_mode = RunModeIpsWinDivertGetDefaultMode();
338  break;
339 #endif
340 #ifdef HAVE_DPDK
341  case RUNMODE_DPDK:
342  custom_mode = RunModeDpdkGetDefaultMode();
343  break;
344 #endif
345  default:
346  return NULL;
347  }
348  } else {
349  /* Add compatibility with old 'worker' name */
350  if (!strcmp("worker", custom_mode)) {
351  SCLogWarning("'worker' mode have been renamed "
352  "to 'workers', please modify your setup.");
353  custom_mode = "workers";
354  }
355  }
356 
357  return custom_mode;
358 }
359 
360 int RunModeEngineIsIPS(int capture_mode, const char *runmode, const char *capture_plugin_name)
361 {
362  if (runmode == NULL) {
363  runmode = RunModeGetConfOrDefault(capture_mode, capture_plugin_name);
364  if (runmode == NULL) // non-standard runmode
365  return 0;
366  }
367 
368  RunMode *mode = RunModeGetCustomMode(capture_mode, runmode);
369  if (mode == NULL) {
370  return 0;
371  }
372 
373  int ips_enabled = 0;
374  if (mode->RunModeIsIPSEnabled != NULL) {
375  ips_enabled = mode->RunModeIsIPSEnabled();
376  if (ips_enabled == 1) {
377  extern uint16_t g_livedev_mask;
378  if (g_livedev_mask != 0 && LiveGetDeviceCount() > 0) {
379  SCLogWarning("disabling livedev.use-for-tracking with IPS mode. See ticket #6726.");
380  g_livedev_mask = 0;
381  }
382  }
383  }
384 
385  return ips_enabled;
386 }
387 
388 /**
389  */
390 void RunModeDispatch(int runmode, const char *custom_mode, const char *capture_plugin_name,
391  const char *capture_plugin_args)
392 {
393  char *local_custom_mode = NULL;
394 
395  if (custom_mode == NULL) {
396  custom_mode = RunModeGetConfOrDefault(runmode, capture_plugin_name);
397  if (custom_mode == NULL)
398  FatalError("Unknown runtime mode. Aborting");
399  }
400 
401  RunMode *mode = RunModeGetCustomMode(runmode, custom_mode);
402  if (mode == NULL) {
403  SCLogError("The custom type \"%s\" doesn't exist "
404  "for this runmode type \"%s\". Please use --list-runmodes to "
405  "see available custom types for this runmode",
406  custom_mode, RunModeTranslateModeToName(runmode));
407  exit(EXIT_FAILURE);
408  }
409 
410  /* Export the custom mode */
411  if (active_runmode) {
412  SCFree(active_runmode);
413  }
414  active_runmode = SCStrdup(custom_mode);
415  if (unlikely(active_runmode == NULL)) {
416  FatalError("Unable to dup active mode");
417  }
418 
419  if (strcasecmp(active_runmode, "autofp") == 0) {
421  }
422 
423  mode->RunModeFunc();
424 
425  if (local_custom_mode != NULL)
426  SCFree(local_custom_mode);
427 
428  /* Check if the alloted queues have at least 1 reader and writer */
430 
431  if (runmode != RUNMODE_UNIX_SOCKET) {
432  /* spawn management threads */
437  }
440  }
441 }
442 
443 static int g_runmode_needs_bypass = 0;
444 
446 {
447  g_runmode_needs_bypass = 1;
448 }
449 
451 {
452  return g_runmode_needs_bypass;
453 }
454 
455 
456 
457 /**
458  * \brief Registers a new runmode.
459  *
460  * \param runmode Runmode type.
461  * \param name Custom mode for this specific runmode type. Within each
462  * runmode type, each custom name is a primary key.
463  * \param description Description for this runmode.
464  * \param RunModeFunc The function to be run for this runmode.
465  */
466 void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description,
467  int (*RunModeFunc)(void), int (*RunModeIsIPSEnabled)(void))
468 {
469  if (RunModeGetCustomMode(runmode, name) != NULL) {
470  FatalError("runmode '%s' has already "
471  "been registered. Please use an unique name.",
472  name);
473  }
474 
475  void *ptmp = SCRealloc(runmodes[runmode].runmodes,
476  (runmodes[runmode].cnt + 1) * sizeof(RunMode));
477  if (ptmp == NULL) {
478  SCFree(runmodes[runmode].runmodes);
479  runmodes[runmode].runmodes = NULL;
480  exit(EXIT_FAILURE);
481  }
482  runmodes[runmode].runmodes = ptmp;
483 
484  RunMode *mode = &runmodes[runmode].runmodes[runmodes[runmode].cnt];
485  runmodes[runmode].cnt++;
486  memset(mode, 0x00, sizeof(*mode));
487 
488  mode->runmode = runmode;
489  mode->name = SCStrdup(name);
490  if (unlikely(mode->name == NULL)) {
491  FatalError("Failed to allocate string");
492  }
493  mode->description = SCStrdup(description);
494  if (unlikely(mode->description == NULL)) {
495  FatalError("Failed to allocate string");
496  }
497  mode->RunModeFunc = RunModeFunc;
498  mode->RunModeIsIPSEnabled = RunModeIsIPSEnabled;
499 }
500 
501 /**
502  * Setup the outputs for this run mode.
503  *
504  * \param tv The ThreadVars for the thread the outputs will be
505  * appended to.
506  */
507 static void RunOutputFreeList(void)
508 {
509  OutputFreeList *output;
510  while ((output = TAILQ_FIRST(&output_free_list))) {
511  TAILQ_REMOVE(&output_free_list, output, entries);
512 
513  SCLogDebug("output %s %p %p", output->output_module->name, output, output->output_ctx);
514  if (output->output_ctx != NULL && output->output_ctx->DeInit != NULL)
515  output->output_ctx->DeInit(output->output_ctx);
516  SCFree(output);
517  }
518 }
519 
520 static int file_logger_count = 0;
521 static int filedata_logger_count = 0;
522 
524 {
525  return filedata_logger_count > 0;
526 }
527 
528 bool IsRunModeSystem(enum RunModes run_mode_to_check)
529 {
530  switch (run_mode_to_check) {
531  case RUNMODE_PCAP_FILE:
532  case RUNMODE_ERF_FILE:
534  return false;
535  break;
536  default:
537  return true;
538  }
539 }
540 
541 bool IsRunModeOffline(enum RunModes run_mode_to_check)
542 {
543  switch(run_mode_to_check) {
544  case RUNMODE_CONF_TEST:
545  case RUNMODE_PCAP_FILE:
546  case RUNMODE_ERF_FILE:
548  case RUNMODE_UNIX_SOCKET:
549  return true;
550  break;
551  default:
552  return false;
553  }
554 }
555 
556 /**
557  * Cleanup the run mode.
558  */
559 void RunModeShutDown(void)
560 {
561  RunOutputFreeList();
562 
570 
572 
573  /* Reset logger counts. */
574  file_logger_count = 0;
575  filedata_logger_count = 0;
576 }
577 
578 /** \internal
579  * \brief add Sub RunModeOutput to list for Submodule so we can free
580  * the output ctx at shutdown and unix socket reload */
581 static void AddOutputToFreeList(OutputModule *module, OutputCtx *output_ctx)
582 {
583  OutputFreeList *fl_output = SCCalloc(1, sizeof(OutputFreeList));
584  if (unlikely(fl_output == NULL))
585  return;
586  fl_output->output_module = module;
587  fl_output->output_ctx = output_ctx;
588  TAILQ_INSERT_TAIL(&output_free_list, fl_output, entries);
589 }
590 
591 /** \brief Turn output into thread module */
592 static void SetupOutput(
593  const char *name, OutputModule *module, OutputCtx *output_ctx, LoggerId *logger_bits)
594 {
595  /* flow logger doesn't run in the packet path */
596  if (module->FlowLogFunc) {
597  SCOutputRegisterFlowLogger(module->name, module->FlowLogFunc, output_ctx,
598  module->ThreadInit, module->ThreadDeinit);
599  return;
600  }
601  /* stats logger doesn't run in the packet path */
602  if (module->StatsLogFunc) {
603  OutputRegisterStatsLogger(module->name, module->StatsLogFunc, output_ctx,
604  module->ThreadInit, module->ThreadDeinit);
605  return;
606  }
607 
608  if (module->logger_id == LOGGER_ALERT_DEBUG) {
609  debuglog_enabled = 1;
610  }
611 
612  if (module->PacketLogFunc) {
613  SCLogDebug("%s is a packet logger", module->name);
614  SCOutputRegisterPacketLogger(module->logger_id, module->name, module->PacketLogFunc,
615  module->PacketConditionFunc, output_ctx, module->ThreadInit, module->ThreadDeinit);
616  } else if (module->TxLogFunc) {
617  SCLogDebug("%s is a tx logger", module->name);
618  SCOutputRegisterTxLogger(module->logger_id, module->name, module->alproto,
619  module->TxLogFunc, output_ctx, module->tc_log_progress, module->ts_log_progress,
620  module->TxLogCondition, module->ThreadInit, module->ThreadDeinit);
621  /* Not used with wild card loggers */
622  if (module->alproto != ALPROTO_UNKNOWN) {
623  logger_bits[module->alproto] |= BIT_U32(module->logger_id);
624  }
625  } else if (module->FiledataLogFunc) {
626  SCLogDebug("%s is a filedata logger", module->name);
628  output_ctx, module->ThreadInit, module->ThreadDeinit);
629  filedata_logger_count++;
630  } else if (module->FileLogFunc) {
631  SCLogDebug("%s is a file logger", module->name);
632  SCOutputRegisterFileLogger(module->logger_id, module->name, module->FileLogFunc, output_ctx,
633  module->ThreadInit, module->ThreadDeinit);
634  file_logger_count++;
635  } else if (module->StreamingLogFunc) {
636  SCLogDebug("%s is a streaming logger", module->name);
638  output_ctx, module->stream_type, module->ThreadInit, module->ThreadDeinit);
639  } else {
640  SCLogError("Unknown logger type: name=%s", module->name);
641  }
642 }
643 
644 static void RunModeInitializeEveOutput(ConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
645 {
646  ConfNode *types = ConfNodeLookupChild(conf, "types");
647  SCLogDebug("types %p", types);
648  if (types == NULL) {
649  return;
650  }
651 
652  ConfNode *type = NULL;
653  TAILQ_FOREACH(type, &types->head, next) {
654  int sub_count = 0;
655  char subname[256];
656 
657  if (strcmp(type->val, "ikev2") == 0) {
658  SCLogWarning("eve module 'ikev2' has been replaced by 'ike'");
659  strlcpy(subname, "eve-log.ike", sizeof(subname));
660  } else {
661  snprintf(subname, sizeof(subname), "eve-log.%s", type->val);
662  }
663 
664  SCLogConfig("enabling 'eve-log' module '%s'", type->val);
665 
666  ConfNode *sub_output_config = ConfNodeLookupChild(type, type->val);
667  if (sub_output_config != NULL) {
668  const char *enabled = ConfNodeLookupChildValue(
669  sub_output_config, "enabled");
670  if (enabled != NULL && !ConfValIsTrue(enabled)) {
671  continue;
672  }
673  }
674 
675  /* Now setup all registers logger of this name. */
676  OutputModule *sub_module;
677  TAILQ_FOREACH(sub_module, &output_modules, entries) {
678  if (strcmp(subname, sub_module->conf_name) == 0) {
679  sub_count++;
680 
681  if (sub_module->parent_name == NULL ||
682  strcmp(sub_module->parent_name, "eve-log") != 0) {
683  FatalError("bad parent for %s", subname);
684  }
685  if (sub_module->InitSubFunc == NULL) {
686  FatalError("bad sub-module for %s", subname);
687  }
688 
689  /* pass on parent output_ctx */
690  OutputInitResult result =
691  sub_module->InitSubFunc(sub_output_config, parent_ctx);
692  if (!result.ok || result.ctx == NULL) {
693  FatalError("unable to initialize sub-module %s", subname);
694  }
695 
696  AddOutputToFreeList(sub_module, result.ctx);
697  SetupOutput(sub_module->name, sub_module, result.ctx, logger_bits);
698  }
699  }
700 
701  /* Error is no registered loggers with this name
702  * were found .*/
703  if (!sub_count) {
704  FatalErrorOnInit("No output module named %s", subname);
705  continue;
706  }
707  }
708 }
709 
710 static void RunModeInitializeLuaOutput(ConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
711 {
712  OutputModule *lua_module = OutputGetModuleByConfName("lua");
713  BUG_ON(lua_module == NULL);
714 
715  ConfNode *scripts = ConfNodeLookupChild(conf, "scripts");
716  BUG_ON(scripts == NULL); //TODO
717 
718  OutputModule *m;
719  TAILQ_FOREACH(m, &parent_ctx->submodules, entries) {
720  SCLogDebug("m %p %s:%s", m, m->name, m->conf_name);
721 
722  ConfNode *script = NULL;
723  TAILQ_FOREACH(script, &scripts->head, next) {
724  SCLogDebug("script %s", script->val);
725  if (strcmp(script->val, m->conf_name) == 0) {
726  break;
727  }
728  }
729  BUG_ON(script == NULL);
730 
731  /* pass on parent output_ctx */
732  OutputInitResult result = m->InitSubFunc(script, parent_ctx);
733  if (!result.ok || result.ctx == NULL) {
734  continue;
735  }
736 
737  AddOutputToFreeList(m, result.ctx);
738  SetupOutput(m->name, m, result.ctx, logger_bits);
739  }
740 }
741 
742 extern bool g_file_logger_enabled;
743 extern bool g_filedata_logger_enabled;
744 
745 /**
746  * Initialize the output modules.
747  */
749 {
750  ConfNode *outputs = ConfGetNode("outputs");
751  if (outputs == NULL) {
752  /* No "outputs" section in the configuration. */
753  return;
754  }
755 
756  ConfNode *output, *output_config;
757  const char *enabled;
758  char tls_log_enabled = 0;
759  char tls_store_present = 0;
760 
761  // g_alproto_max is set to its final value
762  LoggerId logger_bits[g_alproto_max];
763  memset(logger_bits, 0, g_alproto_max * sizeof(LoggerId));
764  TAILQ_FOREACH(output, &outputs->head, next) {
765 
766  output_config = ConfNodeLookupChild(output, output->val);
767  if (output_config == NULL) {
768  /* Shouldn't happen. */
769  FatalError("Failed to lookup configuration child node: %s", output->val);
770  }
771 
772  if (strcmp(output->val, "tls-store") == 0) {
773  tls_store_present = 1;
774  }
775 
776  enabled = ConfNodeLookupChildValue(output_config, "enabled");
777  if (enabled == NULL || !ConfValIsTrue(enabled)) {
778  continue;
779  }
780 
781  if (strcmp(output->val, "file-log") == 0) {
782  SCLogWarning("file-log is no longer supported,"
783  " use eve.files instead "
784  "(see ticket #2376"
785  " for an explanation)");
786  continue;
787  } else if (strncmp(output->val, "unified-", sizeof("unified-") - 1) == 0) {
788  SCLogWarning("Unified1 is no longer supported,"
789  " use Unified2 instead "
790  "(see ticket #353"
791  " for an explanation)");
792  continue;
793  } else if (strncmp(output->val, "unified2-", sizeof("unified2-") - 1) == 0) {
794  SCLogWarning("Unified2 is no longer supported.");
795  continue;
796  } else if (strcmp(output->val, "dns-log") == 0) {
797  SCLogWarning("dns-log is not longer available as of Suricata 5.0");
798  continue;
799  } else if (strcmp(output->val, "tls-log") == 0) {
800  tls_log_enabled = 1;
801  }
802 
803  OutputModule *module;
804  int count = 0;
805  TAILQ_FOREACH(module, &output_modules, entries) {
806  if (strcmp(module->conf_name, output->val) != 0) {
807  continue;
808  }
809 
810  count++;
811 
812  OutputCtx *output_ctx = NULL;
813  if (module->InitFunc != NULL) {
814  OutputInitResult r = module->InitFunc(output_config);
815  if (!r.ok) {
816  FatalErrorOnInit("output module \"%s\": setup failed", output->val);
817  continue;
818  } else if (r.ctx == NULL) {
819  continue;
820  }
821  output_ctx = r.ctx;
822  } else if (module->InitSubFunc != NULL) {
823  SCLogInfo("skipping submodule");
824  continue;
825  }
826 
827  // TODO if module == parent, find it's children
828  if (strcmp(output->val, "eve-log") == 0) {
829  RunModeInitializeEveOutput(output_config, output_ctx, logger_bits);
830 
831  /* add 'eve-log' to free list as it's the owner of the
832  * main output ctx from which the sub-modules share the
833  * LogFileCtx */
834  AddOutputToFreeList(module, output_ctx);
835  } else if (strcmp(output->val, "lua") == 0) {
836  SCLogDebug("handle lua");
837  if (output_ctx == NULL)
838  continue;
839  RunModeInitializeLuaOutput(output_config, output_ctx, logger_bits);
840  AddOutputToFreeList(module, output_ctx);
841  } else {
842  AddOutputToFreeList(module, output_ctx);
843  SetupOutput(module->name, module, output_ctx, logger_bits);
844  }
845  }
846  if (count == 0) {
847  FatalErrorOnInit("No output module named %s", output->val);
848  continue;
849  }
850  }
851 
852  /* Backward compatibility code */
853  if (!tls_store_present && tls_log_enabled) {
854  /* old YAML with no "tls-store" in outputs. "tls-log" value needs
855  * to be started using 'tls-log' config as own config */
856  SCLogWarning("Please use 'tls-store' in YAML to configure TLS storage");
857 
858  TAILQ_FOREACH(output, &outputs->head, next) {
859  output_config = ConfNodeLookupChild(output, output->val);
860 
861  if (strcmp(output->val, "tls-log") == 0) {
862 
863  OutputModule *module = OutputGetModuleByConfName("tls-store");
864  if (module == NULL) {
865  SCLogWarning("No output module named %s, ignoring", "tls-store");
866  continue;
867  }
868 
869  OutputCtx *output_ctx = NULL;
870  if (module->InitFunc != NULL) {
871  OutputInitResult r = module->InitFunc(output_config);
872  if (!r.ok) {
873  FatalErrorOnInit("output module setup failed");
874  continue;
875  } else if (r.ctx == NULL) {
876  continue;
877  }
878  output_ctx = r.ctx;
879  }
880 
881  AddOutputToFreeList(module, output_ctx);
882  SetupOutput(module->name, module, output_ctx, logger_bits);
883  }
884  }
885  }
886 
887  /* register the logger bits to the app-layer */
888  AppProto a;
889  for (a = 0; a < g_alproto_max; a++) {
890  if (AppLayerParserSupportsFiles(IPPROTO_TCP, a)) {
892  logger_bits[a] |= BIT_U32(LOGGER_FILE);
894  logger_bits[a] |= BIT_U32(LOGGER_FILEDATA);
895  SCLogDebug("IPPROTO_TCP::%s: g_file_logger_enabled %d g_filedata_logger_enabled %d -> "
896  "%08x",
898  logger_bits[a]);
899  }
900  if (AppLayerParserSupportsFiles(IPPROTO_UDP, a)) {
902  logger_bits[a] |= BIT_U32(LOGGER_FILE);
904  logger_bits[a] |= BIT_U32(LOGGER_FILEDATA);
905  }
906 
907  if (logger_bits[a] == 0)
908  continue;
909 
910  const int tcp = AppLayerParserProtocolHasLogger(IPPROTO_TCP, a) | (g_file_logger_enabled) |
912  const int udp = AppLayerParserProtocolHasLogger(IPPROTO_UDP, a) | (g_file_logger_enabled) |
914  SCLogDebug("tcp %d udp %d", tcp, udp);
915 
916  SCLogDebug("logger for %s: %s %s", AppProtoToString(a),
917  tcp ? "true" : "false", udp ? "true" : "false");
918 
919  SCLogDebug("logger bits for %s: %08x", AppProtoToString(a), logger_bits[a]);
920  if (tcp)
921  AppLayerParserRegisterLoggerBits(IPPROTO_TCP, a, logger_bits[a]);
922  if (udp)
923  AppLayerParserRegisterLoggerBits(IPPROTO_UDP, a, logger_bits[a]);
924  }
926 }
927 
929 
930 /**
931  * Initialize multithreading settings.
932  */
934 {
935  int affinity = 0;
936  if ((ConfGetBool("threading.set-cpu-affinity", &affinity)) == 0) {
938  } else {
939  threading_set_cpu_affinity = affinity == 1;
940  }
941 
942  /* try to get custom cpu mask value if needed */
945  }
946  if ((ConfGetFloat("threading.detect-thread-ratio", &threading_detect_ratio)) != 1) {
947  if (ConfGetNode("threading.detect-thread-ratio") != NULL)
948  WarnInvalidConfEntry("threading.detect-thread-ratio", "%s", "1");
950  }
951 
952  SCLogDebug("threading.detect-thread-ratio %f", threading_detect_ratio);
953 
954  /*
955  * Check if there's a configuration setting for the per-thread stack size
956  * in case the default per-thread stack size is to be adjusted
957  */
958  const char *ss = NULL;
959  if ((ConfGet("threading.stack-size", &ss)) == 1) {
960  if (ss != NULL) {
962  FatalError("Failed to initialize thread_stack_size output, invalid limit: %s", ss);
963  }
964  }
965  } else {
966  pthread_attr_t attr;
967  pthread_attr_init(&attr);
968  size_t size;
969  if (pthread_attr_getstacksize(&attr, &size) == 0 && size < 512 * 1024) {
970  threading_set_stack_size = 512 * 1024;
971  SCLogNotice("thread stack size of %" PRIuMAX " too small: setting to 512k",
972  (uintmax_t)size);
973  }
974  }
975 
976  SCLogDebug("threading.stack-size %" PRIu64, threading_set_stack_size);
977 }
thread_name_workers
const char * thread_name_workers
Definition: runmodes.c:66
RUNMODE_AFXDP_DEV
@ RUNMODE_AFXDP_DEV
Definition: runmodes.h:37
RunModeIpsIPFWGetDefaultMode
const char * RunModeIpsIPFWGetDefaultMode(void)
Definition: runmode-ipfw.c:44
FlowManagerThreadSpawn
void FlowManagerThreadSpawn(void)
spawn the flow manager thread
Definition: flow-manager.c:1000
suricata-plugin.h
AffinitySetupLoadFromConfig
void AffinitySetupLoadFromConfig(void)
Extract cpu affinity configuration from current config file.
Definition: util-affinity.c:164
OutputModule_::parent_name
const char * parent_name
Definition: output.h:60
TmThreadsSealThreads
void TmThreadsSealThreads(void)
Definition: tm-threads.c:2091
thread_name_counter_wakeup
const char * thread_name_counter_wakeup
Definition: runmodes.c:74
OutputModule_::FileLogFunc
SCFileLogger FileLogFunc
Definition: output.h:71
flow-bypass.h
RunMode_::description
const char * description
Definition: runmodes.c:83
g_livedev_mask
uint16_t g_livedev_mask
Definition: suricata.c:203
detect-engine.h
SCRunmodeGet
int SCRunmodeGet(void)
Get the current run mode.
Definition: suricata.c:260
RUNMODE_UNIX_SOCKET
@ RUNMODE_UNIX_SOCKET
Definition: runmodes.h:41
threading_set_cpu_affinity
bool threading_set_cpu_affinity
Definition: runmodes.c:60
RunModeErfFileRegister
void RunModeErfFileRegister(void)
Definition: runmode-erf-file.c:39
OutputStreamingShutdown
void OutputStreamingShutdown(void)
Definition: output-streaming.c:439
RunMode_::RunModeIsIPSEnabled
int(* RunModeIsIPSEnabled)(void)
Definition: runmodes.c:86
AppLayerParserProtocolHasLogger
int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:1524
thread_name_flow_mgr
const char * thread_name_flow_mgr
Definition: runmodes.c:68
RUNMODE_UNITTEST
@ RUNMODE_UNITTEST
Definition: runmodes.h:40
RunModeErfFileGetDefaultMode
const char * RunModeErfFileGetDefaultMode(void)
Definition: runmode-erf-file.c:34
ConfNode_::val
char * val
Definition: conf.h:34
ConfGetBool
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:482
RUNMODE_DPDK
@ RUNMODE_DPDK
Definition: runmodes.h:39
runmode-af-packet.h
RUNMODE_UNKNOWN
@ RUNMODE_UNKNOWN
Definition: runmodes.h:28
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
LOGGER_FILEDATA
@ LOGGER_FILEDATA
Definition: suricata-common.h:470
OutputTxShutdown
void OutputTxShutdown(void)
Definition: output-tx.c:666
TmqhFlowPrintAutofpHandler
void TmqhFlowPrintAutofpHandler(void)
Definition: tmqh-flow.c:84
RunModeIdsAFPRegister
void RunModeIdsAFPRegister(void)
Definition: runmode-af-packet.c:136
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
ParseSizeStringU64
int ParseSizeStringU64(const char *size, uint64_t *res)
Definition: util-misc.c:190
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
BypassedFlowManagerThreadSpawn
void BypassedFlowManagerThreadSpawn(void)
spawn the flow bypass manager thread
Definition: flow-bypass.c:187
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:85
RunModeShutDown
void RunModeShutDown(void)
Definition: runmodes.c:559
RunModeDispatch
void RunModeDispatch(int runmode, const char *custom_mode, const char *capture_plugin_name, const char *capture_plugin_args)
Definition: runmodes.c:390
ConfGetNode
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
Definition: conf.c:181
OutputModule_::name
const char * name
Definition: output.h:58
thread_name_counter_stats
const char * thread_name_counter_stats
Definition: runmodes.c:73
SCOutputRegisterStreamingLogger
int SCOutputRegisterStreamingLogger(LoggerId id, const char *name, SCStreamingLogger LogFunc, void *initdata, enum SCOutputStreamingType type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a streaming logger.
Definition: output-streaming.c:63
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:40
runmode-pcap.h
AppLayerParserSupportsFiles
bool AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:1156
RunModeAFPGetDefaultMode
const char * RunModeAFPGetDefaultMode(void)
Definition: runmode-af-packet.c:64
thread_name_flow_rec
const char * thread_name_flow_rec
Definition: runmodes.c:69
OutputFiledataShutdown
void OutputFiledataShutdown(void)
Definition: output-filedata.c:277
RUNMODE_ERF_FILE
@ RUNMODE_ERF_FILE
Definition: runmodes.h:34
OutputModule_::ts_log_progress
int ts_log_progress
Definition: output.h:79
runmode-erf-file.h
runmode-windivert.h
RunModeFilePcapGetDefaultMode
const char * RunModeFilePcapGetDefaultMode(void)
Definition: runmode-pcap-file.c:35
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:252
thread_name_autofp
const char * thread_name_autofp
Definition: runmodes.c:64
RUNMODE_NFLOG
@ RUNMODE_NFLOG
Definition: runmodes.h:32
OutputGetModuleByConfName
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
Definition: output.c:612
OutputSetupActiveLoggers
void OutputSetupActiveLoggers(void)
Definition: output.c:808
OutputModule_::StatsLogFunc
StatsLogger StatsLogFunc
Definition: output.h:75
RunModeIdsNflogGetDefaultMode
const char * RunModeIdsNflogGetDefaultMode(void)
Definition: runmode-nflog.c:208
RUNMODE_PCAP_DEV
@ RUNMODE_PCAP_DEV
Definition: runmodes.h:29
RunMode_::RunModeFunc
int(* RunModeFunc)(void)
Definition: runmodes.c:85
OutputStatsShutdown
void OutputStatsShutdown(void)
Definition: output-stats.c:184
TAILQ_INSERT_TAIL
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:294
RunmodeGetActive
char * RunmodeGetActive(void)
Definition: runmodes.c:194
m
SCMutex m
Definition: flow-hash.h:6
OutputModule_::InitSubFunc
OutputInitSubFunc InitSubFunc
Definition: output.h:62
SCOutputRegisterFlowLogger
int SCOutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a flow logger.
Definition: output-flow.c:58
RunModes
struct RunModes_ RunModes
OutputModule_::PacketLogFunc
PacketLogger PacketLogFunc
Definition: output.h:67
TmValidateQueueState
void TmValidateQueueState(void)
Checks if all the queues allocated so far have at least one reader and writer.
Definition: tm-queues.c:101
RunModeAFXDPGetDefaultMode
const char * RunModeAFXDPGetDefaultMode(void)
Definition: runmode-af-xdp.c:66
IsRunModeOffline
bool IsRunModeOffline(enum RunModes run_mode_to_check)
Definition: runmodes.c:541
OutputModule_::FiledataLogFunc
SCFiledataLogger FiledataLogFunc
Definition: output.h:72
RunModeInitializeOutputs
void RunModeInitializeOutputs(void)
Definition: runmodes.c:748
OutputRegisterStatsLogger
int OutputRegisterStatsLogger(const char *name, StatsLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Definition: output-stats.c:51
debuglog_enabled
int debuglog_enabled
Definition: runmodes.c:59
thread_name_single
const char * thread_name_single
Definition: runmodes.c:65
OutputModule_::alproto
AppProto alproto
Definition: output.h:76
RUNMODE_DAG
@ RUNMODE_DAG
Definition: runmodes.h:35
RunModes_
Definition: runmodes.c:89
runmode-unix-socket.h
util-unittest.h
RUNMODE_NETMAP
@ RUNMODE_NETMAP
Definition: runmodes.h:38
SCCapturePlugin_::GetDefaultMode
const char *(* GetDefaultMode)(void)
Definition: suricata-plugin.h:49
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:536
OutputClearActiveLoggers
void OutputClearActiveLoggers(void)
Definition: output.c:821
OutputCtx_
Definition: tm-modules.h:84
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
TAILQ_ENTRY
#define TAILQ_ENTRY(type)
Definition: queue.h:239
RunModeUnixSocketGetDefaultMode
const char * RunModeUnixSocketGetDefaultMode(void)
Definition: runmode-unix-socket.c:86
ConfGet
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:335
RUNMODE_USER_MAX
@ RUNMODE_USER_MAX
Definition: runmodes.h:44
RunModeIpsNFQRegister
void RunModeIpsNFQRegister(void)
Definition: runmode-nfq.c:47
OutputModule_::stream_type
enum SCOutputStreamingType stream_type
Definition: output.h:77
counters.h
RunModeInitializeThreadSettings
void RunModeInitializeThreadSettings(void)
Definition: runmodes.c:933
OutputModule_::ThreadInit
ThreadInitFunc ThreadInit
Definition: output.h:64
RunModeDpdkGetDefaultMode
const char * RunModeDpdkGetDefaultMode(void)
Definition: runmode-dpdk.c:1729
TAILQ_HEAD_INITIALIZER
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:236
IsRunModeSystem
bool IsRunModeSystem(enum RunModes run_mode_to_check)
Definition: runmodes.c:528
output_modules
OutputModuleList output_modules
RunModes
RunModes
Definition: runmodes.h:27
TAILQ_REMOVE
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:312
util-device.h
util-debug.h
RunModes_::runmodes
RunMode * runmodes
Definition: runmodes.c:91
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:250
thread_name_flow_bypass
const char * thread_name_flow_bypass
Definition: runmodes.c:70
g_alproto_max
AppProto g_alproto_max
Definition: app-layer-protos.c:29
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
RUNMODE_CONF_TEST
@ RUNMODE_CONF_TEST
Definition: runmodes.h:52
OutputModule_::ThreadDeinit
ThreadDeinitFunc ThreadDeinit
Definition: output.h:65
RunModeListRunmodes
void RunModeListRunmodes(void)
Lists all registered runmodes.
Definition: runmodes.c:241
g_filedata_logger_enabled
bool g_filedata_logger_enabled
Definition: output-filedata.c:37
BIT_U32
#define BIT_U32(n)
Definition: suricata-common.h:400
RunModeRegisterNewRunMode
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
Definition: runmodes.c:466
threading_set_stack_size
uint64_t threading_set_stack_size
Definition: runmodes.c:61
RunModeEnablesBypassManager
void RunModeEnablesBypassManager(void)
Definition: runmodes.c:445
OutputPacketShutdown
void OutputPacketShutdown(void)
Definition: output-packet.c:200
RunModeIdsNflogRegister
void RunModeIdsNflogRegister(void)
Definition: runmode-nflog.c:213
util-affinity.h
RunMode_
Holds description for a runmode.
Definition: runmodes.c:79
SCCapturePlugin_
Definition: suricata-plugin.h:44
AppLayerParserRegisterLoggerBits
void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits)
Definition: app-layer-parser.c:457
RunModeIpsIPFWRegister
void RunModeIpsIPFWRegister(void)
Definition: runmode-ipfw.c:49
OutputModule_::StreamingLogFunc
SCStreamingLogger StreamingLogFunc
Definition: output.h:74
OutputInitResult_::ok
bool ok
Definition: output.h:48
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:249
RunModeErfDagGetDefaultMode
const char * RunModeErfDagGetDefaultMode(void)
Definition: runmode-erf-dag.c:43
app-layer-parser.h
SCOutputRegisterTxLogger
int SCOutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc, void *initdata, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a transaction logger.
Definition: output-tx.c:65
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:300
runmode-netmap.h
runmode-erf-dag.h
thread_name_detect_loader
const char * thread_name_detect_loader
Definition: runmodes.c:72
OutputModule_::conf_name
const char * conf_name
Definition: output.h:59
OutputModule_::FlowLogFunc
FlowLogger FlowLogFunc
Definition: output.h:73
type
uint16_t type
Definition: decode-vlan.c:107
conf.h
OutputFileShutdown
void OutputFileShutdown(void)
Definition: output-file.c:239
runmode-pcap-file.h
name
const char * name
Definition: tm-threads.c:2081
FlowRecyclerThreadSpawn
void FlowRecyclerThreadSpawn(void)
spawn the flow recycler thread
Definition: flow-manager.c:1195
util-plugin.h
RunModeErfDagRegister
void RunModeErfDagRegister(void)
Definition: runmode-erf-dag.c:48
RunMode
struct RunMode_ RunMode
Holds description for a runmode.
SCOutputRegisterPacketLogger
int SCOutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a packet logger.
Definition: output-packet.c:55
SCOutputRegisterFileLogger
int SCOutputRegisterFileLogger(LoggerId id, const char *name, SCFileLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a file logger.
Definition: output-file.c:56
runmodes.h
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:224
WarnInvalidConfEntry
#define WarnInvalidConfEntry(param_name, format, value)
Generic API that can be used by all to log an invalid conf entry.
Definition: util-misc.h:35
RunModes_::cnt
int cnt
Definition: runmodes.c:90
RunModeIpsWinDivertRegister
void RunModeIpsWinDivertRegister(void)
Definition: runmode-windivert.c:45
SCRealloc
#define SCRealloc(ptr, sz)
Definition: util-mem.h:50
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:781
OutputFreeList_::output_ctx
OutputCtx * output_ctx
Definition: runmodes.c:101
runmode-nfq.h
RunModeIdsAFXDPRegister
void RunModeIdsAFXDPRegister(void)
Definition: runmode-af-xdp.c:71
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
OutputInitResult_
Definition: output.h:46
ConfGetFloat
int ConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition: conf.c:615
OutputModule_::TxLogCondition
TxLoggerCondition TxLogCondition
Definition: output.h:70
RunModeUnixSocketRegister
void RunModeUnixSocketRegister(void)
Definition: runmode-unix-socket.c:557
flow-manager.h
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:90
FatalErrorOnInit
#define FatalErrorOnInit(...)
Fatal error IF we're starting up, and configured to consider errors to be fatal errors.
Definition: util-debug.h:511
StatsSpawnThreads
void StatsSpawnThreads(void)
Spawns the wakeup, and the management thread used by the stats api.
Definition: counters.c:902
RunModeNeedsBypassManager
int RunModeNeedsBypassManager(void)
Definition: runmodes.c:450
g_file_logger_enabled
bool g_file_logger_enabled
Definition: output-file.c:39
LOGGER_ALERT_DEBUG
@ LOGGER_ALERT_DEBUG
Definition: suricata-common.h:477
RunModeIdsPcapRegister
void RunModeIdsPcapRegister(void)
Definition: runmode-pcap.c:39
RunModeRegisterRunModes
void RunModeRegisterRunModes(void)
Register all runmodes in the engine.
Definition: runmodes.c:216
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
RunModeFilePcapRegister
void RunModeFilePcapRegister(void)
Definition: runmode-pcap-file.c:40
FatalError
#define FatalError(...)
Definition: util-debug.h:502
OutputModule_::PacketConditionFunc
PacketLogCondition PacketConditionFunc
Definition: output.h:68
RUNMODE_NFQ
@ RUNMODE_NFQ
Definition: runmodes.h:31
LOGGER_FILE
@ LOGGER_FILE
Definition: suricata-common.h:469
SCLogConfig
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
RunModeNetmapGetDefaultMode
const char * RunModeNetmapGetDefaultMode(void)
Definition: runmode-netmap.c:55
RunModeIpsNFQGetDefaultMode
const char * RunModeIpsNFQGetDefaultMode(void)
Definition: runmode-nfq.c:42
RUNMODE_ENGINE_ANALYSIS
@ RUNMODE_ENGINE_ANALYSIS
Definition: runmodes.h:54
RunMode_::runmode
enum RunModes runmode
Definition: runmodes.c:81
runmode-af-xdp.h
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
RunModeIdsNetmapRegister
void RunModeIdsNetmapRegister(void)
Definition: runmode-netmap.c:127
ConfNode_
Definition: conf.h:32
OutputFreeList
struct OutputFreeList_ OutputFreeList
thread_name_verdict
const char * thread_name_verdict
Definition: runmodes.c:67
RunModeDpdkRegister
void RunModeDpdkRegister(void)
Definition: runmode-dpdk.c:1734
OutputModule_::TxLogFunc
TxLogger TxLogFunc
Definition: output.h:69
OutputModule_::tc_log_progress
int tc_log_progress
Definition: output.h:78
TAILQ_HEAD
#define TAILQ_HEAD(name, type)
Definition: queue.h:230
OutputFlowShutdown
void OutputFlowShutdown(void)
Definition: output-flow.c:187
ALPROTO_UNKNOWN
@ ALPROTO_UNKNOWN
Definition: app-layer-protos.h:29
RunModeEngineIsIPS
int RunModeEngineIsIPS(int capture_mode, const char *runmode, const char *capture_plugin_name)
Definition: runmodes.c:360
OutputFreeList_
Definition: runmodes.c:99
tmqh-flow.h
RUNMODE_WINDIVERT
@ RUNMODE_WINDIVERT
Definition: runmodes.h:42
runmode-dpdk.h
SCOutputRegisterFiledataLogger
int SCOutputRegisterFiledataLogger(LoggerId id, const char *name, SCFiledataLogger LogFunc, void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit)
Register a file-data logger.
Definition: output-filedata.c:54
runmode-ipfw.h
thread_name_unix_socket
const char * thread_name_unix_socket
Definition: runmodes.c:71
OutputFreeList_::output_module
OutputModule * output_module
Definition: runmodes.c:100
runmode-nflog.h
RunModeGetMainMode
const char * RunModeGetMainMode(void)
Definition: runmodes.c:206
RunModeOutputFiledataEnabled
int RunModeOutputFiledataEnabled(void)
Definition: runmodes.c:523
LiveGetDeviceCount
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:164
util-misc.h
RunMode_::name
const char * name
Definition: runmodes.c:82
OutputModule_
Definition: output.h:56
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:237
UtRunModeRegister
void UtRunModeRegister(void)
Definition: util-unittest.c:283
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
RUNMODE_AFP_DEV
@ RUNMODE_AFP_DEV
Definition: runmodes.h:36
RUNMODE_PCAP_FILE
@ RUNMODE_PCAP_FILE
Definition: runmodes.h:30
RunModeIpsWinDivertGetDefaultMode
const char * RunModeIpsWinDivertGetDefaultMode(void)
Definition: runmode-windivert.c:40
RUNMODE_PLUGIN
@ RUNMODE_PLUGIN
Definition: runmodes.h:43
RUNMODE_IPFW
@ RUNMODE_IPFW
Definition: runmodes.h:33
SCPluginFindCaptureByName
SCCapturePlugin * SCPluginFindCaptureByName(const char *name)
threading_detect_ratio
float threading_detect_ratio
Definition: runmodes.c:928
output.h
OutputModule_::InitFunc
OutputInitFunc InitFunc
Definition: output.h:61
RunModeIdsGetDefaultMode
const char * RunModeIdsGetDefaultMode(void)
Definition: runmode-pcap.c:32
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:809