diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index f52e8235a5..0b825fb60e 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -79,8 +79,8 @@ void AlpProtoInit(AlpProtoDetectCtx *ctx) { } void AlpProtoDestroy(AlpProtoDetectCtx *ctx) { - ctx->toserver.mpm_ctx.DestroyCtx(&ctx->toserver.mpm_ctx); - ctx->toclient.mpm_ctx.DestroyCtx(&ctx->toclient.mpm_ctx); + mpm_table[ctx->toserver.mpm_ctx.mpm_type].DestroyCtx(&ctx->toserver.mpm_ctx); + mpm_table[ctx->toclient.mpm_ctx.mpm_type].DestroyCtx(&ctx->toclient.mpm_ctx); } /** \brief Add a proto detection string to the detection ctx. @@ -124,12 +124,12 @@ void AlpProtoFinalizeThread(AlpProtoDetectCtx *ctx, AlpProtoDetectThreadCtx *tct if (ctx->toclient.id > 0) { maxid = ctx->toclient.id; - ctx->toclient.mpm_ctx.InitThreadCtx(&ctx->toclient.mpm_ctx, &tctx->toclient.mpm_ctx, maxid); + mpm_table[ctx->toclient.mpm_ctx.mpm_type].InitThreadCtx(&ctx->toclient.mpm_ctx, &tctx->toclient.mpm_ctx, maxid); PmqSetup(&tctx->toclient.pmq, maxid); } if (ctx->toserver.id > 0) { maxid = ctx->toserver.id; - ctx->toserver.mpm_ctx.InitThreadCtx(&ctx->toserver.mpm_ctx, &tctx->toserver.mpm_ctx, maxid); + mpm_table[ctx->toserver.mpm_ctx.mpm_type].InitThreadCtx(&ctx->toserver.mpm_ctx, &tctx->toserver.mpm_ctx, maxid); PmqSetup(&tctx->toserver.pmq, maxid); } } diff --git a/src/detect-ack.c b/src/detect-ack.c index 7c181fd462..80fec40e5c 100644 --- a/src/detect-ack.c +++ b/src/detect-ack.c @@ -186,6 +186,7 @@ static int DetectAckSigTest01Real(int mpm_type) goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; /* These three are crammed in here as there is no Parse */ @@ -226,7 +227,6 @@ static int DetectAckSigTest01Real(int mpm_type) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p[0]); @@ -266,7 +266,6 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); cleanup_engine: DetectEngineCtxFree(de_ctx); diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index eb22cfde4d..a5fbc7e2d1 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -25,6 +25,10 @@ #define PM MPM_B2G //#define PM MPM_B3G +uint16_t PatternMatchDefaultMatcher(void) { + return PM; +} + /** \brief Pattern match, scan part -- searches for only 'scan' patterns, * normally one per signature. * \param tv threadvars @@ -73,15 +77,27 @@ void PacketPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { } } -void PatternMatchDestroy(MpmCtx *mpm_ctx) { - SCLogDebug("mpm_ctx %p", mpm_ctx); - mpm_ctx->DestroyCtx(mpm_ctx); +void PatternMatchDestroy(MpmCtx *mpm_ctx, uint16_t mpm_matcher) { + SCLogDebug("mpm_ctx %p, mpm_matcher %"PRIu16"", mpm_ctx, mpm_matcher); + mpm_table[mpm_matcher].DestroyCtx(mpm_ctx); +} + +void PatternMatchPrepare(MpmCtx *mpm_ctx, uint16_t mpm_matcher) { + SCLogDebug("mpm_ctx %p, mpm_matcher %"PRIu16"", mpm_ctx, mpm_matcher); + MpmInitCtx(mpm_ctx, mpm_matcher); } -void PatternMatchPrepare(MpmCtx *mpm_ctx, int type) { - SCLogDebug("mpm_ctx %p, type %d", mpm_ctx, type); - memset(mpm_ctx, 0x00, sizeof(MpmCtx)); - MpmInitCtx(mpm_ctx, type); +void PatternMatchThreadPrint(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) { + SCLogDebug("mpm_thread_ctx %p, mpm_matcher %"PRIu16" defunct", mpm_thread_ctx, mpm_matcher); + //mpm_table[mpm_matcher].PrintThreadCtx(mpm_thread_ctx); +} +void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) { + SCLogDebug("mpm_thread_ctx %p, mpm_matcher %"PRIu16"", mpm_thread_ctx, mpm_matcher); + mpm_table[mpm_matcher].DestroyThreadCtx(NULL, mpm_thread_ctx); +} +void PatternMatchThreadPrepare(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher, uint32_t max_id) { + SCLogDebug("mpm_thread_ctx %p, type %"PRIu16", max_id %"PRIu32"", mpm_thread_ctx, mpm_matcher, max_id); + MpmInitThreadCtx(mpm_thread_ctx, mpm_matcher, max_id); } @@ -91,7 +107,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) { if (sh->flags & SIG_GROUP_HAVECONTENT && sh->mpm_ctx != NULL && !(sh->flags & SIG_GROUP_HEAD_MPM_COPY)) { SCLogDebug("destroying mpm_ctx %p (sh %p)", sh->mpm_ctx, sh); - sh->mpm_ctx->DestroyCtx(sh->mpm_ctx); + mpm_table[sh->mpm_ctx->mpm_type].DestroyCtx(sh->mpm_ctx); free(sh->mpm_ctx); /* ready for reuse */ @@ -103,7 +119,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) { if (sh->flags & SIG_GROUP_HAVEURICONTENT && sh->mpm_uri_ctx != NULL && !(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) { SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx, sh); - sh->mpm_uri_ctx->DestroyCtx(sh->mpm_uri_ctx); + mpm_table[sh->mpm_uri_ctx->mpm_type].DestroyCtx(sh->mpm_uri_ctx); free(sh->mpm_uri_ctx); /* ready for reuse */ diff --git a/src/detect-engine-mpm.h b/src/detect-engine-mpm.h index a1c47b9a08..c7a792e700 100644 --- a/src/detect-engine-mpm.h +++ b/src/detect-engine-mpm.h @@ -1,19 +1,26 @@ -#ifndef __DETECT_MPM_H__ -#define __DETECT_MPM_H__ +#ifndef __DETECT_ENGINE_MPM_H__ +#define __DETECT_ENGINE_MPM_H__ #include "tm-modules.h" /* XXX remove once */ -MpmCtx mpm_ctx[1]; +//MpmCtx mpm_ctx[1]; +uint16_t PatternMatchDefaultMatcher(void); uint32_t PacketPatternScan(ThreadVars *, DetectEngineThreadCtx *, Packet *); uint32_t PacketPatternMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *); void PacketPatternCleanup(ThreadVars *, DetectEngineThreadCtx *); -void PatternMatchPrepare(MpmCtx *, int); + +void PatternMatchPrepare(MpmCtx *, uint16_t); +void PatternMatchThreadPrepare(MpmThreadCtx *, uint16_t type, uint32_t max_id); + +void PatternMatchDestroy(MpmCtx *, uint16_t); +void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t); +void PatternMatchThreadPrint(MpmThreadCtx *, uint16_t); + int PatternMatchPrepareGroup(DetectEngineCtx *, SigGroupHead *); void DetectEngineThreadCtxInfo(ThreadVars *, DetectEngineThreadCtx *); -void PatternMatchDestroy(MpmCtx *); void PatternMatchDestroyGroup(SigGroupHead *); TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **); @@ -23,5 +30,5 @@ void SigGroupHeadSetMpmMaxlen(DetectEngineCtx *, SigGroupHead *); void DbgPrintScanSearchStats(); -#endif /* __DETECT_MPM_H__ */ +#endif /* __DETECT_ENGINE_MPM_H__ */ diff --git a/src/detect-engine-proto.c b/src/detect-engine-proto.c index f83f2b8efc..ef980f30e9 100644 --- a/src/detect-engine-proto.c +++ b/src/detect-engine-proto.c @@ -363,7 +363,6 @@ static int DetectProtoTestSig01(void) { goto end; SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -385,7 +384,6 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: diff --git a/src/detect-engine-sigorder.c b/src/detect-engine-sigorder.c index 95fd808227..7c7c796de8 100644 --- a/src/detect-engine-sigorder.c +++ b/src/detect-engine-sigorder.c @@ -1070,7 +1070,6 @@ static int SCSigTestSignatureOrdering02(void) sw = sw->next; } - SigFree(sig); DetectEngineCtxFree(de_ctx); end: return result; @@ -1208,7 +1207,6 @@ static int SCSigTestSignatureOrdering03(void) sw = sw->next; } - SigFree(sig); DetectEngineCtxFree(de_ctx); end: return result; @@ -1310,7 +1308,6 @@ static int SCSigTestSignatureOrdering04(void) sw = sw->next; } - SigFree(sig); DetectEngineCtxFree(de_ctx); end: return result; @@ -1405,7 +1402,6 @@ static int SCSigTestSignatureOrdering05(void) sw = sw->next; } - SigFree(sig); DetectEngineCtxFree(de_ctx); end: return result; @@ -1500,7 +1496,6 @@ static int SCSigTestSignatureOrdering06(void) sw = sw->next; } - SigFree(sig); DetectEngineCtxFree(de_ctx); end: return result; diff --git a/src/detect-engine.c b/src/detect-engine.c index 72c0440c79..da7eb897d7 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -33,6 +33,8 @@ DetectEngineCtx *DetectEngineCtxInit(void) { memset(de_ctx,0,sizeof(DetectEngineCtx)); + de_ctx->mpm_matcher = PatternMatchDefaultMatcher(); + SigGroupHeadHashInit(de_ctx); SigGroupHeadMpmHashInit(de_ctx); SigGroupHeadMpmUriHashInit(de_ctx); @@ -49,7 +51,6 @@ error: void DetectEngineCtxFree(DetectEngineCtx *de_ctx) { - SigCleanSignatures(de_ctx); /* Normally the hashes are freed elsewhere, but * to be sure look at them again here. @@ -63,6 +64,8 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) { DetectPortSpHashFree(de_ctx); DetectPortDpHashFree(de_ctx); + SigCleanSignatures(de_ctx); + VariableNameFreeHash(de_ctx); if (de_ctx->sig_array) free(de_ctx->sig_array); @@ -100,8 +103,10 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) { * of the content and uricontent id's so our match lookup * table is always big enough */ - mpm_ctx[0].InitThreadCtx(&mpm_ctx[0], &det_ctx->mtc, DetectContentMaxId(de_ctx)); - mpm_ctx[0].InitThreadCtx(&mpm_ctx[0], &det_ctx->mtcu, DetectUricontentMaxId(de_ctx)); + PatternMatchThreadPrepare(&det_ctx->mtc, de_ctx->mpm_matcher, DetectContentMaxId(de_ctx)); + PatternMatchThreadPrepare(&det_ctx->mtcu, de_ctx->mpm_matcher, DetectUricontentMaxId(de_ctx)); + //mpm_ctx[0].InitThreadCtx(&mpm_ctx[0], &det_ctx->mtc, DetectContentMaxId(de_ctx)); + //mpm_ctx[0].InitThreadCtx(&mpm_ctx[0], &det_ctx->mtcu, DetectUricontentMaxId(de_ctx)); PmqSetup(&det_ctx->pmq, DetectEngineGetMaxSigId(de_ctx)); @@ -122,15 +127,19 @@ TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data) { DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data; /** \todo get rid of this static */ - mpm_ctx[0].DestroyThreadCtx(&mpm_ctx[0], &det_ctx->mtc); - mpm_ctx[0].DestroyThreadCtx(&mpm_ctx[0], &det_ctx->mtcu); + PatternMatchThreadDestroy(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher); + PatternMatchThreadDestroy(&det_ctx->mtcu, det_ctx->de_ctx->mpm_matcher); + //mpm_ctx[0].DestroyThreadCtx(&mpm_ctx[0], &det_ctx->mtc); + //mpm_ctx[0].DestroyThreadCtx(&mpm_ctx[0], &det_ctx->mtcu); return TM_ECODE_OK; } void DetectEngineThreadCtxInfo(ThreadVars *t, DetectEngineThreadCtx *det_ctx) { /* XXX */ - mpm_ctx[0].PrintThreadCtx(&det_ctx->mtc); - mpm_ctx[0].PrintThreadCtx(&det_ctx->mtcu); + PatternMatchThreadPrint(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher); + PatternMatchThreadPrint(&det_ctx->mtcu, det_ctx->de_ctx->mpm_matcher); + //mpm_ctx[0].PrintThreadCtx(&det_ctx->mtc); + //mpm_ctx[0].PrintThreadCtx(&det_ctx->mtcu); } diff --git a/src/detect-id.c b/src/detect-id.c index 50f5d654bb..b1138038cd 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -469,7 +469,6 @@ int DetectIdTestSig1(void) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -482,7 +481,6 @@ int DetectIdTestSig1(void) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); FlowShutdown(); @@ -498,8 +496,6 @@ end: DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); } - PatternMatchDestroy(mpm_ctx); - if (de_ctx != NULL) { DetectEngineCtxFree(de_ctx); } @@ -562,7 +558,6 @@ int DetectIdTestSig2(void) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -575,7 +570,6 @@ int DetectIdTestSig2(void) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); FlowShutdown(); @@ -591,8 +585,6 @@ end: if (det_ctx) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); - if (de_ctx) DetectEngineCtxFree(de_ctx); diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index dadc7b3acb..594c2442d5 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -561,7 +561,6 @@ static int DetectIPProtoTestSig1(void) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -586,7 +585,6 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: diff --git a/src/detect-parse.c b/src/detect-parse.c index c0de5b8b27..5f801b44a2 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -521,8 +521,12 @@ void SigFree(Signature *s) { DetectAddressGroupsHeadCleanup(&s->src); DetectAddressGroupsHeadCleanup(&s->dst); - DetectPortCleanupList(s->sp); - DetectPortCleanupList(s->dp); + if (s->sp != NULL) { + DetectPortCleanupList(s->sp); + } + if (s->dp != NULL) { + DetectPortCleanupList(s->dp); + } if (s->msg != NULL) free(s->msg); diff --git a/src/detect-pcre.c b/src/detect-pcre.c index e4d71420df..6da4e9d965 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -552,6 +552,7 @@ static int DetectPcreTestSig01Real(int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP TEST\"; pcre:\"^/gEt/i\"; pcre:\"/\\/two\\//U; pcre:\"/GET \\/two\\//\"; pcre:\"/\\s+HTTP/R\"; sid:1;)"); @@ -561,7 +562,6 @@ static int DetectPcreTestSig01Real(int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx,mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -572,7 +572,6 @@ static int DetectPcreTestSig01Real(int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; diff --git a/src/detect-sameip.c b/src/detect-sameip.c index 3535ddaac6..1183262f0f 100644 --- a/src/detect-sameip.c +++ b/src/detect-sameip.c @@ -141,6 +141,7 @@ static int DetectSameipSigTest01Real(int mpm_type) goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx, @@ -151,7 +152,6 @@ static int DetectSameipSigTest01Real(int mpm_type) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p[0]); @@ -173,7 +173,6 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: diff --git a/src/detect-seq.c b/src/detect-seq.c index b1d8648447..02f0b83ed9 100644 --- a/src/detect-seq.c +++ b/src/detect-seq.c @@ -186,6 +186,7 @@ static int DetectSeqSigTest01Real(int mpm_type) goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; /* These three are crammed in here as there is no Parse */ @@ -226,7 +227,6 @@ static int DetectSeqSigTest01Real(int mpm_type) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p[0]); @@ -266,7 +266,6 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); cleanup_engine: DetectEngineCtxFree(de_ctx); diff --git a/src/detect.c b/src/detect.c index 8123a05f8a..d8319e864a 100644 --- a/src/detect.c +++ b/src/detect.c @@ -2634,6 +2634,7 @@ static int SigTest01Real (int mpm_type) { if (de_ctx == NULL) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; @@ -2644,7 +2645,7 @@ static int SigTest01Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2668,7 +2669,7 @@ static int SigTest01Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -2711,6 +2712,7 @@ static int SigTest02Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:41; sid:1;)"); @@ -2720,7 +2722,7 @@ static int SigTest02Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx,mpm_type); + //PatternMatchPrepare(mpm_ctx,mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2731,7 +2733,7 @@ static int SigTest02Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -2774,6 +2776,7 @@ static int SigTest03Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:40; sid:1;)"); @@ -2783,7 +2786,7 @@ static int SigTest03Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2794,7 +2797,7 @@ static int SigTest03Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -2838,6 +2841,7 @@ static int SigTest04Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:47; within:52; sid:1;)"); @@ -2847,7 +2851,7 @@ static int SigTest04Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2858,7 +2862,7 @@ static int SigTest04Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -2901,6 +2905,7 @@ static int SigTest05Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:48; within:52; sid:1;)"); @@ -2910,7 +2915,7 @@ static int SigTest05Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2921,7 +2926,7 @@ static int SigTest05Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -2964,6 +2969,7 @@ static int SigTest06Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; recursive; sid:1;)"); @@ -2978,7 +2984,7 @@ static int SigTest06Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -2993,7 +2999,7 @@ static int SigTest06Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3036,6 +3042,7 @@ static int SigTest07Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; recursive; sid:1;)"); @@ -3050,7 +3057,7 @@ static int SigTest07Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3063,7 +3070,7 @@ static int SigTest07Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3106,6 +3113,7 @@ static int SigTest08Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)"); @@ -3120,7 +3128,7 @@ static int SigTest08Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3135,7 +3143,7 @@ static int SigTest08Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3178,6 +3186,7 @@ static int SigTest09Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)"); @@ -3192,7 +3201,7 @@ static int SigTest09Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3204,7 +3213,7 @@ static int SigTest09Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3242,6 +3251,7 @@ static int SigTest10Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"Long content test (1)\"; content:\"ABCD\"; depth:4; sid:1;)"); @@ -3256,7 +3266,7 @@ static int SigTest10Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3268,7 +3278,7 @@ static int SigTest10Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3306,6 +3316,7 @@ static int SigTest11Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"Scan vs Search (1)\"; content:\"ABCDEFGHIJ\"; content:\"klmnop\"; content:\"1234\"; sid:1;)"); @@ -3320,7 +3331,7 @@ static int SigTest11Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3332,7 +3343,7 @@ static int SigTest11Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3370,6 +3381,7 @@ static int SigTest12Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"klmnop\"; content:\"1234\"; sid:1;)"); @@ -3379,7 +3391,7 @@ static int SigTest12Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3391,7 +3403,7 @@ static int SigTest12Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3429,6 +3441,7 @@ static int SigTest13Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"1234\"; content:\"klmnop\"; sid:1;)"); @@ -3438,7 +3451,7 @@ static int SigTest13Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3450,7 +3463,7 @@ static int SigTest13Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3488,6 +3501,7 @@ static int SigTest14Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"Content order test\"; content:\"ABCDEFGHIJ\"; content:\"1234\"; content:\"klmnop\"; distance:0; sid:1;)"); @@ -3497,7 +3511,7 @@ static int SigTest14Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3509,7 +3523,7 @@ static int SigTest14Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3548,6 +3562,7 @@ static int SigTest15Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any !$HTTP_PORTS (msg:\"ET POLICY Inbound HTTP CONNECT Attempt on Off-Port\"; content:\"CONNECT \"; nocase; depth:8; content:\" HTTP/1.\"; nocase; within:1000; classtype:misc-activity; sid:2008284; rev:2;)"); @@ -3557,7 +3572,7 @@ static int SigTest15Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3569,7 +3584,7 @@ static int SigTest15Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3608,6 +3623,7 @@ static int SigTest16Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any !$HTTP_PORTS (msg:\"ET POLICY Inbound HTTP CONNECT Attempt on Off-Port\"; content:\"CONNECT \"; nocase; depth:8; content:\" HTTP/1.\"; nocase; within:1000; classtype:misc-activity; sid:2008284; rev:2;)"); @@ -3616,7 +3632,7 @@ static int SigTest16Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3628,7 +3644,7 @@ static int SigTest16Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3672,6 +3688,7 @@ static int SigTest17Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP host cap\"; content:\"Host:\"; pcre:\"/^Host: (?P.*)\\r\\n/m\"; noalert; sid:1;)"); @@ -3681,7 +3698,7 @@ static int SigTest17Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3702,7 +3719,7 @@ static int SigTest17Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3742,6 +3759,7 @@ static int SigTest18Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any !21:902 -> any any (msg:\"ET MALWARE Suspicious 220 Banner on Local Port\"; content:\"220\"; offset:0; depth:4; pcre:\"/220[- ]/\"; classtype:non-standard-protocol; sid:2003055; rev:4;)"); @@ -3751,7 +3769,7 @@ static int SigTest18Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -3763,7 +3781,7 @@ static int SigTest18Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3806,6 +3824,7 @@ int SigTest19Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert ip $HOME_NET any -> 1.2.3.4 any (msg:\"IP-ONLY test (1)\"; sid:999; rev:1;)"); @@ -3815,7 +3834,7 @@ int SigTest19Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); //DetectEngineIPOnlyThreadInit(de_ctx,&det_ctx->io_ctx); @@ -3828,7 +3847,7 @@ int SigTest19Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3870,6 +3889,7 @@ static int SigTest20Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert ip $HOME_NET any -> [99.99.99.99,1.2.3.0/24,1.1.1.1,3.0.0.0/8] any (msg:\"IP-ONLY test (2)\"; sid:999; rev:1;)"); @@ -3879,7 +3899,7 @@ static int SigTest20Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); //DetectEngineIPOnlyThreadInit(de_ctx,&det_ctx->io_ctx); @@ -3892,7 +3912,7 @@ static int SigTest20Real (int mpm_type) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -3950,6 +3970,7 @@ static int SigTest21Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:set,TEST.one; flowbits:noalert; sid:1;)"); @@ -3964,7 +3985,7 @@ static int SigTest21Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -3980,7 +4001,7 @@ static int SigTest21Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4038,6 +4059,7 @@ static int SigTest22Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:set,TEST.one; flowbits:noalert; sid:1;)"); @@ -4052,7 +4074,7 @@ static int SigTest22Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4070,7 +4092,7 @@ static int SigTest22Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4127,6 +4149,7 @@ static int SigTest23Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"FLOWBIT SET\"; content:\"/one/\"; flowbits:toggle,TEST.one; flowbits:noalert; sid:1;)"); @@ -4141,7 +4164,7 @@ static int SigTest23Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4159,7 +4182,7 @@ static int SigTest23Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4244,7 +4267,7 @@ int SigTest24IPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4264,7 +4287,7 @@ int SigTest24IPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4340,7 +4363,7 @@ int SigTest25NegativeIPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4358,7 +4381,7 @@ int SigTest25NegativeIPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4448,7 +4471,7 @@ int SigTest26TCPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4466,7 +4489,7 @@ int SigTest26TCPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4556,7 +4579,7 @@ int SigTest27NegativeTCPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4575,7 +4598,7 @@ int SigTest27NegativeTCPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4670,7 +4693,7 @@ int SigTest28TCPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4688,7 +4711,7 @@ int SigTest28TCPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4784,7 +4807,7 @@ int SigTest29NegativeTCPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4802,7 +4825,7 @@ int SigTest29NegativeTCPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -4901,7 +4924,7 @@ int SigTest30UDPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -4919,7 +4942,7 @@ int SigTest30UDPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5017,7 +5040,7 @@ int SigTest31NegativeUDPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5036,7 +5059,7 @@ int SigTest31NegativeUDPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5128,7 +5151,7 @@ int SigTest32UDPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5146,7 +5169,7 @@ int SigTest32UDPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5237,7 +5260,7 @@ int SigTest33NegativeUDPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5255,7 +5278,7 @@ int SigTest33NegativeUDPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5347,7 +5370,6 @@ int SigTest34ICMPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5365,7 +5387,6 @@ int SigTest34ICMPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5457,7 +5478,7 @@ int SigTest35NegativeICMPV4Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5476,7 +5497,7 @@ int SigTest35NegativeICMPV4Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5580,7 +5601,7 @@ int SigTest36ICMPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5598,7 +5619,7 @@ int SigTest36ICMPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5702,7 +5723,7 @@ int SigTest37NegativeICMPV6Keyword(void) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5720,7 +5741,7 @@ int SigTest37NegativeICMPV6Keyword(void) SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -5794,6 +5815,7 @@ int SigTest38Real(int mpm_type) goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx, @@ -5816,7 +5838,7 @@ int SigTest38Real(int mpm_type) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5840,7 +5862,7 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: @@ -5924,6 +5946,7 @@ int SigTest39Real(int mpm_type) goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx, @@ -5951,7 +5974,7 @@ int SigTest39Real(int mpm_type) } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p1); @@ -5975,7 +5998,7 @@ cleanup: SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: @@ -6054,6 +6077,7 @@ int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"SigTest36ContentAndIsdataatKeywords01 \"; content:\"HTTP\"; isdataat:404, relative; sid:101;)"); @@ -6063,7 +6087,7 @@ int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -6078,7 +6102,7 @@ int SigTest36ContentAndIsdataatKeywords01Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); FlowShutdown(); @@ -6094,7 +6118,7 @@ end: if(det_ctx) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); if(de_ctx) DetectEngineCtxFree(de_ctx); @@ -6166,6 +6190,7 @@ int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) { goto end; } + de_ctx->mpm_matcher = mpm_type; de_ctx->flags |= DE_QUIET; de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> any any (msg:\"SigTest36ContentAndIsdataatKeywords01 \"; content:\"HTTP\"; isdataat:500, relative; sid:101;)"); @@ -6175,7 +6200,7 @@ int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, mpm_type); + //PatternMatchPrepare(mpm_ctx, mpm_type); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, &p); @@ -6190,7 +6215,7 @@ int SigTest37ContentAndIsdataatKeywords02Real (int mpm_type) { SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); FlowShutdown(); @@ -6206,7 +6231,7 @@ end: if(det_ctx) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); if(de_ctx) DetectEngineCtxFree(de_ctx); @@ -6285,7 +6310,7 @@ int SigTest40NoPacketInspection01(void) { } SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx,(void *)&det_ctx); //DetectEngineIPOnlyThreadInit(de_ctx,&det_ctx->io_ctx); det_ctx->de_ctx = de_ctx; @@ -6299,7 +6324,7 @@ int SigTest40NoPacketInspection01(void) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; @@ -6347,7 +6372,7 @@ int SigTest40NoPayloadInspection02(void) { de_ctx->sig_list->match->type = DETECT_CONTENT; SigGroupBuild(de_ctx); - PatternMatchPrepare(mpm_ctx,MPM_B2G); + //PatternMatchPrepare(mpm_ctx,MPM_B2G); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); if (!(de_ctx->sig_list->flags & SIG_FLAG_PAYLOAD)) @@ -6366,7 +6391,7 @@ int SigTest40NoPayloadInspection02(void) { SigGroupCleanup(de_ctx); SigCleanSignatures(de_ctx); DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - PatternMatchDestroy(mpm_ctx); + //PatternMatchDestroy(mpm_ctx); DetectEngineCtxFree(de_ctx); end: return result; diff --git a/src/detect.h b/src/detect.h index 1bb97c44df..fb753d566b 100644 --- a/src/detect.h +++ b/src/detect.h @@ -258,6 +258,8 @@ typedef struct DetectEngineCtx_ { uint32_t mpm_memory_size; DetectEngineIPOnlyCtx io_ctx; + + uint16_t mpm_matcher; /**< mpm matcher this ctx uses */ } DetectEngineCtx; /** diff --git a/src/eidps.c b/src/eidps.c index 8514d6ad90..981db66f92 100644 --- a/src/eidps.c +++ b/src/eidps.c @@ -388,7 +388,7 @@ int main(int argc, char **argv) BinSearchInit(); CIDRInit(); SigParsePrepare(); - PatternMatchPrepare(mpm_ctx, MPM_B2G); + //PatternMatchPrepare(mpm_ctx, MPM_B2G); PerfInitCounterApi(); /** \todo we need an api for these */ @@ -462,9 +462,11 @@ int main(int argc, char **argv) else { uint32_t failed = UtRunTests(regex_arg); UtCleanup(); - if (failed) + if (failed) { exit(EXIT_FAILURE); + } } + exit(EXIT_SUCCESS); } #endif /* UNITTESTS */ diff --git a/src/util-mpm-b2g.c b/src/util-mpm-b2g.c index 45be1ce800..a4b38301f0 100644 --- a/src/util-mpm-b2g.c +++ b/src/util-mpm-b2g.c @@ -893,8 +893,6 @@ void B2gInitCtx (MpmCtx *mpm_ctx) { BUG_ON(mpm_ctx->ctx != NULL); - memset(mpm_ctx, 0, sizeof(MpmCtx)); - mpm_ctx->ctx = malloc(sizeof(B2gCtx)); if (mpm_ctx->ctx == NULL) return; @@ -1060,6 +1058,8 @@ void B2gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t ma mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_size += (keys * sizeof(MpmMatchBucket)); } + + mpm_thread_ctx->matchsize = matchsize; } void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { @@ -1070,7 +1070,7 @@ void B2gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { if (ctx) { if (mpm_thread_ctx->match != NULL) { mpm_thread_ctx->memory_cnt--; - mpm_thread_ctx->memory_size -= ((mpm_ctx->max_pattern_id + 1) * sizeof(MpmMatchBucket)); + mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket)); free(mpm_thread_ctx->match); } diff --git a/src/util-mpm-b3g.c b/src/util-mpm-b3g.c index ae3e14a437..b48b15aec4 100644 --- a/src/util-mpm-b3g.c +++ b/src/util-mpm-b3g.c @@ -919,8 +919,6 @@ memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) { void B3gInitCtx (MpmCtx *mpm_ctx) { //printf("B3gInitCtx: mpm_ctx %p\n", mpm_ctx); - memset(mpm_ctx, 0, sizeof(MpmCtx)); - mpm_ctx->ctx = malloc(sizeof(B3gCtx)); if (mpm_ctx->ctx == NULL) return; @@ -1110,6 +1108,8 @@ void B3gThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t ma mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_size += (keys * sizeof(MpmMatchBucket)); } + + mpm_thread_ctx->matchsize = matchsize; } void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { @@ -1120,7 +1120,7 @@ void B3gThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { if (ctx) { if (mpm_thread_ctx->match != NULL) { mpm_thread_ctx->memory_cnt--; - mpm_thread_ctx->memory_size -= ((mpm_ctx->max_pattern_id + 1) * sizeof(MpmMatchBucket)); + mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket)); free(mpm_thread_ctx->match); } @@ -1965,6 +1965,7 @@ uint32_t B3gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche static int B3gTestInit01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -1987,6 +1988,7 @@ static int B3gTestInit01 (void) { static int B3gTestS0Init01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2006,6 +2008,7 @@ static int B3gTestS0Init01 (void) { static int B3gTestS0Init02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2026,6 +2029,7 @@ static int B3gTestS0Init02 (void) { static int B3gTestS0Init03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2046,6 +2050,7 @@ static int B3gTestS0Init03 (void) { static int B3gTestS0Init04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2065,6 +2070,7 @@ static int B3gTestS0Init04 (void) { static int B3gTestS0Init05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_B3G); B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2085,6 +2091,7 @@ static int B3gTestS0Init05 (void) { static int B3gTestScan01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2110,6 +2117,7 @@ static int B3gTestScan01 (void) { static int B3gTestScan02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2135,6 +2143,7 @@ static int B3gTestScan02 (void) { static int B3gTestScan03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2163,6 +2172,7 @@ static int B3gTestScan03 (void) { static int B3gTestScan04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2191,6 +2201,7 @@ static int B3gTestScan04 (void) { static int B3gTestScan05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2218,6 +2229,7 @@ static int B3gTestScan05 (void) { static int B3gTestScan06 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2243,6 +2255,7 @@ static int B3gTestScan06 (void) { static int B3gTestScan07 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); //B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2275,6 +2288,7 @@ static int B3gTestScan07 (void) { static int B3gTestScan08 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2300,6 +2314,7 @@ static int B3gTestScan08 (void) { static int B3gTestScan09 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2325,6 +2340,7 @@ static int B3gTestScan09 (void) { static int B3gTestScan10 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2350,6 +2366,7 @@ static int B3gTestScan10 (void) { static int B3gTestScan11 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2376,6 +2393,7 @@ static int B3gTestScan11 (void) { static int B3gTestScan12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2402,6 +2420,7 @@ static int B3gTestScan12 (void) { static int B3gTestSearch01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2427,6 +2446,7 @@ static int B3gTestSearch01 (void) { static int B3gTestSearch02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2452,6 +2472,7 @@ static int B3gTestSearch02 (void) { static int B3gTestSearch03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2480,6 +2501,7 @@ static int B3gTestSearch03 (void) { static int B3gTestSearch04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2508,6 +2530,7 @@ static int B3gTestSearch04 (void) { static int B3gTestSearch05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2535,6 +2558,7 @@ static int B3gTestSearch05 (void) { static int B3gTestSearch06 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2560,6 +2584,7 @@ static int B3gTestSearch06 (void) { static int B3gTestSearch07 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); //B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx; @@ -2592,6 +2617,7 @@ static int B3gTestSearch07 (void) { static int B3gTestSearch08 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2617,6 +2643,7 @@ static int B3gTestSearch08 (void) { static int B3gTestSearch09 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2642,6 +2669,7 @@ static int B3gTestSearch09 (void) { static int B3gTestSearch10 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2667,6 +2695,7 @@ static int B3gTestSearch10 (void) { static int B3gTestSearch11 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); @@ -2693,6 +2722,7 @@ static int B3gTestSearch11 (void) { static int B3gTestSearch12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_B3G); diff --git a/src/util-mpm-wumanber.c b/src/util-mpm-wumanber.c index e3ff0d6013..0e1e5a957c 100644 --- a/src/util-mpm-wumanber.c +++ b/src/util-mpm-wumanber.c @@ -2171,8 +2171,6 @@ uint32_t WmSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatcher void WmInitCtx (MpmCtx *mpm_ctx) { //printf("WmInitCtx: mpm_ctx %p\n", mpm_ctx); - memset(mpm_ctx, 0, sizeof(MpmCtx)); - mpm_ctx->ctx = malloc(sizeof(WmCtx)); if (mpm_ctx->ctx == NULL) return; @@ -2336,6 +2334,8 @@ void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t mat mpm_thread_ctx->memory_cnt++; mpm_thread_ctx->memory_size += (keys * sizeof(MpmMatchBucket)); } + + mpm_thread_ctx->matchsize = matchsize; } void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { @@ -2343,7 +2343,7 @@ void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { if (ctx) { if (mpm_thread_ctx->match != NULL) { mpm_thread_ctx->memory_cnt--; - mpm_thread_ctx->memory_size -= ((mpm_ctx->max_pattern_id + 1) * sizeof(MpmMatchBucket)); + mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket)); free(mpm_thread_ctx->match); } @@ -2364,6 +2364,7 @@ void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) { int WmTestInitCtx01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); WmInitCtx(&mpm_ctx); if (mpm_ctx.ctx != NULL) @@ -2376,6 +2377,7 @@ int WmTestInitCtx01 (void) { int WmTestInitCtx02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); WmInitCtx(&mpm_ctx); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -2390,6 +2392,7 @@ int WmTestInitCtx02 (void) { int WmTestInitCtx03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); if (mpm_ctx.Search == WmSearch2Hash16) @@ -2402,6 +2405,7 @@ int WmTestInitCtx03 (void) { int WmTestThreadInitCtx01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2419,6 +2423,7 @@ int WmTestThreadInitCtx02 (void) { #ifdef WUMANBER_COUNTERS int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2440,6 +2445,7 @@ int WmTestThreadInitCtx02 (void) { int WmTestInitAddPattern01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2457,6 +2463,7 @@ int WmTestInitAddPattern01 (void) { int WmTestInitAddPattern02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2475,6 +2482,7 @@ int WmTestInitAddPattern02 (void) { int WmTestInitAddPattern03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2496,6 +2504,7 @@ int WmTestInitAddPattern03 (void) { int WmTestInitAddPattern04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2517,6 +2526,7 @@ int WmTestInitAddPattern04 (void) { int WmTestInitAddPattern05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2538,6 +2548,7 @@ int WmTestInitAddPattern05 (void) { int WmTestInitAddPattern06 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2559,6 +2570,7 @@ int WmTestInitAddPattern06 (void) { int WmTestInitAddPattern07 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2577,6 +2589,7 @@ int WmTestInitAddPattern07 (void) { int WmTestPrepare01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 0, 0, 0, 0); @@ -2592,6 +2605,7 @@ int WmTestPrepare01 (void) { int WmTestPrepare02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0); @@ -2608,6 +2622,7 @@ int WmTestPrepare02 (void) { int WmTestPrepare03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0); @@ -2626,6 +2641,7 @@ int WmTestPrepare03 (void) { int WmTestPrepare04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 1, 0, 0, 0); @@ -2641,6 +2657,7 @@ int WmTestPrepare04 (void) { int WmTestPrepare05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 1, 0, 0, 0); @@ -2657,6 +2674,7 @@ int WmTestPrepare05 (void) { int WmTestPrepare06 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 1, 0, 0, 0); @@ -2675,6 +2693,7 @@ int WmTestPrepare06 (void) { int WmTestSearch01 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2700,6 +2719,7 @@ int WmTestSearch01 (void) { int WmTestSearch01Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2728,6 +2748,7 @@ int WmTestSearch01Hash12 (void) { int WmTestSearch01Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2756,6 +2777,7 @@ int WmTestSearch01Hash14 (void) { int WmTestSearch01Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2784,6 +2806,7 @@ int WmTestSearch01Hash15 (void) { int WmTestSearch01Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2812,6 +2835,7 @@ int WmTestSearch01Hash16 (void) { int WmTestSearch02 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2833,6 +2857,7 @@ int WmTestSearch02 (void) { int WmTestSearch03 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2855,6 +2880,7 @@ int WmTestSearch03 (void) { int WmTestSearch04 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2876,6 +2902,7 @@ int WmTestSearch04 (void) { int WmTestSearch05 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2897,6 +2924,7 @@ int WmTestSearch05 (void) { int WmTestSearch06 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2918,6 +2946,7 @@ int WmTestSearch06 (void) { int WmTestSearch07 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2940,6 +2969,7 @@ int WmTestSearch07 (void) { int WmTestSearch08 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2962,6 +2992,7 @@ int WmTestSearch08 (void) { int WmTestSearch09 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -2983,6 +3014,7 @@ int WmTestSearch09 (void) { int WmTestSearch10 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3005,6 +3037,7 @@ int WmTestSearch10 (void) { int WmTestSearch11 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3028,6 +3061,7 @@ int WmTestSearch11 (void) { int WmTestSearch12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3053,6 +3087,7 @@ int WmTestSearch12 (void) { int WmTestSearch13 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3078,6 +3113,7 @@ int WmTestSearch13 (void) { int WmTestSearch14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3101,6 +3137,7 @@ int WmTestSearch14 (void) { int WmTestSearch15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3127,6 +3164,7 @@ int WmTestSearch15 (void) { int WmTestSearch16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3153,6 +3191,7 @@ int WmTestSearch16 (void) { int WmTestSearch17 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3177,6 +3216,7 @@ int WmTestSearch17 (void) { int WmTestSearch18Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3203,6 +3243,7 @@ int WmTestSearch18Hash12 (void) { int WmTestSearch18Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3229,6 +3270,7 @@ int WmTestSearch18Hash14 (void) { int WmTestSearch18Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3255,6 +3297,7 @@ int WmTestSearch18Hash15 (void) { int WmTestSearch18 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3281,6 +3324,7 @@ int WmTestSearch18 (void) { int WmTestSearch18Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3307,6 +3351,7 @@ int WmTestSearch18Hash16 (void) { int WmTestSearch19 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3331,6 +3376,7 @@ int WmTestSearch19 (void) { int WmTestSearch19Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3357,6 +3403,7 @@ int WmTestSearch19Hash12 (void) { int WmTestSearch19Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3383,6 +3430,7 @@ int WmTestSearch19Hash14 (void) { int WmTestSearch19Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3409,6 +3457,7 @@ int WmTestSearch19Hash15 (void) { int WmTestSearch19Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3435,6 +3484,7 @@ int WmTestSearch19Hash16 (void) { int WmTestSearch20 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3459,6 +3509,7 @@ int WmTestSearch20 (void) { int WmTestSearch20Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3485,6 +3536,7 @@ int WmTestSearch20Hash12 (void) { int WmTestSearch20Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3511,6 +3563,7 @@ int WmTestSearch20Hash14 (void) { int WmTestSearch20Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3537,6 +3590,7 @@ int WmTestSearch20Hash15 (void) { int WmTestSearch20Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3563,6 +3617,7 @@ int WmTestSearch20Hash16 (void) { int WmTestSearch21 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); @@ -3587,6 +3642,7 @@ int WmTestSearch21 (void) { static int WmTestSearch21Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3613,6 +3669,7 @@ static int WmTestSearch21Hash12 (void) { static int WmTestSearch21Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3639,6 +3696,7 @@ static int WmTestSearch21Hash14 (void) { static int WmTestSearch21Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3665,6 +3723,7 @@ static int WmTestSearch21Hash15 (void) { static int WmTestSearch21Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3691,6 +3750,7 @@ static int WmTestSearch21Hash16 (void) { static int WmTestSearch22Hash9 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3724,6 +3784,7 @@ static int WmTestSearch22Hash9 (void) { static int WmTestSearch22Hash12 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3757,6 +3818,7 @@ static int WmTestSearch22Hash12 (void) { static int WmTestSearch22Hash14 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3790,6 +3852,7 @@ static int WmTestSearch22Hash14 (void) { static int WmTestSearch22Hash15 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; @@ -3823,6 +3886,7 @@ static int WmTestSearch22Hash15 (void) { static int WmTestSearch22Hash16 (void) { int result = 0; MpmCtx mpm_ctx; + memset(&mpm_ctx, 0x00, sizeof(MpmCtx)); MpmThreadCtx mpm_thread_ctx; MpmInitCtx(&mpm_ctx, MPM_WUMANBER); WmCtx *ctx = (WmCtx *)mpm_ctx.ctx; diff --git a/src/util-mpm.c b/src/util-mpm.c index 5b03a3ffa9..1d988f3509 100644 --- a/src/util-mpm.c +++ b/src/util-mpm.c @@ -271,13 +271,14 @@ void MpmEndMatchFreeAll(MpmCtx *mpm_ctx, MpmEndMatch *em) { } } +void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher, uint32_t max_id) { + mpm_table[matcher].InitThreadCtx(NULL, mpm_thread_ctx, max_id); +} + void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher) { + mpm_ctx->mpm_type = matcher; mpm_table[matcher].InitCtx(mpm_ctx); - mpm_ctx->InitCtx = mpm_table[matcher].InitCtx; - mpm_ctx->InitThreadCtx = mpm_table[matcher].InitThreadCtx; - mpm_ctx->DestroyCtx = mpm_table[matcher].DestroyCtx; - mpm_ctx->DestroyThreadCtx = mpm_table[matcher].DestroyThreadCtx; mpm_ctx->AddScanPattern = mpm_table[matcher].AddScanPattern; mpm_ctx->AddScanPatternNocase = mpm_table[matcher].AddScanPatternNocase; mpm_ctx->AddPattern = mpm_table[matcher].AddPattern; @@ -285,8 +286,6 @@ void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher) { mpm_ctx->Prepare = mpm_table[matcher].Prepare; mpm_ctx->Scan = mpm_table[matcher].Scan; mpm_ctx->Search = mpm_table[matcher].Search; - mpm_ctx->PrintCtx = mpm_table[matcher].PrintCtx; - mpm_ctx->PrintThreadCtx = mpm_table[matcher].PrintThreadCtx; mpm_ctx->Cleanup = mpm_table[matcher].Cleanup; } diff --git a/src/util-mpm.h b/src/util-mpm.h index 698cea812e..ad296ee09e 100644 --- a/src/util-mpm.h +++ b/src/util-mpm.h @@ -9,7 +9,7 @@ #define MPM_ENDMATCH_NOSEARCH 0x08 /* if this matches, no search is required (for this pattern) */ enum { - MPM_WUMANBER, + MPM_WUMANBER = 0, MPM_B2G, MPM_B3G, @@ -53,6 +53,8 @@ typedef struct MpmThreadCtx_ { MpmMatch *qlist; /* spare list */ MpmMatch *sparelist; + + uint32_t matchsize; } MpmThreadCtx; #define PMQ_MODE_SCAN 0 @@ -74,11 +76,12 @@ typedef struct PatternMatcherQueue_ { typedef struct MpmCtx_ { void *ctx; + uint16_t mpm_type; - void (*InitCtx)(struct MpmCtx_ *); - void (*InitThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *, uint32_t); - void (*DestroyCtx)(struct MpmCtx_ *); - void (*DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *); +// void (*InitCtx)(struct MpmCtx_ *); +// void (*InitThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *, uint32_t); +// void (*DestroyCtx)(struct MpmCtx_ *); +// void (*DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *); int (*AddScanPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, uint8_t); int (*AddScanPatternNocase)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, uint8_t); int (*AddPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, uint32_t); @@ -87,8 +90,8 @@ typedef struct MpmCtx_ { uint32_t (*Scan)(struct MpmCtx_ *, struct MpmThreadCtx_ *, PatternMatcherQueue *, uint8_t *, uint16_t); uint32_t (*Search)(struct MpmCtx_ *, struct MpmThreadCtx_ *, PatternMatcherQueue *, uint8_t *, uint16_t); void (*Cleanup)(struct MpmThreadCtx_ *); - void (*PrintCtx)(struct MpmCtx_ *); - void (*PrintThreadCtx)(struct MpmThreadCtx_ *); +// void (*PrintCtx)(struct MpmCtx_ *); +// void (*PrintThreadCtx)(struct MpmThreadCtx_ *); uint32_t memory_cnt; uint32_t memory_size; @@ -148,6 +151,7 @@ void MpmTableSetup(void); void MpmRegisterTests(void); void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher); +void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t, uint32_t); #endif /* __UTIL_MPM_H__ */