From 833ba003138464d2681fbac55a5531f61133c0ce Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Sat, 16 Jun 2012 10:47:30 +0530 Subject: [PATCH] #482 - use decode_flag for all decode TMs. Use the flag as a way to retrieve decode TMs from ThreadVars --- src/flow-timeout.c | 22 +++++++++++++++++++++- src/source-af-packet.c | 2 ++ src/source-erf-dag.c | 2 ++ src/source-erf-file.c | 1 + src/source-ipfw.c | 2 ++ src/source-napatech.c | 2 ++ src/source-nfq.c | 2 ++ src/source-pcap-file.c | 1 + src/source-pcap.c | 1 + src/source-pfring.c | 2 ++ src/tm-modules.h | 1 + 11 files changed, 37 insertions(+), 1 deletions(-) diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 170eebb..e38eae4 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 9ffec71..1ce85ef 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 e2c66a8..1641352 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 f93afdf..f259173 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 f81c79b..1b94c1c 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 07d4e9b..04c280f 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 8df666f..a9fd7c1 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 3919fcd..aabb87d 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 93b31ac..dc47f94 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 4457892..0aa862f 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 a244e26..b547ab3 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; -- 1.7.1