Go to the documentation of this file.
62 const char *name,
void (*FreeFunc)(
void *));
66 static inline void QuickSortSigIntId(
SigIntId *sids, uint32_t n)
86 QuickSortSigIntId(sids, r - sids + 1);
87 QuickSortSigIntId(l, sids + n - l);
96 const uint8_t ipproto,
97 const uint8_t flow_flags,
105 SCLogDebug(
"packet %" PRIu64
" tx %p progress %d tx->prefilter_flags %" PRIx64, p->
pcap_cnt,
110 if (engine->
alproto != alproto)
204 void *pectx,
void (*FreeFunc)(
void *pectx),
207 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
213 memset(e, 0x00,
sizeof(*e));
223 while (t->
next != NULL) {
238 void *pectx,
void (*FreeFunc)(
void *pectx),
241 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
247 memset(e, 0x00,
sizeof(*e));
257 while (t->
next != NULL) {
272 void (*FreeFunc)(
void *pectx),
const char *name)
274 if (sgh == NULL || PrefilterTxFunc == NULL || pectx == NULL)
280 memset(e, 0x00,
sizeof(*e));
294 while (t->
next != NULL) {
309 void (*FreeFunc)(
void *pectx),
const char *name)
311 if (sgh == NULL || PrefilterFrameFunc == NULL || pectx == NULL)
317 memset(e, 0x00,
sizeof(*e));
329 while (t->
next != NULL) {
356 PrefilterFreeEngineList(t);
398 static int PrefilterSetupRuleGroupSortHelper(
const void *a,
const void *b)
417 FatalError(
"failed to set up pattern matching");
455 if (el->
next == NULL) {
479 if (el->
next == NULL) {
496 uint16_t local_id = 0;
511 PrefilterSetupRuleGroupSortHelper);
520 int last_tx_progress = 0;
521 bool last_tx_progress_set =
false;
533 last_tx_progress_set =
true;
534 prev_engine = engine;
550 SCLogDebug(
"engine: gid %u alproto %s tx_min_progress %d is_last %s "
551 "is_last_for_progress %s",
553 engine->
is_last ?
"true" :
"false",
581 if (el->
next == NULL) {
591 static uint32_t PrefilterStoreHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
595 uint32_t hash = strlen(ctx->
name);
597 for (
size_t u = 0; u < strlen(ctx->
name); u++) {
598 hash += ctx->
name[u];
605 static char PrefilterStoreCompareFunc(
void *data1, uint16_t len1,
606 void *data2, uint16_t len2)
610 return (strcmp(ctx1->
name, ctx2->
name) == 0);
613 static void PrefilterStoreFreeFunc(
void *ptr)
630 PrefilterStoreHashFunc,
631 PrefilterStoreCompareFunc,
632 PrefilterStoreFreeFunc);
637 const char *name,
void (*FreeFunc)(
void *))
728 const uint8_t *data = buffer->
inspect;
733 if (data != NULL && data_len >= mpm_ctx->
minlen) {
735 &det_ctx->
mtcu, &det_ctx->
pmq, data, data_len);
740 static void PrefilterGenericMpmFree(
void *ptr)
758 mpm_reg->
app_v2.alproto, mpm_reg->
app_v2.tx_min_progress,
759 pectx, PrefilterGenericMpmFree, mpm_reg->
pname);
784 Packet *p,
const void *pectx)
798 const uint8_t *data = buffer->
inspect;
803 if (data != NULL && data_len >= mpm_ctx->
minlen) {
805 &det_ctx->
mtcu, &det_ctx->
pmq, data, data_len);
810 static void PrefilterMpmPktFree(
void *ptr)
828 pectx, PrefilterMpmPktFree, mpm_reg->
pname);
#define HashListTableGetListData(hb)
int PrefilterGenericMpmPktRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
PrefilterEngine * tx_engines
struct AppLayerTxData * tx_data_ptr
void(* Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
Prepare the pattern matcher ctx in a sig group head.
struct PrefilterMpmPktCtx PrefilterMpmPktCtx
union PrefilterEngine_::@99 ctx
#define PREFILTER_PROFILING_END(ctx, profile_id)
void Prefilter(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t flags)
uint32_t rule_id_array_cnt
Container for matching data for a signature group.
struct HtpBodyChunk_ * next
InspectionBufferGetDataPtr GetData
#define PREFILTER_PROFILING_START(det_ctx)
InspectionBuffer *(* InspectionBufferGetDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
main detection engine ctx
HashListTableBucket * HashListTableGetListHead(HashListTable *ht)
InspectionBuffer *(* InspectionBufferGetPktDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Packet *p, const int list_id)
void PrefilterDeinit(DetectEngineCtx *de_ctx)
one time registration of keywords at start up
void(* Prefilter)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
PrefilterEngine * payload_engines
enum DetectEnginePrefilterSetting prefilter_setting
#define PKT_NOPAYLOAD_INSPECTION
#define PACKET_PROFILING_DETECT_END(p, id)
void * HashListTableLookup(HashListTable *ht, void *data, uint16_t datalen)
void(* Free)(void *pectx)
int PrefilterAppendFrameEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
DetectEngineTransforms transforms
int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen)
bool is_last_for_progress
struct PrefilterEngineList_ * next
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
AppLayerParserState * alparser
#define HashListTableGetListNext(hb)
HashListTable * prefilter_hash_table
HashListTable * HashListTableInit(uint32_t size, uint32_t(*Hash)(struct HashListTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *))
const char * PrefilterStoreGetName(const uint32_t id)
PrefilterEngineList * tx_engines
PrefilterFrameFn PrefilterFrame
PrefilterTxFn PrefilterTx
struct DetectBufferMpmRegistry_::@86::@89 pkt_v1
InspectionBufferGetPktDataPtr GetData
#define PKT_DETECT_HAS_STREAMDATA
struct PrefilterMpmCtx PrefilterMpmCtx
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
void(* PrefilterFrameFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, const struct Frames *frames, const struct Frame *frame)
SigGroupHeadInitData * init
PrefilterFrameFn PrefilterFrame
void(* PrefilterTxFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f, void *tx, const uint64_t tx_id, const AppLayerTxData *tx_data, const uint8_t flags)
uint32_t(* Search)(const struct MpmCtx_ *, struct MpmThreadCtx_ *, PrefilterRuleStore *, const uint8_t *, uint32_t)
PrefilterEngine * frame_engines
PrefilterEngineList * pkt_engines
struct AppLayerTxData AppLayerTxData
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
PrefilterEngineList * frame_engines
PrefilterEngineList * payload_engines
struct DetectBufferMpmRegistry_::@86::@88 app_v2
void HashListTableFree(HashListTable *ht)
#define SCMallocAligned(size, align)
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
DetectEnginePrefilterSetting
void PrefilterCleanupRuleGroup(const DetectEngineCtx *de_ctx, SigGroupHead *sgh)
const DetectEngineTransforms * transforms
int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, AppProto alproto, int tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
void PrefilterInit(DetectEngineCtx *de_ctx)
bool sm_types_prefilter[DETECT_TBLSIZE]
#define PACKET_PROFILING_DETECT_START(p, id)
const DetectEngineTransforms * transforms
int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, void(*PrefilterFunc)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), void *pectx, void(*FreeFunc)(void *pectx), const char *name)
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
PrefilterEngine * pkt_engines
PrefilterTxFn PrefilterTx
int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, void(*PrefilterFunc)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx), void *pectx, void(*FreeFunc)(void *pectx), const char *name)
union PrefilterEngine_::@100 cb
AppProto alproto
application level protocol
void PrefilterFreeEnginesList(PrefilterEngineList *list)
#define DEBUG_VALIDATE_BUG_ON(exp)
void DetectRunPrefilterTx(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t ipproto, const uint8_t flow_flags, const AppProto alproto, void *alstate, DetectTransaction *tx)
run prefilter engines on a transaction