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
31 typedef 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. */
39  uint8_t detect_progress;
40  /* original value to track changes. */
41  const uint8_t detect_progress_orig;
42 
43  const uint8_t tx_progress;
44  const uint8_t tx_end_state;
45  bool is_last; /* is this the last tx? */
46 
47  /** app-layer specific transaction type (for sub-state support). 0 if not used. */
48  const uint8_t tx_type;
50 
51 typedef struct PrefilterStore_ {
52  const char *name;
53  void (*FreeFunc)(void *);
54  uint32_t id;
56 
57 void Prefilter(DetectEngineThreadCtx *, const SigGroupHead *, Packet *p, const uint8_t flags,
58  const SignatureMask mask);
59 
61  SignatureMask mask, enum SignatureHookPkt hook, void *pectx, void (*FreeFunc)(void *pectx),
62  const char *name);
63 
65  DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, Flow *f);
66 
68  PrefilterPktFn PrefilterFunc, void *pectx, void (*FreeFunc)(void *pectx), const char *name);
70  PrefilterTxFn PrefilterTxFunc, AppProto alproto, uint8_t sub_state,
71  const int8_t tx_min_progress, void *pectx, void (*FreeFunc)(void *pectx), const char *name);
73  PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int8_t tx_min_progress,
74  void *pectx, void (*FreeFunc)(void *pectx), const char *name);
76  PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx,
77  void (*FreeFunc)(void *pectx), const char *name);
79  void (*PrefilterPostRuleFunc)(
80  DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f),
81  void *pectx, void (*FreeFunc)(void *pectx), const char *name);
82 
84  const SigGroupHead *sgh,
85  Packet *p,
86  const uint8_t ipproto,
87  const uint8_t flow_flags,
88  const AppProto alproto,
89  void *alstate,
90  DetectTransaction *tx);
91 
93 
96 
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  const DetectBufferMpmRegistry *mpm_reg, int list_id);
111 
113  DetectEngineThreadCtx *det_ctx, const Signature *s, const int type, const uint32_t value);
114 
115 void PrefilterPktNonPFStatsDump(void);
116 
117 #endif
PostRuleMatchWorkQueueAppend
void PostRuleMatchWorkQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, const int type, const uint32_t value)
Definition: detect-engine-prefilter.c:1845
DetectTransaction_::tx_data_ptr
struct AppLayerTxData * tx_data_ptr
Definition: detect-engine-prefilter.h:34
PrefilterStore_::FreeFunc
void(* FreeFunc)(void *)
Definition: detect-engine-prefilter.h:53
PrefilterStore_
Definition: detect-engine-prefilter.h:51
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1693
DetectRunPrefilterTx
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
Definition: detect-engine-prefilter.c:95
PrefilterAppendPayloadEngine
int PrefilterAppendPayloadEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:342
PrefilterPktNonPFStatsDump
void PrefilterPktNonPFStatsDump(void)
Definition: detect-engine-prefilter.c:625
name
const char * name
Definition: detect-engine-proto.c:48
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:87
type
uint8_t type
Definition: decode-sctp.h:0
Flow_
Flow data structure.
Definition: flow.h:354
PrefilterDeinit
void PrefilterDeinit(DetectEngineCtx *de_ctx)
Definition: detect-engine-prefilter.c:1517
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:981
DetectBufferMpmRegistry_
one time registration of keywords at start up
Definition: detect.h:777
PrefilterAppendFrameEngine
int PrefilterAppendFrameEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterFrameFn PrefilterFrameFunc, AppProto alproto, uint8_t frame_type, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:420
p
Packet * p
Definition: fuzz_iprep.c:21
PrefilterSingleMpmRegister
int PrefilterSingleMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
Definition: detect-engine-prefilter.c:1696
PrefilterStore_::id
uint32_t id
Definition: detect-engine-prefilter.h:54
PrefilterGenericMpmRegister
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
Definition: detect-engine-prefilter.c:1674
PrefilterMultiGenericMpmRegister
int PrefilterMultiGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
Definition: detect-engine-prefilter.c:1751
PrefilterCleanupRuleGroup
void PrefilterCleanupRuleGroup(const DetectEngineCtx *de_ctx, SigGroupHead *sgh)
Definition: detect-engine-prefilter.c:524
DetectTransaction_::tx_end_state
const uint8_t tx_end_state
Definition: detect-engine-prefilter.h:44
AppLayerTxData
Definition: app-layer-parser.h:166
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:22
DetectTransaction
struct DetectTransaction_ DetectTransaction
DetectTransaction_::detect_progress_orig
const uint8_t detect_progress_orig
Definition: detect-engine-prefilter.h:41
DetectEngineThreadCtx_
Definition: detect.h:1300
DetectTransaction_::detect_progress
uint8_t detect_progress
Definition: detect-engine-prefilter.h:39
PrefilterFreeEnginesList
void PrefilterFreeEnginesList(PrefilterEngineList *list)
Definition: detect-engine-prefilter.c:496
PrefilterAppendPostRuleEngine
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)
Definition: detect-engine-prefilter.c:455
detect.h
SignatureHookPkt
SignatureHookPkt
Definition: detect.h:540
DetectTransaction_::is_last
bool is_last
Definition: detect-engine-prefilter.h:45
PrefilterAppendTxEngine
int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, const AppProto alproto, const int8_t tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:412
PrefilterFrameFn
void(* PrefilterFrameFn)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, const struct Frames *frames, const struct Frame *frame)
Definition: detect.h:1581
DetectTransaction_::tx_id
const uint64_t tx_id
Definition: detect-engine-prefilter.h:33
PrefilterStore
struct PrefilterStore_ PrefilterStore
PrefilterAppendTxEngineSubState
int PrefilterAppendTxEngineSubState(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterTxFn PrefilterTxFunc, AppProto alproto, uint8_t sub_state, const int8_t tx_min_progress, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:374
Packet_
Definition: decode.h:516
DetectTransaction_::de_state
DetectEngineStateDirection * de_state
Definition: detect-engine-prefilter.h:35
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
DetectTransaction_::tx_type
const uint8_t tx_type
Definition: detect-engine-prefilter.h:48
PrefilterTxFn
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:1585
PrefilterInit
void PrefilterInit(DetectEngineCtx *de_ctx)
Definition: detect-engine-prefilter.c:1524
PrefilterAppendEngine
int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, SignatureMask mask, enum SignatureHookPkt hook, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
Definition: detect-engine-prefilter.c:303
flags
uint8_t flags
Definition: decode-gre.h:0
DetectTransaction_
Definition: detect-engine-prefilter.h:31
PrefilterEngineList_
Definition: detect.h:1588
DetectEngineStateDirection_
Definition: detect-engine-state.h:85
PrefilterPktFn
void(* PrefilterPktFn)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
Definition: detect.h:1580
DetectTransaction_::tx_ptr
void * tx_ptr
Definition: detect-engine-prefilter.h:32
PrefilterStore_::name
const char * name
Definition: detect-engine-prefilter.h:52
Signature_
Signature container.
Definition: detect.h:682
Prefilter
void Prefilter(DetectEngineThreadCtx *, const SigGroupHead *, Packet *p, const uint8_t flags, const SignatureMask mask)
Definition: detect-engine-prefilter.c:237
DetectTransaction_::tx_progress
const uint8_t tx_progress
Definition: detect-engine-prefilter.h:43
MpmCtx_
Definition: util-mpm.h:97
PrefilterPostRuleMatch
void PrefilterPostRuleMatch(DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh, Packet *p, Flow *f)
invoke post-rule match "prefilter" engines
Definition: detect-engine-prefilter.c:214
PrefilterGenericMpmPktRegister
int PrefilterGenericMpmPktRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
Definition: detect-engine-prefilter.c:1822
PrefilterSetupRuleGroup
int PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
Definition: detect-engine-prefilter.c:1257
SignatureMask
#define SignatureMask
Definition: decode.h:100