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