suricata
util-spm-bm.h File Reference
#include "suricata-common.h"
Include dependency graph for util-spm-bm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BmCtx_
 

Macros

#define ALPHABET_SIZE   256
 

Typedefs

typedef struct BmCtx_ BmCtx
 

Functions

BmCtxBoyerMooreCtxInit (const uint8_t *needle, uint16_t needle_len)
 Setup a Boyer Moore context. More...
 
BmCtxBoyerMooreNocaseCtxInit (uint8_t *needle, uint16_t needle_len)
 Setup a Boyer Moore context for nocase search. More...
 
void BoyerMooreCtxToNocase (BmCtx *, uint8_t *, uint16_t)
 Given a BmCtx structure, recreate the pre/suffixes for nocase. More...
 
uint8_t * BoyerMoore (const uint8_t *x, const uint16_t m, const uint8_t *y, const uint32_t n, const BmCtx *bm_ctx)
 Boyer Moore search algorithm Is better as the pattern length increases and for big buffers to search in. The algorithm needs a context of two arrays already prepared by prep_bad_chars() and prep_good_suffix() More...
 
uint8_t * BoyerMooreNocase (const uint8_t *x, const uint16_t m, const uint8_t *y, const uint32_t n, const BmCtx *bm_ctx)
 Boyer Moore search algorithm Is better as the pattern length increases and for big buffers to search in. The algorithm needs a context of two arrays already prepared by prep_bad_chars() and prep_good_suffix() More...
 
void BoyerMooreCtxDeInit (BmCtx *)
 Free the memory allocated to Boyer Moore context. More...
 
void SpmBMRegister (void)
 

Detailed Description

Macro Definition Documentation

◆ ALPHABET_SIZE

#define ALPHABET_SIZE   256

Definition at line 31 of file util-spm-bm.h.

Typedef Documentation

◆ BmCtx

typedef struct BmCtx_ BmCtx

Function Documentation

◆ BoyerMoore()

uint8_t* BoyerMoore ( const uint8_t *  x,
const uint16_t  m,
const uint8_t *  y,
const uint32_t  n,
const BmCtx bm_ctx 
)

Boyer Moore search algorithm Is better as the pattern length increases and for big buffers to search in. The algorithm needs a context of two arrays already prepared by prep_bad_chars() and prep_good_suffix()

Parameters
ypointer to the buffer to search in
nlength limit of the buffer
xpointer to the pattern we ar searching for
mlength limit of the needle
bmBcpointer to an array of BoyerMooreSuffixes prepared by prep_good_suffix()
bmGspointer to an array of bachars prepared by prep_bad_chars()
Return values
ptrto start of the match; NULL if no match

Definition at line 300 of file util-spm-bm.c.

References BmCtx_::bmBc, BmCtx_::bmGs, m, and unlikely.

Referenced by BoyerMooreSearch().

Here is the caller graph for this function:

◆ BoyerMooreCtxDeInit()

void BoyerMooreCtxDeInit ( BmCtx bmctx)

Free the memory allocated to Boyer Moore context.

Parameters
bmCtxpointer to the Context for the pattern

Definition at line 119 of file util-spm-bm.c.

References SCEnter, SCFree, and SCReturn.

Referenced by BoyerMooreNocaseSearch(), and BoyerMooreSearch().

Here is the caller graph for this function:

◆ BoyerMooreCtxInit()

BmCtx* BoyerMooreCtxInit ( const uint8_t *  needle,
uint16_t  needle_len 
)

Setup a Boyer Moore context.

Prepare and return a Boyer Moore context

Parameters
strpointer to the pattern string
sizelength of the string
Return values
BmCtxpointer to the newly created Context for the pattern \initonly BoyerMoore contexts should be created at init

Definition at line 78 of file util-spm-bm.c.

References FatalError, SCMalloc, and unlikely.

Referenced by BoyerMooreNocaseCtxInit(), and BoyerMooreSearch().

Here is the caller graph for this function:

◆ BoyerMooreCtxToNocase()

void BoyerMooreCtxToNocase ( BmCtx bm_ctx,
uint8_t *  needle,
uint16_t  needle_len 
)

Given a BmCtx structure, recreate the pre/suffixes for nocase.

Return values
BmCtxpointer to the already created BmCtx (with BoyerMooreCtxInit())
Parameters
strpointer to the pattern string
sizelength of the string

Definition at line 58 of file util-spm-bm.c.

Referenced by BoyerMooreNocaseCtxInit().

Here is the caller graph for this function:

◆ BoyerMooreNocase()

uint8_t* BoyerMooreNocase ( const uint8_t *  x,
const uint16_t  m,
const uint8_t *  y,
const uint32_t  n,
const BmCtx bm_ctx 
)

Boyer Moore search algorithm Is better as the pattern length increases and for big buffers to search in. The algorithm needs a context of two arrays already prepared by prep_bad_chars() and prep_good_suffix()

Parameters
ypointer to the buffer to search in
nlength limit of the buffer
xpointer to the pattern we ar searching for
mlength limit of the needle
bmBcpointer to an array of BoyerMooreSuffixes prepared by prep_good_suffix()
bmGspointer to an array of bachars prepared by prep_bad_chars()
Return values
ptrto start of the match; NULL if no match

Definition at line 338 of file util-spm-bm.c.

References BmCtx_::bmBc, BmCtx_::bmGs, m, u8_tolower, and unlikely.

Referenced by BoyerMooreNocaseSearch().

Here is the caller graph for this function:

◆ BoyerMooreNocaseCtxInit()

BmCtx* BoyerMooreNocaseCtxInit ( uint8_t *  needle,
uint16_t  needle_len 
)

Setup a Boyer Moore context for nocase search.

Parameters
strpointer to the pattern string
sizelength of the string
Return values
BmCtxpointer to the newly created Context for the pattern \initonly BoyerMoore contexts should be created at init

Definition at line 105 of file util-spm-bm.c.

References BoyerMooreCtxInit(), and BoyerMooreCtxToNocase().

Referenced by BoyerMooreNocaseSearch().

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

◆ SpmBMRegister()

void SpmBMRegister ( void  )

Definition at line 475 of file util-spm-bm.c.

References SpmTableElmt_::InitGlobalThreadCtx, SpmTableElmt_::name, SPM_BM, and spm_table.

Referenced by SpmTableSetup().

Here is the caller graph for this function: