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->detect_progress %02x", p->
pcap_cnt,
112 if (tx_ptr == NULL) {
122 SCLogDebug(
"tx already marked progress as beyond engine: %u > %u",
138 SCLogDebug(
"tx->tx_progress %d engine->ctx.tx_min_progress %d "
139 "engine->is_last_for_progress %d => tx->detect_progress updated to %02x",
220 SignatureMask mask,
void *pectx,
void (*FreeFunc)(
void *pectx),
const char *
name)
222 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
228 memset(e, 0x00,
sizeof(*e));
239 while (t->
next != NULL) {
253 PrefilterPktFn PrefilterFunc,
void *pectx,
void (*FreeFunc)(
void *pectx),
const char *
name)
255 if (sgh == NULL || PrefilterFunc == NULL || pectx == NULL)
261 memset(e, 0x00,
sizeof(*e));
271 while (t->
next != NULL) {
286 void (*FreeFunc)(
void *pectx),
const char *
name)
288 if (sgh == NULL || PrefilterTxFunc == NULL || pectx == NULL)
294 memset(e, 0x00,
sizeof(*e));
308 while (t->
next != NULL) {
323 void (*FreeFunc)(
void *pectx),
const char *
name)
325 if (sgh == NULL || PrefilterFrameFunc == NULL || pectx == NULL)
331 memset(e, 0x00,
sizeof(*e));
343 while (t->
next != NULL) {
370 PrefilterFreeEngineList(t);
412 static int PrefilterSetupRuleGroupSortHelper(
const void *a,
const void *b)
431 FatalError(
"failed to set up pattern matching");
470 if (el->
next == NULL) {
495 if (el->
next == NULL) {
512 uint16_t local_id = 0;
527 PrefilterSetupRuleGroupSortHelper);
536 int last_tx_progress = 0;
537 bool last_tx_progress_set =
false;
549 last_tx_progress_set =
true;
550 prev_engine = engine;
566 SCLogDebug(
"engine: gid %u alproto %s tx_min_progress %d is_last %s "
567 "is_last_for_progress %s",
569 engine->
is_last ?
"true" :
"false",
597 if (el->
next == NULL) {
607 static uint32_t PrefilterStoreHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
611 uint32_t hash = strlen(
ctx->name);
613 for (
size_t u = 0; u < strlen(
ctx->name); u++) {
614 hash +=
ctx->name[u];
621 static char PrefilterStoreCompareFunc(
void *data1, uint16_t len1,
622 void *data2, uint16_t len2)
626 return (strcmp(ctx1->
name, ctx2->
name) == 0);
629 static void PrefilterStoreFreeFunc(
void *ptr)
646 PrefilterStoreHashFunc,
647 PrefilterStoreCompareFunc,
648 PrefilterStoreFreeFunc);
653 const char *
name,
void (*FreeFunc)(
void *))
744 const uint8_t *data = buffer->
inspect;
749 if (data != NULL && data_len >= mpm_ctx->
minlen) {
751 mpm_ctx, &det_ctx->
mtc, &det_ctx->
pmq, data, data_len);
756 static void PrefilterGenericMpmFree(
void *ptr)
774 mpm_reg->
app_v2.alproto, mpm_reg->
app_v2.tx_min_progress,
775 pectx, PrefilterGenericMpmFree, mpm_reg->
pname);
782 static void PrefilterMultiGenericMpmFree(
void *ptr)
796 uint32_t local_id = 0;
801 ctx->GetData(det_ctx,
ctx->transforms, f,
flags, txv,
ctx->list_id, local_id);
828 mpm_reg->
app_v2.tx_min_progress, pectx, PrefilterMultiGenericMpmFree, mpm_reg->
pname);
853 Packet *p,
const void *pectx)
867 const uint8_t *data = buffer->
inspect;
872 if (data != NULL && data_len >= mpm_ctx->
minlen) {
874 mpm_ctx, &det_ctx->
mtc, &det_ctx->
pmq, data, data_len);
879 static void PrefilterMpmPktFree(
void *ptr)
897 de_ctx, sgh, PrefilterMpmPkt, 0, pectx, PrefilterMpmPktFree, mpm_reg->
pname);
struct DetectBufferMpmRegistry_::@82::@85 pkt_v1
#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)
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)
union PrefilterEngine_::@97 cb
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)
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
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
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)
struct DetectBufferMpmRegistry_::@82::@84 app_v2
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)
struct PrefilterMpm PrefilterMpm
PrefilterEngine * pkt_engines
PrefilterTxFn PrefilterTx
union PrefilterEngine_::@96 ctx
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