diff --git a/src/runmodes.c b/src/runmodes.c index f1e14727c0..e8fb89b355 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -81,6 +81,8 @@ TAILQ_HEAD(, RunModeOutput_) RunModeOutputs = static RunModes runmodes[RUNMODE_MAX]; +static char *active_runmode; + /** * \internal * \brief Translate a runmode mode to a printale string. @@ -141,6 +143,19 @@ static RunMode *RunModeGetCustomMode(int runmode, const char *custom_mode) return NULL; } + +/** + * Return the running mode + * + * The returned string must not be freed. + * + * \return a string containing the current running mode + */ +char *RunmodeGetActive(void) +{ + return active_runmode; +} + /** * \brief Register all runmodes in the engine. */ @@ -257,6 +272,10 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c custom_mode, RunModeTranslateModeToName(runmode)); exit(EXIT_FAILURE); } + + /* Export the custom mode */ + active_runmode = SCStrdup(custom_mode); + mode->RunModeFunc(de_ctx); return; diff --git a/src/runmodes.h b/src/runmodes.h index 7555b45eb4..2770f3668f 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -38,6 +38,8 @@ enum { RUNMODE_MAX, }; +char *RunmodeGetActive(void); + void RunModeListRunmodes(void); void RunModeDispatch(int, const char *, DetectEngineCtx *); void RunModeRegisterRunModes(void);