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