mpm b2g cuda support added

remotes/origin/master-1.0.x
Anoop Saldanha 17 years ago committed by Victor Julien
parent 84df26d3fd
commit 41e6735b92

@ -117,6 +117,7 @@ util-spm-bs2bm.c util-spm-bs2bm.h \
util-spm-bm.c util-spm-bm.h \
util-mpm-wumanber.c util-mpm-wumanber.h \
util-mpm-b2g.c util-mpm-b2g.h \
util-mpm-b2g-cuda.c util-mpm-b2g-cuda.h \
util-mpm-b3g.c util-mpm-b3g.h \
util-cidr.c util-cidr.h \
util-unittest.c util-unittest.h \
@ -144,6 +145,7 @@ util-classification-config.c util-classification-config.h \
util-strlcatu.c \
util-strlcpyu.c \
util-cuda.c util-cuda.h \
util-cuda-handlers.c util-cuda-handlers.h \
tm-modules.c tm-modules.h \
tm-queues.c tm-queues.h \
tm-queuehandlers.c tm-queuehandlers.h \

@ -19,6 +19,7 @@
#include "conf.h"
#include "threads.h"
#include "tm-threads.h"
#include "threadvars.h"
#include "tm-modules.h"
#include "util-debug.h"
@ -33,6 +34,9 @@
#include "output.h"
#include "alert-fastlog.h"
#include "util-mpm-b2g-cuda.h"
#include "util-cuda-handlers.h"
#define DEFAULT_LOG_FILENAME "fast.log"
#define MODULE_NAME "AlertFastLog"
@ -306,6 +310,14 @@ int AlertFastLogTest01()
else
result = 0;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadRC();
if (SCCudaHlPushCudaContextFromModule("SC_RULES_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
@ -365,6 +377,14 @@ int AlertFastLogTest02()
result = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadRC();
if (SCCudaHlPushCudaContextFromModule("SC_RULES_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
@ -384,9 +404,19 @@ void AlertFastLogRegisterTests(void)
#ifdef UNITTESTS
#ifdef __SC_CUDA_SUPPORT__
UtRegisterTest("AlertFastLogCudaContextInit",
SCCudaHlTestEnvCudaContextInit, 1);
#endif
UtRegisterTest("AlertFastLogTest01", AlertFastLogTest01, 1);
UtRegisterTest("AlertFastLogTest02", AlertFastLogTest02, 1);
#ifdef __SC_CUDA_SUPPORT__
UtRegisterTest("AlertFastLogCudaContextDeInit",
SCCudaHlTestEnvCudaContextDeInit, 1);
#endif
#endif /* UNITTESTS */
}

@ -35,7 +35,11 @@
#include "app-layer-protos.h"
#include "app-layer-parser.h"
#include "app-layer-detect-proto.h"
#include "util-cuda.h"
#include "util-cuda-handlers.h"
#include "util-mpm-b2g-cuda.h"
#include "util-debug.h"
#define INSPECT_BYTES 32
@ -53,6 +57,8 @@ typedef struct AlpProtoDetectDirection_ {
typedef struct AlpProtoDetectCtx_ {
AlpProtoDetectDirection toserver;
AlpProtoDetectDirection toclient;
int alp_content_module_handle;
} AlpProtoDetectCtx;
static AlpProtoDetectCtx alp_proto_ctx;
@ -62,8 +68,14 @@ static AlpProtoDetectCtx alp_proto_ctx;
void AlpProtoInit(AlpProtoDetectCtx *ctx) {
memset(ctx, 0x00, sizeof(AlpProtoDetectCtx));
MpmInitCtx(&ctx->toserver.mpm_ctx, PatternMatchDefaultMatcher());
MpmInitCtx(&ctx->toclient.mpm_ctx, PatternMatchDefaultMatcher());
#ifndef __SC_CUDA_SUPPORT__
MpmInitCtx(&ctx->toserver.mpm_ctx, PatternMatchDefaultMatcher()), -1);
MpmInitCtx(&ctx->toclient.mpm_ctx, PatternMatchDefaultMatcher()), -1);
#else
ctx->alp_content_module_handle = SCCudaHlRegisterModule("SC_ALP_CONTENT_B2G_CUDA");
MpmInitCtx(&ctx->toserver.mpm_ctx, MPM_B2G_CUDA, ctx->alp_content_module_handle);
MpmInitCtx(&ctx->toclient.mpm_ctx, MPM_B2G_CUDA, ctx->alp_content_module_handle);
#endif
memset(&ctx->toserver.map, 0x00, sizeof(ctx->toserver.map));
memset(&ctx->toclient.map, 0x00, sizeof(ctx->toclient.map));
@ -165,6 +177,14 @@ void AlpProtoFinalizeGlobal(AlpProtoDetectCtx *ctx) {
mpm_table[ctx->toclient.mpm_ctx.mpm_type].Prepare(&ctx->toclient.mpm_ctx);
mpm_table[ctx->toserver.mpm_ctx.mpm_type].Prepare(&ctx->toserver.mpm_ctx);
#ifdef __SC_CUDA_SUPPORT__
CUcontext context;
if (SCCudaCtxPopCurrent(&context) == -1)
exit(EXIT_FAILURE);
if (B2gCudaStartDispatcherThreadAPC("SC_ALP_CONTENT_B2G_CUDA") == -1)
exit(EXIT_FAILURE);
#endif
/* tell the stream reassembler we only want chunks of size max_depth */
StreamMsgQueueSetMinInitChunkLen(FLOW_PKT_TOCLIENT, ctx->toclient.max_depth);
StreamMsgQueueSetMinInitChunkLen(FLOW_PKT_TOSERVER, ctx->toserver.max_depth);
@ -275,7 +295,31 @@ uint16_t AppLayerDetectGetProto(AlpProtoDetectCtx *ctx, AlpProtoDetectThreadCtx
scanlen = dir->max_depth;
uint16_t proto;
uint32_t cnt = mpm_table[dir->mpm_ctx.mpm_type].Scan(&dir->mpm_ctx, &tdir->mpm_ctx, &tdir->pmq, buf, scanlen);
uint32_t cnt;
#ifndef __SC_CUDA_SUPPORT__
cnt = mpm_table[dir->mpm_ctx.mpm_type].Scan(&dir->mpm_ctx,
&tdir->mpm_ctx,
&tdir->pmq, buf,
scanlen);
#else
Packet *p = malloc(sizeof(Packet));
if (p == NULL) goto end;
memset(p, 0, sizeof(Packet));
p->cuda_done = 0;
p->cuda_free_packet = 1;
p->cuda_search = 0;
p->cuda_mpm_ctx = &dir->mpm_ctx;
p->cuda_mtc = &tdir->mpm_ctx;
p->cuda_pmq = &tdir->pmq;
p->payload = buf;
p->payload_len = scanlen;
B2gCudaPushPacketTo_tv_CMB2_APC(p);
SCMutexLock(&p->cuda_mutex_q);
SCondWait(&p->cuda_cond_q, &p->cuda_mutex_q);
p->cuda_done = 1;
SCMutexUnlock(&p->cuda_mutex_q);
cnt = p->cuda_matches;
#endif
SCLogDebug("scan cnt %" PRIu32 "", cnt);
if (cnt == 0) {
proto = ALPROTO_UNKNOWN;
@ -481,6 +525,14 @@ int AlpDetectTest01(void) {
int r = 1;
AlpProtoDetectCtx ctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -498,6 +550,14 @@ int AlpDetectTest01(void) {
free(buf);
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -506,6 +566,14 @@ int AlpDetectTest02(void) {
int r = 1;
AlpProtoDetectCtx ctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -532,6 +600,14 @@ int AlpDetectTest02(void) {
}
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -542,6 +618,14 @@ int AlpDetectTest03(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -570,6 +654,14 @@ int AlpDetectTest03(void) {
AlpProtoFinalizeGlobal(&ctx);
AlpProtoFinalizeThread(&ctx, &tctx);
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
uint32_t cnt = mpm_table[ctx.toclient.mpm_ctx.mpm_type].Scan(&ctx.toclient.mpm_ctx, &tctx.toclient.mpm_ctx, NULL, l7data, sizeof(l7data));
if (cnt != 1) {
printf("cnt %u != 1: ", cnt);
@ -577,6 +669,14 @@ int AlpDetectTest03(void) {
}
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -587,6 +687,14 @@ int AlpDetectTest04(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -603,6 +711,14 @@ int AlpDetectTest04(void) {
AlpProtoFinalizeGlobal(&ctx);
AlpProtoFinalizeThread(&ctx, &tctx);
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
uint32_t cnt = mpm_table[ctx.toclient.mpm_ctx.mpm_type].Scan(&ctx.toclient.mpm_ctx, &tctx.toclient.mpm_ctx, NULL, l7data, sizeof(l7data));
if (cnt != 0) {
printf("cnt %u != 0: ", cnt);
@ -610,6 +726,14 @@ int AlpDetectTest04(void) {
}
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -621,6 +745,14 @@ int AlpDetectTest05(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -655,7 +787,23 @@ int AlpDetectTest05(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -666,6 +814,14 @@ int AlpDetectTest06(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -700,7 +856,23 @@ int AlpDetectTest06(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -711,6 +883,14 @@ int AlpDetectTest07(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_HTTP, buf, 4, 0, STREAM_TOCLIENT);
@ -733,7 +913,23 @@ int AlpDetectTest07(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -755,6 +951,14 @@ int AlpDetectTest08(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB, buf, 8, 4, STREAM_TOCLIENT);
@ -777,7 +981,23 @@ int AlpDetectTest08(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -796,6 +1016,14 @@ int AlpDetectTest09(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_SMB2, buf, 8, 4, STREAM_TOCLIENT);
@ -818,7 +1046,22 @@ int AlpDetectTest09(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}
@ -833,6 +1076,14 @@ int AlpDetectTest10(void) {
AlpProtoDetectCtx ctx;
AlpProtoDetectThreadCtx tctx;
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoInit(&ctx);
AlpProtoAdd(&ctx, IPPROTO_TCP, ALPROTO_DCERPC, buf, 4, 0, STREAM_TOCLIENT);
@ -855,7 +1106,23 @@ int AlpDetectTest10(void) {
r = 0;
}
#ifdef __SC_CUDA_SUPPORT__
B2gCudaKillDispatcherThreadAPC();
if (SCCudaHlPushCudaContextFromModule("SC_ALP_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
return 0;
}
#endif
AlpProtoTestDestroy(&ctx);
#ifdef __SC_CUDA_SUPPORT__
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
#endif
return r;
}

@ -34,6 +34,9 @@
#include "decode-raw.h"
#include "decode-vlan.h"
/* forward declaration */
struct DetectionEngineThreadCtx_;
/* Address */
typedef struct Address_
{
@ -317,6 +320,40 @@ typedef struct Packet_
* It should always point to the lowest
* packet in a encapsulated packet */
/* required for cuda support */
#ifdef __SC_CUDA_SUPPORT__
PatternMatcherQueue *cuda_pmq;
MpmCtx *cuda_mpm_ctx;
MpmThreadCtx *cuda_mtc;
/* this mutex corresponds to the condition variable defined below it */
SCMutex cuda_mutex_q;
/* we need this condition variable so that the cuda dispatcher thread
* can inform the client threads, when they are done with the pattern
* matching */
SCCondT cuda_cond_q;
/* used to hold the match results. We can instead use a void *result
* instead here. That way we can make them hold any result. *todo* */
uint16_t cuda_matches;
/* the client thread uses this flag to inform the dispatcher that it
* has woken up and has retrieved the results and that the dispatcher
* can now continue its operations */
uint8_t cuda_done;
/* indicates if the dispatcher should call the search or the scan phase
* of the pattern matcher. We can instead use a void *cuda_data instead.
* This way we can send any data across to the dispatcher */
uint8_t cuda_search;
/* indicates if the dispatcher should free this packet it has received.
* For some modules which don't send a packet to the dispatcher, we will
* have to create dummy Packets, fill them with data and send them over
* to the dispatcher. The callling thread can't free the Packet once
* it gets the results, since the dispatcher might still be accessing
* the final stages of the packets. Instead we make the dispatcher
* free the packet, if we want the packet to be destoryed after it has
* been used. A probable *todo* would be using a static Packet, in the
* the modules that requires a dummy Packet. That way we are not forced
* to create a new Packet every time using the expensive malloc() */
uint8_t cuda_free_packet;
#endif
} Packet;
typedef struct PacketQueue_ {

@ -17,13 +17,19 @@
#include "detect-content.h"
#include "detect-uricontent.h"
#include "util-mpm-b2g-cuda.h"
#include "util-debug.h"
/** \todo make it possible to use multiple pattern matcher algorithms next to
eachother. */
//#define PM MPM_WUMANBER
//#define PM MPM_B2G
#ifdef __SC_CUDA_SUPPORT__
#define PM MPM_B2G_CUDA
#else
#define PM MPM_B2G
#endif
//#define PM MPM_B3G
/** \brief Function to return the default multi pattern matcher algorithm to be
@ -58,14 +64,31 @@ uint32_t PacketPatternScan(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
Packet *p)
{
SCEnter();
uint32_t ret;
det_ctx->pmq.mode = PMQ_MODE_SCAN;
ret = mpm_table[det_ctx->sgh->mpm_ctx->mpm_type].Scan
(det_ctx->sgh->mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, p->payload,
p->payload_len);
#ifndef __SC_CUDA_SUPPORT__
uint32_t ret;
ret = mpm_table[det_ctx->sgh->mpm_ctx->mpm_type].Scan(det_ctx->sgh->mpm_ctx,
&det_ctx->mtc,
&det_ctx->pmq,
p->payload,
p->payload_len);
SCReturnInt(ret);
#else
p->cuda_done = 0;
p->cuda_search = 0;
p->cuda_free_packet = 0;
p->cuda_mpm_ctx = det_ctx->sgh->mpm_ctx;
p->cuda_mtc = &det_ctx->mtc;
p->cuda_pmq = &det_ctx->pmq;
B2gCudaPushPacketTo_tv_CMB2_RC(p);
SCMutexLock(&p->cuda_mutex_q);
SCondWait(&p->cuda_cond_q, &p->cuda_mutex_q);
p->cuda_done = 1;
SCMutexUnlock(&p->cuda_mutex_q);
SCReturnInt(p->cuda_matches);
#endif
}
/** \brief Uri Pattern match, scan part -- searches for only 'scan' patterns,
@ -78,14 +101,32 @@ uint32_t UriPatternScan(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
uint8_t *uri, uint16_t uri_len)
{
SCEnter();
uint32_t ret;
det_ctx->pmq.mode = PMQ_MODE_SCAN;
#ifndef __SC_CUDA_SUPPORT__
uint32_t ret;
ret = mpm_table[det_ctx->sgh->mpm_uri_ctx->mpm_type].Scan
(det_ctx->sgh->mpm_uri_ctx, &det_ctx->mtcu, &det_ctx->pmq,
uri, uri_len);
SCReturnInt(ret);
#else
Packet *p = malloc(sizeof(Packet));
memset(p, 0, sizeof(Packet));
p->cuda_done = 0;
p->cuda_free_packet = 1;
p->cuda_search = 0;
p->cuda_mpm_ctx = det_ctx->sgh->mpm_uri_ctx;
p->cuda_mtc = &det_ctx->mtcu;
p->cuda_pmq = &det_ctx->pmq;
p->payload = uri;
p->payload_len = uri_len;
B2gCudaPushPacketTo_tv_CMB2_RC(p);
SCMutexLock(&p->cuda_mutex_q);
SCondWait(&p->cuda_cond_q, &p->cuda_mutex_q);
p->cuda_done = 1;
SCMutexUnlock(&p->cuda_mutex_q);
SCReturnInt(p->cuda_matches);
#endif
}
/** \brief Pattern match, search part -- searches for all other patterns
@ -97,14 +138,30 @@ uint32_t PacketPatternMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
Packet *p)
{
SCEnter();
uint32_t ret;
det_ctx->pmq.mode = PMQ_MODE_SEARCH;
ret = mpm_table[det_ctx->sgh->mpm_ctx->mpm_type].Search
(det_ctx->sgh->mpm_ctx, &det_ctx->mtc, &det_ctx->pmq, p->payload,
p->payload_len);
#ifndef __SC_CUDA_SUPPORT__
uint32_t ret;
ret = mpm_table[det_ctx->sgh->mpm_ctx->mpm_type].Search(det_ctx->sgh->mpm_ctx,
&det_ctx->mtc,
&det_ctx->pmq,
p->payload,
p->payload_len);
SCReturnInt(ret);
#else
p->cuda_done = 0;
p->cuda_search = 1;
p->cuda_free_packet = 0;
p->cuda_mpm_ctx = det_ctx->sgh->mpm_ctx;
p->cuda_mtc = &det_ctx->mtc;
p->cuda_pmq = &det_ctx->pmq;
B2gCudaPushPacketTo_tv_CMB2_RC(p);
SCMutexLock(&p->cuda_mutex_q);
SCondWait(&p->cuda_cond_q, &p->cuda_mutex_q);
p->cuda_done = 1;
SCMutexUnlock(&p->cuda_mutex_q);
SCReturnInt(p->cuda_matches);
#endif
}
/** \brief Uri Pattern match, search part -- searches for all other patterns
@ -116,14 +173,32 @@ uint32_t UriPatternMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
uint8_t *uri, uint16_t uri_len)
{
SCEnter();
uint32_t ret;
det_ctx->pmq.mode = PMQ_MODE_SEARCH;
#ifndef __SC_CUDA_SUPPORT__
uint32_t ret;
ret = mpm_table[det_ctx->sgh->mpm_uri_ctx->mpm_type].Search
(det_ctx->sgh->mpm_uri_ctx, &det_ctx->mtcu, &det_ctx->pmq, uri,
uri_len);
SCReturnInt(ret);
#else
Packet *p = malloc(sizeof(Packet));
memset(p, 0, sizeof(Packet));
p->cuda_done = 0;
p->cuda_free_packet = 1;
p->cuda_search = 1;
p->cuda_mpm_ctx = det_ctx->sgh->mpm_uri_ctx;
p->cuda_mtc = &det_ctx->mtcu;
p->cuda_pmq = &det_ctx->pmq;
B2gCudaPushPacketTo_tv_CMB2_RC(p);
SCMutexLock(&p->cuda_mutex_q);
SCondWait(&p->cuda_cond_q, &p->cuda_mutex_q);
p->cuda_done = 1;
SCMutexUnlock(&p->cuda_mutex_q);
SCReturnInt(p->cuda_matches);
#endif
//printf("PacketPatternMatch: ret %" PRIu32 "\n", ret);
}
/** \brief cleans up the mpm instance after a match */
@ -150,7 +225,7 @@ void PatternMatchDestroy(MpmCtx *mpm_ctx, uint16_t mpm_matcher) {
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);
MpmInitCtx(mpm_ctx, mpm_matcher, -1);
}
void PatternMatchThreadPrint(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher) {
@ -621,7 +696,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
goto error;
memset(sh->mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(sh->mpm_ctx, de_ctx->mpm_matcher);
#ifndef __SC_CUDA_SUPPORT__
MpmInitCtx(sh->mpm_ctx, de_ctx->mpm_matcher, -1);
#else
MpmInitCtx(sh->mpm_ctx, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle);
#endif
}
if (sh->flags & SIG_GROUP_HAVEURICONTENT && !(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) {
sh->mpm_uri_ctx = malloc(sizeof(MpmCtx));
@ -629,7 +708,11 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
goto error;
memset(sh->mpm_uri_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(sh->mpm_uri_ctx, de_ctx->mpm_matcher);
#ifndef __SC_CUDA_SUPPORT__
MpmInitCtx(sh->mpm_uri_ctx, de_ctx->mpm_matcher, -1);
#else
MpmInitCtx(sh->mpm_uri_ctx, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle);
#endif
}
uint32_t mpm_content_cnt = 0, mpm_uricontent_cnt = 0;

@ -102,6 +102,10 @@
#include "util-debug.h"
#include "util-hashlist.h"
#include "util-cuda-handlers.h"
#include "util-mpm-b2g-cuda.h"
#include "util-cuda.h"
SigMatch *SigMatchAlloc(void);
void SigMatchFree(SigMatch *sm);
void DetectExitPrintStats(ThreadVars *tv, void *data);
@ -2823,7 +2827,29 @@ int SigAddressPrepareStage5(DetectEngineCtx *de_ctx) {
int SigGroupBuild (DetectEngineCtx *de_ctx) {
SigAddressPrepareStage1(de_ctx);
SigAddressPrepareStage2(de_ctx);
#ifdef __SC_CUDA_SUPPORT__
/* we register a module that would require cuda handler service. This
* module would hold the context for all the patterns in the rules */
de_ctx->cuda_rc_mod_handle = SCCudaHlRegisterModule("SC_RULES_CONTENT_B2G_CUDA");
#endif
SigAddressPrepareStage3(de_ctx);
#ifdef __SC_CUDA_SUPPORT__
/* the AddressPrepareStage3 actually handles the creation of device pointers
* on the gpu. The cuda context that stage3 used would still be attached to
* this host thread. We need to pop this cuda context so that the dispatcher
* thread that we are going to create for the above module we registered
* can attach to this cuda context */
CUcontext context;
if (SCCudaCtxPopCurrent(&context) == -1)
exit(EXIT_FAILURE);
/* start the dispatcher thread for this module */
if (B2gCudaStartDispatcherThreadRC("SC_RULES_CONTENT_B2G_CUDA") == -1)
exit(EXIT_FAILURE);
#endif
// SigAddressPrepareStage5(de_ctx);
DbgPrintScanSearchStats();
// DetectAddressPrintMemory();

@ -292,6 +292,13 @@ typedef struct DetectEngineCtx_ {
ThresholdCtx ths_ctx;
uint16_t mpm_matcher; /**< mpm matcher this ctx uses */
#ifdef __SC_CUDA_SUPPORT__
/* cuda rules content module handle. Holds the handler serivice's
* (util-cuda-handler.c) handle for a module. This module would
* hold the cuda context for all the rules content */
int cuda_rc_mod_handle;
#endif
} DetectEngineCtx;
/**

@ -7,6 +7,8 @@
#ifndef __SURICATA_COMMON_H__
#define __SURICATA_COMMON_H__
//#define __SC_CUDA_SUPPORT__
#define TRUE 1
#define FALSE 0

@ -95,6 +95,9 @@
#include "util-daemon.h"
#include "reputation.h"
/* holds the cuda b2g module */
#include "util-mpm-b2g-cuda.h"
#include "output.h"
/*
@ -623,16 +626,6 @@ int main(int argc, char **argv)
SCPerfInitCounterApi();
SCReputationInitCtx();
/** \todo we need an api for these */
AppLayerDetectProtoThreadInit();
RegisterAppLayerParsers();
RegisterHTPParsers();
RegisterTLSParsers();
RegisterSMBParsers();
RegisterDCERPCParsers();
RegisterFTPParsers();
AppLayerParsersInitPostProcess();
TmModuleReceiveNFQRegister();
TmModuleVerdictNFQRegister();
TmModuleDecodeNFQRegister();
@ -659,8 +652,21 @@ int main(int argc, char **argv)
TmModuleLogHttpLogRegister();
TmModuleLogHttpLogIPv4Register();
TmModuleLogHttpLogIPv6Register();
#ifdef __SC_CUDA_SUPPORT__
TmModuleCudaMpmB2gRegister();
#endif
TmModuleDebugList();
/** \todo we need an api for these */
AppLayerDetectProtoThreadInit();
RegisterAppLayerParsers();
RegisterHTPParsers();
RegisterTLSParsers();
RegisterSMBParsers();
RegisterDCERPCParsers();
RegisterFTPParsers();
AppLayerParsersInitPostProcess();
#ifdef UNITTESTS
if (run_mode == MODE_UNITTEST) {
/* test and initialize the unittesting subsystem */

@ -50,6 +50,9 @@ enum {
TMM_DECODEIPFW,
TMM_VERDICTIPFW,
TMM_RECEIVEIPFW,
#ifdef __SC_CUDA_SUPPORT__
TMM_CUDA_MPM_B2G,
#endif
TMM_SIZE,
};

@ -862,6 +862,91 @@ void TmThreadAppend(ThreadVars *tv, int type)
//printf("TmThreadAppend: thread \'%s\' is added to the list.\n", tv->name);
}
/**
* \brief Removes this TV from tv_root based on its type
*
* \param tv The tv instance to remove from the global tv list.
* \param type Holds the type this TV belongs to.
*/
void TmThreadRemove(ThreadVars *tv, int type)
{
SCMutexLock(&tv_root_lock);
if (tv_root[type] == NULL) {
SCMutexUnlock(&tv_root_lock);
return;
}
ThreadVars *t = tv_root[type];
while (t != tv) {
t = t->next;
}
if (t != NULL) {
if (t->prev != NULL)
t->prev->next = t->next;
if (t->next != NULL)
t->next->prev = t->prev;
if (t == tv_root[type])
tv_root[type] = t->next;;
}
SCMutexUnlock(&tv_root_lock);
return;
}
/**
* \brief Kill a thread.
*
* \param tv A ThreadVars instance corresponding to the thread that has to be
* killed.
*/
void TmThreadKillThread(ThreadVars *tv)
{
int i = 0;
if (tv == NULL)
return;
/* set the thread flag informing the thread that it needs to be
* terminated */
TmThreadsSetFlag(tv, THV_KILL);
if (tv->inq != NULL) {
/* signal the queue for the number of users */
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++)
SCCondSignal(&trans_q[tv->inq->id].cond_q);
/* to be sure, signal more */
while (1) {
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
break;
}
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++)
SCCondSignal(&trans_q[tv->inq->id].cond_q);
usleep(100);
}
}
if (tv->cond != NULL ) {
while (1) {
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
break;
}
pthread_cond_broadcast(tv->cond);
usleep(100);
}
}
return;
}
void TmThreadKillThreads(void) {
ThreadVars *tv = NULL;
int i = 0;

@ -15,54 +15,35 @@ extern ThreadVars *tv_root[TVT_MAX];
extern SCMutex tv_root_lock;
void Tm1SlotSetFunc(ThreadVars *, TmModule *, void *);
void TmVarSlotSetFuncAppend(ThreadVars *, TmModule *, void *);
ThreadVars *TmThreadCreate(char *, char *, char *, char *, char *, char *,
void *(fn_p)(void *), int);
ThreadVars *TmThreadCreatePacketHandler(char *, char *, char *, char *, char *,
char *);
ThreadVars *TmThreadCreateMgmtThread(char *name, void *(fn_p)(void *), int);
TmEcode TmThreadSpawn(ThreadVars *);
void TmThreadSetFlags(ThreadVars *, uint8_t);
void TmThreadSetAOF(ThreadVars *, uint8_t);
void TmThreadKillThread(ThreadVars *);
void TmThreadKillThreads(void);
void TmThreadAppend(ThreadVars *, int);
void TmThreadRemove(ThreadVars *, int);
TmEcode TmThreadSetCPUAffinity(ThreadVars *, uint16_t);
TmEcode TmThreadSetThreadPriority(ThreadVars *, int);
TmEcode TmThreadSetupOptions(ThreadVars *);
void TmThreadPrioSummary(char *);
void TmThreadInitMC(ThreadVars *);
void TmThreadTestThreadUnPaused(ThreadVars *);
void TmThreadContinue(ThreadVars *);
void TmThreadContinueThreads(void);
void TmThreadPause(ThreadVars *);
void TmThreadPauseThreads(void);
void TmThreadCheckThreadState(void);
TmEcode TmThreadWaitOnThreadInit(void);
inline int TmThreadsCheckFlag(ThreadVars *, uint8_t);
inline void TmThreadsSetFlag(ThreadVars *, uint8_t);
ThreadVars *TmThreadsGetCallingThread(void);
#endif /* __TM_THREADS_H__ */

@ -0,0 +1,631 @@
/**
* Copyright (c) 2010 Open Information Security Foundation.
*
* \author Anoop Saldanha <poonaatsoc@gmail.com>
*
* \file Provides cuda utility functions.
*
* A module in the engine that wants to use the cuda engine, might need
* some utilities to handle contexts, modules and device_pointers.
*
* Let us say we have a module that needs to share a context among various
* sections inside it. To enable it share contexts within various
* sections the module first register itself using the function
* SCCudaHlRegisterModule() and receive a unique handle. Once it has
* retrieved the unique handle, it can then call SCCudaHlGetCudaContext(),
* with the handle. A new cuda context would be created and the internal
* data structures would be updated to associate this newly created
* context with this module handle. Any future calls to
* SCCudaHlGetCudaContext() with the same handle will return the
* cuda_context, which has already been created and associated with the
* handle. Any calls to SCCudaHlGetCudaContext() with a new handle,
* would result in the creation of a new cuda context.
*
* Similarly if we want to create a new cuda_module against a particular
* context, we can call SCCudaHlGetCudaModule() with the handle and it
* should work as above. Please do note that a cuda module can't be
* created against a handle using SCCudaHlGetCudaModule(), unless
* a cuda_context has been associated with the handle by a previous call
* to SCCudaHlGetCudaContext(). Also do note that, a cuda module is
* created against a cuda context that is associated with the current
* host thread. So do takecare to associate your host thread with the
* cuda_context that is associated with the handle, against which you
* want to call SCCudaHlGetCudaModule().
*
* \todo Provide support for multiple cuda context storage and creating multiple
* cuda modules against a cuda_context, although it is highly unlikely we
* would need this feature.
*
* We also need to use a mutex for module_datas.
*/
#include "suricata-common.h"
#include "suricata.h"
#include "detect.h"
#include "decode.h"
#include "util-cuda.h"
#include "util-cuda-handlers.h"
#include "util-error.h"
#include "util-debug.h"
#include "util-unittest.h"
#include "packet-queue.h"
/* macros decides if cuda is enabled for the platform or not */
#ifdef __SC_CUDA_SUPPORT__
static SCCudaHlModuleData *module_datas = NULL;
static uint8_t module_handle = 1;
/**
* \internal
* \brief Returns a SCCudaHlModuleData instance from the global data store
* that matches the handle sent as arg.
*
* \param handle The handle for the SCCudaHlModuleData that has to be returned.
*
* \retval data The SCCudaHlModuleData instance that matches the handle.
*/
SCCudaHlModuleData *SCCudaHlGetModuleData(uint8_t handle)
{
SCCudaHlModuleData *data = module_datas;
if (data == NULL)
return NULL;
while (data != NULL && data->handle != handle) {
data = data->next;
}
return data;
}
/**
* \internal
* \brief Get a unique handle for a new module registration. This new handle
* returned uniquely represents a module. All future calls to functions
* requires suppling this handle.
*
* \param module_handle A unique module handle that needs to used to refer
* to data(like cuda_contexts, cuda_modules, device pointers).
*/
static int SCCudaHlGetUniqueHandle(void)
{
return module_handle++;
}
/**
* \brief Returns a cuda context against the handle in the argument.
*
* If a cuda_context is not present for a handle, it is created
* and associated with this handle and the context is returned
* in the argument. If a cuda_context is already present for
* a handle, it is returned.
*
* \param p_context Pointer to a cuda context instance that should be updated
* with a cuda context.
* \param handle A unique handle which identifies a module. Obtained from
* a call to SCCudaHlGetUniqueHandle().
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlGetCudaContext(CUcontext *p_context, int handle)
{
SCCudaHlModuleData *data = NULL;
SCCudaDevices *devices = NULL;
if (p_context == NULL) {
SCLogError(SC_INVALID_ARGUMENTS, "Error invalid arguments. "
"p_context NULL");
return -1;
}
/* check if the particular module that wants a CUDA context
* is already registered or not. If it is not registered
* log a warning and get out of here */
if ( (data = SCCudaHlGetModuleData(handle)) == NULL) {
SCLogDebug("Module not registered. You can't create a CUDA context "
"without registering a module first. To use this "
"registration facility, first register a module using "
"SCCudaHlRegisterModule(), and then register "
"a cuda context with that module hanle using "
"SCCudaHlGetCudaContext(), after which you can call this "
"function ");
return -1;
}
if (data->cuda_context != 0) {
p_context[0] = data->cuda_context;
return 0;
}
/* Get the device list for this CUDA platform and create a new cuda context */
devices = SCCudaGetDeviceList();
if (SCCudaCtxCreate(p_context, 0, devices->devices[0]->device) == -1)
goto error;
data->cuda_context = p_context[0];
return 0;
error:
return -1;
}
/**
* \brief Returns a cuda_module against the handle in the argument.
*
* If a cuda_module is not present for a handle, it is created
* and associated with this handle and the cuda_module is returned
* in the argument. If a cuda_module is already present for
* a handle, it is returned.
*
* \param p_context Pointer to a cuda context instance that should be updated
* with a cuda context.
* \param handle A unique handle which identifies a module. Obtained from
* a call to SCCudaHlGetUniqueHandle().
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlGetCudaModule(CUmodule *p_module, const char *ptx_image, int handle)
{
SCCudaHlModuleData *data = NULL;
if (p_module == NULL) {
SCLogError(SC_INVALID_ARGUMENTS, "Error invalid arguments"
"p_module NULL");
return -1;
}
/* check if the particular module that wants a CUDA module is already
* registered or not. If it is registered, check if a context has
* been associated with the module. If yes, then we can go ahead and
* create a cuda module or return the reference to the cuda module if
* we already have a cuda module associated with the module. If no, "
* log warning and get out of here */
if ( ((data = SCCudaHlGetModuleData(handle)) == NULL) ||
(data->cuda_context == 0)) {
SCLogDebug("Module not registered or no cuda context associated with "
"this module. You can't create a CUDA module without"
"associatin a context with a module first. To use this "
"registration facility, first register a module using "
"context using SCCudaHlRegisterModule(), and then register "
"a cuda context with that module using "
"SCCudaHlGetCudaContext(), after which you can call this "
"function ");
return -1;
}
/* we already have a cuda module associated with this module. Return the
* cuda module */
if (data->cuda_module != 0) {
p_module[0] = data->cuda_module;
return 0;
}
/* we don't have a cuda module associated with this module. Create a
* cuda module, update the module with this cuda module reference and
* then return the module refernce back to the calling function using
* the argument */
if (SCCudaModuleLoadData(p_module, (void *)ptx_image) == -1)
goto error;
data->cuda_module = p_module[0];
return 0;
error:
return -1;
}
/**
* \brief Verify if a device pointer by a particular name is registered under
* a module. If it is registered, return this device pointer instance
* back; else return NULL.
*
* \param data Pointer to the module SCCudaHlModuleData instance which has to
* checked for the registration of the device pointer.
* \param name Name of the device pointer to search in the module.
*
* \retval module_device_ptr Pointer to the device pointer instance on finding
* it; NULL otherwise.
*/
SCCudaHlModuleDevicePointer *SCCudaHlCudaDevicePtrAvailable(SCCudaHlModuleData *data,
const char *name)
{
SCCudaHlModuleDevicePointer *module_device_ptr = data->device_ptrs;
while (module_device_ptr != NULL &&
strcmp(module_device_ptr->name, name) != 0) {
module_device_ptr = module_device_ptr->next;
}
return module_device_ptr;
}
/**
* \brief Returns a cuda_device_pointer against the handle in the argument.
*
* If a device pointer by the name \"name\" is not registered for the
* handle, it is created and associated with this handle and cuda mem is
* alloted and the cuda_device_pointer is returned in the argument.
* If a device pointer by the name \"name\" is already registered with
* the handle, the cuda_device_pointer is returned in the argument.
*
* \param device_ptr Pointer to the device pointer instance which should be
* with the cuda_device_pointer that has to be returned back.
* \param name Name of the device pointer by which we have to search
* module for its existance.
* \param size Size of the cuda device memory to be alloted.
* \param host_ptr If any host memory has to be transferred to the cuda device
* memory, it can sent using this argument. host_ptr should
* hold atleast size bytes in memory.
* \param handle A unique handle which identifies a module. Obtained from
* a call to SCCudaHlGetUniqueHandle().
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlGetCudaDevicePtr(CUdeviceptr *device_ptr, const char *name,
size_t size, void *host_ptr, int handle)
{
SCCudaHlModuleData *data = NULL;
SCCudaHlModuleDevicePointer *new_module_device_ptr = NULL;
SCCudaHlModuleDevicePointer *module_device_ptr = NULL;
if (device_ptr == NULL || name == NULL) {
SCLogError(SC_INVALID_ARGUMENTS, "Error invalid arguments"
"device_ptr is NULL or name is NULL");
goto error;
}
/* check if the particular module that wants to allocate device memory is
* already registered or not. If it is registered, check if a context has
* been associated with the module. If yes, then we can go ahead and
* create the device memory or return the reference to the device memory if
* we already have the device memory associated with the module. If no, "
* log warning and get out of here */
if ( ((data = SCCudaHlGetModuleData(handle)) == NULL) ||
(data->cuda_context == 0)) {
SCLogDebug("Module not registered or no cuda context associated with "
"this module. You can't create a CUDA module without"
"associatin a context with a module first. To use this "
"registration facility, first register a module using "
"context using SCCudaHlRegisterModule(), and then register "
"a cuda context with that module using "
"SCCudaHlGetCudaContext(), after which you can call this "
"function ");
goto error;
}
/* if we already have a device pointer registered by this name return the
* cuda device pointer instance */
if ( (module_device_ptr = SCCudaHlCudaDevicePtrAvailable(data, name)) != NULL) {
device_ptr[0] = module_device_ptr->d_ptr;
return 0;
}
new_module_device_ptr = malloc(sizeof(SCCudaHlModuleDevicePointer));
if (new_module_device_ptr == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(new_module_device_ptr, 0, sizeof(SCCudaHlModuleDevicePointer));
if ( (new_module_device_ptr->name = strdup(name)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* allocate the cuda memory */
if (SCCudaMemAlloc(&new_module_device_ptr->d_ptr, size) == -1)
goto error;
/* if the user has supplied a host buffer, copy contents to the device mem */
if (host_ptr != NULL) {
if (SCCudaMemcpyHtoD(new_module_device_ptr->d_ptr, host_ptr,
size) == -1) {
goto error;
}
}
/* insert it into the device_ptr list for the module instance */
if (data->device_ptrs == NULL) {
data->device_ptrs = new_module_device_ptr;
device_ptr[0] = new_module_device_ptr->d_ptr;
return 0;
}
module_device_ptr = data->device_ptrs;
while (module_device_ptr->next != NULL)
module_device_ptr = module_device_ptr->next;
module_device_ptr->next = new_module_device_ptr;
return 0;
error:
if (new_module_device_ptr != NULL)
free(new_module_device_ptr);
return -1;
}
/**
* \brief Registers a Dispatcher function against this handle.
*
* \param SCCudaHlDispFunc Pointer to a dispatcher function to be registered
* for this handle.
* \param handle A unique handle which identifies a module. Obtained
* from a call to SCCudaHlGetUniqueHandle().
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlRegisterDispatcherFunc(void *(*SCCudaHlDispFunc)(void *), int handle)
{
SCCudaHlModuleData *data = NULL;
if (SCCudaHlDispFunc == NULL) {
SCLogError(SC_INVALID_ARGUMENTS, "Error invalid arguments"
"SCCudaHlDispFunc NULL");
return -1;
}
if ( (data = SCCudaHlGetModuleData(handle)) == NULL) {
SCLogDebug("Module not registered. To avail the benefits of this "
"registration facility, first register a module using "
"context using SCCudaHlRegisterModule(), after which you "
"can call this function");
return -1;
}
data->SCCudaHlDispFunc = SCCudaHlDispFunc;
return 0;
}
/**
* \brief Get the name of the module associated with the module whose handle is
* sent as the arg.
*
* \param handle The handle of the module which has to be searched.
*
* \retval data->name The name of the module on finding a module that matches
* the handle sent as argument; NULL on failure.
*/
const char *SCCudaHlGetModuleName(int handle)
{
SCCudaHlModuleData *data = module_datas;
while (data != NULL && data->handle != handle) {
data = data->next;
}
if (data == NULL)
return NULL;
return data->name;
}
/**
* \brief Get the handle associated with this module who name is sent as the arg.
*
* \param name The name of the module which has to be searched.
*
* \retval data->handle The handle to the module on finding a module that
* matches the name sent as argument; -1 on failure.
*/
int SCCudaHlGetModuleHandle(const char *name)
{
SCCudaHlModuleData *data = module_datas;
while (data != NULL &&
strcmp(data->name, name) != 0) {
data = data->next;
}
if (data == NULL)
return -1;
return data->handle;
}
/**
* \brief Register a new module. To understand what exactly these utilities are
* needed for please look at the file comments.
*
* \param name A unique name to register the module with. No module should have
* registered itself previously with this name.
*
* \retval handle A unique handle that is associated with this module and all
* future use of API would require supplying this handle.
*/
int SCCudaHlRegisterModule(const char *name)
{
SCCudaHlModuleData *data = module_datas;
SCCudaHlModuleData *new_data = NULL;
while (data != NULL &&
strcmp(data->name, name) != 0) {
data = data->next;
}
if (data != NULL) {
SCLogError(SC_ERR_CUDA_HANDLER_ERROR, "Module \"%s\" already "
"registered. Returning the handle for the already "
"registered module", name);
return data->handle;
}
/* the module is not already registered. Register the module */
new_data = malloc(sizeof(SCCudaHlModuleData));
if (new_data == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
memset(new_data, 0, sizeof(SCCudaHlModuleData));
if ( (new_data->name = strdup(name)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
new_data->handle = SCCudaHlGetUniqueHandle();
/* first module to be registered */
if (module_datas == NULL) {
module_datas = new_data;
return new_data->handle;
}
/* add this new module_data instance to the global module_data list */
data = module_datas;
while (data->next != NULL)
data = data->next;
data->next = new_data;
return new_data->handle;
}
/**
* \brief DeRegister a registered module.
*
* \param name Name of the module to deregister.
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlDeRegisterModule(const char *name)
{
SCCudaHlModuleData *data = NULL;
SCCudaHlModuleData *prev_data = NULL;
SCCudaHlModuleDevicePointer *device_ptr = NULL;
SCCudaHlModuleDevicePointer *temp_device_ptr = NULL;
int module_handle = SCCudaHlGetModuleHandle(name);
/* get the module */
data = (module_handle == -1) ? NULL : SCCudaHlGetModuleData(module_handle);
/* a module by this name doesn't exist. Log Error and return */
if (data == NULL) {
SCLogError(SC_ERR_CUDA_HANDLER_ERROR, "Module \"%s\" not "
"registered", name);
return -1;
}
/* looks like we do have a module registered by this name */
/* first clean the cuda device pointers */
device_ptr = data->device_ptrs;
while (device_ptr != NULL) {
temp_device_ptr = device_ptr;
device_ptr = device_ptr->next;
if (SCCudaMemFree(temp_device_ptr->d_ptr) == -1)
goto error;
free(temp_device_ptr->name);
free(temp_device_ptr);
}
data->device_ptrs = NULL;
/* clean the dispatcher function registered */
data->SCCudaHlDispFunc = NULL;
/* unload the cuda module */
if (data->cuda_module != 0) {
if (SCCudaModuleUnload(data->cuda_module) == -1)
goto error;
}
/* destroy the cuda context */
if (data->cuda_context != 0) {
if (SCCudaCtxDestroy(data->cuda_context) == -1)
goto error;
}
/* find the previous module data instance */
if (module_datas == data) {
module_datas = module_datas->next;
} else {
prev_data = module_datas;
while (prev_data->next != data)
prev_data = prev_data->next;
prev_data->next = data->next;
}
/* delete the module data instance */
free(data);
/* mission accomplished. let's go */
return 0;
error:
return -1;
}
/**
* \brief Pushes a cuda context for the calling thread.
*
* Before calling this function make sure that the cuda context belonging
* to the registered module, is floating(not attached to any host thread).
*
* \param name Name of the registered module whose cuda context has to be
* pushed for the calling thread.
*
* \retval 0 On success.
* \retval -1 On failure.
*/
int SCCudaHlPushCudaContextFromModule(const char *name)
{
SCCudaHlModuleData *data = SCCudaHlGetModuleData(SCCudaHlGetModuleHandle(name));
if (data == NULL) {
SCLogError(SC_ERR_CUDA_HANDLER_ERROR, "No module registered by the "
"name \"%s\"", name);
return -1;
}
if (SCCudaCtxPushCurrent(data->cuda_context) == -1) {
SCLogError(SC_ERR_CUDA_HANDLER_ERROR, "Error pushing cuda context from "
"module \"%s\" for this calling thread\n", name);
return -1;
}
return 0;
}
/**
* \brief Used for testing purposes. Running tests with cuda enabled
* requires some hacks, which is what this function does.
*
* \retval 1 Always.
*/
int SCCudaHlTestEnvCudaContextInit(void)
{
CUcontext context;
int module_handle = SCCudaHlRegisterModule("SC_RULES_CONTENT_B2G_CUDA");
if (SCCudaHlGetCudaContext(&context, module_handle) == -1) {
printf("Error getting a cuda context");
}
if (SCCudaHlPushCudaContextFromModule("SC_RULES_CONTENT_B2G_CUDA") == -1) {
printf("Call to SCCudaHlPushCudaContextForModule() failed\n");
}
return 1;
}
/**
* \brief Used for testing purposes. Running tests with cuda enabled
* requires some hacks, which is what this function does.
*
* \retval 1 Always.
*/
int SCCudaHlTestEnvCudaContextDeInit(void)
{
if (SCCudaCtxPopCurrent(NULL) == -1) {
printf("Call to SCCudaCtxPopCurrent() failed\n");
return 0;
}
return 1;
}
#endif /* __SC_CUDA_SUPPORT */

@ -0,0 +1,66 @@
/**
* Copyright (c) 2010 Open Information Security Foundation.
*
* \author Anoop Saldanha <poonaatsoc@gmail.com>
*/
/* macros decides if cuda is enabled for the platform or not */
#ifdef __SC_CUDA_SUPPORT__
#include <cuda.h>
#ifndef __UTIL_MPM_CUDA_HANDLERS_H__
#define __UTIL_MPM_CUDA_HANDLERS_H__
typedef enum {
SC_CUDA_HL_MTYPE_RULE_NONE = -1,
SC_CUDA_HL_MTYPE_RULE_CONTENTS = 0,
SC_CUDA_HL_MTYPE_RULE_URICONTENTS,
SC_CUDA_HL_MTYPE_APP_LAYER,
SC_CUDA_HL_MTYPE_RULE_CUSTOM,
SC_CUDA_HL_MTYPE_MAX,
} SCCudaHlModuleType;
typedef struct SCCudaHlModuleDevicePointer_ {
/* device pointer name. This is a primary key. For the same module you
* can't register different device pointers */
char *name;
CUdeviceptr d_ptr;
struct SCCudaHlModuleDevicePointer_ *next;
} SCCudaHlModuleDevicePointer;
typedef struct SCCudaHlModuleData_ {
/* The unique module handle. This has to be first obtained from the
* call to SCCudaHlGetUniqueHandle() */
const char *name;
int handle;
CUcontext cuda_context;
CUmodule cuda_module;
void *(*SCCudaHlDispFunc)(void *);
SCCudaHlModuleDevicePointer *device_ptrs;
struct SCCudaHlModuleData_ *next;
} SCCudaHlModuleData;
int SCCudaHlGetCudaContext(CUcontext *, int);
int SCCudaHlGetCudaModule(CUmodule *, const char *, int);
int SCCudaHlGetCudaDevicePtr(CUdeviceptr *, const char *, size_t, void *, int);
int SCCudaHlRegisterDispatcherFunc(void *(*SCCudaHlDispFunc)(void *), int);
SCCudaHlModuleData *SCCudaHlGetModuleData(uint8_t);
const char *SCCudaHlGetModuleName(int);
int SCCudaHlGetModuleHandle(const char *);
int SCCudaHlRegisterModule(const char *);
int SCCudaHlDeRegisterModule(const char *);
int SCCudaHlPushCudaContextFromModule(const char *);
int SCCudaHlTestEnvCudaContextInit(void);
int SCCudaHlTestEnvCudaContextDeInit(void);
#endif /* __UTIL_CUDA_HANDLERS__ */
#endif /* __SC_CUDA_SUPPORT__ */

@ -7,10 +7,6 @@
// use this for now
#define __SC_CUDA_SUPPORT__
/* compile in, only if we have a CUDA enabled device on the machine, with the
* toolkit and the driver installed */
#ifdef __SC_CUDA_SUPPORT__
#include <cuda.h>
#include "util-cuda.h"
#include "suricata-common.h"
@ -19,6 +15,10 @@
#include "util-debug.h"
#include "util-unittest.h"
/* compile in, only if we have a CUDA enabled device on the machine, with the
* toolkit and the driver installed */
#ifdef __SC_CUDA_SUPPORT__
#define CASE_CODE(E) case E: return #E
typedef enum SCCudaAPIS_ {
@ -3213,12 +3213,6 @@ int SCCudaCtxPopCurrent(CUcontext *pctx)
{
CUresult result = 0;
if (pctx == NULL) {
SCLogError(SC_INVALID_ARGUMENTS, "Invalid argument supplied. "
"pctx NULL");
goto error;
}
result = cuCtxPopCurrent(pctx);
if (SCCudaHandleRetValue(result, SC_CUDA_CU_CTX_POP_CURRENT) == -1)
goto error;
@ -3995,8 +3989,6 @@ static int SCCudaInit(unsigned int flags)
return -1;
}
#endif /* __SC_CUDA_SUPPORT__ */
/**************************Cuda_Env_Initialization_API*************************/
/**
@ -4171,3 +4163,5 @@ void SCCudaRegisterTests(void)
return;
}
#endif /* __SC_CUDA_SUPPORT__ */

@ -106,6 +106,11 @@ const char * SCErrorToString(SCError err)
CASE_CODE (SC_ERR_PCAP_RECV_INIT);
CASE_CODE (SC_ERR_NFQ_UNBIND);
CASE_CODE (SC_ERR_NFQ_BIND);
CASE_CODE (SC_ERR_CUDA_ERROR);
CASE_CODE (SC_ERR_CUDA_HANDLER_ERROR);
CASE_CODE (SC_ERR_TM_THREADS_ERROR);
CASE_CODE (SC_ERR_TM_MODULES_ERROR);
CASE_CODE (SC_ERR_B2G_CUDA_ERROR);
default:
return "UNKNOWN_ERROR";
}

@ -124,6 +124,10 @@ typedef enum {
SC_ERR_INVALID_OPERATOR,
SC_ERR_PCAP_RECV_INIT,
SC_ERR_CUDA_ERROR,
SC_ERR_CUDA_HANDLER_ERROR,
SC_ERR_TM_THREADS_ERROR,
SC_ERR_TM_MODULES_ERROR,
SC_ERR_B2G_CUDA_ERROR,
} SCError;
const char *SCErrorToString(SCError);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,157 @@
/**
* Copyright (c) 2009 Open Information Security Foundation.
*
* \author Anoop Saldanha <poonaatsoc@gmail.com>
*/
#ifndef __UTIL_MPM_B2G_CUDA_H__
#define __UTIL_MPM_B2G_CUDA_H__
#include <cuda.h>
#include "decode.h"
#include "util-mpm.h"
#include "util-bloomfilter.h"
#define B2G_CUDA_NOCASE 0x01
#define B2G_CUDA_SCAN 0x02
#define B2G_CUDA_HASHSIZE 4096
#define B2G_CUDA_HASHSHIFT 4
#define B2G_CUDA_TYPE uint32_t
#define B2G_CUDA_WORD_SIZE 32
#define B2G_CUDA_BLOOMSIZE 1024
#define B2G_CUDA_Q 2
#define B2G_CUDA_HASH16(a, b) (((a) << B2G_CUDA_HASHSHIFT) | (b))
#define B2G_CUDA_SCANFUNC_NAME "B2gCudaScanBNDMq"
#define B2G_CUDA_SEARCHFUNC_NAME "B2gCudaSearchBNDMq"
#define B2G_CUDA_SCANFUNC B2gCudaScanBNDMq
#define B2G_CUDA_SEARCHFUNC B2gCudaSearchBNDMq
typedef struct B2gCudaPattern_ {
uint8_t flags;
/** \todo we're limited to 32/64 byte lengths, uint8_t would be fine here */
uint16_t len;
/* case sensitive */
uint8_t *cs;
/* case INsensitive */
uint8_t *ci;
struct B2gCudaPattern_ *next;
MpmEndMatch *em;
} B2gCudaPattern;
typedef struct B2gCudaHashItem_ {
uint16_t idx;
uint8_t flags;
struct B2gCudaHashItem_ *nxt;
} B2gCudaHashItem;
typedef struct B2gCudaCtx_ {
int module_handle;
CUcontext cuda_context;
CUmodule cuda_module;
CUfunction cuda_search_kernel;
CUfunction cuda_scan_kernel;
CUdeviceptr cuda_g_u8_lowercasetable;
CUdeviceptr cuda_search_B2G;
CUdeviceptr cuda_scan_B2G;
B2G_CUDA_TYPE *scan_B2G;
B2G_CUDA_TYPE scan_m;
BloomFilter **scan_bloom;
/* array containing the minimal length of the patters in a hash bucket.
* Used for the BloomFilter. */
uint8_t *scan_pminlen;
/* pattern arrays */
B2gCudaPattern **parray;
B2G_CUDA_TYPE search_m;
B2G_CUDA_TYPE *search_B2G;
uint16_t scan_1_pat_cnt;
#ifdef B2G_CUDA_SCAN2
uint16_t scan_2_pat_cnt;
#endif
uint16_t scan_x_pat_cnt;
uint32_t scan_hash_size;
B2gCudaHashItem **scan_hash;
B2gCudaHashItem scan_hash1[256];
#ifdef B2G_CUDA_SCAN2
B2gHashItem **scan_hash2;
#endif
uint32_t search_hash_size;
BloomFilter **search_bloom;
/* array containing the minimal length of the patters in a hash bucket.
* Used for the BloomFilter. */
uint8_t *search_pminlen;
B2gCudaHashItem **search_hash;
B2gCudaHashItem search_hash1[256];
/* hash used during ctx initialization */
B2gCudaPattern **init_hash;
uint8_t scan_s0;
uint8_t search_s0;
/* we store our own multi byte scan ptr here for B2gCudaSearch1 */
uint32_t (*Scan)(struct MpmCtx_ *, struct MpmThreadCtx_ *,
PatternMatcherQueue *, uint8_t *, uint16_t);
/* we store our own multi byte search ptr here for B2gCudaSearch1 */
uint32_t (*Search)(struct MpmCtx_ *, struct MpmThreadCtx_ *,
PatternMatcherQueue *, uint8_t *, uint16_t);
/* we store our own multi byte scan ptr here for B2gCudaSearch1 */
uint32_t (*MBScan2)(struct MpmCtx_ *, struct MpmThreadCtx_ *,
PatternMatcherQueue *, uint8_t *, uint16_t);
uint32_t (*MBScan)(struct MpmCtx_ *, struct MpmThreadCtx_ *,
PatternMatcherQueue *, uint8_t *, uint16_t);
/* we store our own multi byte search ptr here for B2gCudaSearch1 */
uint32_t (*MBSearch)(struct MpmCtx_ *, struct MpmThreadCtx_ *,
PatternMatcherQueue *, uint8_t *, uint16_t);
} B2gCudaCtx;
typedef struct B2gCudaThreadCtx_ {
#ifdef B2G_CUDA_COUNTERS
uint32_t scan_stat_pminlen_calls;
uint32_t scan_stat_pminlen_total;
uint32_t scan_stat_bloom_calls;
uint32_t scan_stat_bloom_hits;
uint32_t scan_stat_calls;
uint32_t scan_stat_m_total;
uint32_t scan_stat_d0;
uint32_t scan_stat_d0_hashloop;
uint32_t scan_stat_loop_match;
uint32_t scan_stat_loop_no_match;
uint32_t scan_stat_num_shift;
uint32_t scan_stat_total_shift;
uint32_t search_stat_d0;
uint32_t search_stat_loop_match;
uint32_t search_stat_loop_no_match;
uint32_t search_stat_num_shift;
uint32_t search_stat_total_shift;
#endif /* B2G_CUDA_COUNTERS */
} B2gCudaThreadCtx;
void MpmB2gCudaRegister(void);
void TmModuleCudaMpmB2gRegister(void);
int B2gCudaStartDispatcherThreadRC(const char *);
int B2gCudaStartDispatcherThreadAPC(const char *);
void B2gCudaKillDispatcherThreadRC(void);
void B2gCudaKillDispatcherThreadAPC(void);
void B2gCudaPushPacketTo_tv_CMB2_RC(Packet *);
void B2gCudaPushPacketTo_tv_CMB2_APC(Packet *);
#endif /* __UTIL_MPM_B2G_CUDA_H__ */

@ -39,7 +39,7 @@ static uint32_t b2g_bloom_size = 0;
static void *b2g_scan_func;
static void *b2g_search_func;
void B2gInitCtx (MpmCtx *);
void B2gInitCtx (MpmCtx *, int);
void B2gThreadInitCtx(MpmCtx *, MpmThreadCtx *, uint32_t);
void B2gDestroyCtx(MpmCtx *);
void B2gThreadDestroyCtx(MpmCtx *, MpmThreadCtx *);
@ -987,9 +987,7 @@ static void B2gGetConfig()
}
}
void B2gInitCtx (MpmCtx *mpm_ctx)
{
SCEnter();
void B2gInitCtx (MpmCtx *mpm_ctx, int module_handle) {
SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx);
BUG_ON(mpm_ctx->ctx != NULL);
@ -1888,7 +1886,7 @@ static int B2gTestInit01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -1908,7 +1906,7 @@ static int B2gTestInit01 (void) {
static int B2gTestS0Init01 (void) {
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -1927,7 +1925,7 @@ static int B2gTestS0Init01 (void) {
static int B2gTestS0Init02 (void) {
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -1947,7 +1945,7 @@ static int B2gTestS0Init02 (void) {
static int B2gTestS0Init03 (void) {
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -1967,7 +1965,7 @@ static int B2gTestS0Init03 (void) {
static int B2gTestS0Init04 (void) {
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abab", 4, 0, 0, 0, 0); /* 1 match */
@ -1986,7 +1984,7 @@ static int B2gTestS0Init04 (void) {
static int B2gTestS0Init05 (void) {
int result = 0;
MpmCtx mpm_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcab", 5, 0, 0, 0, 0); /* 1 match */
@ -2008,7 +2006,7 @@ static int B2gTestScan01 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2035,7 +2033,7 @@ static int B2gTestScan02 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2062,7 +2060,7 @@ static int B2gTestScan03 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2092,7 +2090,7 @@ static int B2gTestScan04 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2122,7 +2120,7 @@ static int B2gTestScan05 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2151,7 +2149,7 @@ static int B2gTestScan06 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2178,7 +2176,7 @@ static int B2gTestScan07 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0, 0); /* should match 30 times */
@ -2211,7 +2209,7 @@ static int B2gTestScan08 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2238,7 +2236,7 @@ static int B2gTestScan09 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0); /* 1 match */
@ -2265,7 +2263,7 @@ static int B2gTestScan10 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0); /* 1 match */
@ -2297,7 +2295,7 @@ static int B2gTestScan11 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2325,7 +2323,7 @@ static int B2gTestScan12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2353,7 +2351,7 @@ static int B2gTestScan13 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefghijklmnopqrstuvwxyzABCD", 30, 0, 0, 0, 0, 0); /* 1 match */
@ -2380,7 +2378,7 @@ static int B2gTestScan14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefghijklmnopqrstuvwxyzABCDE", 31, 0, 0, 0, 0, 0); /* 1 match */
@ -2407,7 +2405,7 @@ static int B2gTestScan15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefghijklmnopqrstuvwxyzABCDEF", 32, 0, 0, 0, 0, 0); /* 1 match */
@ -2434,7 +2432,7 @@ static int B2gTestScan16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefghijklmnopqrstuvwxyzABC", 29, 0, 0, 0, 0, 0); /* 1 match */
@ -2461,7 +2459,7 @@ static int B2gTestScan17 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefghijklmnopqrstuvwxyzAB", 28, 0, 0, 0, 0, 0); /* 1 match */
@ -2488,7 +2486,7 @@ static int B2gTestScan18 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcde""fghij""klmno""pqrst""uvwxy""z", 26, 0, 0, 0, 0, 0); /* 1 match */
@ -2515,7 +2513,7 @@ static int B2gTestScan19 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 30, 0, 0, 0, 0, 0); /* 1 */
@ -2542,7 +2540,7 @@ static int B2gTestScan20 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AAAAA""AA", 32, 0, 0, 0, 0, 0); /* 1 */
@ -2571,7 +2569,7 @@ static int B2gTestScan21 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddScanPatternCS(&mpm_ctx, (uint8_t *)"AA", 2, 0, 0, 0, 0, 0); /* 1 */
@ -2598,7 +2596,7 @@ static int B2gTestSearch01 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2625,7 +2623,7 @@ static int B2gTestSearch02 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0); /* 1 match */
@ -2652,7 +2650,7 @@ static int B2gTestSearch03 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2682,7 +2680,7 @@ static int B2gTestSearch04 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2712,7 +2710,7 @@ static int B2gTestSearch05 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0); /* 1 match */
@ -2741,7 +2739,7 @@ static int B2gTestSearch06 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2768,7 +2766,7 @@ static int B2gTestSearch07 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -2801,7 +2799,7 @@ static int B2gTestSearch08 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2828,7 +2826,7 @@ static int B2gTestSearch09 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0); /* 1 match */
@ -2855,7 +2853,7 @@ static int B2gTestSearch10 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0); /* 1 match */
@ -2887,7 +2885,7 @@ static int B2gTestSearch11 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2915,7 +2913,7 @@ static int B2gTestSearch12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
MpmInitCtx(&mpm_ctx, MPM_B2G, -1);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
B2gAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0); /* 1 match */
@ -2991,7 +2989,7 @@ int main () {
#define R 4
int i;
B2gCtx bg_ctx;
B2gInitCtx(&bg_ctx);
B2gInitCtx(&bg_ctx, -1);
B2gAddPatternCI(&bg_ctx, "grep", 4, 0, 0, 0, 0);
B2pPrepare(&bg_ctx);

@ -34,7 +34,7 @@ static uint32_t b3g_bloom_size = 0;
static void *b3g_scan_func;
static void *b3g_search_func;
void B3gInitCtx (MpmCtx *);
void B3gInitCtx (MpmCtx *, int);
void B3gThreadInitCtx(MpmCtx *, MpmThreadCtx *, uint32_t);
void B3gDestroyCtx(MpmCtx *);
void B3gThreadDestroyCtx(MpmCtx *, MpmThreadCtx *);
@ -993,9 +993,8 @@ void B3gGetConfig()
}
}
void B3gInitCtx (MpmCtx *mpm_ctx)
{
SCLogDebug("mpm_ctx %p\n", mpm_ctx);
void B3gInitCtx (MpmCtx *mpm_ctx, int module_handle) {
//printf("B3gInitCtx: mpm_ctx %p\n", mpm_ctx);
mpm_ctx->ctx = malloc(sizeof(B3gCtx));
if (mpm_ctx->ctx == NULL)
@ -2064,7 +2063,7 @@ static int B3gTestInit01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2087,7 +2086,7 @@ static int B3gTestS0Init01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2107,7 +2106,7 @@ static int B3gTestS0Init02 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2128,7 +2127,7 @@ static int B3gTestS0Init03 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2149,7 +2148,7 @@ static int B3gTestS0Init04 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abab", 4, 0, 0, 0, 0); /* 1 match */
@ -2169,7 +2168,7 @@ static int B3gTestS0Init05 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcab", 5, 0, 0, 0, 0); /* 1 match */
@ -2191,7 +2190,7 @@ static int B3gTestScan01 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2218,7 +2217,7 @@ static int B3gTestScan02 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2245,7 +2244,7 @@ static int B3gTestScan03 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2275,7 +2274,7 @@ static int B3gTestScan04 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2305,7 +2304,7 @@ static int B3gTestScan05 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2334,7 +2333,7 @@ static int B3gTestScan06 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2361,7 +2360,7 @@ static int B3gTestScan07 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0, 0); /* should match 30 times */
@ -2394,7 +2393,7 @@ static int B3gTestScan08 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2421,7 +2420,7 @@ static int B3gTestScan09 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0, 0); /* 1 match */
@ -2448,7 +2447,7 @@ static int B3gTestScan10 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0, 0); /* 1 match */
@ -2475,7 +2474,7 @@ static int B3gTestScan11 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2503,7 +2502,7 @@ static int B3gTestScan12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddScanPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0, 0); /* 1 match */
@ -2531,7 +2530,7 @@ static int B3gTestSearch01 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2558,7 +2557,7 @@ static int B3gTestSearch02 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abce", 4, 0, 0, 0, 0); /* 1 match */
@ -2585,7 +2584,7 @@ static int B3gTestSearch03 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2615,7 +2614,7 @@ static int B3gTestSearch04 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2645,7 +2644,7 @@ static int B3gTestSearch05 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0); /* 1 match */
@ -2674,7 +2673,7 @@ static int B3gTestSearch06 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2701,7 +2700,7 @@ static int B3gTestSearch07 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -2734,7 +2733,7 @@ static int B3gTestSearch08 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2761,7 +2760,7 @@ static int B3gTestSearch09 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 0, 0); /* 1 match */
@ -2788,7 +2787,7 @@ static int B3gTestSearch10 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcdefgh", 8, 0, 0, 0, 0); /* 1 match */
@ -2815,7 +2814,7 @@ static int B3gTestSearch11 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0); /* 1 match */
@ -2843,7 +2842,7 @@ static int B3gTestSearch12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B3G);
MpmInitCtx(&mpm_ctx, MPM_B3G, -1);
B3gCtx *ctx = (B3gCtx *)mpm_ctx.ctx;
B3gAddPatternCS(&mpm_ctx, (uint8_t *)"wxyz", 4, 0, 0, 0, 0); /* 1 match */
@ -2911,7 +2910,7 @@ int main () {
#define R 4
int i;
B3gCtx bg_ctx;
B3gInitCtx(&bg_ctx);
B3gInitCtx(&bg_ctx, -1);
B3gAddPatternCI(&bg_ctx, "grep", 4, 0, 0, 0, 0);
B2pPrepare(&bg_ctx);

@ -40,7 +40,7 @@
static uint32_t wm_hash_size = 0;
static uint32_t wm_bloom_size = 0;
void WmInitCtx (MpmCtx *mpm_ctx);
void WmInitCtx (MpmCtx *mpm_ctx, int);
void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t);
void WmDestroyCtx(MpmCtx *mpm_ctx);
void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx);
@ -2230,9 +2230,8 @@ void WmGetConfig()
}
}
void WmInitCtx (MpmCtx *mpm_ctx)
{
SCLogDebug("mpm_ctx %p\n", mpm_ctx);
void WmInitCtx (MpmCtx *mpm_ctx, int module_handle) {
SCLogDebug("mpm_ctx %p", mpm_ctx);
mpm_ctx->ctx = malloc(sizeof(WmCtx));
if (mpm_ctx->ctx == NULL)
@ -2436,7 +2435,7 @@ int WmTestInitCtx01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
WmInitCtx(&mpm_ctx);
WmInitCtx(&mpm_ctx, -1);
if (mpm_ctx.ctx != NULL)
result = 1;
@ -2449,7 +2448,7 @@ int WmTestInitCtx02 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
WmInitCtx(&mpm_ctx);
WmInitCtx(&mpm_ctx, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2464,7 +2463,7 @@ int WmTestInitCtx03 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
if (mpm_table[MPM_WUMANBER].Search == WmSearch)
result = 1;
@ -2480,7 +2479,7 @@ int WmTestThreadInitCtx01 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
if (mpm_thread_ctx.memory_cnt == 2)
@ -2501,7 +2500,7 @@ int WmTestThreadInitCtx02 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmThreadCtx *tctx = (WmThreadCtx *)mpm_thread_ctx.ctx;
@ -2523,7 +2522,7 @@ int WmTestInitAddPattern01 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
int ret = WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 1234, 0, 0);
@ -2541,7 +2540,7 @@ int WmTestInitAddPattern02 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2560,7 +2559,7 @@ int WmTestInitAddPattern03 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2582,7 +2581,7 @@ int WmTestInitAddPattern04 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2604,7 +2603,7 @@ int WmTestInitAddPattern05 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2626,7 +2625,7 @@ int WmTestInitAddPattern06 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmThreadInitCtx(&mpm_ctx, &mpm_thread_ctx, 1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
@ -2646,7 +2645,7 @@ int WmTestPrepare01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 0, 0, 0, 0);
@ -2663,7 +2662,7 @@ int WmTestPrepare02 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
WmPreparePatterns(&mpm_ctx);
@ -2680,7 +2679,7 @@ int WmTestPrepare03 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
WmPreparePatterns(&mpm_ctx);
@ -2699,7 +2698,7 @@ int WmTestPrepare04 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 1, 0, 0, 0);
@ -2716,7 +2715,7 @@ int WmTestPrepare05 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 1, 0, 0, 0);
WmPreparePatterns(&mpm_ctx);
@ -2733,7 +2732,7 @@ int WmTestPrepare06 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 1, 0, 0, 0);
WmPreparePatterns(&mpm_ctx);
@ -2754,7 +2753,7 @@ int WmTestSearch01 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2781,7 +2780,7 @@ int WmTestSearch01Hash12 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2810,7 +2809,7 @@ int WmTestSearch01Hash14 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2839,7 +2838,7 @@ int WmTestSearch01Hash15 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2868,7 +2867,7 @@ int WmTestSearch01Hash16 (void) {
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2896,7 +2895,7 @@ int WmTestSearch02 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2919,7 +2918,7 @@ int WmTestSearch03 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2943,7 +2942,7 @@ int WmTestSearch04 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"bcde", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2966,7 +2965,7 @@ int WmTestSearch05 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"efgh", 4, 0, 0, 1, 0, 0, 0, 0);
@ -2989,7 +2988,7 @@ int WmTestSearch06 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"eFgH", 4, 0, 0, 1, 0, 0, 0, 0);
@ -3012,7 +3011,7 @@ int WmTestSearch07 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0, 0, 0);
@ -3036,7 +3035,7 @@ int WmTestSearch08 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"abcde", 5, 0, 0, 1, 0, 0, 0, 0);
@ -3060,7 +3059,7 @@ int WmTestSearch09 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"ab", 2, 0, 0, 1, 0, 0, 0, 0);
@ -3083,7 +3082,7 @@ int WmTestSearch10 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"bc", 2, 0, 0, 1, 0, 0, 0, 0);
WmAddPattern(&mpm_ctx, (uint8_t *)"gh", 2, 0, 0, 1, 0, 1, 0, 0);
@ -3107,7 +3106,7 @@ int WmTestSearch11 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 0, 0, 0, 0);
WmAddPattern(&mpm_ctx, (uint8_t *)"d", 1, 0, 0, 1, 0, 1, 0, 0);
@ -3132,7 +3131,7 @@ int WmTestSearch12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 1, 0, 0, 0, 0);
@ -3159,7 +3158,7 @@ int WmTestSearch13 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"a", 1, 0, 0, 1, 0, 0, 0, 0);
@ -3186,7 +3185,7 @@ int WmTestSearch14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 1, 0, 0, 0, 0);
@ -3211,7 +3210,7 @@ int WmTestSearch15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 1, 0, 0, 0, 0);
@ -3239,7 +3238,7 @@ int WmTestSearch16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPattern(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 1, 0, 0, 0, 0);
@ -3267,7 +3266,7 @@ int WmTestSearch17 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3293,7 +3292,7 @@ int WmTestSearch18Hash12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3320,7 +3319,7 @@ int WmTestSearch18Hash14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3347,7 +3346,7 @@ int WmTestSearch18Hash15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3374,7 +3373,7 @@ int WmTestSearch18 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3401,7 +3400,7 @@ int WmTestSearch18Hash16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3428,7 +3427,7 @@ int WmTestSearch19 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCI(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3454,7 +3453,7 @@ int WmTestSearch19Hash12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCI(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3481,7 +3480,7 @@ int WmTestSearch19Hash14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCI(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3508,7 +3507,7 @@ int WmTestSearch19Hash15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCI(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3535,7 +3534,7 @@ int WmTestSearch19Hash16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCI(&mpm_ctx, (uint8_t *)"/VideoAccessCodecInstall.exe", 28, 0, 0, 0, 0);
@ -3562,7 +3561,7 @@ int WmTestSearch20 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3588,7 +3587,7 @@ int WmTestSearch20Hash12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3615,7 +3614,7 @@ int WmTestSearch20Hash14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3642,7 +3641,7 @@ int WmTestSearch20Hash15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3669,7 +3668,7 @@ int WmTestSearch20Hash16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3696,7 +3695,7 @@ int WmTestSearch21 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3722,7 +3721,7 @@ static int WmTestSearch21Hash12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3749,7 +3748,7 @@ static int WmTestSearch21Hash14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3776,7 +3775,7 @@ static int WmTestSearch21Hash15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3803,7 +3802,7 @@ static int WmTestSearch21Hash16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"/videoaccesscodecinstall.exe", 28, 0, 0, 0, 0);
@ -3830,7 +3829,7 @@ static int WmTestSearch22Hash9 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -3864,7 +3863,7 @@ static int WmTestSearch22Hash12 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -3898,7 +3897,7 @@ static int WmTestSearch22Hash14 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -3932,7 +3931,7 @@ static int WmTestSearch22Hash15 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */
@ -3966,7 +3965,7 @@ static int WmTestSearch22Hash16 (void) {
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_WUMANBER);
MpmInitCtx(&mpm_ctx, MPM_WUMANBER, -1);
WmCtx *ctx = (WmCtx *)mpm_ctx.ctx;
WmAddPatternCS(&mpm_ctx, (uint8_t *)"A", 1, 0, 0, 0, 0); /* should match 30 times */

@ -5,6 +5,7 @@
/* include pattern matchers */
#include "util-mpm-wumanber.h"
#include "util-mpm-b2g.h"
#include "util-mpm-b2g-cuda.h"
#include "util-mpm-b3g.h"
#include "util-hashlist.h"
@ -282,9 +283,9 @@ void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher, uint32_t m
mpm_table[matcher].InitThreadCtx(NULL, mpm_thread_ctx, max_id);
}
void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher) {
void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher, int module_handle) {
mpm_ctx->mpm_type = matcher;
mpm_table[matcher].InitCtx(mpm_ctx);
mpm_table[matcher].InitCtx(mpm_ctx, module_handle);
}
void MpmTableSetup(void) {
@ -292,6 +293,9 @@ void MpmTableSetup(void) {
MpmWuManberRegister();
MpmB2gRegister();
#ifdef __SC_CUDA_SUPPORT__
MpmB2gCudaRegister();
#endif
MpmB3gRegister();
}

@ -33,7 +33,9 @@ enum {
MPM_WUMANBER,
MPM_B2G,
#ifdef __SC_CUDA_SUPPORT__
MPM_B2G_CUDA,
#endif
MPM_B3G,
/* table size */
@ -119,7 +121,7 @@ typedef struct MpmCtx_ {
typedef struct MpmTableElmt_ {
char *name;
uint8_t max_pattern_length;
void (*InitCtx)(struct MpmCtx_ *);
void (*InitCtx)(struct MpmCtx_ *, int);
void (*InitThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *, uint32_t);
void (*DestroyCtx)(struct MpmCtx_ *);
void (*DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *);
@ -157,7 +159,7 @@ void MpmRegisterTests(void);
/** Return the max pattern length of a Matcher type given as arg */
int32_t MpmMatcherGetMaxPatternLength(uint16_t);
void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher);
void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher, int module_handle);
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t, uint32_t);
uint32_t MpmGetHashSize(const char *);
uint32_t MpmGetBloomSize(const char *);

Loading…
Cancel
Save