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,
112 if (tx_ptr == NULL) {
209 SignatureMask mask,
void *pectx,
void (*FreeFunc)(
void *pectx),
const char *name)
211 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
217 memset(e, 0x00,
sizeof(*e));
228 while (t->
next != NULL) {
242 PrefilterPktFn PrefilterFunc,
void *pectx,
void (*FreeFunc)(
void *pectx),
const char *name)
244 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
250 memset(e, 0x00,
sizeof(*e));
260 while (t->
next != NULL) {
275 void (*FreeFunc)(
void *pectx),
const char *name)
277 if (sgh == NULL || PrefilterTxFunc == NULL || pectx == NULL)
283 memset(e, 0x00,
sizeof(*e));
297 while (t->
next != NULL) {
312 void (*FreeFunc)(
void *pectx),
const char *name)
314 if (sgh == NULL || PrefilterFrameFunc == NULL || pectx == NULL)
320 memset(e, 0x00,
sizeof(*e));
332 while (t->
next != NULL) {
359 PrefilterFreeEngineList(t);
401 static int PrefilterSetupRuleGroupSortHelper(
const void *a,
const void *b)
420 FatalError(
"failed to set up pattern matching");
459 if (el->
next == NULL) {
484 if (el->
next == NULL) {
501 uint16_t local_id = 0;
516 PrefilterSetupRuleGroupSortHelper);
525 int last_tx_progress = 0;
526 bool last_tx_progress_set =
false;
538 last_tx_progress_set =
true;
539 prev_engine = engine;
555 SCLogDebug(
"engine: gid %u alproto %s tx_min_progress %d is_last %s "
556 "is_last_for_progress %s",
558 engine->
is_last ?
"true" :
"false",
586 if (el->
next == NULL) {
596 static uint32_t PrefilterStoreHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
600 uint32_t hash = strlen(
ctx->name);
602 for (
size_t u = 0; u < strlen(
ctx->name); u++) {
603 hash +=
ctx->name[u];
610 static char PrefilterStoreCompareFunc(
void *data1, uint16_t len1,
611 void *data2, uint16_t len2)
615 return (strcmp(ctx1->
name, ctx2->
name) == 0);
618 static void PrefilterStoreFreeFunc(
void *ptr)
635 PrefilterStoreHashFunc,
636 PrefilterStoreCompareFunc,
637 PrefilterStoreFreeFunc);
642 const char *name,
void (*FreeFunc)(
void *))
733 const uint8_t *data = buffer->
inspect;
738 if (data != NULL && data_len >= mpm_ctx->
minlen) {
740 mpm_ctx, &det_ctx->
mtc, &det_ctx->
pmq, data, data_len);
745 static void PrefilterGenericMpmFree(
void *ptr)
763 mpm_reg->
app_v2.alproto, mpm_reg->
app_v2.tx_min_progress,
764 pectx, PrefilterGenericMpmFree, mpm_reg->
pname);
771 static void PrefilterMultiGenericMpmFree(
void *ptr)
785 uint32_t local_id = 0;
790 ctx->GetData(det_ctx,
ctx->transforms, f,
flags, txv,
ctx->list_id, local_id);
817 mpm_reg->
app_v2.tx_min_progress, pectx, PrefilterMultiGenericMpmFree, mpm_reg->
pname);
842 Packet *p,
const void *pectx)
856 const uint8_t *data = buffer->
inspect;
861 if (data != NULL && data_len >= mpm_ctx->
minlen) {
863 mpm_ctx, &det_ctx->
mtc, &det_ctx->
pmq, data, data_len);
868 static void PrefilterMpmPktFree(
void *ptr)
886 de_ctx, sgh, PrefilterMpmPkt, 0, 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
SigTableElmt * sigmatch_table
int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
Prepare the pattern matcher ctx in a sig group head.
struct PrefilterMpmPktCtx PrefilterMpmPktCtx
#define PREFILTER_PROFILING_END(ctx, profile_id)
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)
struct DetectBufferMpmRegistry_::@84::@86 app_v2
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
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 PrefilterMultiGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen)
union PrefilterEngine_::@99 cb
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 *))
void Prefilter(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, const uint8_t flags, const SignatureMask mask)
const char * PrefilterStoreGetName(const uint32_t id)
PrefilterEngineList * tx_engines
PrefilterFrameFn PrefilterFrame
PrefilterTxFn PrefilterTx
bool * sm_types_prefilter
union PrefilterEngine_::@98 ctx
InspectionBufferGetPktDataPtr GetData
#define PKT_DETECT_HAS_STREAMDATA
struct DetectBufferMpmRegistry_::@84::@87 pkt_v1
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
const DetectEngineTransforms * transforms
PrefilterFrameFn PrefilterFrame
int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, SignatureMask mask, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
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
int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
PrefilterEngineList * pkt_engines
struct AppLayerTxData AppLayerTxData
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
PrefilterEngineList * frame_engines
PrefilterEngineList * payload_engines
void HashListTableFree(HashListTable *ht)
#define SCMallocAligned(size, align)
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(* PrefilterPktFn)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
InspectionMultiBufferGetDataPtr GetData
void PrefilterInit(DetectEngineCtx *de_ctx)
#define PACKET_PROFILING_DETECT_START(p, id)
const DetectEngineTransforms * transforms
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
void * DetectGetInnerTx(void *tx_ptr, AppProto alproto, AppProto engine_alproto, uint8_t flow_flags)
void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
PrefilterEngine * pkt_engines
PrefilterTxFn PrefilterTx
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