Go to the documentation of this file.
95 static char *active_runmode;
115 static const char *RunModeTranslateModeToName(
int runmode)
126 return "PFRING(DISABLED)";
145 return "AF_PACKET_DEV";
150 return "NETMAP(DISABLED)";
153 return "UNIX_SOCKET";
158 return "WINDIVERT(DISABLED)";
173 static RunMode *RunModeGetCustomMode(
enum RunModes runmode,
const char *custom_mode)
176 for (
int i = 0; i < runmodes[runmode].cnt; i++) {
177 if (strcmp(runmodes[runmode].runmodes[i].name, custom_mode) == 0)
178 return &runmodes[runmode].runmodes[i];
194 return active_runmode;
208 return RunModeTranslateModeToName(mainmode);
216 memset(runmodes, 0,
sizeof(runmodes));
242 printf(
"------------------------------------- Runmodes -------------------"
243 "-----------------------\n");
245 printf(
"| %-17s | %-17s | %-10s \n",
246 "RunMode Type",
"Custom Mode ",
"Description");
247 printf(
"|-----------------------------------------------------------------"
248 "-----------------------\n");
252 int mode_displayed = 0;
253 for (j = 0; j < runmodes[i].cnt; j++) {
254 if (mode_displayed == 1) {
255 printf(
"| ----------------------------------------------"
256 "-----------------------\n");
257 RunMode *runmode = &runmodes[i].runmodes[j];
258 printf(
"| %-17s | %-17s | %-27s \n",
263 RunMode *runmode = &runmodes[i].runmodes[j];
264 printf(
"| %-17s | %-17s | %-27s \n",
265 RunModeTranslateModeToName(runmode->
runmode),
269 if (mode_displayed == 0)
272 if (mode_displayed == 1) {
273 printf(
"|-----------------------------------------------------------------"
274 "-----------------------\n");
284 const char *capture_plugin_name,
const char *capture_plugin_args)
286 char *local_custom_mode = NULL;
288 if (custom_mode == NULL) {
289 const char *val = NULL;
290 if (
ConfGet(
"runmode", &val) != 1) {
297 if (custom_mode == NULL || strcmp(custom_mode,
"auto") == 0) {
313 if (plugin == NULL) {
315 capture_plugin_name);
358 if (!strcmp(
"worker", custom_mode)) {
360 "to 'workers', please modify your setup.");
361 local_custom_mode =
SCStrdup(
"workers");
362 if (
unlikely(local_custom_mode == NULL)) {
365 custom_mode = local_custom_mode;
369 RunMode *mode = RunModeGetCustomMode(runmode, custom_mode);
372 "for this runmode type \"%s\". Please use --list-runmodes to "
373 "see available custom types for this runmode",
374 custom_mode, RunModeTranslateModeToName(runmode));
379 if (active_runmode) {
382 active_runmode =
SCStrdup(custom_mode);
383 if (
unlikely(active_runmode == NULL)) {
387 if (strcasecmp(active_runmode,
"autofp") == 0) {
393 if (local_custom_mode != NULL)
394 SCFree(local_custom_mode);
410 static int g_runmode_needs_bypass = 0;
414 g_runmode_needs_bypass = 1;
419 return g_runmode_needs_bypass;
435 const char *description,
436 int (*RunModeFunc)(
void))
438 if (RunModeGetCustomMode(runmode, name) != NULL) {
440 "been registered. Please use an unique name.", name);
443 void *ptmp =
SCRealloc(runmodes[runmode].runmodes,
444 (runmodes[runmode].cnt + 1) *
sizeof(
RunMode));
446 SCFree(runmodes[runmode].runmodes);
447 runmodes[runmode].runmodes = NULL;
450 runmodes[runmode].runmodes = ptmp;
452 RunMode *mode = &runmodes[runmode].runmodes[runmodes[runmode].cnt];
453 runmodes[runmode].cnt++;
454 memset(mode, 0x00,
sizeof(*mode));
476 static void RunOutputFreeList(
void)
479 while ((output =
TAILQ_FIRST(&output_free_list))) {
491 static int file_logger_count = 0;
492 static int filedata_logger_count = 0;
497 return file_logger_count > 0;
502 return filedata_logger_count > 0;
507 switch (run_mode_to_check) {
520 switch(run_mode_to_check) {
551 file_logger_count = 0;
552 filedata_logger_count = 0;
612 filedata_logger_count++;
645 snprintf(subname,
sizeof(subname),
"eve-log.%s",
type->val);
648 if (sub_output_config != NULL) {
650 sub_output_config,
"enabled");
659 if (strcmp(subname, sub_module->
conf_name) == 0) {
665 "bad parent for %s", subname);
669 "bad sub-module for %s", subname);
674 sub_module->
InitSubFunc(sub_output_config, parent_ctx);
675 if (!result.
ok || result.
ctx == NULL) {
679 AddOutputToFreeList(sub_module, result.
ctx);
680 SetupOutput(sub_module->
name, sub_module,
689 "No output module named %s", subname);
698 BUG_ON(lua_module == NULL);
710 if (strcmp(script->
val,
m->conf_name) == 0) {
718 if (!result.
ok || result.
ctx == NULL) {
722 AddOutputToFreeList(
m, result.
ctx);
723 SetupOutput(
m->name,
m, result.
ctx);
733 if (outputs == NULL) {
740 char tls_log_enabled = 0;
741 char tls_store_present = 0;
743 memset(&logger_bits, 0,
sizeof(logger_bits));
748 if (output_config == NULL) {
751 "Failed to lookup configuration child node: %s", output->
val);
754 if (strcmp(output->
val,
"tls-store") == 0) {
755 tls_store_present = 1;
763 if (strcmp(output->
val,
"file-log") == 0) {
765 "file-log is no longer supported,"
766 " use eve.files instead "
767 "(see https://redmine.openinfosecfoundation.org/issues/2376"
768 " for an explanation)");
770 }
else if (strncmp(output->
val,
"unified-",
sizeof(
"unified-") - 1) == 0) {
772 "Unified1 is no longer supported,"
773 " use Unified2 instead "
774 "(see https://redmine.openinfosecfoundation.org/issues/353"
775 " for an explanation)");
777 }
else if (strncmp(output->
val,
"unified2-",
sizeof(
"unified2-") - 1) == 0) {
779 "Unified2 is no longer supported.");
781 }
else if (strcmp(output->
val,
"alert-prelude") == 0) {
784 "Prelude support not compiled in. Reconfigure/"
785 "recompile with --enable-prelude to add Prelude "
789 }
else if (strcmp(output->
val,
"lua") == 0) {
792 "lua support not compiled in. Reconfigure/"
793 "recompile with lua(jit) and its development "
794 "files installed to add lua support.");
797 }
else if (strcmp(output->
val,
"dns-log") == 0) {
799 "dns-log is not longer available as of Suricata 5.0");
801 }
else if (strcmp(output->
val,
"tls-log") == 0) {
819 "output module \"%s\": setup failed", output->
val);
821 }
else if (r.
ctx == NULL) {
831 if (strcmp(output->
val,
"eve-log") == 0) {
832 RunModeInitializeEveOutput(output_config, output_ctx);
837 AddOutputToFreeList(module, output_ctx);
838 }
else if (strcmp(output->
val,
"lua") == 0) {
840 if (output_ctx == NULL)
842 RunModeInitializeLuaOutput(output_config, output_ctx);
843 AddOutputToFreeList(module, output_ctx);
845 AddOutputToFreeList(module, output_ctx);
846 SetupOutput(module->
name, module, output_ctx);
851 "No output module named %s", output->
val);
857 if (!tls_store_present && tls_log_enabled) {
861 "Please use 'tls-store' in YAML to configure TLS storage");
866 if (strcmp(output->
val,
"tls-log") == 0) {
869 if (module == NULL) {
871 "No output module named %s, ignoring",
"tls-store");
880 "output module setup failed");
882 }
else if (r.
ctx == NULL) {
888 AddOutputToFreeList(module, output_ctx);
889 SetupOutput(module->
name, module, output_ctx);
897 if (logger_bits[a] == 0)
904 tcp ?
"true" :
"false", udp ?
"true" :
"false");
932 if (
ConfGetNode(
"threading.detect-thread-ratio") != NULL)
const char * thread_name_workers
const char * RunModeIpsIPFWGetDefaultMode(void)
int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger LogFunc, OutputCtx *output_ctx, enum OutputStreamingType type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
const char * thread_name_counter_wakeup
void RunModeErfFileRegister(void)
void OutputStreamingShutdown(void)
int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
const char * thread_name_flow_mgr
#define FatalErrorOnInit(x,...)
Fatal error IF we're starting up, and configured to consider errors to be fatal errors.
const char * RunModeErfFileGetDefaultMode(void)
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as an boolen.
void OutputTxShutdown(void)
void TmqhFlowPrintAutofpHandler(void)
void RunModeIdsAFPRegister(void)
struct HtpBodyChunk_ * next
int OutputRegisterFileLogger(LoggerId id, const char *name, FileLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
void RunModeShutDown(void)
int OutputRegisterStatsLogger(const char *name, StatsLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
void RunModeDispatch(int runmode, const char *custom_mode, const char *capture_plugin_name, const char *capture_plugin_args)
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
const char * thread_name_counter_stats
StreamingLogger StreamingLogFunc
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
const char * RunModeAFPGetDefaultMode(void)
const char * thread_name_flow_rec
void OutputFiledataShutdown(void)
void RunModeInitialize(void)
void RunModeIdsPfringRegister(void)
const char * RunModeFilePcapGetDefaultMode(void)
#define TAILQ_FOREACH(var, head, field)
const char * thread_name_autofp
OutputModule * OutputGetModuleByConfName(const char *conf_name)
Get an output module by name.
void OutputSetupActiveLoggers(void)
const char * RunModeIdsNflogGetDefaultMode(void)
void OutputStatsShutdown(void)
#define TAILQ_INSERT_TAIL(head, elm, field)
char * RunmodeGetActive(void)
OutputInitSubFunc InitSubFunc
struct RunModes_ RunModes
PacketLogger PacketLogFunc
void TmValidateQueueState(void)
Checks if all the queues allocated so far have at least one reader and writer.
bool IsRunModeOffline(enum RunModes run_mode_to_check)
void RunModeInitializeOutputs(void)
const char * thread_name_single
const char *(* GetDefaultMode)(void)
int ConfValIsTrue(const char *val)
Check if a value is true.
void OutputClearActiveLoggers(void)
const char * RunModeIdsPfringGetDefaultMode(void)
enum OutputStreamingType stream_type
int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
#define TAILQ_ENTRY(type)
const char * RunModeUnixSocketGetDefaultMode(void)
int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
void RunModeIpsNFQRegister(void)
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 *))
ThreadInitFunc ThreadInit
#define TAILQ_HEAD_INITIALIZER(head)
bool IsRunModeSystem(enum RunModes run_mode_to_check)
OutputModuleList output_modules
#define TAILQ_REMOVE(head, elm, field)
FiledataLogger FiledataLogFunc
#define TAILQ_FIRST(head)
const char * thread_name_flow_bypass
void BypassedFlowManagerThreadSpawn()
spawn the flow bypass manager thread
ThreadDeinitFunc ThreadDeinit
void RunModeListRunmodes(void)
Lists all registered runmodes.
void RunModeEnablesBypassManager(void)
void OutputPacketShutdown(void)
void RunModeIdsNflogRegister(void)
Holds description for a runmode.
void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits)
void RunModeIpsIPFWRegister(void)
const char * RunModeErfDagGetDefaultMode(void)
int threading_set_cpu_affinity
@ SC_ERR_INVALID_ARGUMENT
const char * thread_name_detect_loader
void FlowManagerThreadSpawn()
spawn the flow manager thread
void OutputFileShutdown(void)
void RunModeErfDagRegister(void)
ThreadExitPrintStatsFunc ThreadExitPrintStats
struct RunMode_ RunMode
Holds description for a runmode.
void FlowRecyclerThreadSpawn()
spawn the flow recycler thread
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define WarnInvalidConfEntry(param_name, format, value)
Generic API that can be used by all to log an invalid conf entry.
void RunModeIpsWinDivertRegister(void)
#define SCRealloc(ptr, sz)
const char * RunModeNapatechGetDefaultMode(void)
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
@ SC_ERR_UNKNOWN_RUN_MODE
int ConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
TxLoggerCondition TxLogCondition
void RunModeUnixSocketRegister(void)
void(* DeInit)(struct OutputCtx_ *)
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void))
Registers a new runmode.
void StatsSpawnThreads(void)
Spawns the wakeup, and the management thread used by the stats api.
int RunModeNeedsBypassManager(void)
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
void RunModeIdsPcapRegister(void)
void RunModeRegisterRunModes(void)
Register all runmodes in the engine.
void RunModeFilePcapRegister(void)
#define FatalError(x,...)
void AffinitySetupLoadFromConfig()
Extract cpu affinity configuration from current config file.
PacketLogCondition PacketConditionFunc
int RunmodeGetCurrent(void)
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
const char * RunModeNetmapGetDefaultMode(void)
const char * RunModeIpsNFQGetDefaultMode(void)
@ RUNMODE_ENGINE_ANALYSIS
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
void RunModeIdsNetmapRegister(void)
struct OutputFreeList_ OutputFreeList
const char * thread_name_verdict
#define TAILQ_HEAD(name, type)
void OutputFlowShutdown(void)
const char * thread_name_unix_socket
void RunModeNapatechRegister(void)
OutputModule * output_module
const char * RunModeGetMainMode(void)
int RunModeOutputFiledataEnabled(void)
void UtRunModeRegister(void)
const char * RunModeIpsWinDivertGetDefaultMode(void)
SCCapturePlugin * SCPluginFindCaptureByName(const char *name)
float threading_detect_ratio
int RunModeOutputFileEnabled(void)
int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
const char * RunModeIdsGetDefaultMode(void)
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.