modify runmode api to accept conf runmode paramter as a char string, instead of an interger id

remotes/origin/master-1.1.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent fb4ffc9aef
commit e4d890e186

@ -37,19 +37,19 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode;
int RunModeErfDagGetDefaultMode(void) const char *RunModeErfDagGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeErfDagRegister(void) void RunModeErfDagRegister(void)
{ {
default_mode = RunModeRegisterNewRunMode(RUNMODE_DAG, default_mode = "auto";
"erf_dag_auto", RunModeRegisterNewRunMode(RUNMODE_DAG, "auto",
"multi threaded Erf dag mode", "Multi threaded Erf dag mode",
RunModeErfDagAuto); RunModeErfDagAuto);
return; return;
} }

@ -25,6 +25,6 @@
int RunModeErfDagAuto(DetectEngineCtx *); int RunModeErfDagAuto(DetectEngineCtx *);
void RunModeErfDagRegister(void); void RunModeErfDagRegister(void);
int RunModeErfDagGetDefaultMode(void); const char *RunModeErfDagGetDefaultMode(void);
#endif /* __RUNMODE_ERF_DAG_H__ */ #endif /* __RUNMODE_ERF_DAG_H__ */

@ -37,19 +37,19 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode;
int RunModeErfFileGetDefaultMode(void) const char *RunModeErfFileGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeErfFileRegister(void) void RunModeErfFileRegister(void)
{ {
default_mode = RunModeRegisterNewRunMode(RUNMODE_ERF_FILE, default_mode = "auto";
"erf_file_auto", RunModeRegisterNewRunMode(RUNMODE_ERF_FILE, "auto",
"multi threaded Erf File mode", "Multi threaded Erf File mode",
RunModeErfFileAuto); RunModeErfFileAuto);
return; return;
} }

@ -25,6 +25,6 @@
int RunModeErfFileAuto(DetectEngineCtx *); int RunModeErfFileAuto(DetectEngineCtx *);
void RunModeErfFileRegister(void); void RunModeErfFileRegister(void);
int RunModeErfFileGetDefaultMode(void); const char *RunModeErfFileGetDefaultMode(void);
#endif /* __RUNMODE_ERF_FILE_H__ */ #endif /* __RUNMODE_ERF_FILE_H__ */

@ -37,19 +37,19 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode;
int RunModeIpsIPFWGetDefaultMode(void) const char *RunModeIpsIPFWGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeIpsIPFWRegister(void) void RunModeIpsIPFWRegister(void)
{ {
default_mode = RunModeRegisterNewRunMode(RUNMODE_IPFW, default_mode = "auto";
"pfring_ipfw_auto", RunModeRegisterNewRunMode(RUNMODE_IPFW, "auto",
"multi threaded IPFW IPS mode", "Multi threaded IPFW IPS mode",
RunModeIpsIPFWAuto); RunModeIpsIPFWAuto);
return; return;
} }

@ -25,6 +25,6 @@
int RunModeIpsIPFWAuto(DetectEngineCtx *); int RunModeIpsIPFWAuto(DetectEngineCtx *);
void RunModeIpsIPFWRegister(void); void RunModeIpsIPFWRegister(void);
int RunModeIpsIPFWGetDefaultMode(void); const char *RunModeIpsIPFWGetDefaultMode(void);
#endif /* __RUNMODE_IPFW_H__ */ #endif /* __RUNMODE_IPFW_H__ */

@ -37,19 +37,19 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode;
int RunModeIpsNFQGetDefaultMode(void) const char *RunModeIpsNFQGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeIpsNFQRegister(void) void RunModeIpsNFQRegister(void)
{ {
default_mode = RunModeRegisterNewRunMode(RUNMODE_NFQ, default_mode = "auto";
"nfq_auto", RunModeRegisterNewRunMode(RUNMODE_NFQ, "auto",
"multi threaded NFQ IPS mode", "Multi threaded NFQ IPS mode",
RunModeIpsNFQAuto); RunModeIpsNFQAuto);
return; return;
} }

@ -25,6 +25,6 @@
int RunModeIpsNFQAuto(DetectEngineCtx *); int RunModeIpsNFQAuto(DetectEngineCtx *);
void RunModeIpsNFQRegister(void); void RunModeIpsNFQRegister(void);
int RunModeIpsNFQGetDefaultMode(void); const char *RunModeIpsNFQGetDefaultMode(void);
#endif /* __RUNMODE_NFQ_H__ */ #endif /* __RUNMODE_NFQ_H__ */

@ -37,26 +37,24 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode = NULL;
int RunModeFilePcapGetDefaultMode(void) const char *RunModeFilePcapGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeFilePcapRegister(void) void RunModeFilePcapRegister(void)
{ {
RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, "single",
"pcap_file_single",
"Single threaded pcap file mode", "Single threaded pcap file mode",
RunModeFilePcap2); RunModeFilePcap2);
default_mode = RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, "auto",
"pcap_file_auto", "Multi threaded pcap file mode",
"multi threaded pcap file mode", RunModeFilePcapAuto);
RunModeFilePcapAuto); default_mode = "auto";
RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, RunModeRegisterNewRunMode(RUNMODE_PCAP_FILE, "autofp",
"pcap_file_autofp", "Multi threaded pcap file mode. Packets from "
"multi threaded pcap file mode. Packets from "
"each flow are assigned to a single detect thread, " "each flow are assigned to a single detect thread, "
"unlike \"pcap_file_auto\" where packets from " "unlike \"pcap_file_auto\" where packets from "
"the same flow can be processed by any detect " "the same flow can be processed by any detect "

@ -27,6 +27,6 @@ int RunModeFilePcap2(DetectEngineCtx *);
int RunModeFilePcapAuto(DetectEngineCtx *); int RunModeFilePcapAuto(DetectEngineCtx *);
int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx); int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx);
void RunModeFilePcapRegister(void); void RunModeFilePcapRegister(void);
int RunModeFilePcapGetDefaultMode(void); const char *RunModeFilePcapGetDefaultMode(void);
#endif /* __RUNMODE_PCAP_FILE_H__ */ #endif /* __RUNMODE_PCAP_FILE_H__ */

@ -37,19 +37,19 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode; static const char *default_mode = NULL;
int RunModeIdsGetDefaultMode(void) const char *RunModeIdsGetDefaultMode(void)
{ {
return default_mode; return default_mode;
} }
void RunModeIdsPcapRegister(void) void RunModeIdsPcapRegister(void)
{ {
default_mode = RunModeRegisterNewRunMode(RUNMODE_PCAP_DEV, RunModeRegisterNewRunMode(RUNMODE_PCAP_DEV, "auto",
"pcap_dev_auto", "Multi threaded pcap live mode",
"Multi threaded pcap live mode", RunModeIdsPcapAuto);
RunModeIdsPcapAuto); default_mode = "auto";
return; return;
} }

@ -25,6 +25,6 @@
int RunModeIdsPcapAuto(DetectEngineCtx *); int RunModeIdsPcapAuto(DetectEngineCtx *);
void RunModeIdsPcapRegister(void); void RunModeIdsPcapRegister(void);
int RunModeIdsGetDefaultMode(void); const char *RunModeIdsGetDefaultMode(void);
#endif /* __RUNMODE_PCAP_H__ */ #endif /* __RUNMODE_PCAP_H__ */

@ -38,10 +38,10 @@
#include "util-cpu.h" #include "util-cpu.h"
#include "util-affinity.h" #include "util-affinity.h"
static int default_mode_auto; static const char *default_mode_auto = NULL;
static int default_mode_autofp; static const char *default_mode_autofp = NULL;
int RunModeIdsPfringGetDefaultMode(void) const char *RunModeIdsPfringGetDefaultMode(void)
{ {
#ifdef HAVE_PFRING #ifdef HAVE_PFRING
if (PfringConfGetThreads() == 1) { if (PfringConfGetThreads() == 1) {
@ -50,26 +50,24 @@ int RunModeIdsPfringGetDefaultMode(void)
return default_mode_autofp; return default_mode_autofp;
} }
#else #else
return -2; return NULL;
#endif #endif
} }
void RunModeIdsPfringRegister(void) void RunModeIdsPfringRegister(void)
{ {
default_mode_auto = default_mode_auto = "auto";
RunModeRegisterNewRunMode(RUNMODE_PFRING, RunModeRegisterNewRunMode(RUNMODE_PFRING, "auto",
"pfring_auto", "Multi threaded pfring mode",
"multi threaded pfring mode", RunModeIdsPfringAuto);
RunModeIdsPfringAuto); default_mode_autofp = "autofp";
default_mode_autofp = RunModeRegisterNewRunMode(RUNMODE_PFRING, "autofp",
RunModeRegisterNewRunMode(RUNMODE_PFRING, "Multi threaded pfring mode. Packets from "
"pfring_autofp", "each flow are assigned to a single detect "
"multi threaded pfring mode. Packets from " "thread, unlike \"pfring_auto\" where packets "
"each flow are assigned to a single detect " "from the same flow can be processed by any "
"thread, unlike \"pfring_auto\" where packets " "detect thread",
"from the same flow can be processed by any " RunModeIdsPfringAutoFp);
"detect thread",
RunModeIdsPfringAutoFp);
return; return;
} }

@ -28,6 +28,6 @@
int RunModeIdsPfringAuto(DetectEngineCtx *); int RunModeIdsPfringAuto(DetectEngineCtx *);
int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx); int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx);
void RunModeIdsPfringRegister(void); void RunModeIdsPfringRegister(void);
int RunModeIdsPfringGetDefaultMode(void); const char *RunModeIdsPfringGetDefaultMode(void);
#endif /* __RUNMODE_PFRING_H__ */ #endif /* __RUNMODE_PFRING_H__ */

@ -56,8 +56,6 @@
* \brief Holds description for a runmode. * \brief Holds description for a runmode.
*/ */
typedef struct RunMode_ { typedef struct RunMode_ {
/* unique custom id generated for this runmode */
int custom_id;
/* the runmode type */ /* the runmode type */
int runmode; int runmode;
const char *name; const char *name;
@ -66,6 +64,11 @@ typedef struct RunMode_ {
int (*RunModeFunc)(DetectEngineCtx *); int (*RunModeFunc)(DetectEngineCtx *);
} RunMode; } RunMode;
typedef struct RunModes_ {
int no_of_runmodes;
RunMode *runmodes;
} RunModes;
/** /**
* A list of output modules that will be active for the run mode. * A list of output modules that will be active for the run mode.
*/ */
@ -78,44 +81,7 @@ typedef struct RunModeOutput_ {
TAILQ_HEAD(, RunModeOutput_) RunModeOutputs = TAILQ_HEAD(, RunModeOutput_) RunModeOutputs =
TAILQ_HEAD_INITIALIZER(RunModeOutputs); TAILQ_HEAD_INITIALIZER(RunModeOutputs);
/* unique key used to generate runmode custom ids */ static RunModes runmodes[RUNMODE_MAX];
static int runmode_id = 0;
RunMode *runmodes = NULL;
/**
* \internal
* \brief Check if a runmode custom id is valid.
*
* \param runmode_custom_id The id to be validated.
*
* \retval 1 If true.
* \retval 0 Otherwise.
*/
int RunModeCustomIdValid(int runmode_custom_id)
{
if (runmode_custom_id < 0 || runmode_custom_id >= runmode_id) {
return 0;
}
return 1;
}
/**
* \brief Register all runmodes in the engine.
*/
void RunModeRegisterRunModes(void)
{
RunModeIdsPcapRegister();
RunModeFilePcapRegister();
RunModeIdsPfringRegister();
RunModeIpsNFQRegister();
RunModeIpsIPFWRegister();
RunModeErfFileRegister();
RunModeErfDagRegister();
UtRunModeRegister();
return;
}
/** /**
* \internal * \internal
@ -130,38 +96,70 @@ static const char *RunModeTranslateModeToName(int runmode)
switch (runmode) { switch (runmode) {
case RUNMODE_PCAP_DEV: case RUNMODE_PCAP_DEV:
return "PCAP_DEV"; return "PCAP_DEV";
break;
case RUNMODE_PCAP_FILE: case RUNMODE_PCAP_FILE:
return "PCAP_FILE"; return "PCAP_FILE";
break;
case RUNMODE_PFRING: case RUNMODE_PFRING:
#ifdef HAVE_PFRING #ifdef HAVE_PFRING
return "PFRING"; return "PFRING";
#else #else
return "PFRING(DISABLED)"; return "PFRING(DISABLED)";
#endif #endif
break;
case RUNMODE_NFQ: case RUNMODE_NFQ:
return "NFQ"; return "NFQ";
break;
case RUNMODE_IPFW: case RUNMODE_IPFW:
return "IPFW"; return "IPFW";
break;
case RUNMODE_ERF_FILE: case RUNMODE_ERF_FILE:
return "ERF_FILE"; return "ERF_FILE";
break;
case RUNMODE_DAG: case RUNMODE_DAG:
return "ERF_DAG"; return "ERF_DAG";
break;
case RUNMODE_UNITTEST: case RUNMODE_UNITTEST:
return "UNITTEST"; return "UNITTEST";
break;
default: default:
SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting"); SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
/**
* \internal
* \brief Dispatcher function for runmodes. Calls the required runmode function
* based on runmode + runmode_custom_id.
*
* \param runmode The runmode type.
* \param runmode_customd_id The runmode custom id.
* \param de_ctx Detection Engine Context.
*/
static RunMode *RunModeGetCustomMode(int runmode, const char *custom_mode)
{
int i;
for (i = 0; i < runmodes[runmode].no_of_runmodes; i++) {
if (strcmp(runmodes[runmode].runmodes[i].name, custom_mode) == 0)
return &runmodes[runmode].runmodes[i];
}
return NULL;
}
/**
* \brief Register all runmodes in the engine.
*/
void RunModeRegisterRunModes(void)
{
memset(runmodes, 0, sizeof(runmodes));
RunModeIdsPcapRegister();
RunModeFilePcapRegister();
RunModeIdsPfringRegister();
RunModeIpsNFQRegister();
RunModeIpsIPFWRegister();
RunModeErfFileRegister();
RunModeErfDagRegister();
UtRunModeRegister();
return;
}
/** /**
* \brief Lists all registered runmodes. * \brief Lists all registered runmodes.
*/ */
@ -174,92 +172,91 @@ void RunModeListRunmodes(void)
printf("------------------------------------------------------------------" printf("------------------------------------------------------------------"
"-----------------------\n"); "-----------------------\n");
printf("| %-2s | %-17s | %-17s | %-10s \n", printf("| %-17s | %-17s | %-10s \n",
"Id", " Mode", " Name-", "Descripition"); " RunMode Type", " Custom Mode ", "Descripition");
printf("|-----------------------------------------------------------------" printf("|-----------------------------------------------------------------"
"-----------------------\n"); "-----------------------\n");
int i; int i = RUNMODE_UNKNOWN + 1;
for (i = 0; i < runmode_id; i++) { int j = 0;
printf("| %-2d | %-17s | %-17s | %-27s \n", for ( ; i < RUNMODE_MAX; i++) {
i, int mode_displayed = 0;
RunModeTranslateModeToName(runmodes[i].runmode), for (j = 0; j < runmodes[i].no_of_runmodes; j++) {
runmodes[i].name, if (mode_displayed == 1) {
runmodes[i].description); printf("| ----------------------------------------------"
"-----------------------\n");
RunMode *runmode = &runmodes[i].runmodes[j];
printf("| %-17s | %-17s | %-27s \n",
"",
runmode->name,
runmode->description);
} else {
RunMode *runmode = &runmodes[i].runmodes[j];
printf("| %-17s | %-17s | %-27s \n",
RunModeTranslateModeToName(runmode->runmode),
runmode->name,
runmode->description);
}
if (mode_displayed == 0)
mode_displayed = 1;
}
printf("|-----------------------------------------------------------------"
"-----------------------\n");
} }
printf("|-----------------------------------------------------------------"
"-----------------------\n");
return; return;
} }
/** void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_ctx)
* \brief Dispatcher function for runmodes. Calls the required runmode function
* based on runmode + runmode_custom_id.
*
* \param runmode The runmode type.
* \param runmode_customd_id The runmode custom id.
* \param de_ctx Detection Engine Context.
*/
void RunModeDispatch(int runmode, int runmode_custom_id, DetectEngineCtx *de_ctx)
{ {
if (runmode_custom_id != -1 && if (custom_mode == NULL) {
(runmode_custom_id < 0 || runmode_custom_id >= runmode_id)) { char *val = NULL;
SCLogError(SC_ERR_RUNMODE, "You have supplied wrong runmode type - " if (ConfGet("runmode", &val) != 1) {
"%d", runmode_custom_id); custom_mode = NULL;
exit(EXIT_FAILURE); } else {
} custom_mode = val;
if (runmode_custom_id != -1) {
if (runmode != runmodes[runmode_custom_id].runmode) {
SCLogError(SC_ERR_RUNMODE, "The runmode custom id's(%d) "
"runmode - \"%s\" doesn't match the runmode type - \"%s\" "
"being used. Please use runmode id whose RunMode "
"mode matches the mode you are running the "
"engine in.",
runmode_custom_id,
RunModeTranslateModeToName(runmodes[runmode_custom_id].runmode),
RunModeTranslateModeToName(runmode));
exit(EXIT_FAILURE);
} }
runmodes[runmode_custom_id].RunModeFunc(de_ctx);
return;
} }
switch (runmode) { if (custom_mode == NULL) {
case RUNMODE_PCAP_DEV: switch (runmode) {
runmode_custom_id = RunModeIdsGetDefaultMode(); case RUNMODE_PCAP_DEV:
break; custom_mode = RunModeIdsGetDefaultMode();
case RUNMODE_PCAP_FILE: break;
runmode_custom_id = RunModeFilePcapGetDefaultMode(); case RUNMODE_PCAP_FILE:
break; custom_mode = RunModeFilePcapGetDefaultMode();
break;
#ifdef HAVE_PFRING #ifdef HAVE_PFRING
case RUNMODE_PFRING: case RUNMODE_PFRING:
runmode_custom_id = RunModeIdsPfringGetDefaultMode(); custom_mode = RunModeIdsPfringGetDefaultMode();
break; break;
#endif #endif
case RUNMODE_NFQ: case RUNMODE_NFQ:
runmode_custom_id = RunModeIpsNFQGetDefaultMode(); custom_mode = RunModeIpsNFQGetDefaultMode();
break; break;
case RUNMODE_IPFW: case RUNMODE_IPFW:
runmode_custom_id = RunModeIpsIPFWGetDefaultMode(); custom_mode = RunModeIpsIPFWGetDefaultMode();
break; break;
case RUNMODE_ERF_FILE: case RUNMODE_ERF_FILE:
runmode_custom_id = RunModeErfFileGetDefaultMode(); custom_mode = RunModeErfFileGetDefaultMode();
break; break;
case RUNMODE_DAG: case RUNMODE_DAG:
runmode_custom_id = RunModeErfDagGetDefaultMode(); custom_mode = RunModeErfDagGetDefaultMode();
break; break;
default: default:
SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting"); SCLogError(SC_ERR_UNKNOWN_RUN_MODE, "Unknown runtime mode. Aborting");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} /* if (custom_mode == NULL) */
if (runmode_custom_id < 0 && runmode_custom_id >= runmode_id) {
SCLogError(SC_ERR_RUNMODE, "Wrong default custom id - %d, returned by " RunMode *mode = RunModeGetCustomMode(runmode, custom_mode);
"runmode - %d", runmode_custom_id, runmode); if (mode == NULL) {
SCLogError(SC_ERR_RUNMODE, "The custom type \"%s\" doesn't exist "
"for this runmode type \"%s\". Please use --list-runmodes to "
"see available custom types for this runmode",
custom_mode, RunModeTranslateModeToName(runmode));
exit(EXIT_FAILURE);
} }
mode->RunModeFunc(de_ctx);
runmodes[runmode_custom_id].RunModeFunc(de_ctx);
return; return;
} }
@ -268,26 +265,37 @@ void RunModeDispatch(int runmode, int runmode_custom_id, DetectEngineCtx *de_ctx
* \brief Registers a new runmode. * \brief Registers a new runmode.
* *
* \param runmode Runmode type. * \param runmode Runmode type.
* \param name Simple name. Need not be unique, although suggested. * \param name Custom mode for this specific runmode type. Within each
* runmode type, each custom name is a primary key.
* \param description Description for this runmode. * \param description Description for this runmode.
* \param RunModeFunc The function to be run for this runmode. * \param RunModeFunc The function to be run for this runmode.
*/ */
int RunModeRegisterNewRunMode(uint8_t runmode, const char *name, void RunModeRegisterNewRunMode(int runmode, const char *name,
const char *description, const char *description,
int (*RunModeFunc)(DetectEngineCtx *)) int (*RunModeFunc)(DetectEngineCtx *))
{ {
runmodes = SCRealloc(runmodes, (runmode_id + 1) * sizeof(RunMode)); if (RunModeGetCustomMode(runmode, name) != NULL) {
if (runmodes == NULL) { SCLogError(SC_ERR_RUNMODE, "A runmode by this custom name has already "
"been registered. Please use an unique name");
return;
}
runmodes[runmode].runmodes =
SCRealloc(runmodes[runmode].runmodes,
(runmodes[runmode].no_of_runmodes + 1) * sizeof(RunMode));
if (runmodes[runmode].runmodes == NULL) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
runmodes[runmode_id].custom_id = runmode_id;
runmodes[runmode_id].runmode = runmode; RunMode *mode = &runmodes[runmode].runmodes[runmodes[runmode].no_of_runmodes];
runmodes[runmode_id].name = SCStrdup(name); runmodes[runmode].no_of_runmodes++;
runmodes[runmode_id].description = SCStrdup(description);
runmodes[runmode_id].RunModeFunc = RunModeFunc; mode->runmode = runmode;
runmode_id++; mode->name = SCStrdup(name);
mode->description = SCStrdup(description);
return runmode_id - 1; mode->RunModeFunc = RunModeFunc;
return;
} }
/** /**

@ -37,13 +37,11 @@ enum {
RUNMODE_MAX, RUNMODE_MAX,
}; };
int RunModeCustomIdValid(int);
void RunModeListRunmodes(void); void RunModeListRunmodes(void);
void RunModeDispatch(int, int, DetectEngineCtx *); void RunModeDispatch(int, const char *, DetectEngineCtx *);
void RunModeRegisterRunModes(void); void RunModeRegisterRunModes(void);
int RunModeRegisterNewRunMode(uint8_t, const char *, void RunModeRegisterNewRunMode(int, const char *, const char *,
const char *, int (*RunModeFunc)(DetectEngineCtx *));
int (*RunModeFunc)(DetectEngineCtx *));
void RunModeInitialize(void); void RunModeInitialize(void);
void RunModeInitializeOutputs(void); void RunModeInitializeOutputs(void);
void SetupOutputs(ThreadVars *); void SetupOutputs(ThreadVars *);

@ -497,7 +497,7 @@ int main(int argc, char **argv)
int list_unittests = 0; int list_unittests = 0;
int list_cuda_cards = 0; int list_cuda_cards = 0;
int list_runmodes = 0; int list_runmodes = 0;
int runmode_custom_id = -1; const char *runmode_custom_mode = NULL;
int daemon = 0; int daemon = 0;
char *user_name = NULL; char *user_name = NULL;
char *group_name = NULL; char *group_name = NULL;
@ -659,13 +659,7 @@ int main(int argc, char **argv)
RunModeListRunmodes(); RunModeListRunmodes();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (strcmp((long_opts[option_index]).name, "runmode") == 0) { } else if (strcmp((long_opts[option_index]).name, "runmode") == 0) {
runmode_custom_id = atoi(optarg); runmode_custom_mode = optarg;
if (!RunModeCustomIdValid(runmode_custom_id)) {
fprintf(stderr, "ERROR: Invalid runmode id - \"%d\" supplied. "
"Please pass valid runmode id from "
"--list-runmodes.\n", runmode_custom_id);
exit(EXIT_FAILURE);
}
} else if(strcmp((long_opts[option_index]).name, "engine-analysis") == 0) { } else if(strcmp((long_opts[option_index]).name, "engine-analysis") == 0) {
// do nothing for now // do nothing for now
} }
@ -941,24 +935,6 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
/* If runmode isn't supplied in the command line, retrieve it from the conf
* file. If supplied in command line, the command line version overrides
* conf file */
if (runmode_custom_id == -1) {
intmax_t val;
if (ConfGetInt("runmode", &val) != 1) {
runmode_custom_id = -1;
} else {
runmode_custom_id = val;
if (!RunModeCustomIdValid(runmode_custom_id)) {
fprintf(stderr, "ERROR: Invalid runmode id - \"%d\" supplied "
"in conf file. Please pass valid runmode id from "
"--list-runmodes.\n", runmode_custom_id);
exit(EXIT_FAILURE);
}
}
}
/* Check for the existance of the default logging directory which we pick /* Check for the existance of the default logging directory which we pick
* from suricata.yaml. If not found, shut the engine down */ * from suricata.yaml. If not found, shut the engine down */
if (ConfGet("default-log-dir", &log_dir) != 1) if (ConfGet("default-log-dir", &log_dir) != 1)
@ -1335,7 +1311,7 @@ int main(int argc, char **argv)
} }
} }
RunModeDispatch(run_mode, runmode_custom_id, de_ctx); RunModeDispatch(run_mode, runmode_custom_mode, de_ctx);
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__
if (PatternMatchDefaultMatcher() == MPM_B2G_CUDA) { if (PatternMatchDefaultMatcher() == MPM_B2G_CUDA) {

@ -15,9 +15,9 @@
# pattern matcher scans many packets in parallel. # pattern matcher scans many packets in parallel.
#max-pending-packets: 50 #max-pending-packets: 50
# Runmode custom id the engine should run in. Please check --list-runmodes # Runmode custom mode the engine should run in. Please check --list-runmodes
# to get the runmode ids that can be used here. # to get the runmode custom modes that can be used here for a particular runmode.
#runmode: 0 #runmode: auto
# Preallocated size for packet. Default is 1514 which is the classical # Preallocated size for packet. Default is 1514 which is the classical
# size for pcap on ethernet. You should adjust this value to the highest # size for pcap on ethernet. You should adjust this value to the highest

Loading…
Cancel
Save