diff --git a/src/detect-engine.c b/src/detect-engine.c index 7e0f57138a..8abf373de2 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -1796,6 +1796,22 @@ void *DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int 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) { DetectEngineMasterCtx *master = &g_master_de_ctx; diff --git a/src/detect-engine.h b/src/detect-engine.h index 14c6e6f18f..1b6d553984 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -74,6 +74,7 @@ void DetectEnginePruneFreeList(void); int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx); void DetectEngineDeReference(DetectEngineCtx **de_ctx); int DetectEngineReload(void); +int DetectEngineEnabled(void); /** * \brief Registers an app inspection engine. diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 29817d22be..3a20cd09b3 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -433,7 +433,7 @@ int AFPRunModeIsIPS() return has_ips; } -int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsAFPAutoFp(void) { SCEnter(); @@ -455,8 +455,7 @@ int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureAutoFp(de_ctx, - ParseAFPConfig, + ret = RunModeSetLiveCaptureAutoFp(ParseAFPConfig, AFPConfigGeThreadsCount, "ReceiveAFP", "DecodeAFP", "RxAFP", @@ -481,14 +480,12 @@ int RunModeIdsAFPAutoFp(DetectEngineCtx *de_ctx) /** * \brief Single thread version of the AF_PACKET processing. */ -int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx) +int RunModeIdsAFPSingle(void) { + SCEnter(); #ifdef HAVE_AF_PACKET int ret; char *live_dev = NULL; -#endif - SCEnter(); -#ifdef HAVE_AF_PACKET RunModeInitialize(); TimeModeSetLive(); @@ -500,8 +497,7 @@ int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureSingle(de_ctx, - ParseAFPConfig, + ret = RunModeSetLiveCaptureSingle(ParseAFPConfig, AFPConfigGeThreadsCount, "ReceiveAFP", "DecodeAFP", "AFPacket", @@ -529,14 +525,12 @@ int RunModeIdsAFPSingle(DetectEngineCtx *de_ctx) * Start N threads with each thread doing all the work. * */ -int RunModeIdsAFPWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsAFPWorkers(void) { + SCEnter(); #ifdef HAVE_AF_PACKET int ret; char *live_dev = NULL; -#endif - SCEnter(); -#ifdef HAVE_AF_PACKET RunModeInitialize(); TimeModeSetLive(); @@ -548,8 +542,7 @@ int RunModeIdsAFPWorkers(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureWorkers(de_ctx, - ParseAFPConfig, + ret = RunModeSetLiveCaptureWorkers(ParseAFPConfig, AFPConfigGeThreadsCount, "ReceiveAFP", "DecodeAFP", "AFPacket", diff --git a/src/runmode-af-packet.h b/src/runmode-af-packet.h index 0e1c764dd7..79fe436a69 100644 --- a/src/runmode-af-packet.h +++ b/src/runmode-af-packet.h @@ -23,10 +23,9 @@ #ifndef __RUNMODE_AF_PACKET_H__ #define __RUNMODE_AF_PACKET_H__ -int RunModeIdsAFPAuto(DetectEngineCtx *); -int RunModeIdsAFPSingle(DetectEngineCtx *); -int RunModeIdsAFPAutoFp(DetectEngineCtx *); -int RunModeIdsAFPWorkers(DetectEngineCtx *); +int RunModeIdsAFPSingle(void); +int RunModeIdsAFPAutoFp(void); +int RunModeIdsAFPWorkers(void); void RunModeIdsAFPRegister(void); const char *RunModeAFPGetDefaultMode(void); int AFPRunModeIsIPS(); diff --git a/src/runmode-erf-dag.c b/src/runmode-erf-dag.c index 4fa9a6fccb..5653b9ecfb 100644 --- a/src/runmode-erf-dag.c +++ b/src/runmode-erf-dag.c @@ -20,14 +20,9 @@ #include "conf.h" #include "runmodes.h" #include "runmode-erf-dag.h" -#include "log-httplog.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 "detect-engine.h" #include "util-debug.h" #include "util-time.h" @@ -76,7 +71,7 @@ void RunModeErfDagRegister(void) return; } -int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx) +int RunModeIdsErfDagSingle(void) { int ret; @@ -86,8 +81,7 @@ int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx) TimeModeSetLive(); - ret = RunModeSetLiveCaptureSingle(de_ctx, - ParseDagConfig, + ret = RunModeSetLiveCaptureSingle(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag", "DecodeErfDag", @@ -103,7 +97,7 @@ int RunModeIdsErfDagSingle(DetectEngineCtx *de_ctx) SCReturnInt(0); } -int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsErfDagAutoFp(void) { int ret; @@ -113,8 +107,7 @@ int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx) TimeModeSetLive(); - ret = RunModeSetLiveCaptureAutoFp(de_ctx, - ParseDagConfig, + ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag", "DecodeErfDag", @@ -130,7 +123,7 @@ int RunModeIdsErfDagAutoFp(DetectEngineCtx *de_ctx) SCReturnInt(0); } -int RunModeIdsErfDagWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsErfDagWorkers(void) { int ret; @@ -140,8 +133,7 @@ int RunModeIdsErfDagWorkers(DetectEngineCtx *de_ctx) TimeModeSetLive(); - ret = RunModeSetLiveCaptureWorkers(de_ctx, - ParseDagConfig, + ret = RunModeSetLiveCaptureWorkers(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag", "DecodeErfDag", diff --git a/src/runmode-erf-dag.h b/src/runmode-erf-dag.h index 2a4b20ea52..c4b2a59cee 100644 --- a/src/runmode-erf-dag.h +++ b/src/runmode-erf-dag.h @@ -23,9 +23,9 @@ #ifndef __RUNMODE_ERF_DAG_H__ #define __RUNMODE_ERF_DAG_H__ -int RunModeIdsErfDagAutoFp(DetectEngineCtx *); -int RunModeIdsErfDagSingle(DetectEngineCtx *); -int RunModeIdsErfDagWorkers(DetectEngineCtx *); +int RunModeIdsErfDagAutoFp(void); +int RunModeIdsErfDagSingle(void); +int RunModeIdsErfDagWorkers(void); void RunModeErfDagRegister(void); const char *RunModeErfDagGetDefaultMode(void); diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index 50f47669d0..ef7d2e09ec 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -20,14 +20,9 @@ #include "conf.h" #include "runmodes.h" #include "runmode-erf-file.h" -#include "log-httplog.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 "detect-engine.h" #include "util-debug.h" #include "util-time.h" @@ -59,7 +54,7 @@ void RunModeErfFileRegister(void) return; } -int RunModeErfFileSingle(DetectEngineCtx *de_ctx) +int RunModeErfFileSingle(void) { char *file; @@ -106,13 +101,13 @@ int RunModeErfFileSingle(DetectEngineCtx *de_ctx) } TmSlotSetFuncAppend(tv, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { printf("ERROR: TmModuleGetByName Detect failed\n"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); + TmSlotSetFuncAppend(tv, tm_module, NULL); } SetupOutputs(tv); @@ -127,7 +122,7 @@ int RunModeErfFileSingle(DetectEngineCtx *de_ctx) SCReturnInt(0); } -int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx) +int RunModeErfFileAutoFp(void) { SCEnter(); char tname[TM_THREAD_NAME_MAX]; @@ -235,13 +230,13 @@ int RunModeErfFileAutoFp(DetectEngineCtx *de_ctx) } TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { printf("ERROR: TmModuleGetByName Detect failed\n"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, (void *)de_ctx); + TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); } if (threading_set_cpu_affinity) { diff --git a/src/runmode-erf-file.h b/src/runmode-erf-file.h index 0612e9fa43..54a8ba8972 100644 --- a/src/runmode-erf-file.h +++ b/src/runmode-erf-file.h @@ -23,8 +23,8 @@ #ifndef __RUNMODE_ERF_FILE_H__ #define __RUNMODE_ERF_FILE_H__ -int RunModeErfFileSingle(DetectEngineCtx *); -int RunModeErfFileAutoFp(DetectEngineCtx *); +int RunModeErfFileSingle(void); +int RunModeErfFileAutoFp(void); void RunModeErfFileRegister(void); const char *RunModeErfFileGetDefaultMode(void); diff --git a/src/runmode-ipfw.c b/src/runmode-ipfw.c index 03bb02e55f..841692e116 100644 --- a/src/runmode-ipfw.c +++ b/src/runmode-ipfw.c @@ -31,14 +31,7 @@ #include "conf.h" #include "runmodes.h" #include "runmode-ipfw.h" -#include "log-httplog.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-time.h" @@ -70,7 +63,7 @@ void RunModeIpsIPFWRegister(void) return; } -int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx) +int RunModeIpsIPFWAutoFp(void) { SCEnter(); int ret = 0; @@ -82,8 +75,7 @@ int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx) LiveDeviceHasNoStats(); - ret = RunModeSetIPSAutoFp(de_ctx, - IPFWGetThread, + ret = RunModeSetIPSAutoFp(IPFWGetThread, "ReceiveIPFW", "VerdictIPFW", "DecodeIPFW"); @@ -91,7 +83,7 @@ int RunModeIpsIPFWAutoFp(DetectEngineCtx *de_ctx) return ret; } -int RunModeIpsIPFWWorker(DetectEngineCtx *de_ctx) +int RunModeIpsIPFWWorker(void) { SCEnter(); int ret = 0; @@ -103,8 +95,7 @@ int RunModeIpsIPFWWorker(DetectEngineCtx *de_ctx) LiveDeviceHasNoStats(); - ret = RunModeSetIPSWorker(de_ctx, - IPFWGetThread, + ret = RunModeSetIPSWorker(IPFWGetThread, "ReceiveIPFW", "VerdictIPFW", "DecodeIPFW"); diff --git a/src/runmode-ipfw.h b/src/runmode-ipfw.h index 92fae6b8ad..5c8345b174 100644 --- a/src/runmode-ipfw.h +++ b/src/runmode-ipfw.h @@ -23,9 +23,8 @@ #ifndef __RUNMODE_IPFW_H__ #define __RUNMODE_IPFW_H__ -int RunModeIpsIPFWAuto(DetectEngineCtx *); -int RunModeIpsIPFWAutoFp(DetectEngineCtx *); -int RunModeIpsIPFWWorker(DetectEngineCtx *); +int RunModeIpsIPFWAutoFp(void); +int RunModeIpsIPFWWorker(void); void RunModeIpsIPFWRegister(void); const char *RunModeIpsIPFWGetDefaultMode(void); diff --git a/src/runmode-napatech.c b/src/runmode-napatech.c index 0c9be2a233..7c161ad864 100644 --- a/src/runmode-napatech.c +++ b/src/runmode-napatech.c @@ -25,14 +25,8 @@ #include "tm-threads.h" #include "conf.h" #include "runmodes.h" -#include "log-httplog.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-time.h" #include "util-cpu.h" @@ -185,7 +179,7 @@ int NapatechGetThreadsCount(void *conf __attribute__((unused))) { return 1; } -int NapatechInit(DetectEngineCtx *de_ctx, int runmode) +static int NapatechInit(int runmode) { int ret; char errbuf[100]; @@ -208,12 +202,12 @@ int NapatechInit(DetectEngineCtx *de_ctx, int runmode) switch(runmode) { case NT_RUNMODE_AUTOFP: - ret = RunModeSetLiveCaptureAutoFp(de_ctx, NapatechConfigParser, NapatechGetThreadsCount, + ret = RunModeSetLiveCaptureAutoFp(NapatechConfigParser, NapatechGetThreadsCount, "NapatechStream", "NapatechDecode", "RxNT", NULL); break; case NT_RUNMODE_WORKERS: - ret = RunModeSetLiveCaptureWorkers(de_ctx, NapatechConfigParser, NapatechGetThreadsCount, + ret = RunModeSetLiveCaptureWorkers(NapatechConfigParser, NapatechGetThreadsCount, "NapatechStream", "NapatechDecode", "RxNT", NULL); break; @@ -228,14 +222,14 @@ int NapatechInit(DetectEngineCtx *de_ctx, int runmode) 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 diff --git a/src/runmode-napatech.h b/src/runmode-napatech.h index ffb1d42efe..d10b406376 100644 --- a/src/runmode-napatech.h +++ b/src/runmode-napatech.h @@ -29,9 +29,8 @@ #include #endif -int RunModeNapatechAuto(DetectEngineCtx *); -int RunModeNapatechAutoFp(DetectEngineCtx *); -int RunModeNapatechWorkers(DetectEngineCtx *); +int RunModeNapatechAutoFp(void); +int RunModeNapatechWorkers(void); void RunModeNapatechRegister(void); const char *RunModeNapatechGetDefaultMode(void); diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index f5172aba1a..3639bef92e 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -332,7 +332,7 @@ int NetmapRunModeIsIPS() #endif // #ifdef HAVE_NETMAP -int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsNetmapAutoFp(void) { SCEnter(); @@ -348,7 +348,7 @@ int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx) SCLogDebug("live_dev %s", live_dev); - ret = RunModeSetLiveCaptureAutoFp(de_ctx, + ret = RunModeSetLiveCaptureAutoFp( ParseNetmapConfig, NetmapConfigGeThreadsCount, "ReceiveNetmap", @@ -368,7 +368,7 @@ int RunModeIdsNetmapAutoFp(DetectEngineCtx *de_ctx) /** * \brief Single thread version of the netmap processing. */ -int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx) +int RunModeIdsNetmapSingle(void) { SCEnter(); @@ -381,7 +381,7 @@ int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx) (void)ConfGet("netmap.live-interface", &live_dev); - ret = RunModeSetLiveCaptureSingle(de_ctx, + ret = RunModeSetLiveCaptureSingle( ParseNetmapConfig, NetmapConfigGeThreadsCount, "ReceiveNetmap", @@ -404,7 +404,7 @@ int RunModeIdsNetmapSingle(DetectEngineCtx *de_ctx) * Start N threads with each thread doing all the work. * */ -int RunModeIdsNetmapWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsNetmapWorkers(void) { SCEnter(); @@ -417,7 +417,7 @@ int RunModeIdsNetmapWorkers(DetectEngineCtx *de_ctx) (void)ConfGet("netmap.live-interface", &live_dev); - ret = RunModeSetLiveCaptureWorkers(de_ctx, + ret = RunModeSetLiveCaptureWorkers( ParseNetmapConfig, NetmapConfigGeThreadsCount, "ReceiveNetmap", diff --git a/src/runmode-netmap.h b/src/runmode-netmap.h index 392e9781ca..988c349ab5 100644 --- a/src/runmode-netmap.h +++ b/src/runmode-netmap.h @@ -23,9 +23,9 @@ #ifndef __RUNMODE_NETMAP_H__ #define __RUNMODE_NETMAP_H__ -int RunModeIdsNetmapSingle(DetectEngineCtx *); -int RunModeIdsNetmapAutoFp(DetectEngineCtx *); -int RunModeIdsNetmapWorkers(DetectEngineCtx *); +int RunModeIdsNetmapSingle(void); +int RunModeIdsNetmapAutoFp(void); +int RunModeIdsNetmapWorkers(void); void RunModeIdsNetmapRegister(void); const char *RunModeNetmapGetDefaultMode(void); int NetmapRunModeIsIPS(); diff --git a/src/runmode-nflog.c b/src/runmode-nflog.c index 17725622b5..9c08f9aef0 100644 --- a/src/runmode-nflog.c +++ b/src/runmode-nflog.c @@ -169,7 +169,7 @@ int NflogConfigGeThreadsCount(void *conf) return 1; } -int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsNflogAutoFp(void) { SCEnter(); @@ -180,8 +180,7 @@ int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx) RunModeInitialize(); TimeModeSetLive(); - ret = RunModeSetLiveCaptureAutoFp(de_ctx, - ParseNflogConfig, + ret = RunModeSetLiveCaptureAutoFp(ParseNflogConfig, NflogConfigGeThreadsCount, "ReceiveNFLOG", "DecodeNFLOG", @@ -198,7 +197,7 @@ int RunModeIdsNflogAutoFp(DetectEngineCtx *de_ctx) SCReturnInt(0); } -int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx) +int RunModeIdsNflogSingle(void) { SCEnter(); @@ -209,8 +208,7 @@ int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx) RunModeInitialize(); TimeModeSetLive(); - ret = RunModeSetLiveCaptureSingle(de_ctx, - ParseNflogConfig, + ret = RunModeSetLiveCaptureSingle(ParseNflogConfig, NflogConfigGeThreadsCount, "ReceiveNFLOG", "DecodeNFLOG", @@ -227,7 +225,7 @@ int RunModeIdsNflogSingle(DetectEngineCtx *de_ctx) SCReturnInt(0); } -int RunModeIdsNflogWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsNflogWorkers(void) { SCEnter(); @@ -238,8 +236,7 @@ int RunModeIdsNflogWorkers(DetectEngineCtx *de_ctx) RunModeInitialize(); TimeModeSetLive(); - ret = RunModeSetLiveCaptureWorkers(de_ctx, - ParseNflogConfig, + ret = RunModeSetLiveCaptureWorkers(ParseNflogConfig, NflogConfigGeThreadsCount, "ReceiveNFLOG", "DecodeNFLOG", diff --git a/src/runmode-nflog.h b/src/runmode-nflog.h index 2dd4e7a635..9c70c69397 100644 --- a/src/runmode-nflog.h +++ b/src/runmode-nflog.h @@ -23,9 +23,9 @@ #ifndef __RUNMODE_NFLOG_H__ #define __RUNMODE_NFLOG_H__ -int RunModeIdsNflogAutoFp(DetectEngineCtx *); -int RunModeIdsNflogSingle(DetectEngineCtx *); -int RunModeIdsNflogWorkers(DetectEngineCtx *); +int RunModeIdsNflogAutoFp(void); +int RunModeIdsNflogSingle(void); +int RunModeIdsNflogWorkers(void); void RunModeIdsNflogRegister(void); const char *RunModeIdsNflogGetDefaultMode(void); diff --git a/src/runmode-nfq.c b/src/runmode-nfq.c index edf7bc7e55..67fa5bcbe9 100644 --- a/src/runmode-nfq.c +++ b/src/runmode-nfq.c @@ -30,14 +30,7 @@ #include "conf.h" #include "runmodes.h" #include "runmode-nfq.h" -#include "log-httplog.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-time.h" @@ -66,7 +59,7 @@ void RunModeIpsNFQRegister(void) return; } -int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx) +int RunModeIpsNFQAutoFp(void) { SCEnter(); int ret = 0; @@ -78,8 +71,7 @@ int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx) LiveDeviceHasNoStats(); - ret = RunModeSetIPSAutoFp(de_ctx, - NFQGetThread, + ret = RunModeSetIPSAutoFp(NFQGetThread, "ReceiveNFQ", "VerdictNFQ", "DecodeNFQ"); @@ -87,7 +79,7 @@ int RunModeIpsNFQAutoFp(DetectEngineCtx *de_ctx) return ret; } -int RunModeIpsNFQWorker(DetectEngineCtx *de_ctx) +int RunModeIpsNFQWorker(void) { SCEnter(); int ret = 0; @@ -99,8 +91,7 @@ int RunModeIpsNFQWorker(DetectEngineCtx *de_ctx) LiveDeviceHasNoStats(); - ret = RunModeSetIPSWorker(de_ctx, - NFQGetThread, + ret = RunModeSetIPSWorker(NFQGetThread, "ReceiveNFQ", "VerdictNFQ", "DecodeNFQ"); diff --git a/src/runmode-nfq.h b/src/runmode-nfq.h index 677fff682b..6ad8801466 100644 --- a/src/runmode-nfq.h +++ b/src/runmode-nfq.h @@ -23,9 +23,8 @@ #ifndef __RUNMODE_NFQ_H__ #define __RUNMODE_NFQ_H__ -int RunModeIpsNFQAuto(DetectEngineCtx *); -int RunModeIpsNFQAutoFp(DetectEngineCtx *); -int RunModeIpsNFQWorker(DetectEngineCtx *); +int RunModeIpsNFQAutoFp(void); +int RunModeIpsNFQWorker(void); void RunModeIpsNFQRegister(void); const char *RunModeIpsNFQGetDefaultMode(void); diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index f5a3c196b4..d337cb9711 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -20,17 +20,11 @@ #include "conf.h" #include "runmodes.h" #include "runmode-pcap-file.h" -#include "log-httplog.h" #include "output.h" -#include "detect-engine-mpm.h" +#include "detect-engine.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-time.h" #include "util-cpu.h" @@ -65,7 +59,7 @@ void RunModeFilePcapRegister(void) /** * \brief Single thread version of the Pcap file processing. */ -int RunModeFilePcapSingle(DetectEngineCtx *de_ctx) +int RunModeFilePcapSingle(void) { char *file = NULL; if (ConfGet("pcap-file.file", &file) == 0) { @@ -109,13 +103,13 @@ int RunModeFilePcapSingle(DetectEngineCtx *de_ctx) } TmSlotSetFuncAppend(tv, tm_module, NULL); - if (de_ctx) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); + TmSlotSetFuncAppend(tv, tm_module, NULL); } SetupOutputs(tv); @@ -142,12 +136,10 @@ int RunModeFilePcapSingle(DetectEngineCtx *de_ctx) * By default the threads will use the first cpu available * 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 * exit()). */ -int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx) +int RunModeFilePcapAutoFp(void) { SCEnter(); char tname[TM_THREAD_NAME_MAX]; @@ -253,13 +245,13 @@ int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx) } TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); - if (de_ctx) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); 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"); diff --git a/src/runmode-pcap-file.h b/src/runmode-pcap-file.h index 5dbd3a9c26..52cab02228 100644 --- a/src/runmode-pcap-file.h +++ b/src/runmode-pcap-file.h @@ -23,9 +23,8 @@ #ifndef __RUNMODE_PCAP_FILE_H__ #define __RUNMODE_PCAP_FILE_H__ -int RunModeFilePcapSingle(DetectEngineCtx *); -int RunModeFilePcapAuto(DetectEngineCtx *); -int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx); +int RunModeFilePcapSingle(void); +int RunModeFilePcapAutoFp(void); void RunModeFilePcapRegister(void); const char *RunModeFilePcapGetDefaultMode(void); diff --git a/src/runmode-pcap.c b/src/runmode-pcap.c index 17d9e692ee..6561c1c8c4 100644 --- a/src/runmode-pcap.c +++ b/src/runmode-pcap.c @@ -22,13 +22,6 @@ #include "runmode-pcap.h" #include "log-httplog.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-time.h" @@ -46,7 +39,7 @@ const char *RunModeIdsGetDefaultMode(void) return default_mode; } -int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx); +int RunModeIdsPcapWorkers(void); void RunModeIdsPcapRegister(void) { @@ -234,7 +227,7 @@ int PcapConfigGeThreadsCount(void *conf) /** * \brief Single thread version of the Pcap live processing. */ -int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx) +int RunModeIdsPcapSingle(void) { int ret; char *live_dev = NULL; @@ -246,8 +239,7 @@ int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx) (void)ConfGet("pcap.single-pcap-dev", &live_dev); - ret = RunModeSetLiveCaptureSingle(de_ctx, - ParsePcapConfig, + ret = RunModeSetLiveCaptureSingle(ParsePcapConfig, PcapConfigGeThreadsCount, "ReceivePcap", "DecodePcap", "PcapLive", @@ -274,12 +266,10 @@ int RunModeIdsPcapSingle(DetectEngineCtx *de_ctx) * By default the threads will use the first cpu available * 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 * exit()). */ -int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsPcapAutoFp(void) { int ret; char *live_dev = NULL; @@ -290,8 +280,7 @@ int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx) (void) ConfGet("pcap.single-pcap-dev", &live_dev); - ret = RunModeSetLiveCaptureAutoFp(de_ctx, - ParsePcapConfig, + ret = RunModeSetLiveCaptureAutoFp(ParsePcapConfig, PcapConfigGeThreadsCount, "ReceivePcap", "DecodePcap", "RxPcap", @@ -312,7 +301,7 @@ int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx) * Start N threads with each thread doing all the work. * */ -int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsPcapWorkers(void) { int ret; char *live_dev = NULL; @@ -323,8 +312,7 @@ int RunModeIdsPcapWorkers(DetectEngineCtx *de_ctx) (void) ConfGet("pcap.single-pcap-dev", &live_dev); - ret = RunModeSetLiveCaptureWorkers(de_ctx, - ParsePcapConfig, + ret = RunModeSetLiveCaptureWorkers(ParsePcapConfig, PcapConfigGeThreadsCount, "ReceivePcap", "DecodePcap", "RxPcap", diff --git a/src/runmode-pcap.h b/src/runmode-pcap.h index 9e88c6d90f..b68c6ddcfc 100644 --- a/src/runmode-pcap.h +++ b/src/runmode-pcap.h @@ -23,9 +23,8 @@ #ifndef __RUNMODE_PCAP_H__ #define __RUNMODE_PCAP_H__ -int RunModeIdsPcapAuto(DetectEngineCtx *); -int RunModeIdsPcapSingle(DetectEngineCtx *); -int RunModeIdsPcapAutoFp(DetectEngineCtx *de_ctx); +int RunModeIdsPcapSingle(void); +int RunModeIdsPcapAutoFp(void); void RunModeIdsPcapRegister(void); const char *RunModeIdsGetDefaultMode(void); diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index 21c22fc2e6..8c9a06fde4 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -21,14 +21,7 @@ #include "runmodes.h" #include "runmode-pfring.h" #include "source-pfring.h" -#include "log-httplog.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-time.h" @@ -418,7 +411,7 @@ static int GetDevAndParser(char **live_dev, ConfigIfaceParserFunc *parser) } #endif -int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx) +int RunModeIdsPfringAutoFp(void) { SCEnter(); @@ -439,8 +432,7 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureAutoFp(de_ctx, - tparser, + ret = RunModeSetLiveCaptureAutoFp(tparser, PfringConfigGeThreadsCount, "ReceivePfring", "DecodePfring", "RxPFR", @@ -456,7 +448,7 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx) return 0; } -int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx) +int RunModeIdsPfringSingle(void) { SCEnter(); @@ -477,8 +469,7 @@ int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureSingle(de_ctx, - tparser, + ret = RunModeSetLiveCaptureSingle(tparser, PfringConfigGeThreadsCount, "ReceivePfring", "DecodePfring", "RxPFR", @@ -494,7 +485,7 @@ int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx) return 0; } -int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx) +int RunModeIdsPfringWorkers(void) { SCEnter(); @@ -515,8 +506,7 @@ int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } - ret = RunModeSetLiveCaptureWorkers(de_ctx, - tparser, + ret = RunModeSetLiveCaptureWorkers(tparser, PfringConfigGeThreadsCount, "ReceivePfring", "DecodePfring", "RxPFR", diff --git a/src/runmode-pfring.h b/src/runmode-pfring.h index 9ba7d5c93f..316c82f74a 100644 --- a/src/runmode-pfring.h +++ b/src/runmode-pfring.h @@ -25,10 +25,9 @@ #include "suricata-common.h" -int RunModeIdsPfringAuto(DetectEngineCtx *); -int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx); -int RunModeIdsPfringSingle(DetectEngineCtx *de_ctx); -int RunModeIdsPfringWorkers(DetectEngineCtx *de_ctx); +int RunModeIdsPfringAutoFp(void); +int RunModeIdsPfringSingle(void); +int RunModeIdsPfringWorkers(void); void RunModeIdsPfringRegister(void); const char *RunModeIdsPfringGetDefaultMode(void); diff --git a/src/runmode-tile.c b/src/runmode-tile.c index 1839234ddd..38f5afecc0 100644 --- a/src/runmode-tile.c +++ b/src/runmode-tile.c @@ -29,14 +29,10 @@ #include "conf.h" #include "runmodes.h" #include "runmode-tile.h" -#include "log-httplog.h" #include "output.h" #include "source-mpipe.h" -#include "alert-fastlog.h" -#include "alert-prelude.h" -#include "alert-unified2-alert.h" -#include "alert-debuglog.h" +#include "detect-engine.h" #include "util-debug.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. * - * \param de_ctx pointer to the Detection Engine * \param iface pointer to the name of the interface from which we will * fetch the packets * \retval 0 if all goes well. (If any problem is detected the engine will * exit()) */ -int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx) +int RunModeTileMpipeWorkers(void) { SCEnter(); char tname[TM_THREAD_NAME_MAX]; @@ -262,13 +257,13 @@ int RunModeTileMpipeWorkers(DetectEngineCtx *de_ctx) } TmSlotSetFuncAppend(tv_worker, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { printf("ERROR: TmModuleGetByName Detect failed\n"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppend(tv_worker, tm_module, (void *)de_ctx); + TmSlotSetFuncAppend(tv_worker, tm_module, NULL); } tm_module = TmModuleGetByName("RespondReject"); diff --git a/src/runmode-tile.h b/src/runmode-tile.h index 8e0af793a9..ec6c9e5042 100644 --- a/src/runmode-tile.h +++ b/src/runmode-tile.h @@ -34,7 +34,7 @@ void RunModeTileMpipeRegister(void); extern int tile_num_pipelines; -int RunModeTileMpipeWorkers(DetectEngineCtx *); +int RunModeTileMpipeWorkers(void); void *ParseMpipeConfig(const char *iface); diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index bff022d6eb..1ee5ce0815 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -20,15 +20,7 @@ #include "conf.h" #include "runmodes.h" #include "runmode-pcap-file.h" -#include "log-httplog.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-time.h" @@ -36,6 +28,8 @@ #include "util-affinity.h" #include "unix-manager.h" +#include "detect-engine.h" + #include "flow-manager.h" #include "flow-timeout.h" #include "stream-tcp.h" @@ -56,7 +50,6 @@ typedef struct PcapFiles_ { } PcapFiles; typedef struct PcapCommand_ { - DetectEngineCtx *de_ctx; TAILQ_HEAD(, PcapFiles_) files; int running; char *currentfile; @@ -354,7 +347,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data) StreamTcpInitConfig(STREAM_VERBOSE); RunModeInitializeOutputs(); SCPerfInitCounterApi(); - RunModeDispatch(RUNMODE_PCAP_FILE, NULL, this->de_ctx); + RunModeDispatch(RUNMODE_PCAP_FILE, NULL); FlowManagerThreadSpawn(); FlowRecyclerThreadSpawn(); SCPerfSpawnThreads(); @@ -396,7 +389,7 @@ void UnixSocketPcapFile(TmEcode tm) /** * \brief Single thread version of the Pcap file processing. */ -int RunModeUnixSocketSingle(DetectEngineCtx *de_ctx) +int RunModeUnixSocketSingle(void) { #ifdef BUILD_UNIX_SOCKET PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand)); @@ -405,12 +398,11 @@ int RunModeUnixSocketSingle(DetectEngineCtx *de_ctx) SCLogError(SC_ERR_MEM_ALLOC, "Can not allocate pcap command"); return 1; } - pcapcmd->de_ctx = de_ctx; TAILQ_INIT(&pcapcmd->files); pcapcmd->running = 0; pcapcmd->currentfile = NULL; - UnixManagerThreadSpawn(de_ctx, 1); + UnixManagerThreadSpawn(1); unix_socket_mode_is_running = 1; diff --git a/src/runmode-unix-socket.h b/src/runmode-unix-socket.h index c2674f2d4a..578469ec24 100644 --- a/src/runmode-unix-socket.h +++ b/src/runmode-unix-socket.h @@ -23,7 +23,7 @@ #ifndef __RUNMODE_UNIX_SOCKET_H__ #define __RUNMODE_UNIX_SOCKET_H__ -int RunModeUnixSocketSingle(DetectEngineCtx *); +int RunModeUnixSocketSingle(void); void RunModeUnixSocketRegister(void); const char *RunModeUnixSocketGetDefaultMode(void); diff --git a/src/runmodes.c b/src/runmodes.c index 4ce80d7a93..5fd9b91458 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -60,7 +60,7 @@ typedef struct RunMode_ { const char *name; const char *description; /* runmode function */ - int (*RunModeFunc)(DetectEngineCtx *); + int (*RunModeFunc)(void); } RunMode; typedef struct RunModes_ { @@ -154,7 +154,6 @@ static const char *RunModeTranslateModeToName(int runmode) * * \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) { @@ -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; @@ -365,7 +363,7 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c exit(EXIT_FAILURE); } - mode->RunModeFunc(de_ctx); + mode->RunModeFunc(); if (local_custom_mode != NULL) 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, const char *description, - int (*RunModeFunc)(DetectEngineCtx *)) + int (*RunModeFunc)(void)) { void *ptmp; if (RunModeGetCustomMode(runmode, name) != NULL) { diff --git a/src/runmodes.h b/src/runmodes.h index 80ad652b34..bd8d03263e 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -64,10 +64,10 @@ char *RunmodeGetActive(void); const char *RunModeGetMainMode(void); void RunModeListRunmodes(void); -void RunModeDispatch(int, const char *, DetectEngineCtx *); +void RunModeDispatch(int, const char *); void RunModeRegisterRunModes(void); void RunModeRegisterNewRunMode(int, const char *, const char *, - int (*RunModeFunc)(DetectEngineCtx *)); + int (*RunModeFunc)(void)); void RunModeInitialize(void); void RunModeInitializeOutputs(void); void SetupOutputs(ThreadVars *); diff --git a/src/suricata.c b/src/suricata.c index 96a61b8190..ff9ff74c7a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2359,7 +2359,7 @@ int main(int argc, char **argv) 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 */ 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) unix_socket = 0; if (unix_socket == 1) { - UnixManagerThreadSpawn(de_ctx, 0); + UnixManagerThreadSpawn(0); #ifdef BUILD_UNIX_SOCKET UnixManagerRegisterCommand("iface-stat", LiveDeviceIfaceStat, NULL, UNIX_CMD_TAKE_ARGS); diff --git a/src/unix-manager.c b/src/unix-manager.c index c3fbfc3d89..e9538a194b 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -903,10 +903,9 @@ void *UnixManagerThread(void *td) /** \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 * */ -void UnixManagerThreadSpawn(DetectEngineCtx *de_ctx, int mode) +void UnixManagerThreadSpawn(int mode) { ThreadVars *tv_unixmgr = NULL; diff --git a/src/unix-manager.h b/src/unix-manager.h index 937737ef11..2bbdee11ed 100644 --- a/src/unix-manager.h +++ b/src/unix-manager.h @@ -33,7 +33,7 @@ SCCtrlCondT unix_manager_ctrl_cond; SCCtrlMutex unix_manager_ctrl_mutex; -void UnixManagerThreadSpawn(DetectEngineCtx *de_ctx, int mode); +void UnixManagerThreadSpawn(int mode); void UnixSocketKillSocketThread(void); diff --git a/src/util-runmodes.c b/src/util-runmodes.c index 26ef2b76c0..5e89f7b28d 100644 --- a/src/util-runmodes.c +++ b/src/util-runmodes.c @@ -32,6 +32,8 @@ #include "runmode-af-packet.h" #include "log-httplog.h" #include "output.h" + +#include "detect-engine.h" #include "detect-engine-mpm.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, - ConfigIfaceParserFunc ConfigParser, +int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, @@ -275,14 +275,13 @@ int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx, } TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppendDelayed(tv_detect_ncpu, tm_module, - (void *)de_ctx, de_ctx->delayed_detect); + TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); } 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, - ConfigIfaceThreadsCountFunc ModThreadsCount, +static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev, void *aconf, @@ -382,14 +379,13 @@ static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx, } TmSlotSetFuncAppend(tv, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppendDelayed(tv, tm_module, - (void *)de_ctx, de_ctx->delayed_detect); + TmSlotSetFuncAppend(tv, tm_module, NULL); } tm_module = TmModuleGetByName("RespondReject"); @@ -412,8 +408,7 @@ static int RunModeSetLiveCaptureWorkersForDevice(DetectEngineCtx *de_ctx, return 0; } -int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc ConfigParser, +int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, @@ -436,8 +431,7 @@ int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, live_dev_c = LiveGetDeviceName(ldev); aconf = ConfigParser(live_dev_c); } - RunModeSetLiveCaptureWorkersForDevice(de_ctx, - ModThreadsCount, + RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount, recv_mod_name, decode_mod_name, thread_name, @@ -449,8 +443,7 @@ int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, return 0; } -int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc ConfigParser, +int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_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 */ } - return RunModeSetLiveCaptureWorkersForDevice(de_ctx, + return RunModeSetLiveCaptureWorkersForDevice( ModThreadsCount, recv_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, - ConfigIPSParserFunc ConfigParser, +int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser, char *recv_mod_name, char *verdict_mod_name, char *decode_mod_name) @@ -592,14 +583,13 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx, } TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppendDelayed(tv_detect_ncpu, tm_module, - (void *)de_ctx, de_ctx->delayed_detect); + TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); } 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, - ConfigIPSParserFunc ConfigParser, +int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser, char *recv_mod_name, char *verdict_mod_name, char *decode_mod_name) @@ -725,14 +713,13 @@ int RunModeSetIPSWorker(DetectEngineCtx *de_ctx, } TmSlotSetFuncAppend(tv, tm_module, NULL); - if (de_ctx != NULL) { + if (DetectEngineEnabled()) { tm_module = TmModuleGetByName("Detect"); if (tm_module == NULL) { SCLogError(SC_ERR_RUNMODE, "TmModuleGetByName Detect failed"); exit(EXIT_FAILURE); } - TmSlotSetFuncAppendDelayed(tv, tm_module, - (void *)de_ctx, de_ctx->delayed_detect); + TmSlotSetFuncAppend(tv, tm_module, NULL); } tm_module = TmModuleGetByName(verdict_mod_name); @@ -741,7 +728,7 @@ int RunModeSetIPSWorker(DetectEngineCtx *de_ctx, exit(EXIT_FAILURE); } - TmSlotSetFuncAppend(tv, tm_module, (void *)de_ctx); + TmSlotSetFuncAppend(tv, tm_module, NULL); tm_module = TmModuleGetByName("RespondReject"); if (tm_module == NULL) { diff --git a/src/util-runmodes.h b/src/util-runmodes.h index c1852ccd8a..607895a4ab 100644 --- a/src/util-runmodes.h +++ b/src/util-runmodes.h @@ -30,48 +30,36 @@ typedef void *(*ConfigIfaceParserFunc) (const char *); typedef void *(*ConfigIPSParserFunc) (int); typedef int (*ConfigIfaceThreadsCountFunc) (void *); -int RunModeSetLiveCaptureAuto(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc configparser, +int RunModeSetLiveCaptureAuto(ConfigIfaceParserFunc configparser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev); -int RunModeSetLiveCaptureAutoFp(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc configparser, +int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc configparser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev); -int RunModeSetLiveCaptureSingle(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc configparser, +int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc configparser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev); -int RunModeSetLiveCaptureWorkers(DetectEngineCtx *de_ctx, - ConfigIfaceParserFunc configparser, +int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc configparser, ConfigIfaceThreadsCountFunc ModThreadsCount, char *recv_mod_name, char *decode_mod_name, char *thread_name, const char *live_dev); -int RunModeSetIPSAuto(DetectEngineCtx *de_ctx, - ConfigIPSParserFunc ConfigParser, - char *recv_mod_name, - char *verdict_mod_name, - char *decode_mod_name); - -int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx, - ConfigIPSParserFunc ConfigParser, +int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser, char *recv_mod_name, char *verdict_mod_name, char *decode_mod_name); -int RunModeSetIPSWorker(DetectEngineCtx *de_ctx, - ConfigIPSParserFunc ConfigParser, +int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser, char *recv_mod_name, char *verdict_mod_name, char *decode_mod_name);