suricata
util-spm-bs2bm.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "util-spm-bs2bm.h"
Include dependency graph for util-spm-bs2bm.c:

Go to the source code of this file.

Functions

void Bs2BmBadchars (const uint8_t *needle, uint16_t needle_len, uint8_t *badchars)
 Array setup function for Bs2Bm of bad characters index (not found at the needle) More...
 
uint8_t * Bs2Bm (const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len, const uint8_t badchars[])
 Basic search with a bad characters array. The array badchars contains flags at character's ascii index that can't be inside the needle. So the skips can be faster. More...
 
uint8_t * Bs2BmNocase (const uint8_t *haystack, uint32_t haystack_len, const uint8_t *needle, uint16_t needle_len, const uint8_t badchars[])
 Basic search case less with a bad characters array. The array badchars contains flags at character's ascii index that can't be inside the needle. So the skips can be faster. More...
 

Detailed Description

Author
Pablo Rincon Crespo pablo.nosp@m..rin.nosp@m.con.c.nosp@m.resp.nosp@m.o@gma.nosp@m.il.c.nosp@m.om

Bs2Bm use a simple context array to determine the characters that are not present on the pattern. This way on partial matches broken by a char not present, we can skip to the next character making less checks

Definition in file util-spm-bs2bm.c.

Function Documentation

◆ Bs2Bm()

uint8_t* Bs2Bm ( const uint8_t *  haystack,
uint32_t  haystack_len,
const uint8_t *  needle,
uint16_t  needle_len,
const uint8_t  badchars[] 
)

Basic search with a bad characters array. The array badchars contains flags at character's ascii index that can't be inside the needle. So the skips can be faster.

Parameters
haystackpointer to the buffer to search in
haystack_lenlength limit of the buffer
needlepointer to the pattern we ar searching for
needle_lenlength limit of the needle
badcharspointer to an array of bachars prepared by Bs2BmBadchars()
Return values
ptrto start of the match; NULL if no match

Definition at line 69 of file util-spm-bs2bm.c.

Referenced by Bs2bmSearch().

Here is the caller graph for this function:

◆ Bs2BmBadchars()

void Bs2BmBadchars ( const uint8_t *  needle,
uint16_t  needle_len,
uint8_t *  badchars 
)

Array setup function for Bs2Bm of bad characters index (not found at the needle)

Parameters
needlepointer to the pattern we ar searching for
needle_lenlength limit of the needle
badcharspointer to an empty array of bachars. The array prepared contains characters that can't be inside the needle_len. So the skips can be faster

Definition at line 43 of file util-spm-bs2bm.c.

References ALPHABET_SIZE.

Referenced by Bs2bmSearch().

Here is the caller graph for this function:

◆ Bs2BmNocase()

uint8_t* Bs2BmNocase ( const uint8_t *  haystack,
uint32_t  haystack_len,
const uint8_t *  needle,
uint16_t  needle_len,
const uint8_t  badchars[] 
)

Basic search case less with a bad characters array. The array badchars contains flags at character's ascii index that can't be inside the needle. So the skips can be faster.

Parameters
haystackpointer to the buffer to search in
haystack_lenlength limit of the buffer
needlepointer to the pattern we ar searching for
needle_lenlength limit of the needle
badcharspointer to an array of bachars prepared by Bs2BmBadchars()
Return values
ptrto start of the match; NULL if no match

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

References u8_tolower.