suricata
util-mpm.c File Reference
#include "suricata-common.h"
#include "util-mpm.h"
#include "util-debug.h"
#include "util-mpm-ac.h"
#include "util-mpm-ac-bs.h"
#include "util-mpm-ac-ks.h"
#include "util-mpm-hs.h"
#include "util-hashlist.h"
#include "detect-engine.h"
#include "util-misc.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "queue.h"
#include "util-unittest.h"
#include "util-memcpy.h"
Include dependency graph for util-mpm.c:

Go to the source code of this file.

Macros

#define DEFAULT_MPM   MPM_AC
 

Functions

int32_t MpmFactoryRegisterMpmCtxProfile (DetectEngineCtx *de_ctx, const char *name)
 Register a new Mpm Context. More...
 
int32_t MpmFactoryIsMpmCtxAvailable (const DetectEngineCtx *de_ctx, const MpmCtx *mpm_ctx)
 
MpmCtxMpmFactoryGetMpmCtxForProfile (const DetectEngineCtx *de_ctx, int32_t id, int direction)
 
void MpmFactoryReClaimMpmCtx (const DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
 
void MpmFactoryDeRegisterAllMpmCtxProfiles (DetectEngineCtx *de_ctx)
 
void MpmInitThreadCtx (MpmThreadCtx *mpm_thread_ctx, uint16_t matcher)
 
void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher)
 
void MpmTableSetup (void)
 
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)
 
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 MpmFreePattern (MpmCtx *mpm_ctx, MpmPattern *p)
 
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 MpmRegisterTests (void)
 

Variables

MpmTableElmt mpm_table [MPM_TABLE_SIZE]
 
int mpm_default_matcher
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Pattern matcher utility Functions

Definition in file util-mpm.c.

Macro Definition Documentation

◆ DEFAULT_MPM

#define DEFAULT_MPM   MPM_AC

Definition at line 277 of file util-mpm.c.

Function Documentation

◆ MpmAddPattern()

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 
)

◆ MpmAddPatternCI()

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 
)

Definition at line 314 of file util-mpm.c.

References MpmTableElmt_::AddPatternNocase, flags, mpm_table, MpmCtx_::mpm_type, and offset.

◆ MpmAddPatternCS()

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 
)

Definition at line 305 of file util-mpm.c.

References MpmTableElmt_::AddPattern, flags, mpm_table, MpmCtx_::mpm_type, and offset.

◆ MpmFactoryDeRegisterAllMpmCtxProfiles()

◆ MpmFactoryGetMpmCtxForProfile()

◆ MpmFactoryIsMpmCtxAvailable()

int32_t MpmFactoryIsMpmCtxAvailable ( const DetectEngineCtx de_ctx,
const MpmCtx mpm_ctx 
)

◆ MpmFactoryReClaimMpmCtx()

void MpmFactoryReClaimMpmCtx ( const DetectEngineCtx de_ctx,
MpmCtx mpm_ctx 
)

Definition at line 218 of file util-mpm.c.

References de_ctx, MpmTableElmt_::DestroyCtx, MPM_NOTSET, mpm_table, MpmCtx_::mpm_type, MpmFactoryIsMpmCtxAvailable(), and SCFree.

Here is the call graph for this function:

◆ MpmFactoryRegisterMpmCtxProfile()

int32_t MpmFactoryRegisterMpmCtxProfile ( DetectEngineCtx de_ctx,
const char *  name 
)

Register a new Mpm Context.

Parameters
nameA new profile to be registered to store this MpmCtx.
Return values
idReturn the id created for the new MpmCtx profile.

Definition at line 58 of file util-mpm.c.

References de_ctx, MpmCtx_::flags, MpmCtxFactoryItem_::id, MpmCtxFactoryContainer_::items, DetectEngineCtx_::mpm_ctx_factory_container, MpmCtxFactoryItem_::mpm_ctx_tc, MpmCtxFactoryItem_::mpm_ctx_ts, MPMCTX_FLAGS_GLOBAL, MpmCtxFactoryItem_::name, MpmCtxFactoryContainer_::no_of_items, SC_ERR_MEM_ALLOC, SCFree, SCLogError, SCMalloc, SCRealloc, and unlikely.

◆ MpmFreePattern()

void MpmFreePattern ( MpmCtx mpm_ctx,
MpmPattern p 
)

Definition at line 413 of file util-mpm.c.

References MpmPattern_::ci, MpmPattern_::cs, MpmPattern_::len, MpmCtx_::memory_cnt, MpmCtx_::memory_size, MpmPattern_::original_pat, and SCFree.

Referenced by SCACBSDestroyCtx(), and SCACDestroyCtx().

Here is the caller graph for this function:

◆ MpmInitCtx()

void MpmInitCtx ( MpmCtx mpm_ctx,
uint16_t  matcher 
)

Definition at line 264 of file util-mpm.c.

References MpmTableElmt_::InitCtx, mpm_table, and MpmCtx_::mpm_type.

◆ MpmInitThreadCtx()

void MpmInitThreadCtx ( MpmThreadCtx mpm_thread_ctx,
uint16_t  matcher 
)

Definition at line 259 of file util-mpm.c.

References MpmTableElmt_::InitThreadCtx, and mpm_table.

Referenced by PatternMatchThreadPrepare().

Here is the caller graph for this function:

◆ MpmRegisterTests()

void MpmRegisterTests ( void  )

Definition at line 627 of file util-mpm.c.

References g_ut_modules, MPM_NOTSET, mpm_table, and MPM_TABLE_SIZE.

◆ MpmTableSetup()

void MpmTableSetup ( void  )

Definition at line 279 of file util-mpm.c.

References DEFAULT_MPM, mpm_default_matcher, mpm_table, MpmACBSRegister(), MpmACRegister(), MpmACTileRegister(), MpmHSRegister(), and SCLogInfo.

Referenced by ListAppLayerProtocols(), ListKeywords(), LLVMFuzzerTestOneInput(), PostConfLoadedSetup(), and RunUnittests().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ mpm_default_matcher

int mpm_default_matcher

Definition at line 49 of file util-mpm.c.

Referenced by MpmTableSetup(), and PatternMatchDefaultMatcher().

◆ mpm_table