*/
#include "suricata.h"
+#include "runmodes.h"
#include "conf.h"
#include "pcap.h"
#include "runmode-lib.h"
return 1;
}
- /* Set lib runmode. There is currently no way to set it via the
- * Conf API. */
- SuricataSetLibRunmode();
+ /* Set the runmode to library mode. Perhaps in the future this
+ * should be done in some library bootstrap function. */
+ SCRunmodeSet(RUNMODE_LIB);
/* Validate/finalize the runmode. */
if (SCFinalizeRunMode() != TM_ECODE_OK) {
*/
typedef struct RunMode_ {
/* the runmode type */
- enum RunModes runmode;
+ enum SCRunModes runmode;
const char *name;
const char *description;
/* runmode function */
* \param runmode The runmode type.
* \param runmode_custom_id The runmode custom id.
*/
-static RunMode *RunModeGetCustomMode(enum RunModes runmode, const char *custom_mode)
+static RunMode *RunModeGetCustomMode(enum SCRunModes runmode, const char *custom_mode)
{
if (runmode < RUNMODE_USER_MAX) {
for (int i = 0; i < runmodes[runmode].cnt; i++) {
* \param description Description for this runmode.
* \param RunModeFunc The function to be run for this runmode.
*/
-void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description,
+void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description,
int (*RunModeFunc)(void), int (*RunModeIsIPSEnabled)(void))
{
if (RunModeGetCustomMode(runmode, name) != NULL) {
return filedata_logger_count > 0;
}
-bool IsRunModeSystem(enum RunModes run_mode_to_check)
+bool IsRunModeSystem(enum SCRunModes run_mode_to_check)
{
switch (run_mode_to_check) {
case RUNMODE_PCAP_FILE:
}
}
-bool IsRunModeOffline(enum RunModes run_mode_to_check)
+bool IsRunModeOffline(enum SCRunModes run_mode_to_check)
{
switch(run_mode_to_check) {
case RUNMODE_CONF_TEST:
#define SURICATA_RUNMODES_H
/* Run mode */
-enum RunModes {
+typedef enum SCRunModes {
RUNMODE_UNKNOWN = 0,
RUNMODE_PCAP_DEV,
RUNMODE_PCAP_FILE,
#endif
RUNMODE_DUMP_FEATURES,
RUNMODE_MAX,
-};
+} SCRunMode;
/* Run Mode Global Thread Names */
extern const char *thread_name_autofp;
int RunModeEngineIsIPS(int capture_mode, const char *runmode, const char *capture_plugin_name);
void RunModeDispatch(int, const char *, const char *capture_plugin_name, const char *capture_plugin_args);
void RunModeRegisterRunModes(void);
-void RunModeRegisterNewRunMode(enum RunModes, const char *, const char *, int (*RunModeFunc)(void),
+void RunModeRegisterNewRunMode(SCRunMode, const char *, const char *, int (*RunModeFunc)(void),
int (*RunModeIsIPSEnabled)(void));
void RunModeInitializeThreadSettings(void);
void RunModeInitializeOutputs(void);
/* bool indicating if filedata logger is enabled */
int RunModeOutputFiledataEnabled(void);
/** bool indicating if run mode is offline */
-bool IsRunModeOffline(enum RunModes run_mode_to_check);
-bool IsRunModeSystem(enum RunModes run_mode_to_check);
+bool IsRunModeOffline(SCRunMode run_mode_to_check);
+bool IsRunModeSystem(SCRunMode run_mode_to_check);
void RunModeEnablesBypassManager(void);
int RunModeNeedsBypassManager(void);
}
#endif
-int SCRunmodeGet(void)
+SCRunMode SCRunmodeGet(void)
{
return suricata.run_mode;
}
-void SCRunmodeSet(int run_mode)
+void SCRunmodeSet(SCRunMode run_mode)
{
suricata.run_mode = run_mode;
}
}
SCPledge();
}
-
-void SuricataSetLibRunmode(void)
-{
- suricata.run_mode = RUNMODE_LIB;
-}
#include "runmodes.h"
typedef struct SCInstance_ {
- enum RunModes run_mode;
- enum RunModes aux_run_mode;
+ enum SCRunModes run_mode;
+ enum SCRunModes aux_run_mode;
char pcap_dev[128];
char *sig_file;
/**
* \brief Get the current run mode.
*/
-int SCRunmodeGet(void);
+SCRunMode SCRunmodeGet(void);
/**
* \brief Set the current run mode.
*
* Mainly exposed outside of suricata.c as a unit-test helper.
*/
-void SCRunmodeSet(int run_mode);
+void SCRunmodeSet(SCRunMode run_mode);
int SuriHasSigFile(void);
const char *GetProgramVersion(void);
-/* Library only methods. */
-void SuricataSetLibRunmode(void);
-
#endif /* SURICATA_SURICATA_H */
CAP_SYS_NICE,
-1);
break;
+ default:
+ break;
}
if (capng_change_id(userid, groupid, CAPNG_DROP_SUPP_GRP |