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)";
164 return "DPDK(DISABLED)";
180 static RunMode *RunModeGetCustomMode(
enum RunModes runmode,
const char *custom_mode)
183 for (
int i = 0; i < runmodes[runmode].cnt; i++) {
184 if (strcmp(runmodes[runmode].runmodes[i].name, custom_mode) == 0)
185 return &runmodes[runmode].runmodes[i];
201 return active_runmode;
215 return RunModeTranslateModeToName(mainmode);
223 memset(runmodes, 0,
sizeof(runmodes));
250 printf(
"------------------------------------- Runmodes -------------------"
251 "-----------------------\n");
253 printf(
"| %-17s | %-17s | %-10s \n",
254 "RunMode Type",
"Custom Mode ",
"Description");
255 printf(
"|-----------------------------------------------------------------"
256 "-----------------------\n");
260 int mode_displayed = 0;
261 for (j = 0; j < runmodes[i].cnt; j++) {
262 if (mode_displayed == 1) {
263 printf(
"| ----------------------------------------------"
264 "-----------------------\n");
265 RunMode *runmode = &runmodes[i].runmodes[j];
266 printf(
"| %-17s | %-17s | %-27s \n",
271 RunMode *runmode = &runmodes[i].runmodes[j];
272 printf(
"| %-17s | %-17s | %-27s \n",
273 RunModeTranslateModeToName(runmode->
runmode),
277 if (mode_displayed == 0)
280 if (mode_displayed == 1) {
281 printf(
"|-----------------------------------------------------------------"
282 "-----------------------\n");
292 const char *capture_plugin_name,
const char *capture_plugin_args)
294 char *local_custom_mode = NULL;
296 if (custom_mode == NULL) {
297 const char *val = NULL;
298 if (
ConfGet(
"runmode", &val) != 1) {
305 if (custom_mode == NULL || strcmp(custom_mode,
"auto") == 0) {
321 if (plugin == NULL) {
323 capture_plugin_name);
371 if (!strcmp(
"worker", custom_mode)) {
373 "to 'workers', please modify your setup.");
374 local_custom_mode =
SCStrdup(
"workers");
375 if (
unlikely(local_custom_mode == NULL)) {
378 custom_mode = local_custom_mode;
382 RunMode *mode = RunModeGetCustomMode(runmode, custom_mode);
385 "for this runmode type \"%s\". Please use --list-runmodes to "
386 "see available custom types for this runmode",
387 custom_mode, RunModeTranslateModeToName(runmode));
392 if (active_runmode) {
395 active_runmode =
SCStrdup(custom_mode);
396 if (
unlikely(active_runmode == NULL)) {
400 if (strcasecmp(active_runmode,
"autofp") == 0) {
406 if (local_custom_mode != NULL)
407 SCFree(local_custom_mode);
423 static int g_runmode_needs_bypass = 0;
427 g_runmode_needs_bypass = 1;
432 return g_runmode_needs_bypass;
448 const char *description,
449 int (*RunModeFunc)(
void))
451 if (RunModeGetCustomMode(runmode, name) != NULL) {
453 "been registered. Please use an unique name.", name);
456 void *ptmp =
SCRealloc(runmodes[runmode].runmodes,
457 (runmodes[runmode].cnt + 1) *
sizeof(
RunMode));
459 SCFree(runmodes[runmode].runmodes);
460 runmodes[runmode].runmodes = NULL;
463 runmodes[runmode].runmodes = ptmp;
465 RunMode *mode = &runmodes[runmode].runmodes[runmodes[runmode].cnt];
466 runmodes[runmode].cnt++;
467 memset(mode, 0x00,
sizeof(*mode));
489 static void RunOutputFreeList(
void)
492 while ((output =
TAILQ_FIRST(&output_free_list))) {
504 static int file_logger_count = 0;
505 static int filedata_logger_count = 0;
510 return file_logger_count > 0;
515 return filedata_logger_count > 0;
520 switch (run_mode_to_check) {
533 switch(run_mode_to_check) {
564 file_logger_count = 0;
565 filedata_logger_count = 0;
625 filedata_logger_count++;
657 if (strcmp(
type->val,
"ikev2") == 0) {
659 strlcpy(subname,
"eve-log.ike",
sizeof(subname));
661 snprintf(subname,
sizeof(subname),
"eve-log.%s",
type->val);
667 if (sub_output_config != NULL) {
669 sub_output_config,
"enabled");
678 if (strcmp(subname, sub_module->
conf_name) == 0) {
684 "bad parent for %s", subname);
688 "bad sub-module for %s", subname);
693 sub_module->
InitSubFunc(sub_output_config, parent_ctx);
694 if (!result.
ok || result.
ctx == NULL) {
698 AddOutputToFreeList(sub_module, result.
ctx);
699 SetupOutput(sub_module->
name, sub_module,
708 "No output module named %s", subname);
717 BUG_ON(lua_module == NULL);
729 if (strcmp(script->
val,
m->conf_name) == 0) {
737 if (!result.
ok || result.
ctx == NULL) {
741 AddOutputToFreeList(
m, result.
ctx);
742 SetupOutput(
m->name,
m, result.
ctx);
752 if (outputs == NULL) {
759 char tls_log_enabled = 0;
760 char tls_store_present = 0;
762 memset(&logger_bits, 0,
sizeof(logger_bits));
767 if (output_config == NULL) {
770 "Failed to lookup configuration child node: %s", output->
val);
773 if (strcmp(output->
val,
"tls-store") == 0) {
774 tls_store_present = 1;
782 if (strcmp(output->
val,
"file-log") == 0) {
784 "file-log is no longer supported,"
785 " use eve.files instead "
786 "(see https://redmine.openinfosecfoundation.org/issues/2376"
787 " for an explanation)");
789 }
else if (strncmp(output->
val,
"unified-",
sizeof(
"unified-") - 1) == 0) {
791 "Unified1 is no longer supported,"
792 " use Unified2 instead "
793 "(see https://redmine.openinfosecfoundation.org/issues/353"
794 " for an explanation)");
796 }
else if (strncmp(output->
val,
"unified2-",
sizeof(
"unified2-") - 1) == 0) {
798 "Unified2 is no longer supported.");
800 }
else if (strcmp(output->
val,
"lua") == 0) {
803 "lua support not compiled in. Reconfigure/"
804 "recompile with lua(jit) and its development "
805 "files installed to add lua support.");
808 }
else if (strcmp(output->
val,
"dns-log") == 0) {
810 "dns-log is not longer available as of Suricata 5.0");
812 }
else if (strcmp(output->
val,
"tls-log") == 0) {
830 "output module \"%s\": setup failed", output->
val);
832 }
else if (r.
ctx == NULL) {
842 if (strcmp(output->
val,
"eve-log") == 0) {
843 RunModeInitializeEveOutput(output_config, output_ctx);
848 AddOutputToFreeList(module, output_ctx);
849 }
else if (strcmp(output->
val,
"lua") == 0) {
851 if (output_ctx == NULL)
853 RunModeInitializeLuaOutput(output_config, output_ctx);
854 AddOutputToFreeList(module, output_ctx);
856 AddOutputToFreeList(module, output_ctx);
857 SetupOutput(module->
name, module, output_ctx);
862 "No output module named %s", output->
val);
868 if (!tls_store_present && tls_log_enabled) {
872 "Please use 'tls-store' in YAML to configure TLS storage");
877 if (strcmp(output->
val,
"tls-log") == 0) {
880 if (module == NULL) {
882 "No output module named %s, ignoring",
"tls-store");
891 "output module setup failed");
893 }
else if (r.
ctx == NULL) {
899 AddOutputToFreeList(module, output_ctx);
900 SetupOutput(module->
name, module, output_ctx);
908 if (logger_bits[a] == 0)
915 tcp ?
"true" :
"false", udp ?
"true" :
"false");
943 if (
ConfGetNode(
"threading.detect-thread-ratio") != NULL)
954 const char *ss = NULL;
959 "Failed to initialize thread_stack_size output, invalid limit: %s", ss);
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)
int ParseSizeStringU64(const char *size, uint64_t *res)
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
size_t strlcpy(char *dst, const char *src, size_t siz)
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
const char * RunModeDpdkGetDefaultMode(void)
#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.
uint64_t threading_set_stack_size
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
void RunModeDpdkRegister(void)
#define TAILQ_HEAD(name, type)
void OutputFlowShutdown(void)
int ConfGetValue(const char *name, const char **vptr)
Retrieve the value of a configuration node.
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.