runmodes: remove DetectEngineCtx passing from API

No longer pass a pointer to the current detection engine to the
runmode API calls.

Note: breaks delayed detect. Will be fixed in a future commit.
pull/1389/head
Victor Julien 11 years ago
parent b038b6a2f8
commit 38b349af1e

@ -1796,6 +1796,22 @@ void *DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int id)
return det_ctx->keyword_ctxs_array[id]; return det_ctx->keyword_ctxs_array[id];
} }
/** \brief Check if detection is enabled
* \retval bool true or false */
int DetectEngineEnabled(void)
{
DetectEngineMasterCtx *master = &g_master_de_ctx;
SCMutexLock(&master->lock);
if (master->list == NULL) {
SCMutexUnlock(&master->lock);
return 0;
}
SCMutexUnlock(&master->lock);
return 1;
}
DetectEngineCtx *DetectEngineGetCurrent(void) DetectEngineCtx *DetectEngineGetCurrent(void)
{ {
DetectEngineMasterCtx *master = &g_master_de_ctx; DetectEngineMasterCtx *master = &g_master_de_ctx;

@ -74,6 +74,7 @@ void DetectEnginePruneFreeList(void);
int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx); int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx);
void DetectEngineDeReference(DetectEngineCtx **de_ctx); void DetectEngineDeReference(DetectEngineCtx **de_ctx);
int DetectEngineReload(void); int DetectEngineReload(void);
int DetectEngineEnabled(void);
/** /**
* \brief Registers an app inspection engine. * \brief Registers an app inspection engine.

@ -433,7 +433,7 @@ int AFPRunModeIsIPS()
return has_ips; return has_ips;
} }
int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsAFPAutoFp(void)
{ {
SCEnter(); SCEnter();
@ -455,8 +455,7 @@ int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(ParseAFPConfig,
ParseAFPConfig,
AFPConfigGeThreadsCount, AFPConfigGeThreadsCount,
"ReceiveAFP", "ReceiveAFP",
"DecodeAFP", "RxAFP", "DecodeAFP", "RxAFP",
@ -481,14 +480,12 @@ int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx)
/** /**
* \brief Single thread version of the AF_PACKET processing. * \brief Single thread version of the AF_PACKET processing.
*/ */
int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx) int RunModeIdsAFPSingle(void)
{ {
SCEnter();
#ifdef HAVE_AF_PACKET #ifdef HAVE_AF_PACKET
int ret; int ret;
char *live_dev = NULL; char *live_dev = NULL;
#endif
SCEnter();
#ifdef HAVE_AF_PACKET
RunModeInitialize(); RunModeInitialize();
TimeModeSetLive(); TimeModeSetLive();
@ -500,8 +497,7 @@ int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(ParseAFPConfig,
ParseAFPConfig,
AFPConfigGeThreadsCount, AFPConfigGeThreadsCount,
"ReceiveAFP", "ReceiveAFP",
"DecodeAFP", "AFPacket", "DecodeAFP", "AFPacket",
@ -529,14 +525,12 @@ int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx)
* Start N threads with each thread doing all the work. * Start N threads with each thread doing all the work.
* *
*/ */
int RunModeIdsAFPWorkers(DetectEngineCtx *de_ctx) int RunModeIdsAFPWorkers(void)
{ {
SCEnter();
#ifdef HAVE_AF_PACKET #ifdef HAVE_AF_PACKET
int ret; int ret;
char *live_dev = NULL; char *live_dev = NULL;
#endif
SCEnter();
#ifdef HAVE_AF_PACKET
RunModeInitialize(); RunModeInitialize();
TimeModeSetLive(); TimeModeSetLive();
@ -548,8 +542,7 @@ int RunModeIdsAFPWorkers(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(ParseAFPConfig,
ParseAFPConfig,
AFPConfigGeThreadsCount, AFPConfigGeThreadsCount,
"ReceiveAFP", "ReceiveAFP",
"DecodeAFP", "AFPacket", "DecodeAFP", "AFPacket",

@ -23,10 +23,9 @@
#ifndef __RUNMODE_AF_PACKET_H__ #ifndef __RUNMODE_AF_PACKET_H__
#define __RUNMODE_AF_PACKET_H__ #define __RUNMODE_AF_PACKET_H__
int RunModeIdsAFPAuto(DetectEngineCtx *); int RunModeIdsAFPSingle(void);
int RunModeIdsAFPSingle(DetectEngineCtx *); int RunModeIdsAFPAutoFp(void);
int RunModeIdsAFPAutoFp(DetectEngineCtx *); int RunModeIdsAFPWorkers(void);
int RunModeIdsAFPWorkers(DetectEngineCtx *);
void RunModeIdsAFPRegister(void); void RunModeIdsAFPRegister(void);
const char *RunModeAFPGetDefaultMode(void); const char *RunModeAFPGetDefaultMode(void);
int AFPRunModeIsIPS(); int AFPRunModeIsIPS();

@ -20,14 +20,9 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-erf-dag.h" #include "runmode-erf-dag.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "alert-fastlog.h" #include "detect-engine.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -76,7 +71,7 @@ void RunModeErfDagRegister(void)
return; return;
} }
int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx) int RunModeIdsErfDagSingle(void)
{ {
int ret; int ret;
@ -86,8 +81,7 @@ int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx)
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
ParseDagConfig,
DagConfigGetThreadCount, DagConfigGetThreadCount,
"ReceiveErfDag", "ReceiveErfDag",
"DecodeErfDag", "DecodeErfDag",
@ -103,7 +97,7 @@ int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx)
SCReturnInt(0); SCReturnInt(0);
} }
int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsErfDagAutoFp(void)
{ {
int ret; int ret;
@ -113,8 +107,7 @@ int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx)
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig,
ParseDagConfig,
DagConfigGetThreadCount, DagConfigGetThreadCount,
"ReceiveErfDag", "ReceiveErfDag",
"DecodeErfDag", "DecodeErfDag",
@ -130,7 +123,7 @@ int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx)
SCReturnInt(0); SCReturnInt(0);
} }
int RunModeIdsErfDagWorkers(DetectEngineCtx *de_ctx) int RunModeIdsErfDagWorkers(void)
{ {
int ret; int ret;
@ -140,8 +133,7 @@ int RunModeIdsErfDagWorkers(DetectEngineCtx *de_ctx)
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(ParseDagConfig,
ParseDagConfig,
DagConfigGetThreadCount, DagConfigGetThreadCount,
"ReceiveErfDag", "ReceiveErfDag",
"DecodeErfDag", "DecodeErfDag",

@ -23,9 +23,9 @@
#ifndef __RUNMODE_ERF_DAG_H__ #ifndef __RUNMODE_ERF_DAG_H__
#define __RUNMODE_ERF_DAG_H__ #define __RUNMODE_ERF_DAG_H__
int RunModeIdsErfDagAutoFp(DetectEngineCtx *); int RunModeIdsErfDagAutoFp(void);
int RunModeIdsErfDagSingle(DetectEngineCtx *); int RunModeIdsErfDagSingle(void);
int RunModeIdsErfDagWorkers(DetectEngineCtx *); int RunModeIdsErfDagWorkers(void);
void RunModeErfDagRegister(void); void RunModeErfDagRegister(void);
const char *RunModeErfDagGetDefaultMode(void); const char *RunModeErfDagGetDefaultMode(void);

@ -20,14 +20,9 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-erf-file.h" #include "runmode-erf-file.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "alert-fastlog.h" #include "detect-engine.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -59,7 +54,7 @@ void RunModeErfFileRegister(void)
return; return;
} }
int RunModeErfFileSingle(DetectEngineCtx *de_ctx) int RunModeErfFileSingle(void)
{ {
char *file; char *file;
@ -106,13 +101,13 @@ int RunModeErfFileSingle(DetectEngineCtx *de_ctx)
} }
TmSlotSetFuncAppend(tv, tm_module, NULL); TmSlotSetFuncAppend(tv, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName Detect failed\n"); printf("ERROR: TmModuleGetByName Detect failed\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv, tm_module, NULL);
} }
SetupOutputs(tv); SetupOutputs(tv);
@ -127,7 +122,7 @@ int RunModeErfFileSingle(DetectEngineCtx *de_ctx)
SCReturnInt(0); SCReturnInt(0);
} }
int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx) int RunModeErfFileAutoFp(void)
{ {
SCEnter(); SCEnter();
char tname[TM_THREAD_NAME_MAX]; char tname[TM_THREAD_NAME_MAX];
@ -235,13 +230,13 @@ int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx)
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName Detect failed\n"); printf("ERROR: TmModuleGetByName Detect failed\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
} }
if (threading_set_cpu_affinity) { if (threading_set_cpu_affinity) {

@ -23,8 +23,8 @@
#ifndef __RUNMODE_ERF_FILE_H__ #ifndef __RUNMODE_ERF_FILE_H__
#define __RUNMODE_ERF_FILE_H__ #define __RUNMODE_ERF_FILE_H__
int RunModeErfFileSingle(DetectEngineCtx *); int RunModeErfFileSingle(void);
int RunModeErfFileAutoFp(DetectEngineCtx *); int RunModeErfFileAutoFp(void);
void RunModeErfFileRegister(void); void RunModeErfFileRegister(void);
const char *RunModeErfFileGetDefaultMode(void); const char *RunModeErfFileGetDefaultMode(void);

@ -31,14 +31,7 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-ipfw.h" #include "runmode-ipfw.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -70,7 +63,7 @@ void RunModeIpsIPFWRegister(void)
return; return;
} }
int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx) int RunModeIpsIPFWAutoFp(void)
{ {
SCEnter(); SCEnter();
int ret = 0; int ret = 0;
@ -82,8 +75,7 @@ int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx)
LiveDeviceHasNoStats(); LiveDeviceHasNoStats();
ret = RunModeSetIPSAutoFp(de_ctx, ret = RunModeSetIPSAutoFp(IPFWGetThread,
IPFWGetThread,
"ReceiveIPFW", "ReceiveIPFW",
"VerdictIPFW", "VerdictIPFW",
"DecodeIPFW"); "DecodeIPFW");
@ -91,7 +83,7 @@ int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx)
return ret; return ret;
} }
int RunModeIpsIPFWWorker(DetectEngineCtx *de_ctx) int RunModeIpsIPFWWorker(void)
{ {
SCEnter(); SCEnter();
int ret = 0; int ret = 0;
@ -103,8 +95,7 @@ int RunModeIpsIPFWWorker(DetectEngineCtx *de_ctx)
LiveDeviceHasNoStats(); LiveDeviceHasNoStats();
ret = RunModeSetIPSWorker(de_ctx, ret = RunModeSetIPSWorker(IPFWGetThread,
IPFWGetThread,
"ReceiveIPFW", "ReceiveIPFW",
"VerdictIPFW", "VerdictIPFW",
"DecodeIPFW"); "DecodeIPFW");

@ -23,9 +23,8 @@
#ifndef __RUNMODE_IPFW_H__ #ifndef __RUNMODE_IPFW_H__
#define __RUNMODE_IPFW_H__ #define __RUNMODE_IPFW_H__
int RunModeIpsIPFWAuto(DetectEngineCtx *); int RunModeIpsIPFWAutoFp(void);
int RunModeIpsIPFWAutoFp(DetectEngineCtx *); int RunModeIpsIPFWWorker(void);
int RunModeIpsIPFWWorker(DetectEngineCtx *);
void RunModeIpsIPFWRegister(void); void RunModeIpsIPFWRegister(void);
const char *RunModeIpsIPFWGetDefaultMode(void); const char *RunModeIpsIPFWGetDefaultMode(void);

@ -25,14 +25,8 @@
#include "tm-threads.h" #include "tm-threads.h"
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
#include "util-cpu.h" #include "util-cpu.h"
@ -185,7 +179,7 @@ int NapatechGetThreadsCount(void *conf __attribute__((unused))) {
return 1; return 1;
} }
int NapatechInit(DetectEngineCtx *de_ctx, int runmode) static int NapatechInit(int runmode)
{ {
int ret; int ret;
char errbuf[100]; char errbuf[100];
@ -208,12 +202,12 @@ int NapatechInit(DetectEngineCtx *de_ctx, int runmode)
switch(runmode) { switch(runmode) {
case NT_RUNMODE_AUTOFP: case NT_RUNMODE_AUTOFP:
ret = RunModeSetLiveCaptureAutoFp(de_ctx, NapatechConfigParser, NapatechGetThreadsCount, ret = RunModeSetLiveCaptureAutoFp(NapatechConfigParser, NapatechGetThreadsCount,
"NapatechStream", "NapatechDecode", "NapatechStream", "NapatechDecode",
"RxNT", NULL); "RxNT", NULL);
break; break;
case NT_RUNMODE_WORKERS: case NT_RUNMODE_WORKERS:
ret = RunModeSetLiveCaptureWorkers(de_ctx, NapatechConfigParser, NapatechGetThreadsCount, ret = RunModeSetLiveCaptureWorkers(NapatechConfigParser, NapatechGetThreadsCount,
"NapatechStream", "NapatechDecode", "NapatechStream", "NapatechDecode",
"RxNT", NULL); "RxNT", NULL);
break; break;
@ -228,14 +222,14 @@ int NapatechInit(DetectEngineCtx *de_ctx, int runmode)
return 0; return 0;
} }
int RunModeNapatechAutoFp(DetectEngineCtx *de_ctx) int RunModeNapatechAutoFp(void)
{ {
return NapatechInit(de_ctx, NT_RUNMODE_AUTOFP); return NapatechInit(NT_RUNMODE_AUTOFP);
} }
int RunModeNapatechWorkers(DetectEngineCtx *de_ctx) int RunModeNapatechWorkers(void)
{ {
return NapatechInit(de_ctx, NT_RUNMODE_WORKERS); return NapatechInit(NT_RUNMODE_WORKERS);
} }
#endif #endif

@ -29,9 +29,8 @@
#include <nt.h> #include <nt.h>
#endif #endif
int RunModeNapatechAuto(DetectEngineCtx *); int RunModeNapatechAutoFp(void);
int RunModeNapatechAutoFp(DetectEngineCtx *); int RunModeNapatechWorkers(void);
int RunModeNapatechWorkers(DetectEngineCtx *);
void RunModeNapatechRegister(void); void RunModeNapatechRegister(void);
const char *RunModeNapatechGetDefaultMode(void); const char *RunModeNapatechGetDefaultMode(void);

@ -332,7 +332,7 @@ int NetmapRunModeIsIPS()
#endif // #ifdef HAVE_NETMAP #endif // #ifdef HAVE_NETMAP
int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsNetmapAutoFp(void)
{ {
SCEnter(); SCEnter();
@ -348,7 +348,7 @@ int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx)
SCLogDebug("live_dev %s", live_dev); SCLogDebug("live_dev %s", live_dev);
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(
ParseNetmapConfig, ParseNetmapConfig,
NetmapConfigGeThreadsCount, NetmapConfigGeThreadsCount,
"ReceiveNetmap", "ReceiveNetmap",
@ -368,7 +368,7 @@ int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx)
/** /**
* \brief Single thread version of the netmap processing. * \brief Single thread version of the netmap processing.
*/ */
int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx) int RunModeIdsNetmapSingle(void)
{ {
SCEnter(); SCEnter();
@ -381,7 +381,7 @@ int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx)
(void)ConfGet("netmap.live-interface", &live_dev); (void)ConfGet("netmap.live-interface", &live_dev);
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(
ParseNetmapConfig, ParseNetmapConfig,
NetmapConfigGeThreadsCount, NetmapConfigGeThreadsCount,
"ReceiveNetmap", "ReceiveNetmap",
@ -404,7 +404,7 @@ int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx)
* Start N threads with each thread doing all the work. * Start N threads with each thread doing all the work.
* *
*/ */
int RunModeIdsNetmapWorkers(DetectEngineCtx *de_ctx) int RunModeIdsNetmapWorkers(void)
{ {
SCEnter(); SCEnter();
@ -417,7 +417,7 @@ int RunModeIdsNetmapWorkers(DetectEngineCtx *de_ctx)
(void)ConfGet("netmap.live-interface", &live_dev); (void)ConfGet("netmap.live-interface", &live_dev);
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(
ParseNetmapConfig, ParseNetmapConfig,
NetmapConfigGeThreadsCount, NetmapConfigGeThreadsCount,
"ReceiveNetmap", "ReceiveNetmap",

@ -23,9 +23,9 @@
#ifndef __RUNMODE_NETMAP_H__ #ifndef __RUNMODE_NETMAP_H__
#define __RUNMODE_NETMAP_H__ #define __RUNMODE_NETMAP_H__
int RunModeIdsNetmapSingle(DetectEngineCtx *); int RunModeIdsNetmapSingle(void);
int RunModeIdsNetmapAutoFp(DetectEngineCtx *); int RunModeIdsNetmapAutoFp(void);
int RunModeIdsNetmapWorkers(DetectEngineCtx *); int RunModeIdsNetmapWorkers(void);
void RunModeIdsNetmapRegister(void); void RunModeIdsNetmapRegister(void);
const char *RunModeNetmapGetDefaultMode(void); const char *RunModeNetmapGetDefaultMode(void);
int NetmapRunModeIsIPS(); int NetmapRunModeIsIPS();

@ -169,7 +169,7 @@ int NflogConfigGeThreadsCount(void *conf)
return 1; return 1;
} }
int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsNflogAutoFp(void)
{ {
SCEnter(); SCEnter();
@ -180,8 +180,7 @@ int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx)
RunModeInitialize(); RunModeInitialize();
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(ParseNflogConfig,
ParseNflogConfig,
NflogConfigGeThreadsCount, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "ReceiveNFLOG",
"DecodeNFLOG", "DecodeNFLOG",
@ -198,7 +197,7 @@ int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx)
SCReturnInt(0); SCReturnInt(0);
} }
int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx) int RunModeIdsNflogSingle(void)
{ {
SCEnter(); SCEnter();
@ -209,8 +208,7 @@ int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx)
RunModeInitialize(); RunModeInitialize();
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(ParseNflogConfig,
ParseNflogConfig,
NflogConfigGeThreadsCount, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "ReceiveNFLOG",
"DecodeNFLOG", "DecodeNFLOG",
@ -227,7 +225,7 @@ int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx)
SCReturnInt(0); SCReturnInt(0);
} }
int RunModeIdsNflogWorkers(DetectEngineCtx *de_ctx) int RunModeIdsNflogWorkers(void)
{ {
SCEnter(); SCEnter();
@ -238,8 +236,7 @@ int RunModeIdsNflogWorkers(DetectEngineCtx *de_ctx)
RunModeInitialize(); RunModeInitialize();
TimeModeSetLive(); TimeModeSetLive();
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(ParseNflogConfig,
ParseNflogConfig,
NflogConfigGeThreadsCount, NflogConfigGeThreadsCount,
"ReceiveNFLOG", "ReceiveNFLOG",
"DecodeNFLOG", "DecodeNFLOG",

@ -23,9 +23,9 @@
#ifndef __RUNMODE_NFLOG_H__ #ifndef __RUNMODE_NFLOG_H__
#define __RUNMODE_NFLOG_H__ #define __RUNMODE_NFLOG_H__
int RunModeIdsNflogAutoFp(DetectEngineCtx *); int RunModeIdsNflogAutoFp(void);
int RunModeIdsNflogSingle(DetectEngineCtx *); int RunModeIdsNflogSingle(void);
int RunModeIdsNflogWorkers(DetectEngineCtx *); int RunModeIdsNflogWorkers(void);
void RunModeIdsNflogRegister(void); void RunModeIdsNflogRegister(void);
const char *RunModeIdsNflogGetDefaultMode(void); const char *RunModeIdsNflogGetDefaultMode(void);

@ -30,14 +30,7 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-nfq.h" #include "runmode-nfq.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -66,7 +59,7 @@ void RunModeIpsNFQRegister(void)
return; return;
} }
int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx) int RunModeIpsNFQAutoFp(void)
{ {
SCEnter(); SCEnter();
int ret = 0; int ret = 0;
@ -78,8 +71,7 @@ int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx)
LiveDeviceHasNoStats(); LiveDeviceHasNoStats();
ret = RunModeSetIPSAutoFp(de_ctx, ret = RunModeSetIPSAutoFp(NFQGetThread,
NFQGetThread,
"ReceiveNFQ", "ReceiveNFQ",
"VerdictNFQ", "VerdictNFQ",
"DecodeNFQ"); "DecodeNFQ");
@ -87,7 +79,7 @@ int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx)
return ret; return ret;
} }
int RunModeIpsNFQWorker(DetectEngineCtx *de_ctx) int RunModeIpsNFQWorker(void)
{ {
SCEnter(); SCEnter();
int ret = 0; int ret = 0;
@ -99,8 +91,7 @@ int RunModeIpsNFQWorker(DetectEngineCtx *de_ctx)
LiveDeviceHasNoStats(); LiveDeviceHasNoStats();
ret = RunModeSetIPSWorker(de_ctx, ret = RunModeSetIPSWorker(NFQGetThread,
NFQGetThread,
"ReceiveNFQ", "ReceiveNFQ",
"VerdictNFQ", "VerdictNFQ",
"DecodeNFQ"); "DecodeNFQ");

@ -23,9 +23,8 @@
#ifndef __RUNMODE_NFQ_H__ #ifndef __RUNMODE_NFQ_H__
#define __RUNMODE_NFQ_H__ #define __RUNMODE_NFQ_H__
int RunModeIpsNFQAuto(DetectEngineCtx *); int RunModeIpsNFQAutoFp(void);
int RunModeIpsNFQAutoFp(DetectEngineCtx *); int RunModeIpsNFQWorker(void);
int RunModeIpsNFQWorker(DetectEngineCtx *);
void RunModeIpsNFQRegister(void); void RunModeIpsNFQRegister(void);
const char *RunModeIpsNFQGetDefaultMode(void); const char *RunModeIpsNFQGetDefaultMode(void);

@ -20,17 +20,11 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-pcap-file.h" #include "runmode-pcap-file.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "detect-engine-mpm.h"
#include "detect-engine.h"
#include "source-pcap-file.h" #include "source-pcap-file.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
#include "util-cpu.h" #include "util-cpu.h"
@ -65,7 +59,7 @@ void RunModeFilePcapRegister(void)
/** /**
* \brief Single thread version of the Pcap file processing. * \brief Single thread version of the Pcap file processing.
*/ */
int RunModeFilePcapSingle(DetectEngineCtx *de_ctx) int RunModeFilePcapSingle(void)
{ {
char *file = NULL; char *file = NULL;
if (ConfGet("pcap-file.file", &file) == 0) { if (ConfGet("pcap-file.file", &file) == 0) {
@ -109,13 +103,13 @@ int RunModeFilePcapSingle(DetectEngineCtx *de_ctx)
} }
TmSlotSetFuncAppend(tv, tm_module, NULL); TmSlotSetFuncAppend(tv, tm_module, NULL);
if (de_ctx) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv, tm_module, NULL);
} }
SetupOutputs(tv); SetupOutputs(tv);
@ -142,12 +136,10 @@ int RunModeFilePcapSingle(DetectEngineCtx *de_ctx)
* By default the threads will use the first cpu available * By default the threads will use the first cpu available
* except the Detection threads if we have more than one cpu. * except the Detection threads if we have more than one cpu.
* *
* \param de_ctx Pointer to the Detection Engine
*
* \retval 0 If all goes well. (If any problem is detected the engine will * \retval 0 If all goes well. (If any problem is detected the engine will
* exit()). * exit()).
*/ */
int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx) int RunModeFilePcapAutoFp(void)
{ {
SCEnter(); SCEnter();
char tname[TM_THREAD_NAME_MAX]; char tname[TM_THREAD_NAME_MAX];
@ -253,13 +245,13 @@ int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx)
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
if (de_ctx) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
} }
char *thread_group_name = SCStrdup("Detect"); char *thread_group_name = SCStrdup("Detect");

@ -23,9 +23,8 @@
#ifndef __RUNMODE_PCAP_FILE_H__ #ifndef __RUNMODE_PCAP_FILE_H__
#define __RUNMODE_PCAP_FILE_H__ #define __RUNMODE_PCAP_FILE_H__
int RunModeFilePcapSingle(DetectEngineCtx *); int RunModeFilePcapSingle(void);
int RunModeFilePcapAuto(DetectEngineCtx *); int RunModeFilePcapAutoFp(void);
int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx);
void RunModeFilePcapRegister(void); void RunModeFilePcapRegister(void);
const char *RunModeFilePcapGetDefaultMode(void); const char *RunModeFilePcapGetDefaultMode(void);

@ -22,13 +22,6 @@
#include "runmode-pcap.h" #include "runmode-pcap.h"
#include "log-httplog.h" #include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "detect-engine-mpm.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -46,7 +39,7 @@ const char *RunModeIdsGetDefaultMode(void)
return default_mode; return default_mode;
} }
int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx); int RunModeIdsPcapWorkers(void);
void RunModeIdsPcapRegister(void) void RunModeIdsPcapRegister(void)
{ {
@ -234,7 +227,7 @@ int PcapConfigGeThreadsCount(void *conf)
/** /**
* \brief Single thread version of the Pcap live processing. * \brief Single thread version of the Pcap live processing.
*/ */
int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx) int RunModeIdsPcapSingle(void)
{ {
int ret; int ret;
char *live_dev = NULL; char *live_dev = NULL;
@ -246,8 +239,7 @@ int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx)
(void)ConfGet("pcap.single-pcap-dev", &live_dev); (void)ConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(ParsePcapConfig,
ParsePcapConfig,
PcapConfigGeThreadsCount, PcapConfigGeThreadsCount,
"ReceivePcap", "ReceivePcap",
"DecodePcap", "PcapLive", "DecodePcap", "PcapLive",
@ -274,12 +266,10 @@ int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx)
* By default the threads will use the first cpu available * By default the threads will use the first cpu available
* except the Detection threads if we have more than one cpu. * except the Detection threads if we have more than one cpu.
* *
* \param de_ctx Pointer to the Detection Engine
*
* \retval 0 If all goes well. (If any problem is detected the engine will * \retval 0 If all goes well. (If any problem is detected the engine will
* exit()). * exit()).
*/ */
int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsPcapAutoFp(void)
{ {
int ret; int ret;
char *live_dev = NULL; char *live_dev = NULL;
@ -290,8 +280,7 @@ int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx)
(void) ConfGet("pcap.single-pcap-dev", &live_dev); (void) ConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(ParsePcapConfig,
ParsePcapConfig,
PcapConfigGeThreadsCount, PcapConfigGeThreadsCount,
"ReceivePcap", "ReceivePcap",
"DecodePcap", "RxPcap", "DecodePcap", "RxPcap",
@ -312,7 +301,7 @@ int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx)
* Start N threads with each thread doing all the work. * Start N threads with each thread doing all the work.
* *
*/ */
int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx) int RunModeIdsPcapWorkers(void)
{ {
int ret; int ret;
char *live_dev = NULL; char *live_dev = NULL;
@ -323,8 +312,7 @@ int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx)
(void) ConfGet("pcap.single-pcap-dev", &live_dev); (void) ConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(ParsePcapConfig,
ParsePcapConfig,
PcapConfigGeThreadsCount, PcapConfigGeThreadsCount,
"ReceivePcap", "ReceivePcap",
"DecodePcap", "RxPcap", "DecodePcap", "RxPcap",

@ -23,9 +23,8 @@
#ifndef __RUNMODE_PCAP_H__ #ifndef __RUNMODE_PCAP_H__
#define __RUNMODE_PCAP_H__ #define __RUNMODE_PCAP_H__
int RunModeIdsPcapAuto(DetectEngineCtx *); int RunModeIdsPcapSingle(void);
int RunModeIdsPcapSingle(DetectEngineCtx *); int RunModeIdsPcapAutoFp(void);
int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx);
void RunModeIdsPcapRegister(void); void RunModeIdsPcapRegister(void);
const char *RunModeIdsGetDefaultMode(void); const char *RunModeIdsGetDefaultMode(void);

@ -21,14 +21,7 @@
#include "runmodes.h" #include "runmodes.h"
#include "runmode-pfring.h" #include "runmode-pfring.h"
#include "source-pfring.h" #include "source-pfring.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -418,7 +411,7 @@ static int GetDevAndParser(char **live_dev, ConfigIfaceParserFunc *parser)
} }
#endif #endif
int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx) int RunModeIdsPfringAutoFp(void)
{ {
SCEnter(); SCEnter();
@ -439,8 +432,7 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureAutoFp(de_ctx, ret = RunModeSetLiveCaptureAutoFp(tparser,
tparser,
PfringConfigGeThreadsCount, PfringConfigGeThreadsCount,
"ReceivePfring", "ReceivePfring",
"DecodePfring", "RxPFR", "DecodePfring", "RxPFR",
@ -456,7 +448,7 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx)
return 0; return 0;
} }
int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx) int RunModeIdsPfringSingle(void)
{ {
SCEnter(); SCEnter();
@ -477,8 +469,7 @@ int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureSingle(de_ctx, ret = RunModeSetLiveCaptureSingle(tparser,
tparser,
PfringConfigGeThreadsCount, PfringConfigGeThreadsCount,
"ReceivePfring", "ReceivePfring",
"DecodePfring", "RxPFR", "DecodePfring", "RxPFR",
@ -494,7 +485,7 @@ int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx)
return 0; return 0;
} }
int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx) int RunModeIdsPfringWorkers(void)
{ {
SCEnter(); SCEnter();
@ -515,8 +506,7 @@ int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = RunModeSetLiveCaptureWorkers(de_ctx, ret = RunModeSetLiveCaptureWorkers(tparser,
tparser,
PfringConfigGeThreadsCount, PfringConfigGeThreadsCount,
"ReceivePfring", "ReceivePfring",
"DecodePfring", "RxPFR", "DecodePfring", "RxPFR",

@ -25,10 +25,9 @@
#include "suricata-common.h" #include "suricata-common.h"
int RunModeIdsPfringAuto(DetectEngineCtx *); int RunModeIdsPfringAutoFp(void);
int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx); int RunModeIdsPfringSingle(void);
int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx); int RunModeIdsPfringWorkers(void);
int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx);
void RunModeIdsPfringRegister(void); void RunModeIdsPfringRegister(void);
const char *RunModeIdsPfringGetDefaultMode(void); const char *RunModeIdsPfringGetDefaultMode(void);

@ -29,14 +29,10 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-tile.h" #include "runmode-tile.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-mpipe.h" #include "source-mpipe.h"
#include "alert-fastlog.h" #include "detect-engine.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -140,13 +136,12 @@ void *ParseMpipeConfig(const char *iface)
/** /**
* \brief RunModeTileMpipeWorkers set up to process all modules in each thread. * \brief RunModeTileMpipeWorkers set up to process all modules in each thread.
* *
* \param de_ctx pointer to the Detection Engine
* \param iface pointer to the name of the interface from which we will * \param iface pointer to the name of the interface from which we will
* fetch the packets * fetch the packets
* \retval 0 if all goes well. (If any problem is detected the engine will * \retval 0 if all goes well. (If any problem is detected the engine will
* exit()) * exit())
*/ */
int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx) int RunModeTileMpipeWorkers(void)
{ {
SCEnter(); SCEnter();
char tname[TM_THREAD_NAME_MAX]; char tname[TM_THREAD_NAME_MAX];
@ -262,13 +257,13 @@ int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx)
} }
TmSlotSetFuncAppend(tv_worker, tm_module, NULL); TmSlotSetFuncAppend(tv_worker, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
printf("ERROR: TmModuleGetByName Detect failed\n"); printf("ERROR: TmModuleGetByName Detect failed\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv_worker, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv_worker, tm_module, NULL);
} }
tm_module = TmModuleGetByName("RespondReject"); tm_module = TmModuleGetByName("RespondReject");

@ -34,7 +34,7 @@ void RunModeTileMpipeRegister(void);
extern int tile_num_pipelines; extern int tile_num_pipelines;
int RunModeTileMpipeWorkers(DetectEngineCtx *); int RunModeTileMpipeWorkers(void);
void *ParseMpipeConfig(const char *iface); void *ParseMpipeConfig(const char *iface);

@ -20,15 +20,7 @@
#include "conf.h" #include "conf.h"
#include "runmodes.h" #include "runmodes.h"
#include "runmode-pcap-file.h" #include "runmode-pcap-file.h"
#include "log-httplog.h"
#include "output.h" #include "output.h"
#include "source-pfring.h"
#include "detect-engine-mpm.h"
#include "alert-fastlog.h"
#include "alert-prelude.h"
#include "alert-unified2-alert.h"
#include "alert-debuglog.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-time.h" #include "util-time.h"
@ -36,6 +28,8 @@
#include "util-affinity.h" #include "util-affinity.h"
#include "unix-manager.h" #include "unix-manager.h"
#include "detect-engine.h"
#include "flow-manager.h" #include "flow-manager.h"
#include "flow-timeout.h" #include "flow-timeout.h"
#include "stream-tcp.h" #include "stream-tcp.h"
@ -56,7 +50,6 @@ typedef struct PcapFiles_ {
} PcapFiles; } PcapFiles;
typedef struct PcapCommand_ { typedef struct PcapCommand_ {
DetectEngineCtx *de_ctx;
TAILQ_HEAD(, PcapFiles_) files; TAILQ_HEAD(, PcapFiles_) files;
int running; int running;
char *currentfile; char *currentfile;
@ -354,7 +347,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
StreamTcpInitConfig(STREAM_VERBOSE); StreamTcpInitConfig(STREAM_VERBOSE);
RunModeInitializeOutputs(); RunModeInitializeOutputs();
SCPerfInitCounterApi(); SCPerfInitCounterApi();
RunModeDispatch(RUNMODE_PCAP_FILE, NULL, this->de_ctx); RunModeDispatch(RUNMODE_PCAP_FILE, NULL);
FlowManagerThreadSpawn(); FlowManagerThreadSpawn();
FlowRecyclerThreadSpawn(); FlowRecyclerThreadSpawn();
SCPerfSpawnThreads(); SCPerfSpawnThreads();
@ -396,7 +389,7 @@ void UnixSocketPcapFile(TmEcode tm)
/** /**
* \brief Single thread version of the Pcap file processing. * \brief Single thread version of the Pcap file processing.
*/ */
int RunModeUnixSocketSingle(DetectEngineCtx *de_ctx) int RunModeUnixSocketSingle(void)
{ {
#ifdef BUILD_UNIX_SOCKET #ifdef BUILD_UNIX_SOCKET
PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand)); PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand));
@ -405,12 +398,11 @@ int RunModeUnixSocketSingle(DetectEngineCtx *de_ctx)
SCLogError(SC_ERR_MEM_ALLOC, "Can not allocate pcap command"); SCLogError(SC_ERR_MEM_ALLOC, "Can not allocate pcap command");
return 1; return 1;
} }
pcapcmd->de_ctx = de_ctx;
TAILQ_INIT(&pcapcmd->files); TAILQ_INIT(&pcapcmd->files);
pcapcmd->running = 0; pcapcmd->running = 0;
pcapcmd->currentfile = NULL; pcapcmd->currentfile = NULL;
UnixManagerThreadSpawn(de_ctx, 1); UnixManagerThreadSpawn(1);
unix_socket_mode_is_running = 1; unix_socket_mode_is_running = 1;

@ -23,7 +23,7 @@
#ifndef __RUNMODE_UNIX_SOCKET_H__ #ifndef __RUNMODE_UNIX_SOCKET_H__
#define __RUNMODE_UNIX_SOCKET_H__ #define __RUNMODE_UNIX_SOCKET_H__
int RunModeUnixSocketSingle(DetectEngineCtx *); int RunModeUnixSocketSingle(void);
void RunModeUnixSocketRegister(void); void RunModeUnixSocketRegister(void);
const char *RunModeUnixSocketGetDefaultMode(void); const char *RunModeUnixSocketGetDefaultMode(void);

@ -60,7 +60,7 @@ typedef struct RunMode_ {
const char *name; const char *name;
const char *description; const char *description;
/* runmode function */ /* runmode function */
int (*RunModeFunc)(DetectEngineCtx *); int (*RunModeFunc)(void);
} RunMode; } RunMode;
typedef struct RunModes_ { typedef struct RunModes_ {
@ -154,7 +154,6 @@ static const char *RunModeTranslateModeToName(int runmode)
* *
* \param runmode The runmode type. * \param runmode The runmode type.
* \param runmode_customd_id The runmode custom id. * \param runmode_customd_id The runmode custom id.
* \param de_ctx Detection Engine Context.
*/ */
static RunMode *RunModeGetCustomMode(int runmode, const char *custom_mode) static RunMode *RunModeGetCustomMode(int runmode, const char *custom_mode)
{ {
@ -264,9 +263,8 @@ void RunModeListRunmodes(void)
} }
/** /**
* \param de_ctx Detection engine ctx. Can be NULL is detect is disabled.
*/ */
void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_ctx) void RunModeDispatch(int runmode, const char *custom_mode)
{ {
char *local_custom_mode = NULL; char *local_custom_mode = NULL;
@ -365,7 +363,7 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
mode->RunModeFunc(de_ctx); mode->RunModeFunc();
if (local_custom_mode != NULL) if (local_custom_mode != NULL)
SCFree(local_custom_mode); SCFree(local_custom_mode);
@ -383,7 +381,7 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c
*/ */
void RunModeRegisterNewRunMode(int runmode, const char *name, void RunModeRegisterNewRunMode(int runmode, const char *name,
const char *description, const char *description,
int (*RunModeFunc)(DetectEngineCtx *)) int (*RunModeFunc)(void))
{ {
void *ptmp; void *ptmp;
if (RunModeGetCustomMode(runmode, name) != NULL) { if (RunModeGetCustomMode(runmode, name) != NULL) {

@ -64,10 +64,10 @@ char *RunmodeGetActive(void);
const char *RunModeGetMainMode(void); const char *RunModeGetMainMode(void);
void RunModeListRunmodes(void); void RunModeListRunmodes(void);
void RunModeDispatch(int, const char *, DetectEngineCtx *); void RunModeDispatch(int, const char *);
void RunModeRegisterRunModes(void); void RunModeRegisterRunModes(void);
void RunModeRegisterNewRunMode(int, const char *, const char *, void RunModeRegisterNewRunMode(int, const char *, const char *,
int (*RunModeFunc)(DetectEngineCtx *)); int (*RunModeFunc)(void));
void RunModeInitialize(void); void RunModeInitialize(void);
void RunModeInitializeOutputs(void); void RunModeInitializeOutputs(void);
void SetupOutputs(ThreadVars *); void SetupOutputs(ThreadVars *);

@ -2359,7 +2359,7 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
RunModeDispatch(suri.run_mode, suri.runmode_custom_mode, de_ctx); RunModeDispatch(suri.run_mode, suri.runmode_custom_mode);
/* In Unix socket runmode, Flow manager is started on demand */ /* In Unix socket runmode, Flow manager is started on demand */
if (suri.run_mode != RUNMODE_UNIX_SOCKET) { if (suri.run_mode != RUNMODE_UNIX_SOCKET) {
@ -2368,7 +2368,7 @@ int main(int argc, char **argv)
if (ConfGetBool("unix-command.enabled", &unix_socket) != 1) if (ConfGetBool("unix-command.enabled", &unix_socket) != 1)
unix_socket = 0; unix_socket = 0;
if (unix_socket == 1) { if (unix_socket == 1) {
UnixManagerThreadSpawn(de_ctx, 0); UnixManagerThreadSpawn(0);
#ifdef BUILD_UNIX_SOCKET #ifdef BUILD_UNIX_SOCKET
UnixManagerRegisterCommand("iface-stat", LiveDeviceIfaceStat, NULL, UnixManagerRegisterCommand("iface-stat", LiveDeviceIfaceStat, NULL,
UNIX_CMD_TAKE_ARGS); UNIX_CMD_TAKE_ARGS);

@ -903,10 +903,9 @@ void *UnixManagerThread(void *td)
/** \brief Spawn the unix socket manager thread /** \brief Spawn the unix socket manager thread
* *
* \param de_ctx context for detection engine
* \param mode if set to 1, init failure cause suricata exit * \param mode if set to 1, init failure cause suricata exit
* */ * */
void UnixManagerThreadSpawn(DetectEngineCtx *de_ctx, int mode) void UnixManagerThreadSpawn(int mode)
{ {
ThreadVars *tv_unixmgr = NULL; ThreadVars *tv_unixmgr = NULL;

@ -33,7 +33,7 @@
SCCtrlCondT unix_manager_ctrl_cond; SCCtrlCondT unix_manager_ctrl_cond;
SCCtrlMutex unix_manager_ctrl_mutex; SCCtrlMutex unix_manager_ctrl_mutex;
void UnixManagerThreadSpawn(DetectEngineCtx *de_ctx, int mode); void UnixManagerThreadSpawn(int mode);
void UnixSocketKillSocketThread(void); void UnixSocketKillSocketThread(void);

@ -32,6 +32,8 @@
#include "runmode-af-packet.h" #include "runmode-af-packet.h"
#include "log-httplog.h" #include "log-httplog.h"
#include "output.h" #include "output.h"
#include "detect-engine.h"
#include "detect-engine-mpm.h" #include "detect-engine-mpm.h"
#include "alert-fastlog.h" #include "alert-fastlog.h"
@ -97,10 +99,8 @@ char *RunmodeAutoFpCreatePickupQueuesString(int n)
} }
/** /**
* \param de_ctx detection engine, can be NULL
*/ */
int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser,
ConfigIfaceParserFunc ConfigParser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
@ -275,14 +275,13 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppendDelayed(tv_detect_ncpu, tm_module, TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
(void *)de_ctx, de_ctx->delayed_detect);
} }
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET); TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
@ -315,10 +314,8 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx,
} }
/** /**
* \param de_ctx detection engine, can be NULL
*/ */
static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx, static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc ModThreadsCount,
ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
const char *live_dev, void *aconf, const char *live_dev, void *aconf,
@ -382,14 +379,13 @@ static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx,
} }
TmSlotSetFuncAppend(tv, tm_module, NULL); TmSlotSetFuncAppend(tv, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppendDelayed(tv, tm_module, TmSlotSetFuncAppend(tv, tm_module, NULL);
(void *)de_ctx, de_ctx->delayed_detect);
} }
tm_module = TmModuleGetByName("RespondReject"); tm_module = TmModuleGetByName("RespondReject");
@ -412,8 +408,7 @@ static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx,
return 0; return 0;
} }
int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser,
ConfigIfaceParserFunc ConfigParser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
@ -436,8 +431,7 @@ int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx,
live_dev_c = LiveGetDeviceName(ldev); live_dev_c = LiveGetDeviceName(ldev);
aconf = ConfigParser(live_dev_c); aconf = ConfigParser(live_dev_c);
} }
RunModeSetLiveCaptureWorkersForDevice(de_ctx, RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount,
ModThreadsCount,
recv_mod_name, recv_mod_name,
decode_mod_name, decode_mod_name,
thread_name, thread_name,
@ -449,8 +443,7 @@ int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx,
return 0; return 0;
} }
int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser,
ConfigIfaceParserFunc ConfigParser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
@ -473,7 +466,7 @@ int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx,
/* \todo Set threads number in config to 1 */ /* \todo Set threads number in config to 1 */
} }
return RunModeSetLiveCaptureWorkersForDevice(de_ctx, return RunModeSetLiveCaptureWorkersForDevice(
ModThreadsCount, ModThreadsCount,
recv_mod_name, recv_mod_name,
decode_mod_name, decode_mod_name,
@ -485,10 +478,8 @@ int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx,
/** /**
* \param de_ctx detection engine, can be NULL
*/ */
int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx, int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser,
ConfigIPSParserFunc ConfigParser,
char *recv_mod_name, char *recv_mod_name,
char *verdict_mod_name, char *verdict_mod_name,
char *decode_mod_name) char *decode_mod_name)
@ -592,14 +583,13 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
} }
TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppendDelayed(tv_detect_ncpu, tm_module, TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
(void *)de_ctx, de_ctx->delayed_detect);
} }
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET); TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
@ -665,10 +655,8 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
} }
/** /**
* \param de_ctx detection engine, can be NULL
*/ */
int RunModeSetIPSWorker(DetectEngineCtx *de_ctx, int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser,
ConfigIPSParserFunc ConfigParser,
char *recv_mod_name, char *recv_mod_name,
char *verdict_mod_name, char *verdict_mod_name,
char *decode_mod_name) char *decode_mod_name)
@ -725,14 +713,13 @@ int RunModeSetIPSWorker(DetectEngineCtx *de_ctx,
} }
TmSlotSetFuncAppend(tv, tm_module, NULL); TmSlotSetFuncAppend(tv, tm_module, NULL);
if (de_ctx != NULL) { if (DetectEngineEnabled()) {
tm_module = TmModuleGetByName("Detect"); tm_module = TmModuleGetByName("Detect");
if (tm_module == NULL) { if (tm_module == NULL) {
SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppendDelayed(tv, tm_module, TmSlotSetFuncAppend(tv, tm_module, NULL);
(void *)de_ctx, de_ctx->delayed_detect);
} }
tm_module = TmModuleGetByName(verdict_mod_name); tm_module = TmModuleGetByName(verdict_mod_name);
@ -741,7 +728,7 @@ int RunModeSetIPSWorker(DetectEngineCtx *de_ctx,
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); TmSlotSetFuncAppend(tv, tm_module, NULL);
tm_module = TmModuleGetByName("RespondReject"); tm_module = TmModuleGetByName("RespondReject");
if (tm_module == NULL) { if (tm_module == NULL) {

@ -30,48 +30,36 @@ typedef void *(*ConfigIfaceParserFunc) (const char *);
typedef void *(*ConfigIPSParserFunc) (int); typedef void *(*ConfigIPSParserFunc) (int);
typedef int (*ConfigIfaceThreadsCountFunc) (void *); typedef int (*ConfigIfaceThreadsCountFunc) (void *);
int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureAuto(ConfigIfaceParserFunc configparser,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
const char *live_dev); const char *live_dev);
int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc configparser,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
const char *live_dev); const char *live_dev);
int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc configparser,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
const char *live_dev); const char *live_dev);
int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc configparser,
ConfigIfaceParserFunc configparser,
ConfigIfaceThreadsCountFunc ModThreadsCount, ConfigIfaceThreadsCountFunc ModThreadsCount,
char *recv_mod_name, char *recv_mod_name,
char *decode_mod_name, char *thread_name, char *decode_mod_name, char *thread_name,
const char *live_dev); const char *live_dev);
int RunModeSetIPSAuto(DetectEngineCtx *de_ctx, int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser,
ConfigIPSParserFunc ConfigParser,
char *recv_mod_name,
char *verdict_mod_name,
char *decode_mod_name);
int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
ConfigIPSParserFunc ConfigParser,
char *recv_mod_name, char *recv_mod_name,
char *verdict_mod_name, char *verdict_mod_name,
char *decode_mod_name); char *decode_mod_name);
int RunModeSetIPSWorker(DetectEngineCtx *de_ctx, int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser,
ConfigIPSParserFunc ConfigParser,
char *recv_mod_name, char *recv_mod_name,
char *verdict_mod_name, char *verdict_mod_name,
char *decode_mod_name); char *decode_mod_name);

Loading…
Cancel
Save