From: Anoop Saldanha Date: Sat, 16 Jun 2012 05:17:30 +0000 (+0530) Subject: #482 - use decode_flag for all decode TMs. Use the flag as a way to retrieve decode... X-Git-Tag: suricata-1.3rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc6cf43840b25c53211563ecbb23d7e7817e94c3;p=thirdparty%2Fsuricata.git #482 - use decode_flag for all decode TMs. Use the flag as a way to retrieve decode TMs from ThreadVars --- diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 170eebb50b..e38eae4eb0 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -685,7 +685,27 @@ void FlowForceReassemblySetup(void) stream_pseudo_pkt_detect_TV = NULL; } - stream_pseudo_pkt_decode_tm_slot = TmThreadGetFirstTmSlotForPartialPattern("Decode"); + + SCMutexLock(&tv_root_lock); + ThreadVars *tv = tv_root[TVT_PPT]; + int done = 0; + while (tv) { + TmSlot *slots = tv->tm_slots; + while (slots) { + TmModule *tm = TmModuleGetById(slots->tm_id); + if (tm->flags & TM_FLAG_DECODE_TM) { + done = 1; + stream_pseudo_pkt_decode_tm_slot = slots; + break; + } + slots = slots->slot_next; + } + if (done) + break; + tv = tv->next; + } + SCMutexUnlock(&tv_root_lock); + if (stream_pseudo_pkt_decode_tm_slot == NULL) { /* yes, this is fatal! */ SCLogError(SC_ERR_TM_MODULES_ERROR, "Looks like we have failed to " diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 9ffec71222..1ce85ef93b 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -106,6 +106,7 @@ void TmModuleDecodeAFPRegister (void) { tmm_modules[TMM_DECODEAFP].ThreadDeinit = NULL; tmm_modules[TMM_DECODEAFP].RegisterTests = NULL; tmm_modules[TMM_DECODEAFP].cap_flags = 0; + tmm_modules[TMM_DECODEAFP].flags = TM_FLAG_DECODE_TM; } /** @@ -226,6 +227,7 @@ void TmModuleDecodeAFPRegister (void) { tmm_modules[TMM_DECODEAFP].ThreadDeinit = NULL; tmm_modules[TMM_DECODEAFP].RegisterTests = NULL; tmm_modules[TMM_DECODEAFP].cap_flags = 0; + tmm_modules[TMM_DECODEAFP].flags = TM_FLAG_DECODE_TM; } static int AFPCreateSocket(AFPThreadVars *ptv, char *devname, int verbose); diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index e2c66a8575..164135293e 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -56,6 +56,7 @@ void TmModuleDecodeErfDagRegister (void) { tmm_modules[TMM_DECODEERFDAG].ThreadDeinit = NULL; tmm_modules[TMM_DECODEERFDAG].RegisterTests = NULL; tmm_modules[TMM_DECODEERFDAG].cap_flags = 0; + tmm_modules[TMM_DECODEERFDAG].flags = TM_FLAG_DECODE_TM; } TmEcode NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data) @@ -137,6 +138,7 @@ TmModuleDecodeErfDagRegister(void) tmm_modules[TMM_DECODEERFDAG].ThreadDeinit = NULL; tmm_modules[TMM_DECODEERFDAG].RegisterTests = NULL; tmm_modules[TMM_DECODEERFDAG].cap_flags = 0; + tmm_modules[TMM_DECODEERFDAG].flags = TM_FLAG_DECODE_TM; } /** diff --git a/src/source-erf-file.c b/src/source-erf-file.c index f93afdfde4..f25917303a 100644 --- a/src/source-erf-file.c +++ b/src/source-erf-file.c @@ -101,6 +101,7 @@ TmModuleDecodeErfFileRegister(void) tmm_modules[TMM_DECODEERFFILE].ThreadDeinit = NULL; tmm_modules[TMM_DECODEERFFILE].RegisterTests = NULL; tmm_modules[TMM_DECODEERFFILE].cap_flags = 0; + tmm_modules[TMM_DECODEERFFILE].flags = TM_FLAG_DECODE_TM; } /** diff --git a/src/source-ipfw.c b/src/source-ipfw.c index f81c79b1c0..1b94c1ce59 100644 --- a/src/source-ipfw.c +++ b/src/source-ipfw.c @@ -83,6 +83,7 @@ void TmModuleDecodeIPFWRegister (void) { tmm_modules[TMM_DECODEIPFW].ThreadDeinit = NULL; tmm_modules[TMM_DECODEIPFW].RegisterTests = NULL; tmm_modules[TMM_DECODEIPFW].cap_flags = 0; + tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } TmEcode NoIPFWSupportExit(ThreadVars *tv, void *initdata, void **data) { @@ -185,6 +186,7 @@ void TmModuleDecodeIPFWRegister (void) { tmm_modules[TMM_DECODEIPFW].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEIPFW].ThreadDeinit = NULL; tmm_modules[TMM_DECODEIPFW].RegisterTests = NULL; + tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } static inline void IPFWMutexInit(IPFWQueueVars *nq) diff --git a/src/source-napatech.c b/src/source-napatech.c index 07d4e9ba9b..04c280fe5a 100644 --- a/src/source-napatech.c +++ b/src/source-napatech.c @@ -60,6 +60,7 @@ void TmModuleNapatechDecodeRegister (void) { tmm_modules[TMM_DECODENAPATECH].ThreadDeinit = NULL; tmm_modules[TMM_DECODENAPATECH].RegisterTests = NULL; tmm_modules[TMM_DECODENAPATECH].cap_flags = 0; + tmm_modules[TMM_DECODENAPATECH].flags = TM_FLAG_DECODE_TM; } TmEcode NoNapatechSupportExit(ThreadVars *tv, void *initdata, void **data) @@ -127,6 +128,7 @@ void TmModuleNapatechDecodeRegister(void) tmm_modules[TMM_DECODENAPATECH].ThreadDeinit = NULL; tmm_modules[TMM_DECODENAPATECH].RegisterTests = NULL; tmm_modules[TMM_DECODENAPATECH].cap_flags = 0; + tmm_modules[TMM_DECODENAPATECH].flags = TM_FLAG_DECODE_TM; } /** diff --git a/src/source-nfq.c b/src/source-nfq.c index 8df666f588..a9fd7c1d31 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -91,6 +91,7 @@ void TmModuleDecodeNFQRegister (void) { tmm_modules[TMM_DECODENFQ].ThreadDeinit = NULL; tmm_modules[TMM_DECODENFQ].RegisterTests = NULL; tmm_modules[TMM_DECODENFQ].cap_flags = 0; + tmm_modules[TMM_DECODENFQ].flags = TM_FLAG_DECODE_TM; } TmEcode NoNFQSupportExit(ThreadVars *tv, void *initdata, void **data) @@ -195,6 +196,7 @@ void TmModuleDecodeNFQRegister (void) { tmm_modules[TMM_DECODENFQ].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODENFQ].ThreadDeinit = NULL; tmm_modules[TMM_DECODENFQ].RegisterTests = NULL; + tmm_modules[TMM_DECODENFQ].flags = TM_FLAG_DECODE_TM; } /** \brief To initialize the NFQ global configuration data diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index 3919fcdaf3..aabb87d40a 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -113,6 +113,7 @@ void TmModuleDecodePcapFileRegister (void) { tmm_modules[TMM_DECODEPCAPFILE].ThreadDeinit = NULL; tmm_modules[TMM_DECODEPCAPFILE].RegisterTests = NULL; tmm_modules[TMM_DECODEPCAPFILE].cap_flags = 0; + tmm_modules[TMM_DECODEPCAPFILE].flags = TM_FLAG_DECODE_TM; } void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) { diff --git a/src/source-pcap.c b/src/source-pcap.c index 93b31acab3..dc47f9421a 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -133,6 +133,7 @@ void TmModuleDecodePcapRegister (void) { tmm_modules[TMM_DECODEPCAP].ThreadDeinit = NULL; tmm_modules[TMM_DECODEPCAP].RegisterTests = NULL; tmm_modules[TMM_DECODEPCAP].cap_flags = 0; + tmm_modules[TMM_DECODEPCAP].flags = TM_FLAG_DECODE_TM; } #if LIBPCAP_VERSION_MAJOR == 1 diff --git a/src/source-pfring.c b/src/source-pfring.c index 4457892b63..0aa862f3f7 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -83,6 +83,7 @@ void TmModuleDecodePfringRegister (void) { tmm_modules[TMM_DECODEPFRING].ThreadDeinit = NULL; tmm_modules[TMM_DECODEPFRING].RegisterTests = NULL; tmm_modules[TMM_DECODEPFRING].cap_flags = 0; + tmm_modules[TMM_DECODEPFRING].flags = TM_FLAG_DECODE_TM; } /** @@ -166,6 +167,7 @@ void TmModuleDecodePfringRegister (void) { tmm_modules[TMM_DECODEPFRING].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEPFRING].ThreadDeinit = NULL; tmm_modules[TMM_DECODEPFRING].RegisterTests = NULL; + tmm_modules[TMM_DECODEPFRING].flags = TM_FLAG_DECODE_TM; } /** diff --git a/src/tm-modules.h b/src/tm-modules.h index a244e26988..b547ab3b57 100644 --- a/src/tm-modules.h +++ b/src/tm-modules.h @@ -29,6 +29,7 @@ /* thread flags */ #define TM_FLAG_RECEIVE_TM 0x01 +#define TM_FLAG_DECODE_TM 0x02 typedef struct TmModule_ { char *name;