suricata
detect-engine-prefilter.h
Go to the documentation of this file.
1/* Copyright (C) 2016-2025 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_DETECT_ENGINE_PREFILTER_H
25#define SURICATA_DETECT_ENGINE_PREFILTER_H
26
27#include "detect.h"
28#include "detect-engine-state.h"
29
30// TODO
31typedef struct DetectTransaction_ {
32 void *tx_ptr;
33 const uint64_t tx_id;
36
37 /* tracking detect progress. Holds the value of
38 * the last completed "progress" + 1. */
40 /* original value to track changes. */
41 const uint8_t detect_progress_orig;
42
43 const int tx_progress;
44 const int tx_end_state;
46
47typedef struct PrefilterStore_ {
48 const char *name;
49 void (*FreeFunc)(void *);
50 uint32_t id;
52
53void Prefilter(DetectEngineThreadCtx *, const SigGroupHead *, Packet *p, const uint8_t flags,
54 const SignatureMask mask);
55
57 SignatureMask mask, enum SignatureHookPkt hook, void *pectx, void (*FreeFunc)(void *pectx),
58 const char *name);
59
61 DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, Flow *f);
62
64 PrefilterPktFn PrefilterFunc, void *pectx, void (*FreeFunc)(void *pectx), const char *name);
66 PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int tx_min_progress,
67 void *pectx, void (*FreeFunc)(void *pectx), const char *name);
69 PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx,
70 void (*FreeFunc)(void *pectx), const char *name);
72 void (*PrefilterPostRuleFunc)(
73 DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f),
74 void *pectx, void (*FreeFunc)(void *pectx), const char *name);
75
77 const SigGroupHead *sgh,
78 Packet *p,
79 const uint8_t ipproto,
80 const uint8_t flow_flags,
81 const AppProto alproto,
82 void *alstate,
84
86
89
90#ifdef PROFILING
91const char *PrefilterStoreGetName(const uint32_t id);
92#endif
93
96
98 const DetectBufferMpmRegistry *mpm_reg, int list_id);
99
101 const DetectBufferMpmRegistry *mpm_reg, int list_id);
102
104 const DetectBufferMpmRegistry *mpm_reg, int list_id);
105
107 const DetectBufferMpmRegistry *mpm_reg, int list_id);
108
110 DetectEngineThreadCtx *det_ctx, const Signature *s, const int type, const uint32_t value);
111
113
114#endif
struct AppLayerTxData AppLayerTxData
uint16_t AppProto
uint8_t flags
Definition decode-gre.h:0
uint16_t type
#define SignatureMask
Definition decode.h:99
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
int PrefilterAppendFrameEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
void PrefilterPostRuleMatch(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, Flow *f)
invoke post-rule match "prefilter" engines
struct DetectTransaction_ DetectTransaction
const char * PrefilterStoreGetName(const uint32_t id)
void PostRuleMatchWorkQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, const int type, const uint32_t value)
void PrefilterPktNonPFStatsDump(void)
int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, SignatureMask mask, enum SignatureHookPkt hook, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
void PrefilterDeinit(DetectEngineCtx *de_ctx)
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
int PrefilterMultiGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
struct PrefilterStore_ PrefilterStore
void PrefilterInit(DetectEngineCtx *de_ctx)
void Prefilter(DetectEngineThreadCtx *, const SigGroupHead *, Packet *p, const uint8_t flags, const SignatureMask mask)
int PrefilterAppendPostRuleEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, void(*PrefilterPostRuleFunc)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f), void *pectx, void(*FreeFunc)(void *pectx), const char *name)
int PrefilterGenericMpmPktRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
void PrefilterFreeEnginesList(PrefilterEngineList *list)
int PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
void PrefilterCleanupRuleGroup(const DetectEngineCtx *de_ctx, SigGroupHead *sgh)
int PrefilterSingleMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
Data structures and function prototypes for keeping state for the detection engine.
SignatureHookPkt
Definition detect.h:538
void(* PrefilterFrameFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, const struct Frames *frames, const struct Frame *frame)
Definition detect.h:1522
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)
Definition detect.h:1526
void(* PrefilterPktFn)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
Definition detect.h:1521
DetectEngineCtx * de_ctx
one time registration of keywords at start up
Definition detect.h:762
main detection engine ctx
Definition detect.h:932
DetectEngineStateDirection * de_state
struct AppLayerTxData * tx_data_ptr
Flow data structure.
Definition flow.h:356
Container for matching data for a signature group.
Definition detect.h:1629
Signature container.
Definition detect.h:668
const char * name