suricata
|
#include "suricata-common.h"
#include "detect-engine.h"
#include "app-layer-parser.h"
#include "util-debug.h"
#include "util-affinity.h"
#include "conf.h"
#include "log-flush.h"
#include "runmodes.h"
#include "runmode-af-packet.h"
#include "runmode-af-xdp.h"
#include "runmode-dpdk.h"
#include "runmode-erf-dag.h"
#include "runmode-erf-file.h"
#include "runmode-ipfw.h"
#include "runmode-lib.h"
#include "runmode-netmap.h"
#include "runmode-nflog.h"
#include "runmode-nfq.h"
#include "runmode-pcap.h"
#include "runmode-pcap-file.h"
#include "runmode-unix-socket.h"
#include "runmode-windivert.h"
#include "util-unittest.h"
#include "util-misc.h"
#include "util-plugin.h"
#include "output.h"
#include "tmqh-flow.h"
#include "flow-manager.h"
#include "flow-bypass.h"
#include "counters.h"
#include "suricata-plugin.h"
#include "util-device-private.h"
Go to the source code of this file.
Data Structures | |
struct | RunMode_ |
Holds description for a runmode. More... | |
struct | RunModes_ |
struct | OutputFreeList_ |
Typedefs | |
typedef struct RunMode_ | RunMode |
Holds description for a runmode. | |
typedef struct RunModes_ | RunModes |
typedef struct OutputFreeList_ | OutputFreeList |
Functions | |
char * | RunmodeGetActive (void) |
bool | RunmodeIsWorkers (void) |
bool | RunmodeIsAutofp (void) |
const char * | RunModeGetMainMode (void) |
void | RunModeRegisterRunModes (void) |
Register all runmodes in the engine. | |
void | RunModeListRunmodes (void) |
Lists all registered runmodes. | |
int | RunModeEngineIsIPS (int capture_mode, const char *runmode, const char *capture_plugin_name) |
void | RunModeDispatch (int runmode, const char *custom_mode, const char *capture_plugin_name, const char *capture_plugin_args) |
void | RunModeEnablesBypassManager (void) |
int | RunModeNeedsBypassManager (void) |
void | RunModeRegisterNewRunMode (enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void)) |
Registers a new runmode. | |
int | RunModeOutputFiledataEnabled (void) |
bool | IsRunModeSystem (enum SCRunModes run_mode_to_check) |
bool | IsRunModeOffline (enum SCRunModes run_mode_to_check) |
void | RunModeShutDown (void) |
void | RunModeInitializeOutputs (void) |
void | RunModeInitializeThreadSettings (void) |
Variables | |
int | debuglog_enabled = 0 |
bool | threading_set_cpu_affinity = false |
uint64_t | threading_set_stack_size = 0 |
const char * | thread_name_autofp = "RX" |
const char * | thread_name_single = "W" |
const char * | thread_name_workers = "W" |
const char * | thread_name_verdict = "TX" |
const char * | thread_name_flow_mgr = "FM" |
const char * | thread_name_flow_rec = "FR" |
const char * | thread_name_flow_bypass = "FB" |
const char * | thread_name_unix_socket = "US" |
const char * | thread_name_detect_loader = "DL" |
const char * | thread_name_counter_stats = "CS" |
const char * | thread_name_counter_wakeup = "CW" |
const char * | thread_name_heartbeat = "HB" |
bool | g_file_logger_enabled |
bool | g_filedata_logger_enabled |
float | threading_detect_ratio = 1 |
Pre-cooked threading runmodes.
Definition in file runmodes.c.
typedef struct OutputFreeList_ OutputFreeList |
bool IsRunModeOffline | ( | enum SCRunModes | run_mode_to_check | ) |
Definition at line 561 of file runmodes.c.
References RUNMODE_CONF_TEST, RUNMODE_ENGINE_ANALYSIS, RUNMODE_ERF_FILE, RUNMODE_PCAP_FILE, and RUNMODE_UNIX_SOCKET.
Referenced by ConfUnixSocketIsEnable(), SCConfLogOpenGeneric(), and SCParseCommandLine().
bool IsRunModeSystem | ( | enum SCRunModes | run_mode_to_check | ) |
Definition at line 548 of file runmodes.c.
References RUNMODE_ENGINE_ANALYSIS, RUNMODE_ERF_FILE, and RUNMODE_PCAP_FILE.
Referenced by SCParseCommandLine().
void RunModeDispatch | ( | int | runmode, |
const char * | custom_mode, | ||
const char * | capture_plugin_name, | ||
const char * | capture_plugin_args | ||
) |
Definition at line 409 of file runmodes.c.
References BypassedFlowManagerThreadSpawn(), FatalError, FlowManagerThreadSpawn(), FlowRecyclerThreadSpawn(), LogFlushThreads(), RUNMODE_UNIX_SOCKET, RunMode_::RunModeFunc, RunModeNeedsBypassManager(), SCFree, SCLogError, SCStrdup, StatsSpawnThreads(), TmqhFlowPrintAutofpHandler(), TmThreadsSealThreads(), TmValidateQueueState(), and unlikely.
Referenced by SuricataInit().
void RunModeEnablesBypassManager | ( | void | ) |
Definition at line 465 of file runmodes.c.
int RunModeEngineIsIPS | ( | int | capture_mode, |
const char * | runmode, | ||
const char * | capture_plugin_name | ||
) |
Definition at line 379 of file runmodes.c.
References g_livedev_mask, LiveGetDeviceCount(), RunMode_::RunModeIsIPSEnabled, and SCLogWarning.
Referenced by PostConfLoadedSetup().
char * RunmodeGetActive | ( | void | ) |
Return the running mode
The returned string must not be freed.
Definition at line 199 of file runmodes.c.
Referenced by RunmodeIsAutofp(), and RunmodeIsWorkers().
const char * RunModeGetMainMode | ( | void | ) |
Return the running mode
The returned string must not be freed.
Definition at line 221 of file runmodes.c.
References SCRunmodeGet().
void RunModeInitializeOutputs | ( | void | ) |
Initialize the output modules.
Definition at line 769 of file runmodes.c.
References AppLayerParserProtocolHasLogger(), AppLayerParserRegisterLoggerBits(), AppLayerParserSupportsFiles(), AppProtoToString(), BIT_U32, OutputModule_::conf_name, OutputInitResult_::ctx, FatalError, FatalErrorOnInit, g_alproto_max, g_file_logger_enabled, g_filedata_logger_enabled, OutputModule_::InitFunc, OutputModule_::InitSubFunc, LOGGER_FILE, LOGGER_FILEDATA, OutputModule_::name, next, OutputInitResult_::ok, output_modules, OutputSetupActiveLoggers(), SCConfGetNode(), SCConfNodeLookupChild(), SCConfNodeLookupChildValue(), SCConfValIsTrue(), SCLogDebug, SCLogInfo, SCLogWarning, TAILQ_FOREACH, and SCConfNode_::val.
Referenced by PreRunPostPrivsDropInit().
void RunModeInitializeThreadSettings | ( | void | ) |
Initialize multithreading settings.
Definition at line 954 of file runmodes.c.
References AffinitySetupLoadFromConfig(), FatalError, ParseSizeStringU64(), SCConfGet(), SCConfGetBool(), SCConfGetFloat(), SCConfGetNode(), SCLogDebug, SCLogNotice, threading_detect_ratio, threading_set_cpu_affinity, threading_set_stack_size, and WarnInvalidConfEntry.
Referenced by LLVMFuzzerTestOneInput(), and SuricataInit().
bool RunmodeIsAutofp | ( | void | ) |
Definition at line 209 of file runmodes.c.
References RunmodeGetActive().
Referenced by TmThreadSetupOptions().
bool RunmodeIsWorkers | ( | void | ) |
Definition at line 204 of file runmodes.c.
References RunmodeGetActive().
Referenced by TmThreadSetupOptions().
void RunModeListRunmodes | ( | void | ) |
Lists all registered runmodes.
Definition at line 257 of file runmodes.c.
References RunModes_::cnt, RunMode_::description, RunMode_::name, RunMode_::runmode, RUNMODE_UNKNOWN, RUNMODE_USER_MAX, and RunModes_::runmodes.
Referenced by SCStartInternalRunMode().
int RunModeNeedsBypassManager | ( | void | ) |
Definition at line 470 of file runmodes.c.
Referenced by RunModeDispatch().
int RunModeOutputFiledataEnabled | ( | void | ) |
Definition at line 543 of file runmodes.c.
void RunModeRegisterNewRunMode | ( | enum SCRunModes | runmode, |
const char * | name, | ||
const char * | description, | ||
int(*)(void) | RunModeFunc, | ||
int(*)(void) | RunModeIsIPSEnabled | ||
) |
Registers a new runmode.
runmode | Runmode type. |
name | Custom mode for this specific runmode type. Within each runmode type, each custom name is a primary key. |
description | Description for this runmode. |
RunModeFunc | The function to be run for this runmode. |
Definition at line 486 of file runmodes.c.
References RunModes_::cnt, cnt, RunMode_::description, FatalError, RunMode_::name, name, RunMode_::runmode, RunMode_::RunModeFunc, RunMode_::RunModeIsIPSEnabled, RunModes_::runmodes, SCFree, SCRealloc, SCStrdup, and unlikely.
Referenced by CiCaptureIdsRegister(), RunModeDpdkRegister(), RunModeErfDagRegister(), RunModeErfFileRegister(), RunModeFilePcapRegister(), RunModeIdsAFPRegister(), RunModeIdsAFXDPRegister(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIpsIPFWRegister(), RunModeIpsNFQRegister(), RunModeIpsWinDivertRegister(), RunModeUnixSocketRegister(), SCRunModeLibIdsRegister(), and UtRunModeRegister().
void RunModeRegisterRunModes | ( | void | ) |
Register all runmodes in the engine.
Definition at line 231 of file runmodes.c.
References RunModeDpdkRegister(), RunModeErfDagRegister(), RunModeErfFileRegister(), RunModeFilePcapRegister(), RunModeIdsAFPRegister(), RunModeIdsAFXDPRegister(), RunModeIdsNetmapRegister(), RunModeIdsNflogRegister(), RunModeIdsPcapRegister(), RunModeIpsIPFWRegister(), RunModeIpsNFQRegister(), RunModeIpsWinDivertRegister(), RunModeUnixSocketRegister(), SCRunModeLibIdsRegister(), and UtRunModeRegister().
Referenced by InitGlobal().
void RunModeShutDown | ( | void | ) |
Cleanup the run mode.
Definition at line 579 of file runmodes.c.
References OutputClearActiveLoggers(), OutputFiledataShutdown(), OutputFileShutdown(), OutputFlowShutdown(), OutputPacketShutdown(), OutputStatsShutdown(), OutputStreamingShutdown(), and OutputTxShutdown().
Referenced by PostRunDeinit().
int debuglog_enabled = 0 |
Definition at line 61 of file runmodes.c.
|
extern |
Definition at line 39 of file output-file.c.
Referenced by RunModeInitializeOutputs(), and SCOutputRegisterFileLogger().
|
extern |
Definition at line 37 of file output-filedata.c.
Referenced by RunModeInitializeOutputs(), and SCOutputRegisterFiledataLogger().
const char* thread_name_autofp = "RX" |
Definition at line 66 of file runmodes.c.
Referenced by RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeIdsAFPAutoFp(), RunModeIdsErfDagAutoFp(), RunModeIdsPcapAutoFp(), RunModeSetIPSAutoFp(), and TmThreadWaitOnThreadRunning().
const char* thread_name_counter_stats = "CS" |
Definition at line 75 of file runmodes.c.
Referenced by StatsSpawnThreads().
const char* thread_name_counter_wakeup = "CW" |
Definition at line 76 of file runmodes.c.
Referenced by StatsSpawnThreads().
const char* thread_name_detect_loader = "DL" |
Definition at line 74 of file runmodes.c.
Referenced by DetectLoaderThreadSpawn().
const char* thread_name_flow_bypass = "FB" |
Definition at line 72 of file runmodes.c.
Referenced by BypassedFlowManagerThreadSpawn().
const char* thread_name_flow_mgr = "FM" |
Definition at line 70 of file runmodes.c.
Referenced by FlowDisableFlowManagerThread(), FlowManagerThreadSpawn(), and TmThreadWaitOnThreadRunning().
const char* thread_name_flow_rec = "FR" |
Definition at line 71 of file runmodes.c.
Referenced by FlowDisableFlowRecyclerThread(), FlowRecyclerThreadSpawn(), and TmThreadWaitOnThreadRunning().
const char* thread_name_heartbeat = "HB" |
Definition at line 77 of file runmodes.c.
Referenced by LogFlushThreads().
const char* thread_name_single = "W" |
Definition at line 67 of file runmodes.c.
Referenced by RunModeErfFileSingle(), RunModeFilePcapSingle(), RunModeIdsAFPSingle(), RunModeIdsAFXDPSingle(), RunModeIdsErfDagSingle(), and RunModeIdsPcapSingle().
const char* thread_name_unix_socket = "US" |
Definition at line 73 of file runmodes.c.
const char* thread_name_verdict = "TX" |
Definition at line 69 of file runmodes.c.
Referenced by RunModeSetIPSAutoFp(), and TmThreadWaitOnThreadRunning().
const char* thread_name_workers = "W" |
Definition at line 68 of file runmodes.c.
Referenced by RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeIdsAFPWorkers(), RunModeIdsAFXDPWorkers(), RunModeIdsDpdkWorkers(), RunModeIdsErfDagWorkers(), RunModeIdsPcapWorkers(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), RunModeSetLiveCaptureAutoFp(), SCRunModeLibCreateThreadVars(), and TmThreadWaitOnThreadRunning().
float threading_detect_ratio = 1 |
Definition at line 949 of file runmodes.c.
Referenced by RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeInitializeThreadSettings(), and TmThreadsGetWorkerThreadMax().
bool threading_set_cpu_affinity = false |
Definition at line 62 of file runmodes.c.
Referenced by RunModeErfFileAutoFp(), RunModeInitializeThreadSettings(), and TmThreadSetCPU().
uint64_t threading_set_stack_size = 0 |
Definition at line 63 of file runmodes.c.
Referenced by RunModeInitializeThreadSettings(), and TmThreadSpawn().