Go to the documentation of this file.
43 #ifdef BUILD_HYPERSCAN
75 strcmp(item->
name, name) == 0) {
125 if (mpm_ctx == i->mpm_ctx_ts || mpm_ctx == i->mpm_ctx_tc) {
140 }
else if (
id < -1) {
150 return (direction == 0) ? i->mpm_ctx_ts : i->mpm_ctx_tc;
198 if (
mpm_table[matcher].InitThreadCtx != NULL) {
205 if (
mpm_table[matcher].DestroyThreadCtx != NULL) {
218 #ifdef BUILD_HYPERSCAN
219 # define DEFAULT_MPM MPM_HS
220 # define DEFAULT_MPM_AC MPM_AC
222 # define DEFAULT_MPM MPM_AC
232 #ifdef BUILD_HYPERSCAN
233 #ifdef HAVE_HS_VALID_PLATFORM
236 if (hs_valid_platform() != HS_SUCCESS) {
237 SCLogInfo(
"SSSE3 support not detected, disabling Hyperscan for "
251 uint16_t
offset, uint16_t depth,
260 uint16_t
offset, uint16_t depth,
279 static inline uint32_t MpmInitHashRaw(uint8_t *pat, uint16_t patlen)
281 uint32_t hash = patlen * pat[0];
301 uint8_t *pat, uint16_t patlen,
302 uint16_t
offset, uint16_t depth,
303 uint8_t
flags, uint32_t pid)
305 uint32_t hash = MpmInitHashRaw(pat, patlen);
307 if (
ctx->init_hash == NULL) {
312 for ( ; t != NULL; t = t->
next) {
362 if (p->
cs != NULL && p->
cs != p->
ci) {
380 if (p->
sids != NULL) {
389 static inline uint32_t MpmInitHash(
MpmPattern *p)
400 uint32_t hash = MpmInitHash(p);
402 if (
ctx->init_hash == NULL) {
406 if (
ctx->init_hash[hash] == NULL) {
407 ctx->init_hash[hash] = p;
440 uint16_t
offset, uint16_t depth, uint32_t pid,
443 SCLogDebug(
"Adding pattern for ctx %p, patlen %"PRIu16
" and pid %" PRIu32,
444 mpm_ctx, patlen, pid);
455 MpmPattern *p = MpmInitHashLookup(mpm_ctx, pat, patlen,
461 p = MpmAllocPattern(mpm_ctx);
484 memcpy_tolower(p->
ci, pat, patlen);
491 if (memcmp(p->
ci, pat, p->
len) == 0) {
500 memcpy(p->
cs, pat, patlen);
505 if (MpmInitHashAdd(mpm_ctx, p) != 0)
517 SCLogDebug(
"%p: alas, no depth for us", mpm_ctx);
521 if (mpm_ctx->
maxlen < patlen)
524 if (mpm_ctx->
minlen == 0) {
527 if (mpm_ctx->
minlen > patlen)
547 if (p->
sids[x] == sid) {
586 if (
mpm_table[i].RegisterUnittests != NULL) {
592 "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(* AddPatternNocase)(struct MpmCtx_ *, uint8_t *, uint16_t, uint16_t, uint16_t, uint32_t, SigIntId, uint8_t)
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
#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.
#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
#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]
int MpmAddPattern(MpmCtx *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
void(* DestroyThreadCtx)(struct MpmCtx_ *, struct MpmThreadCtx_ *)
int MpmAddPatternCI(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
void(* RegisterUnittests)(void)