Go to the documentation of this file.
43 #ifdef BUILD_HYPERSCAN
124 if (mpm_ctx == i->mpm_ctx_ts || mpm_ctx == i->mpm_ctx_tc) {
139 }
else if (
id < -1) {
149 return (direction == 0) ? i->mpm_ctx_ts : i->mpm_ctx_tc;
197 if (
mpm_table[matcher].InitThreadCtx != NULL) {
204 if (
mpm_table[matcher].DestroyThreadCtx != NULL) {
217 #ifdef BUILD_HYPERSCAN
218 # define DEFAULT_MPM MPM_HS
219 # define DEFAULT_MPM_AC MPM_AC
221 # define DEFAULT_MPM MPM_AC
231 #ifdef BUILD_HYPERSCAN
232 #ifdef HAVE_HS_VALID_PLATFORM
235 if (hs_valid_platform() != HS_SUCCESS) {
236 SCLogInfo(
"SSSE3 support not detected, disabling Hyperscan for "
250 uint16_t
offset, uint16_t depth,
277 static inline uint32_t MpmInitHashRaw(
const uint8_t *pat, uint16_t patlen)
279 uint32_t hash = patlen * pat[0];
298 static inline MpmPattern *MpmInitHashLookup(
MpmCtx *
ctx,
const uint8_t *pat, uint16_t patlen,
299 uint16_t
offset, uint16_t depth, uint8_t
flags, uint32_t pid)
301 uint32_t hash = MpmInitHashRaw(pat, patlen);
303 if (
ctx->init_hash == NULL) {
308 for ( ; t != NULL; t = t->
next) {
358 if (p->
cs != NULL && p->
cs != p->
ci) {
376 if (p->
sids != NULL) {
385 static inline uint32_t MpmInitHash(
MpmPattern *p)
396 uint32_t hash = MpmInitHash(p);
398 if (
ctx->init_hash == NULL) {
402 if (
ctx->init_hash[hash] == NULL) {
403 ctx->init_hash[hash] = p;
438 SCLogDebug(
"Adding pattern for ctx %p, patlen %"PRIu16
" and pid %" PRIu32,
439 mpm_ctx, patlen, pid);
450 MpmPattern *p = MpmInitHashLookup(mpm_ctx, pat, patlen,
456 p = MpmAllocPattern(mpm_ctx);
479 memcpy_tolower(p->
ci, pat, patlen);
486 if (memcmp(p->
ci, pat, p->
len) == 0) {
495 memcpy(p->
cs, pat, patlen);
500 if (MpmInitHashAdd(mpm_ctx, p) != 0)
512 SCLogDebug(
"%p: alas, no depth for us", mpm_ctx);
516 if (mpm_ctx->
maxlen < patlen)
519 if (mpm_ctx->
minlen == 0) {
522 if (mpm_ctx->
minlen > patlen)
542 if (p->
sids[x] == sid) {
581 if (
mpm_table[i].RegisterUnittests != NULL) {
587 "unittest registration function.",
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, uint16_t matcher)
void(* InitThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *)
void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
void MpmFreePattern(MpmCtx *mpm_ctx, MpmPattern *p)
void MpmFactoryReClaimMpmCtx(const DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
struct HtpBodyChunk_ * next
void MpmRegisterTests(void)
main detection engine ctx
int(* AddPattern)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t)
uint8_t mpm_default_matcher
MpmCtxFactoryContainer * mpm_ctx_factory_container
void(* InitCtx)(struct MpmCtx_ *)
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher)
struct MpmPattern_ MpmPattern
void MpmDestroyThreadCtx(MpmThreadCtx *mpm_thread_ctx, const uint16_t matcher)
int32_t MpmFactoryIsMpmCtxAvailable(const DetectEngineCtx *de_ctx, const MpmCtx *mpm_ctx)
struct MpmPattern_ * next
MpmCtx * MpmFactoryGetMpmCtxForProfile(const DetectEngineCtx *de_ctx, int32_t id, int direction)
#define MPM_PATTERN_CTX_OWNS_ID
int MpmAddPattern(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
#define SCLogWarning(...)
Macro used to log WARNING messages.
MpmCtxFactoryItem * items
#define MPMCTX_FLAGS_GLOBAL
int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *name, const int sm_list, const AppProto alproto)
Register a new Mpm Context.
int MpmAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
#define MPM_INIT_HASH_SIZE
int MpmAddPatternCS(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
#define MPMCTX_FLAGS_NODEPTH
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void MpmACTileRegister(void)
Register the aho-corasick mpm 'ks' originally developed by Ken Steele for Tilera Tile-Gx processor.
#define ENGINE_SGH_MPM_FACTORY_CONTEXT_START_ID_RANGE
struct MpmCtxFactoryItem * next
#define SCRealloc(ptr, sz)
#define MPM_PATTERN_FLAG_NOCASE
int(* AddPatternNocase)(struct MpmCtx_ *, const uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t)
#define SCLogError(...)
Macro used to log ERROR messages.
void(* DestroyCtx)(struct MpmCtx_ *)
#define MPM_CTX_FACTORY_UNIQUE_CONTEXT
void MpmACRegister(void)
Register the aho-corasick mpm.
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
void(* DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *)
void(* RegisterUnittests)(void)