mpm: thread ctx cleanups

Remove unused thread ctx' from AC variants

Use single thread store in detection.

Minor cleanups.
pull/9816/head
Victor Julien 1 year ago committed by Victor Julien
parent 3b826fff68
commit 68a2fcaad3

@ -1998,7 +1998,7 @@ AppLayerProtoDetectThreadCtx *AppLayerProtoDetectGetCtxThread(void)
for (j = 0; j < 2; j++) {
mpm_ctx = &alpd_ctx.ctx_ipp[i].ctx_pm[j].mpm_ctx;
mpm_tctx = &alpd_tctx->mpm_tctx[i][j];
mpm_table[mpm_ctx->mpm_type].InitThreadCtx(mpm_ctx, mpm_tctx);
MpmInitThreadCtx(mpm_tctx, mpm_ctx->mpm_type);
}
}
@ -2028,7 +2028,7 @@ void AppLayerProtoDetectDestroyCtxThread(AppLayerProtoDetectThreadCtx *alpd_tctx
for (dir = 0; dir < 2; dir++) {
mpm_ctx = &alpd_ctx.ctx_ipp[ipproto_map].ctx_pm[dir].mpm_ctx;
mpm_tctx = &alpd_tctx->mpm_tctx[ipproto_map][dir];
mpm_table[mpm_ctx->mpm_type].DestroyThreadCtx(mpm_ctx, mpm_tctx);
MpmDestroyThreadCtx(mpm_tctx, mpm_ctx->mpm_type);
}
}
PmqFree(&alpd_tctx->pmq);

@ -277,7 +277,7 @@ static void FTPLocalStorageFree(void *ptr)
}
if (td->ftp_mpm_thread_ctx != NULL) {
mpm_table[FTP_MPM].DestroyThreadCtx(ftp_mpm_ctx, td->ftp_mpm_thread_ctx);
MpmDestroyThreadCtx(td->ftp_mpm_thread_ctx, FTP_MPM);
SCFree(td->ftp_mpm_thread_ctx);
}

@ -1590,7 +1590,7 @@ static void SMTPLocalStorageFree(void *ptr)
}
if (td->smtp_mpm_thread_ctx != NULL) {
mpm_table[SMTP_MPM].DestroyThreadCtx(smtp_mpm_ctx, td->smtp_mpm_thread_ctx);
MpmDestroyThreadCtx(td->smtp_mpm_thread_ctx, SMTP_MPM);
SCFree(td->smtp_mpm_thread_ctx);
}

@ -165,9 +165,8 @@ static void PrefilterTxDnsQuery(DetectEngineThreadCtx *det_ctx, const void *pect
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -126,7 +126,7 @@ static int FrameStreamDataPrefilterFunc(
// PrintRawDataFp(stdout, data, data_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, data, data_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
SCLogDebug("det_ctx->pmq.rule_id_array_cnt %u", det_ctx->pmq.rule_id_array_cnt);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}
@ -167,7 +167,7 @@ static void PrefilterMpmFrame(DetectEngineThreadCtx *det_ctx, const void *pectx,
if (data != NULL && data_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, data, data_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
SCLogDebug("det_ctx->pmq.rule_id_array_cnt %u", det_ctx->pmq.rule_id_array_cnt);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}

@ -895,8 +895,7 @@ void PatternMatchThreadPrint(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher)
void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher)
{
SCLogDebug("mpm_thread_ctx %p, mpm_matcher %"PRIu16"", mpm_thread_ctx, mpm_matcher);
if (mpm_table[mpm_matcher].DestroyThreadCtx != NULL)
mpm_table[mpm_matcher].DestroyThreadCtx(NULL, mpm_thread_ctx);
MpmDestroyThreadCtx(mpm_thread_ctx, mpm_matcher);
}
void PatternMatchThreadPrepare(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher)
{

@ -64,9 +64,8 @@ static int StreamMpmFunc(
smd->det_ctx->stream_mpm_cnt++;
smd->det_ctx->stream_mpm_size += data_len;
#endif
(void)mpm_table[smd->mpm_ctx->mpm_type].Search(smd->mpm_ctx,
&smd->det_ctx->mtcs, &smd->det_ctx->pmq,
data, data_len);
(void)mpm_table[smd->mpm_ctx->mpm_type].Search(
smd->mpm_ctx, &smd->det_ctx->mtc, &smd->det_ctx->pmq, data, data_len);
PREFILTER_PROFILING_ADD_BYTES(smd->det_ctx, data_len);
}
return 0;

@ -731,8 +731,8 @@ static void PrefilterMpm(DetectEngineThreadCtx *det_ctx, const void *pectx, Pack
//PrintRawDataFp(stdout, data, data_len);
if (data != NULL && data_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq, data, data_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}
}
@ -801,8 +801,8 @@ static void PrefilterMpmPkt(DetectEngineThreadCtx *det_ctx,
//PrintRawDataFp(stdout, data, data_len);
if (data != NULL && data_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq, data, data_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}
}

@ -3211,8 +3211,6 @@ error:
static TmEcode ThreadCtxDoInit (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx)
{
PatternMatchThreadPrepare(&det_ctx->mtc, de_ctx->mpm_matcher);
PatternMatchThreadPrepare(&det_ctx->mtcs, de_ctx->mpm_matcher);
PatternMatchThreadPrepare(&det_ctx->mtcu, de_ctx->mpm_matcher);
PmqSetup(&det_ctx->pmq);
@ -3463,8 +3461,6 @@ static void DetectEngineThreadCtxFree(DetectEngineThreadCtx *det_ctx)
/** \todo get rid of this static */
if (det_ctx->de_ctx != NULL) {
PatternMatchThreadDestroy(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher);
PatternMatchThreadDestroy(&det_ctx->mtcs, det_ctx->de_ctx->mpm_matcher);
PatternMatchThreadDestroy(&det_ctx->mtcu, det_ctx->de_ctx->mpm_matcher);
}
PmqFree(&det_ctx->pmq);
@ -3552,7 +3548,6 @@ void DetectEngineThreadCtxInfo(ThreadVars *t, DetectEngineThreadCtx *det_ctx)
{
/* XXX */
PatternMatchThreadPrint(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher);
PatternMatchThreadPrint(&det_ctx->mtcu, det_ctx->de_ctx->mpm_matcher);
}
static uint32_t DetectKeywordCtxHashFunc(HashListTable *ht, void *data, uint16_t datalen)

@ -471,8 +471,7 @@ static void PrefilterTxFiledata(DetectEngineThreadCtx *det_ctx, const void *pect
if (buffer->inspect_len >= mpm_ctx->minlen) {
uint32_t prev_rule_id_array_cnt = det_ctx->pmq.rule_id_array_cnt;
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx, &det_ctx->mtc, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);

@ -376,8 +376,7 @@ static void PrefilterTxFilemagic(DetectEngineThreadCtx *det_ctx, const void *pec
continue;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx, &det_ctx->mtc, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -313,8 +313,7 @@ static void PrefilterTxFilename(DetectEngineThreadCtx *det_ctx, const void *pect
continue;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx, &det_ctx->mtc, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -373,7 +373,7 @@ static void PrefilterTxHttpRequestBody(DetectEngineThreadCtx *det_ctx, const voi
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}
}

@ -268,8 +268,8 @@ static void PrefilterMpmHttpHeader(DetectEngineThreadCtx *det_ctx, const void *p
//PrintRawDataFp(stdout, data, data_len);
if (data != NULL && data_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq, data, data_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}
}
@ -520,7 +520,7 @@ static void PrefilterTxHttp2Header(DetectEngineThreadCtx *det_ctx, const void *p
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}
@ -658,7 +658,7 @@ static void PrefilterTxHttp1Header(DetectEngineThreadCtx *det_ctx, const void *p
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -262,8 +262,8 @@ static void PrefilterMpmHttpHeaderRaw(DetectEngineThreadCtx *det_ctx, const void
//PrintRawDataFp(stdout, data, data_len);
if (data != NULL && data_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq, data, data_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, data, data_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, data_len);
}
}

@ -687,9 +687,8 @@ static void PrefilterTxHttp2HName(DetectEngineThreadCtx *det_ctx, const void *pe
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -105,7 +105,7 @@ static void PrefilterTxIkeVendor(DetectEngineThreadCtx *det_ctx, const void *pec
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}
local_id++;

@ -157,9 +157,8 @@ static void PrefilterTxKrb5CName(DetectEngineThreadCtx *det_ctx, const void *pec
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -157,9 +157,8 @@ static void PrefilterTxKrb5SName(DetectEngineThreadCtx *det_ctx, const void *pec
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -158,9 +158,8 @@ static void PrefilterTxMQTTSubscribeTopic(DetectEngineThreadCtx *det_ctx, const
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}
local_id++;

@ -158,9 +158,8 @@ static void PrefilterTxMQTTUnsubscribeTopic(DetectEngineThreadCtx *det_ctx, cons
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}
local_id++;

@ -155,7 +155,7 @@ static void PrefilterTxQuicHash(DetectEngineThreadCtx *det_ctx, const void *pect
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -147,7 +147,7 @@ static void PrefilterTxQuicString(DetectEngineThreadCtx *det_ctx, const void *pe
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtcu, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -232,9 +232,8 @@ static void PrefilterTxTlsCerts(DetectEngineThreadCtx *det_ctx, const void *pect
break;
if (buffer->inspect_len >= mpm_ctx->minlen) {
(void)mpm_table[mpm_ctx->mpm_type].Search(mpm_ctx,
&det_ctx->mtcu, &det_ctx->pmq,
buffer->inspect, buffer->inspect_len);
(void)mpm_table[mpm_ctx->mpm_type].Search(
mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, buffer->inspect, buffer->inspect_len);
PREFILTER_PROFILING_ADD_BYTES(det_ctx, buffer->inspect_len);
}

@ -1179,12 +1179,7 @@ typedef struct DetectEngineThreadCtx_ {
SignatureNonPrefilterStore *non_pf_store_ptr;
uint32_t non_pf_store_cnt;
/** pointer to the current mpm ctx that is stored
* in a rule group head -- can be either a content
* or uricontent ctx. */
MpmThreadCtx mtc; /**< thread ctx for the mpm */
MpmThreadCtx mtcu; /**< thread ctx for uricontent mpm */
MpmThreadCtx mtcs; /**< thread ctx for stream mpm */
MpmThreadCtx mtc; /**< thread ctx for the mpm */
PrefilterRuleStore pmq;
/** SPM thread context used for scanning. This has been cloned from the

@ -63,9 +63,7 @@
#include "util-validate.h"
void SCACBSInitCtx(MpmCtx *);
void SCACBSInitThreadCtx(MpmCtx *, MpmThreadCtx *);
void SCACBSDestroyCtx(MpmCtx *);
void SCACBSDestroyThreadCtx(MpmCtx *, MpmThreadCtx *);
int SCACBSAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCACBSAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
@ -74,7 +72,6 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx);
uint32_t SCACBSSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf, uint32_t buflen);
void SCACBSPrintInfo(MpmCtx *mpm_ctx);
void SCACBSPrintSearchStats(MpmThreadCtx *mpm_thread_ctx);
void SCACBSRegisterTests(void);
/* a placeholder to denote a failure transition in the goto table */
@ -98,18 +95,13 @@ void MpmACBSRegister(void)
{
mpm_table[MPM_AC_BS].name = "ac-bs";
mpm_table[MPM_AC_BS].InitCtx = SCACBSInitCtx;
mpm_table[MPM_AC_BS].InitThreadCtx = SCACBSInitThreadCtx;
mpm_table[MPM_AC_BS].DestroyCtx = SCACBSDestroyCtx;
mpm_table[MPM_AC_BS].DestroyThreadCtx = SCACBSDestroyThreadCtx;
mpm_table[MPM_AC_BS].AddPattern = SCACBSAddPatternCS;
mpm_table[MPM_AC_BS].AddPatternNocase = SCACBSAddPatternCI;
mpm_table[MPM_AC_BS].Prepare = SCACBSPreparePatterns;
mpm_table[MPM_AC_BS].Search = SCACBSSearch;
mpm_table[MPM_AC_BS].PrintCtx = SCACBSPrintInfo;
mpm_table[MPM_AC_BS].PrintThreadCtx = SCACBSPrintSearchStats;
mpm_table[MPM_AC_BS].RegisterUnittests = SCACBSRegisterTests;
return;
}
/**
@ -948,28 +940,6 @@ error:
return -1;
}
/**
* \brief Init the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
* \param matchsize We don't need this.
*/
void SCACBSInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = SCMalloc(sizeof(SCACBSThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
exit(EXIT_FAILURE);
}
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACBSThreadCtx));
mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(SCACBSThreadCtx);
return;
}
/**
* \brief Initialize the AC context.
*
@ -1003,26 +973,6 @@ void SCACBSInitCtx(MpmCtx *mpm_ctx)
SCReturn;
}
/**
* \brief Destroy the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
*/
void SCACBSDestroyThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
SCACBSPrintSearchStats(mpm_thread_ctx);
if (mpm_thread_ctx->ctx != NULL) {
SCFree(mpm_thread_ctx->ctx);
mpm_thread_ctx->ctx = NULL;
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(SCACBSThreadCtx);
}
return;
}
/**
* \brief Destroy the mpm context.
*
@ -1356,19 +1306,6 @@ int SCACBSAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
return MpmAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags);
}
void SCACBSPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
{
#ifdef SC_AC_BS_COUNTERS
SCACBSThreadCtx *ctx = (SCACBSThreadCtx *)mpm_thread_ctx->ctx;
printf("AC Thread Search stats (ctx %p)\n", ctx);
printf("Total calls: %" PRIu32 "\n", ctx->total_calls);
printf("Total matches: %" PRIu64 "\n", ctx->total_matches);
#endif /* SC_AC_BS_COUNTERS */
return;
}
void SCACBSPrintInfo(MpmCtx *mpm_ctx)
{
SCACBSCtx *ctx = (SCACBSCtx *)mpm_ctx->ctx;
@ -1405,7 +1342,6 @@ static int SCACBSTest01(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1424,7 +1360,6 @@ static int SCACBSTest01(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1439,7 +1374,6 @@ static int SCACBSTest02(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
@ -1457,7 +1391,6 @@ static int SCACBSTest02(void)
printf("0 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1472,7 +1405,6 @@ static int SCACBSTest03(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1494,7 +1426,6 @@ static int SCACBSTest03(void)
printf("3 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1509,7 +1440,6 @@ static int SCACBSTest04(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
@ -1528,7 +1458,6 @@ static int SCACBSTest04(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1543,7 +1472,6 @@ static int SCACBSTest05(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -1562,7 +1490,6 @@ static int SCACBSTest05(void)
printf("3 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1577,7 +1504,6 @@ static int SCACBSTest06(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
@ -1594,7 +1520,6 @@ static int SCACBSTest06(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1609,7 +1534,6 @@ static int SCACBSTest07(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* should match 30 times */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0, 0);
@ -1639,7 +1563,6 @@ static int SCACBSTest07(void)
printf("135 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1654,7 +1577,6 @@ static int SCACBSTest08(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1671,7 +1593,6 @@ static int SCACBSTest08(void)
printf("0 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1686,7 +1607,6 @@ static int SCACBSTest09(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
@ -1703,7 +1623,6 @@ static int SCACBSTest09(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1718,7 +1637,6 @@ static int SCACBSTest10(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
@ -1740,7 +1658,6 @@ static int SCACBSTest10(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1755,7 +1672,6 @@ static int SCACBSTest11(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"he", 2, 0, 0, 1, 0, 0) == -1)
goto end;
@ -1786,10 +1702,9 @@ static int SCACBSTest11(void)
strlen(buf)) == 2);
end:
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
SCACBSDestroyCtx(&mpm_ctx);
PmqFree(&pmq);
return result;
}
static int SCACBSTest12(void)
@ -1802,7 +1717,6 @@ static int SCACBSTest12(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
@ -1822,7 +1736,6 @@ static int SCACBSTest12(void)
printf("2 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1837,7 +1750,6 @@ static int SCACBSTest13(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCD";
@ -1856,7 +1768,6 @@ static int SCACBSTest13(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1871,7 +1782,6 @@ static int SCACBSTest14(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDE";
@ -1890,7 +1800,6 @@ static int SCACBSTest14(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1905,7 +1814,6 @@ static int SCACBSTest15(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDEF";
@ -1924,7 +1832,6 @@ static int SCACBSTest15(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1939,7 +1846,6 @@ static int SCACBSTest16(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABC";
@ -1958,7 +1864,6 @@ static int SCACBSTest16(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1973,7 +1878,6 @@ static int SCACBSTest17(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzAB";
@ -1992,7 +1896,6 @@ static int SCACBSTest17(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2007,7 +1910,6 @@ static int SCACBSTest18(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcde"
@ -2031,7 +1933,6 @@ static int SCACBSTest18(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2046,7 +1947,6 @@ static int SCACBSTest19(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
@ -2079,7 +1979,6 @@ static int SCACBSTest20(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAA"
@ -2104,7 +2003,6 @@ static int SCACBSTest20(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2119,7 +2017,6 @@ static int SCACBSTest21(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2136,7 +2033,6 @@ static int SCACBSTest21(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2151,7 +2047,6 @@ static int SCACBSTest22(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -2171,7 +2066,6 @@ static int SCACBSTest22(void)
printf("2 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2186,7 +2080,6 @@ static int SCACBSTest23(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2203,7 +2096,6 @@ static int SCACBSTest23(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2218,7 +2110,6 @@ static int SCACBSTest24(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2235,7 +2126,6 @@ static int SCACBSTest24(void)
printf("1 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2250,7 +2140,6 @@ static int SCACBSTest25(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -2269,7 +2158,6 @@ static int SCACBSTest25(void)
printf("3 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2284,7 +2172,6 @@ static int SCACBSTest26(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
@ -2302,7 +2189,6 @@ static int SCACBSTest26(void)
printf("3 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2317,7 +2203,6 @@ static int SCACBSTest27(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
@ -2335,7 +2220,6 @@ static int SCACBSTest27(void)
printf("0 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2350,7 +2234,6 @@ static int SCACBSTest28(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
@ -2368,7 +2251,6 @@ static int SCACBSTest28(void)
printf("0 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2383,7 +2265,6 @@ static int SCACBSTest29(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_BS);
SCACBSInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdef", 5, 0, 0, 1, 0, 0);
@ -2403,7 +2284,6 @@ static int SCACBSTest29(void)
printf("3 != %" PRIu32 " ",cnt);
SCACBSDestroyCtx(&mpm_ctx);
SCACBSDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}

@ -71,11 +71,4 @@ typedef struct SCACBSCtx_ {
uint16_t single_state_size;
} SCACBSCtx;
typedef struct SCACBSThreadCtx_ {
/* the total calls we make to the search function */
uint32_t total_calls;
/* the total patterns that we ended up matching against */
uint64_t total_matches;
} SCACBSThreadCtx;
void MpmACBSRegister(void);

@ -85,9 +85,7 @@
#if __BYTE_ORDER == __LITTLE_ENDIAN
void SCACTileInitCtx(MpmCtx *);
void SCACTileInitThreadCtx(MpmCtx *, MpmThreadCtx *);
void SCACTileDestroyCtx(MpmCtx *);
void SCACTileDestroyThreadCtx(MpmCtx *, MpmThreadCtx *);
int SCACTileAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCACTileAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
@ -97,7 +95,6 @@ uint32_t SCACTileSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf,
uint32_t buflen);
void SCACTilePrintInfo(MpmCtx *mpm_ctx);
void SCACTilePrintSearchStats(MpmThreadCtx *mpm_thread_ctx);
void SCACTileRegisterTests(void);
uint32_t SCACTileSearchLarge(const SCACTileSearchCtx *ctx, MpmThreadCtx *mpm_thread_ctx,
@ -961,25 +958,6 @@ error:
return -1;
}
/**
* \brief Init the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
*/
void SCACTileInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = SCMalloc(sizeof(SCACTileThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
exit(EXIT_FAILURE);
}
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACTileThreadCtx));
mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(SCACTileThreadCtx);
}
/**
* \brief Initialize the AC context.
*
@ -1024,24 +1002,6 @@ void SCACTileInitCtx(MpmCtx *mpm_ctx)
SCACTileGetConfig();
}
/**
* \brief Destroy the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
*/
void SCACTileDestroyThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
SCACTilePrintSearchStats(mpm_thread_ctx);
if (mpm_thread_ctx->ctx != NULL) {
SCFree(mpm_thread_ctx->ctx);
mpm_thread_ctx->ctx = NULL;
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(SCACTileThreadCtx);
}
}
static void SCACTileDestroyInitCtx(MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
@ -1421,16 +1381,6 @@ int SCACTileAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
pid, sid, flags);
}
void SCACTilePrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
{
#ifdef SC_AC_TILE_COUNTERS
SCACTileThreadCtx *ctx = (SCACTileThreadCtx *)mpm_thread_ctx->ctx;
printf("AC Thread Search stats (ctx %p)\n", ctx);
printf("Total calls: %" PRIu32 "\n", ctx->total_calls);
printf("Total matches: %" PRIu64 "\n", ctx->total_matches);
#endif /* SC_AC_TILE_COUNTERS */
}
void SCACTilePrintInfo(MpmCtx *mpm_ctx)
{
SCACTileSearchCtx *search_ctx = (SCACTileSearchCtx *)mpm_ctx->ctx;
@ -1461,15 +1411,12 @@ void MpmACTileRegister(void)
{
mpm_table[MPM_AC_KS].name = "ac-ks";
mpm_table[MPM_AC_KS].InitCtx = SCACTileInitCtx;
mpm_table[MPM_AC_KS].InitThreadCtx = SCACTileInitThreadCtx;
mpm_table[MPM_AC_KS].DestroyCtx = SCACTileDestroyCtx;
mpm_table[MPM_AC_KS].DestroyThreadCtx = SCACTileDestroyThreadCtx;
mpm_table[MPM_AC_KS].AddPattern = SCACTileAddPatternCS;
mpm_table[MPM_AC_KS].AddPatternNocase = SCACTileAddPatternCI;
mpm_table[MPM_AC_KS].Prepare = SCACTilePreparePatterns;
mpm_table[MPM_AC_KS].Search = SCACTileSearch;
mpm_table[MPM_AC_KS].PrintCtx = SCACTilePrintInfo;
mpm_table[MPM_AC_KS].PrintThreadCtx = SCACTilePrintSearchStats;
mpm_table[MPM_AC_KS].RegisterUnittests = SCACTileRegisterTests;
}
@ -1489,7 +1436,6 @@ static int SCACTileTest01(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1508,7 +1454,6 @@ static int SCACTileTest01(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1523,7 +1468,6 @@ static int SCACTileTest02(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
@ -1541,7 +1485,6 @@ static int SCACTileTest02(void)
printf("0 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1556,7 +1499,6 @@ static int SCACTileTest03(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1578,7 +1520,6 @@ static int SCACTileTest03(void)
printf("3 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1593,7 +1534,6 @@ static int SCACTileTest04(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
@ -1612,7 +1552,6 @@ static int SCACTileTest04(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1627,7 +1566,6 @@ static int SCACTileTest05(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -1646,7 +1584,6 @@ static int SCACTileTest05(void)
printf("3 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1661,7 +1598,6 @@ static int SCACTileTest06(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
@ -1678,7 +1614,6 @@ static int SCACTileTest06(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1693,7 +1628,6 @@ static int SCACTileTest07(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* should match 30 times */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0, 0);
@ -1723,7 +1657,6 @@ static int SCACTileTest07(void)
printf("135 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1738,7 +1671,6 @@ static int SCACTileTest08(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1755,7 +1687,6 @@ static int SCACTileTest08(void)
printf("0 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1770,7 +1701,6 @@ static int SCACTileTest09(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
@ -1787,7 +1717,6 @@ static int SCACTileTest09(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1802,7 +1731,6 @@ static int SCACTileTest10(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
@ -1824,7 +1752,6 @@ static int SCACTileTest10(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1839,7 +1766,6 @@ static int SCACTileTest11(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"he", 2, 0, 0, 1, 0, 0) == -1)
goto end;
@ -1870,10 +1796,9 @@ static int SCACTileTest11(void)
strlen(buf)) == 2);
end:
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
SCACTileDestroyCtx(&mpm_ctx);
PmqFree(&pmq);
return result;
}
static int SCACTileTest12(void)
@ -1886,7 +1811,6 @@ static int SCACTileTest12(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
@ -1906,7 +1830,6 @@ static int SCACTileTest12(void)
printf("2 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1921,7 +1844,6 @@ static int SCACTileTest13(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCD";
@ -1940,7 +1862,6 @@ static int SCACTileTest13(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1955,7 +1876,6 @@ static int SCACTileTest14(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDE";
@ -1974,7 +1894,6 @@ static int SCACTileTest14(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1989,7 +1908,6 @@ static int SCACTileTest15(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDEF";
@ -2008,7 +1926,6 @@ static int SCACTileTest15(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2023,7 +1940,6 @@ static int SCACTileTest16(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABC";
@ -2042,7 +1958,6 @@ static int SCACTileTest16(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2057,7 +1972,6 @@ static int SCACTileTest17(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzAB";
@ -2076,7 +1990,6 @@ static int SCACTileTest17(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2091,7 +2004,6 @@ static int SCACTileTest18(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcde"
@ -2115,7 +2027,6 @@ static int SCACTileTest18(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2130,7 +2041,6 @@ static int SCACTileTest19(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
@ -2149,7 +2059,6 @@ static int SCACTileTest19(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2164,7 +2073,6 @@ static int SCACTileTest20(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAA"
@ -2189,7 +2097,6 @@ static int SCACTileTest20(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2204,7 +2111,6 @@ static int SCACTileTest21(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2221,7 +2127,6 @@ static int SCACTileTest21(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2236,7 +2141,6 @@ static int SCACTileTest22(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -2256,7 +2160,6 @@ static int SCACTileTest22(void)
printf("2 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2271,7 +2174,6 @@ static int SCACTileTest23(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2288,7 +2190,6 @@ static int SCACTileTest23(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2303,7 +2204,6 @@ static int SCACTileTest24(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2320,7 +2220,6 @@ static int SCACTileTest24(void)
printf("1 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2335,7 +2234,6 @@ static int SCACTileTest25(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -2354,7 +2252,6 @@ static int SCACTileTest25(void)
printf("3 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2369,7 +2266,6 @@ static int SCACTileTest26(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
@ -2387,7 +2283,6 @@ static int SCACTileTest26(void)
printf("3 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2402,7 +2297,6 @@ static int SCACTileTest27(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
@ -2420,7 +2314,6 @@ static int SCACTileTest27(void)
printf("0 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2435,7 +2328,6 @@ static int SCACTileTest28(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
@ -2453,7 +2345,6 @@ static int SCACTileTest28(void)
printf("0 != %" PRIu32 " ",cnt);
SCACTileDestroyCtx(&mpm_ctx);
SCACTileDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}

@ -145,14 +145,6 @@ typedef struct SCACTileSearchCtx_ {
} SCACTileSearchCtx;
typedef struct SCACTileThreadCtx_ {
/* the total calls we make to the search function */
uint32_t total_calls;
/* the total patterns that we ended up matching against */
uint64_t total_matches;
} SCACTileThreadCtx;
void MpmACTileRegister(void);
#endif /* __UTIL_MPM_AC_KS__H__ */

@ -63,9 +63,7 @@
#include "util-validate.h"
void SCACInitCtx(MpmCtx *);
void SCACInitThreadCtx(MpmCtx *, MpmThreadCtx *);
void SCACDestroyCtx(MpmCtx *);
void SCACDestroyThreadCtx(MpmCtx *, MpmThreadCtx *);
int SCACAddPatternCI(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
uint32_t, SigIntId, uint8_t);
int SCACAddPatternCS(MpmCtx *, uint8_t *, uint16_t, uint16_t, uint16_t,
@ -74,7 +72,6 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx);
uint32_t SCACSearch(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
PrefilterRuleStore *pmq, const uint8_t *buf, uint32_t buflen);
void SCACPrintInfo(MpmCtx *mpm_ctx);
void SCACPrintSearchStats(MpmThreadCtx *mpm_thread_ctx);
void SCACRegisterTests(void);
/* a placeholder to denote a failure transition in the goto table */
@ -819,28 +816,6 @@ error:
return -1;
}
/**
* \brief Init the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
* \param matchsize We don't need this.
*/
void SCACInitThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
mpm_thread_ctx->ctx = SCMalloc(sizeof(SCACThreadCtx));
if (mpm_thread_ctx->ctx == NULL) {
exit(EXIT_FAILURE);
}
memset(mpm_thread_ctx->ctx, 0, sizeof(SCACThreadCtx));
mpm_thread_ctx->memory_cnt++;
mpm_thread_ctx->memory_size += sizeof(SCACThreadCtx);
return;
}
/**
* \brief Initialize the AC context.
*
@ -874,26 +849,6 @@ void SCACInitCtx(MpmCtx *mpm_ctx)
SCReturn;
}
/**
* \brief Destroy the mpm thread context.
*
* \param mpm_ctx Pointer to the mpm context.
* \param mpm_thread_ctx Pointer to the mpm thread context.
*/
void SCACDestroyThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
{
SCACPrintSearchStats(mpm_thread_ctx);
if (mpm_thread_ctx->ctx != NULL) {
SCFree(mpm_thread_ctx->ctx);
mpm_thread_ctx->ctx = NULL;
mpm_thread_ctx->memory_cnt--;
mpm_thread_ctx->memory_size -= sizeof(SCACThreadCtx);
}
return;
}
/**
* \brief Destroy the mpm context.
*
@ -1153,19 +1108,6 @@ int SCACAddPatternCS(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen,
return MpmAddPattern(mpm_ctx, pat, patlen, offset, depth, pid, sid, flags);
}
void SCACPrintSearchStats(MpmThreadCtx *mpm_thread_ctx)
{
#ifdef SC_AC_COUNTERS
SCACThreadCtx *ctx = (SCACThreadCtx *)mpm_thread_ctx->ctx;
printf("AC Thread Search stats (ctx %p)\n", ctx);
printf("Total calls: %" PRIu32 "\n", ctx->total_calls);
printf("Total matches: %" PRIu64 "\n", ctx->total_matches);
#endif /* SC_AC_COUNTERS */
return;
}
void SCACPrintInfo(MpmCtx *mpm_ctx)
{
SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx;
@ -1197,15 +1139,12 @@ void MpmACRegister(void)
{
mpm_table[MPM_AC].name = "ac";
mpm_table[MPM_AC].InitCtx = SCACInitCtx;
mpm_table[MPM_AC].InitThreadCtx = SCACInitThreadCtx;
mpm_table[MPM_AC].DestroyCtx = SCACDestroyCtx;
mpm_table[MPM_AC].DestroyThreadCtx = SCACDestroyThreadCtx;
mpm_table[MPM_AC].AddPattern = SCACAddPatternCS;
mpm_table[MPM_AC].AddPatternNocase = SCACAddPatternCI;
mpm_table[MPM_AC].Prepare = SCACPreparePatterns;
mpm_table[MPM_AC].Search = SCACSearch;
mpm_table[MPM_AC].PrintCtx = SCACPrintInfo;
mpm_table[MPM_AC].PrintThreadCtx = SCACPrintSearchStats;
mpm_table[MPM_AC].RegisterUnittests = SCACRegisterTests;
return;
@ -1226,7 +1165,6 @@ static int SCACTest01(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1245,7 +1183,6 @@ static int SCACTest01(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1260,7 +1197,6 @@ static int SCACTest02(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0);
@ -1278,7 +1214,6 @@ static int SCACTest02(void)
printf("0 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1293,7 +1228,6 @@ static int SCACTest03(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1315,7 +1249,6 @@ static int SCACTest03(void)
printf("3 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1330,7 +1263,6 @@ static int SCACTest04(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"bcdegh", 6, 0, 0, 1, 0, 0);
@ -1349,7 +1281,6 @@ static int SCACTest04(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1364,7 +1295,6 @@ static int SCACTest05(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -1383,7 +1313,6 @@ static int SCACTest05(void)
printf("3 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1398,7 +1327,6 @@ static int SCACTest06(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
PmqSetup(&pmq);
@ -1415,7 +1343,6 @@ static int SCACTest06(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1430,7 +1357,6 @@ static int SCACTest07(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* should match 30 times */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0, 0);
@ -1460,7 +1386,6 @@ static int SCACTest07(void)
printf("135 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1475,7 +1400,6 @@ static int SCACTest08(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1492,7 +1416,6 @@ static int SCACTest08(void)
printf("0 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1507,7 +1430,6 @@ static int SCACTest09(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0);
@ -1524,7 +1446,6 @@ static int SCACTest09(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1539,7 +1460,6 @@ static int SCACTest10(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0);
@ -1561,7 +1481,6 @@ static int SCACTest10(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1576,7 +1495,6 @@ static int SCACTest11(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"he", 2, 0, 0, 1, 0, 0) == -1)
goto end;
@ -1607,10 +1525,9 @@ static int SCACTest11(void)
strlen(buf)) == 2);
end:
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
SCACDestroyCtx(&mpm_ctx);
PmqFree(&pmq);
return result;
}
static int SCACTest12(void)
@ -1623,7 +1540,6 @@ static int SCACTest12(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0);
@ -1643,7 +1559,6 @@ static int SCACTest12(void)
printf("2 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1658,7 +1573,6 @@ static int SCACTest13(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCD";
@ -1677,7 +1591,6 @@ static int SCACTest13(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1692,7 +1605,6 @@ static int SCACTest14(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDE";
@ -1711,7 +1623,6 @@ static int SCACTest14(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1726,7 +1637,6 @@ static int SCACTest15(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABCDEF";
@ -1745,7 +1655,6 @@ static int SCACTest15(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1760,7 +1669,6 @@ static int SCACTest16(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzABC";
@ -1779,7 +1687,6 @@ static int SCACTest16(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1794,7 +1701,6 @@ static int SCACTest17(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcdefghijklmnopqrstuvwxyzAB";
@ -1813,7 +1719,6 @@ static int SCACTest17(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1828,7 +1733,6 @@ static int SCACTest18(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
const char pat[] = "abcde"
@ -1852,7 +1756,6 @@ static int SCACTest18(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1867,7 +1770,6 @@ static int SCACTest19(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
@ -1886,7 +1788,6 @@ static int SCACTest19(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1901,7 +1802,6 @@ static int SCACTest20(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
const char pat[] = "AAAAA"
@ -1926,7 +1826,6 @@ static int SCACTest20(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1941,7 +1840,6 @@ static int SCACTest21(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -1958,7 +1856,6 @@ static int SCACTest21(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -1973,7 +1870,6 @@ static int SCACTest22(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
@ -1993,7 +1889,6 @@ static int SCACTest22(void)
printf("2 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2008,7 +1903,6 @@ static int SCACTest23(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2025,7 +1919,6 @@ static int SCACTest23(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2040,7 +1933,6 @@ static int SCACTest24(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 1 */
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0);
@ -2057,7 +1949,6 @@ static int SCACTest24(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2072,7 +1963,6 @@ static int SCACTest25(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"bCdEfG", 6, 0, 0, 1, 0, 0);
@ -2091,7 +1981,6 @@ static int SCACTest25(void)
printf("3 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2106,7 +1995,6 @@ static int SCACTest26(void)
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 1, 0, 0);
@ -2124,7 +2012,6 @@ static int SCACTest26(void)
printf("3 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2139,7 +2026,6 @@ static int SCACTest27(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"ONE", 3, 0, 0, 0, 0, 0);
@ -2157,7 +2043,6 @@ static int SCACTest27(void)
printf("0 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}
@ -2172,7 +2057,6 @@ static int SCACTest28(void)
memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC);
SCACInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);
/* 0 match */
MpmAddPatternCS(&mpm_ctx, (uint8_t *)"one", 3, 0, 0, 0, 0, 0);
@ -2190,7 +2074,6 @@ static int SCACTest28(void)
printf("0 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}

@ -77,13 +77,6 @@ typedef struct SCACCtx_ {
} SCACCtx;
typedef struct SCACThreadCtx_ {
/* the total calls we make to the search function */
uint32_t total_calls;
/* the total patterns that we ended up matching against */
uint64_t total_matches;
} SCACThreadCtx;
void MpmACRegister(void);
#endif /* __UTIL_MPM_AC__H__ */

@ -197,7 +197,16 @@ void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher)
{
mpm_table[matcher].InitThreadCtx(NULL, mpm_thread_ctx);
if (mpm_table[matcher].InitThreadCtx != NULL) {
mpm_table[matcher].InitThreadCtx(NULL, mpm_thread_ctx);
}
}
void MpmDestroyThreadCtx(MpmThreadCtx *mpm_thread_ctx, const uint16_t matcher)
{
if (mpm_table[matcher].DestroyThreadCtx != NULL) {
mpm_table[matcher].DestroyThreadCtx(NULL, mpm_thread_ctx);
}
}
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher)

@ -184,6 +184,7 @@ void MpmRegisterTests(void);
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher);
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t);
void MpmDestroyThreadCtx(MpmThreadCtx *mpm_thread_ctx, const uint16_t matcher);
int MpmAddPatternCS(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen,
uint16_t offset, uint16_t depth,

Loading…
Cancel
Save