From cfb605aa8a8328a29abef91a69b466a4fe4ad3a1 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 16 Sep 2009 11:23:53 +0200 Subject: [PATCH] Put the precooked runmodes in a separate file. --- src/Makefile.am | 1 + src/detect-engine.h | 2 + src/eidps.c | 1159 +----------------------------------------- src/runmodes.c | 1166 +++++++++++++++++++++++++++++++++++++++++++ src/runmodes.h | 14 + src/tm-threads.h | 2 + 6 files changed, 1189 insertions(+), 1155 deletions(-) create mode 100644 src/runmodes.c create mode 100644 src/runmodes.h diff --git a/src/Makefile.am b/src/Makefile.am index f7de22519f..a79e32d370 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ bin_PROGRAMS = eidps eidps_SOURCES = eidps.c eidps.h \ +runmodes.c runmodes.h \ packet-queue.c packet-queue.h \ threads.c threads.h \ source-nfq.c source-nfq.h \ diff --git a/src/detect-engine.h b/src/detect-engine.h index 2b01f945ea..3f15dfcb6b 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -1,6 +1,8 @@ #ifndef __DETECT_ENGINE_H__ #define __DETECT_ENGINE_H__ +#include "detect.h" + /* prototypes */ DetectEngineCtx *DetectEngineCtxInit(void); void DetectEngineCtxFree(DetectEngineCtx *); diff --git a/src/eidps.c b/src/eidps.c index da4a56663a..501df48fce 100644 --- a/src/eidps.c +++ b/src/eidps.c @@ -75,6 +75,8 @@ #include "conf.h" #include "conf-yaml-loader.h" +#include "runmodes.h" + /* * we put this here, because we only use it here in main. */ @@ -225,1159 +227,6 @@ void EngineKill(void) { sigflags |= EIDPS_KILL; } -int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) { - TimeModeSetLive(); - - /* create the threads */ - ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); - if (tv_receivepcap == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - TmModule *tm_module = TmModuleGetByName("ReceivePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); - - if (TmThreadSpawn(tv_receivepcap) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); - if (tv_decode1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Decode1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("DecodePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodePcap failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_decode1,tm_module,NULL); - - if (TmThreadSpawn(tv_decode1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); - if (tv_stream1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream1,tm_module,NULL); - - if (TmThreadSpawn(tv_stream1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); - if (tv_detect1 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","verdict-queue","simple","1slot"); - if (tv_detect2 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect2) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","verdict-queue","simple","alert-queue1","simple","1slot"); - if (tv_rreject == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_rreject,tm_module,NULL); - - if (TmThreadSpawn(tv_rreject) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); - if (tv_alert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - if (TmThreadSpawn(tv_alert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); - if (tv_unified == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); - - if (TmThreadSpawn(tv_unified) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); - if (tv_debugalert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); - - if (TmThreadSpawn(tv_debugalert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - return 0; -} - -/** \brief Live pcap mode with 4 stream tracking and reassembly threads, testing the flow queuehandler */ -int RunModeIdsPcap2(DetectEngineCtx *de_ctx, char *iface) { - TimeModeSetLive(); - - /* create the threads */ - ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); - if (tv_receivepcap == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - TmModule *tm_module = TmModuleGetByName("ReceivePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); - - if (TmThreadSpawn(tv_receivepcap) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1,decode-queue2,decode-queue3,decode-queue4","flow","1slot"); - if (tv_decode1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Decode1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("DecodePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodePcap failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_decode1,tm_module,NULL); - - if (TmThreadSpawn(tv_decode1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); - if (tv_stream1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream1,tm_module,NULL); - - if (TmThreadSpawn(tv_stream1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream2 = TmThreadCreatePacketHandler("Stream2","decode-queue2","simple","stream-queue1","simple","1slot"); - if (tv_stream2 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream2\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream2,tm_module,NULL); - - if (TmThreadSpawn(tv_stream2) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream3 = TmThreadCreatePacketHandler("Stream3","decode-queue3","simple","stream-queue2","simple","1slot"); - if (tv_stream3 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream3,tm_module,NULL); - - if (TmThreadSpawn(tv_stream3) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream4 = TmThreadCreatePacketHandler("Stream4","decode-queue4","simple","stream-queue2","simple","1slot"); - if (tv_stream4 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream4,tm_module,NULL); - - if (TmThreadSpawn(tv_stream4) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); - if (tv_detect1 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue2","simple","verdict-queue","simple","1slot"); - if (tv_detect2 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect2) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","verdict-queue","simple","alert-queue1","simple","1slot"); - if (tv_rreject == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_rreject,tm_module,NULL); - - if (TmThreadSpawn(tv_rreject) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); - if (tv_alert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - if (TmThreadSpawn(tv_alert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); - if (tv_unified == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); - - if (TmThreadSpawn(tv_unified) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); - if (tv_debugalert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); - - if (TmThreadSpawn(tv_debugalert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - return 0; -} - -/** \brief Live pcap mode with 4 stream tracking and reassembly threads, testing the flow queuehandler */ -int RunModeIdsPcap3(DetectEngineCtx *de_ctx, char *iface) { - TimeModeSetLive(); - - /* create the threads */ - ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); - if (tv_receivepcap == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - TmModule *tm_module = TmModuleGetByName("ReceivePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); - - if (TmThreadSpawn(tv_receivepcap) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1,decode-queue2,decode-queue3,decode-queue4","flow","1slot"); - if (tv_decode1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Decode1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("DecodePcap"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodePcap failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_decode1,tm_module,NULL); - - if (TmThreadSpawn(tv_decode1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv; - tv = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","packetpool","packetpool","varslot"); - if (tv == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); - - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - TmThreadSetCPUAffinity(tv, 0); - - if (TmThreadSpawn(tv) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - tv = TmThreadCreatePacketHandler("Stream2","decode-queue2","simple","packetpool","packetpool","varslot"); - if (tv == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); - - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - TmThreadSetCPUAffinity(tv, 0); - - if (TmThreadSpawn(tv) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - tv = TmThreadCreatePacketHandler("Stream3","decode-queue3","simple","packetpool","packetpool","varslot"); - if (tv == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); - - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - TmThreadSetCPUAffinity(tv, 1); - - if (TmThreadSpawn(tv) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - tv = TmThreadCreatePacketHandler("Stream4","decode-queue4","simple","packetpool","packetpool","varslot"); - if (tv == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); - - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - TmThreadSetCPUAffinity(tv, 1); - - if (TmThreadSpawn(tv) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - return 0; -} - -int RunModeIpsNFQ(DetectEngineCtx *de_ctx) { - TimeModeSetLive(); - - /* create the threads */ - ThreadVars *tv_receivenfq = TmThreadCreatePacketHandler("ReceiveNFQ","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); - if (tv_receivenfq == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - TmModule *tm_module = TmModuleGetByName("ReceiveNFQ"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceiveNFQ\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_receivenfq,tm_module,NULL); - - if (TmThreadSpawn(tv_receivenfq) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); - if (tv_decode1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Decode1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("DecodeNFQ"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodeNFQ failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_decode1,tm_module,NULL); - - if (TmThreadSpawn(tv_decode1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); - if (tv_stream1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream1,tm_module,NULL); - - if (TmThreadSpawn(tv_stream1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); - if (tv_detect1 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","verdict-queue","simple","1slot"); - if (tv_detect2 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect2) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_verdict = TmThreadCreatePacketHandler("Verdict","verdict-queue","simple","respond-queue","simple","1slot"); - if (tv_verdict == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("VerdictNFQ"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName VerdictNFQ failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_verdict,tm_module,NULL); - - if (TmThreadSpawn(tv_verdict) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","respond-queue","simple","alert-queue1","simple","1slot"); - if (tv_rreject == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("RespondReject"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for RespondReject failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_rreject,tm_module,NULL); - - if (TmThreadSpawn(tv_rreject) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); - if (tv_alert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); - - if (TmThreadSpawn(tv_alert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); - if (tv_unified == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); - - if (TmThreadSpawn(tv_unified) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); - if (tv_debugalert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); - - if (TmThreadSpawn(tv_debugalert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - return 0; -} - -int RunModeFilePcap(DetectEngineCtx *de_ctx, char *file) { - printf("RunModeFilePcap: file %s\n", file); - TimeModeSetOffline(); - - /* create the threads */ - ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcapFile","packetpool","packetpool","pickup-queue","simple","1slot"); - if (tv_receivepcap == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - TmModule *tm_module = TmModuleGetByName("ReceivePcapFile"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_receivepcap,tm_module,file); - - if (TmThreadSpawn(tv_receivepcap) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); - if (tv_decode1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Decode1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("DecodePcapFile"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodePcap failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_decode1,tm_module,NULL); - - if (TmThreadSpawn(tv_decode1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } -//#if 0 - ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); - if (tv_stream1 == NULL) { - printf("ERROR: TmThreadsCreate failed for Stream1\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_stream1,tm_module,NULL); - - if (TmThreadSpawn(tv_stream1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","alert-queue1","simple","1slot"); -//#endif - //ThreadVars *tv_detect1 = TmThreadCreate("Detect1","decode-queue1","simple","alert-queue1","simple","1slot"); - if (tv_detect1 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect1) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","alert-queue1","simple","1slot"); - if (tv_detect2 == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); - - if (TmThreadSpawn(tv_detect2) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); - if (tv_alert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_alert,tm_module,NULL); - - if (TmThreadSpawn(tv_alert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); - if (tv_unified == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); - - if (TmThreadSpawn(tv_unified) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); - if (tv_debugalert == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); - - if (TmThreadSpawn(tv_debugalert) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - return 0; -} - -/** - * \brief Single thread version of the Pcap file processing. - */ -int RunModeFilePcap2(DetectEngineCtx *de_ctx, char *file) { - printf("RunModeFilePcap2: file %s\n", file); - TimeModeSetOffline(); - - /* create the threads */ - ThreadVars *tv = TmThreadCreatePacketHandler("PcapFile","packetpool","packetpool","packetpool","packetpool","varslot"); - if (tv == NULL) { - printf("ERROR: TmThreadsCreate failed\n"); - exit(EXIT_FAILURE); - } - - TmModule *tm_module = TmModuleGetByName("ReceivePcapFile"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,file); - - tm_module = TmModuleGetByName("DecodePcapFile"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName DecodePcap failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("StreamTcp"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName StreamTcp failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("Detect"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName Detect failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); - - tm_module = TmModuleGetByName("AlertFastlog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("LogHttplog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedLog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertUnifiedAlert"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - tm_module = TmModuleGetByName("AlertDebuglog"); - if (tm_module == NULL) { - printf("ERROR: TmModuleGetByName failed\n"); - exit(EXIT_FAILURE); - } - TmVarSlotSetFuncAppend(tv,tm_module,NULL); - - if (TmThreadSpawn(tv) != 0) { - printf("ERROR: TmThreadSpawn failed\n"); - exit(EXIT_FAILURE); - } - - return 0; -} - void usage(const char *progname) { printf("USAGE: %s\n\n", progname); @@ -1598,8 +447,8 @@ int main(int argc, char **argv) gettimeofday(&start_time, NULL); if (mode == MODE_PCAP_DEV) { - RunModeIdsPcap3(de_ctx, pcap_dev); - //RunModeIdsPcap2(de_ctx, pcap_dev); + //RunModeIdsPcap3(de_ctx, pcap_dev); + RunModeIdsPcap2(de_ctx, pcap_dev); //RunModeIdsPcap(de_ctx, pcap_dev); } else if (mode == MODE_PCAP_FILE) { diff --git a/src/runmodes.c b/src/runmodes.c new file mode 100644 index 0000000000..977d329b57 --- /dev/null +++ b/src/runmodes.c @@ -0,0 +1,1166 @@ +/* Copyright (c) 2009 Open Information Security Foundation */ + +/** \file + * \author Victor Julien + * + * Pre-cooked threading runmodes. + */ + +#include "eidps-common.h" +#include "detect-engine.h" +#include "tm-threads.h" +#include "util-time.h" + +int RunModeIdsPcap(DetectEngineCtx *de_ctx, char *iface) { + TimeModeSetLive(); + + /* create the threads */ + ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); + if (tv_receivepcap == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + TmModule *tm_module = TmModuleGetByName("ReceivePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); + + if (TmThreadSpawn(tv_receivepcap) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); + if (tv_decode1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Decode1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("DecodePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodePcap failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_decode1,tm_module,NULL); + + if (TmThreadSpawn(tv_decode1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); + if (tv_stream1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream1,tm_module,NULL); + + if (TmThreadSpawn(tv_stream1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); + if (tv_detect1 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","verdict-queue","simple","1slot"); + if (tv_detect2 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect2) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","verdict-queue","simple","alert-queue1","simple","1slot"); + if (tv_rreject == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_rreject,tm_module,NULL); + + if (TmThreadSpawn(tv_rreject) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); + if (tv_alert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + if (TmThreadSpawn(tv_alert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); + if (tv_unified == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); + + if (TmThreadSpawn(tv_unified) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); + if (tv_debugalert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); + + if (TmThreadSpawn(tv_debugalert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + +/** \brief Live pcap mode with 4 stream tracking and reassembly threads, testing the flow queuehandler */ +int RunModeIdsPcap2(DetectEngineCtx *de_ctx, char *iface) { + TimeModeSetLive(); + + /* create the threads */ + ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); + if (tv_receivepcap == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + TmModule *tm_module = TmModuleGetByName("ReceivePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); + + if (TmThreadSpawn(tv_receivepcap) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1,decode-queue2,decode-queue3,decode-queue4","flow","1slot"); + if (tv_decode1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Decode1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("DecodePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodePcap failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_decode1,tm_module,NULL); + + if (TmThreadSpawn(tv_decode1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); + if (tv_stream1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream1,tm_module,NULL); + + if (TmThreadSpawn(tv_stream1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream2 = TmThreadCreatePacketHandler("Stream2","decode-queue2","simple","stream-queue1","simple","1slot"); + if (tv_stream2 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream2\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream2,tm_module,NULL); + + if (TmThreadSpawn(tv_stream2) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream3 = TmThreadCreatePacketHandler("Stream3","decode-queue3","simple","stream-queue2","simple","1slot"); + if (tv_stream3 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream3,tm_module,NULL); + + if (TmThreadSpawn(tv_stream3) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream4 = TmThreadCreatePacketHandler("Stream4","decode-queue4","simple","stream-queue2","simple","1slot"); + if (tv_stream4 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream4,tm_module,NULL); + + if (TmThreadSpawn(tv_stream4) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); + if (tv_detect1 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue2","simple","verdict-queue","simple","1slot"); + if (tv_detect2 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect2) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","verdict-queue","simple","alert-queue1","simple","1slot"); + if (tv_rreject == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_rreject,tm_module,NULL); + + if (TmThreadSpawn(tv_rreject) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); + if (tv_alert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + if (TmThreadSpawn(tv_alert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); + if (tv_unified == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); + + if (TmThreadSpawn(tv_unified) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); + if (tv_debugalert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); + + if (TmThreadSpawn(tv_debugalert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + +/** \brief Live pcap mode with 4 stream tracking and reassembly threads, testing the flow queuehandler */ +int RunModeIdsPcap3(DetectEngineCtx *de_ctx, char *iface) { + TimeModeSetLive(); + + /* create the threads */ + ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcap","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); + if (tv_receivepcap == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + TmModule *tm_module = TmModuleGetByName("ReceivePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_receivepcap,tm_module,(void *)iface); + + if (TmThreadSpawn(tv_receivepcap) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1,decode-queue2,decode-queue3,decode-queue4","flow","1slot"); + if (tv_decode1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Decode1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("DecodePcap"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodePcap failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_decode1,tm_module,NULL); + + if (TmThreadSpawn(tv_decode1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv; + tv = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","packetpool","packetpool","varslot"); + if (tv == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); + + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + TmThreadSetCPUAffinity(tv, 0); + + if (TmThreadSpawn(tv) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + tv = TmThreadCreatePacketHandler("Stream2","decode-queue2","simple","packetpool","packetpool","varslot"); + if (tv == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); + + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + TmThreadSetCPUAffinity(tv, 0); + + if (TmThreadSpawn(tv) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + tv = TmThreadCreatePacketHandler("Stream3","decode-queue3","simple","packetpool","packetpool","varslot"); + if (tv == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); + + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + TmThreadSetCPUAffinity(tv, 1); + + if (TmThreadSpawn(tv) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + tv = TmThreadCreatePacketHandler("Stream4","decode-queue4","simple","packetpool","packetpool","varslot"); + if (tv == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); + + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + TmThreadSetCPUAffinity(tv, 1); + + if (TmThreadSpawn(tv) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + return 0; +} + +int RunModeIpsNFQ(DetectEngineCtx *de_ctx) { + TimeModeSetLive(); + + /* create the threads */ + ThreadVars *tv_receivenfq = TmThreadCreatePacketHandler("ReceiveNFQ","packetpool","packetpool","pickup-queue","simple","1slot_noinout"); + if (tv_receivenfq == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + TmModule *tm_module = TmModuleGetByName("ReceiveNFQ"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceiveNFQ\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_receivenfq,tm_module,NULL); + + if (TmThreadSpawn(tv_receivenfq) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); + if (tv_decode1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Decode1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("DecodeNFQ"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodeNFQ failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_decode1,tm_module,NULL); + + if (TmThreadSpawn(tv_decode1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); + if (tv_stream1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream1,tm_module,NULL); + + if (TmThreadSpawn(tv_stream1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","verdict-queue","simple","1slot"); + if (tv_detect1 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","verdict-queue","simple","1slot"); + if (tv_detect2 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect2) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_verdict = TmThreadCreatePacketHandler("Verdict","verdict-queue","simple","respond-queue","simple","1slot"); + if (tv_verdict == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("VerdictNFQ"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName VerdictNFQ failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_verdict,tm_module,NULL); + + if (TmThreadSpawn(tv_verdict) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_rreject = TmThreadCreatePacketHandler("RespondReject","respond-queue","simple","alert-queue1","simple","1slot"); + if (tv_rreject == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("RespondReject"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for RespondReject failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_rreject,tm_module,NULL); + + if (TmThreadSpawn(tv_rreject) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); + if (tv_alert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert, tm_module, NULL); + + if (TmThreadSpawn(tv_alert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); + if (tv_unified == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified, tm_module, NULL); + + if (TmThreadSpawn(tv_unified) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); + if (tv_debugalert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); + + if (TmThreadSpawn(tv_debugalert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + +int RunModeFilePcap(DetectEngineCtx *de_ctx, char *file) { + printf("RunModeFilePcap: file %s\n", file); + TimeModeSetOffline(); + + /* create the threads */ + ThreadVars *tv_receivepcap = TmThreadCreatePacketHandler("ReceivePcapFile","packetpool","packetpool","pickup-queue","simple","1slot"); + if (tv_receivepcap == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + TmModule *tm_module = TmModuleGetByName("ReceivePcapFile"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_receivepcap,tm_module,file); + + if (TmThreadSpawn(tv_receivepcap) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_decode1 = TmThreadCreatePacketHandler("Decode1","pickup-queue","simple","decode-queue1","simple","1slot"); + if (tv_decode1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Decode1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("DecodePcapFile"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodePcap failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_decode1,tm_module,NULL); + + if (TmThreadSpawn(tv_decode1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } +//#if 0 + ThreadVars *tv_stream1 = TmThreadCreatePacketHandler("Stream1","decode-queue1","simple","stream-queue1","simple","1slot"); + if (tv_stream1 == NULL) { + printf("ERROR: TmThreadsCreate failed for Stream1\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_stream1,tm_module,NULL); + + if (TmThreadSpawn(tv_stream1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect1 = TmThreadCreatePacketHandler("Detect1","stream-queue1","simple","alert-queue1","simple","1slot"); +//#endif + //ThreadVars *tv_detect1 = TmThreadCreate("Detect1","decode-queue1","simple","alert-queue1","simple","1slot"); + if (tv_detect1 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect1,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect1) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_detect2 = TmThreadCreatePacketHandler("Detect2","stream-queue1","simple","alert-queue1","simple","1slot"); + if (tv_detect2 == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_detect2,tm_module,(void *)de_ctx); + + if (TmThreadSpawn(tv_detect2) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_alert = TmThreadCreatePacketHandler("AlertFastlog&Httplog","alert-queue1","simple","alert-queue2","simple","varslot"); + if (tv_alert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_alert,tm_module,NULL); + + if (TmThreadSpawn(tv_alert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_unified = TmThreadCreatePacketHandler("AlertUnifiedLog","alert-queue2","simple","alert-queue3","simple","varslot"); + if (tv_unified == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv_unified,tm_module,NULL); + + if (TmThreadSpawn(tv_unified) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + ThreadVars *tv_debugalert = TmThreadCreatePacketHandler("AlertDebuglog","alert-queue3","simple","packetpool","packetpool","1slot"); + if (tv_debugalert == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + Tm1SlotSetFunc(tv_debugalert,tm_module,NULL); + + if (TmThreadSpawn(tv_debugalert) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + return 0; +} + +/** + * \brief Single thread version of the Pcap file processing. + */ +int RunModeFilePcap2(DetectEngineCtx *de_ctx, char *file) { + printf("RunModeFilePcap2: file %s\n", file); + TimeModeSetOffline(); + + /* create the threads */ + ThreadVars *tv = TmThreadCreatePacketHandler("PcapFile","packetpool","packetpool","packetpool","packetpool","varslot"); + if (tv == NULL) { + printf("ERROR: TmThreadsCreate failed\n"); + exit(EXIT_FAILURE); + } + + TmModule *tm_module = TmModuleGetByName("ReceivePcapFile"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed for ReceivePcap\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,file); + + tm_module = TmModuleGetByName("DecodePcapFile"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName DecodePcap failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("StreamTcp"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName StreamTcp failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("Detect"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName Detect failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,(void *)de_ctx); + + tm_module = TmModuleGetByName("AlertFastlog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertFastlog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("LogHttplog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedLog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedLog failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertUnifiedAlert"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName for AlertUnifiedAlert failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + tm_module = TmModuleGetByName("AlertDebuglog"); + if (tm_module == NULL) { + printf("ERROR: TmModuleGetByName failed\n"); + exit(EXIT_FAILURE); + } + TmVarSlotSetFuncAppend(tv,tm_module,NULL); + + if (TmThreadSpawn(tv) != 0) { + printf("ERROR: TmThreadSpawn failed\n"); + exit(EXIT_FAILURE); + } + + return 0; +} + diff --git a/src/runmodes.h b/src/runmodes.h new file mode 100644 index 0000000000..02fb1f272c --- /dev/null +++ b/src/runmodes.h @@ -0,0 +1,14 @@ +#ifndef __RUNMODES_H__ +#define __RUNMODES_H__ + +int RunModeIdsPcap(DetectEngineCtx *, char *); +int RunModeIdsPcap2(DetectEngineCtx *, char *); +int RunModeIdsPcap3(DetectEngineCtx *, char *); + +int RunModeIpsNFQ(DetectEngineCtx *); + +int RunModeFilePcap(DetectEngineCtx *, char *); +int RunModeFilePcap2(DetectEngineCtx *, char *); + +#endif /* __RUNMODES_H__ */ + diff --git a/src/tm-threads.h b/src/tm-threads.h index 1cee7eb1e2..6015b8967a 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -1,6 +1,8 @@ #ifndef __TM_THREADS_H__ #define __TM_THREADS_H__ +#include "tm-modules.h" + /* ThreadVars type */ enum { TVT_PPT,