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