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