suricata
detect-engine-mpm.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2010 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_MPM_H
25#define SURICATA_DETECT_ENGINE_MPM_H
26
27#include "detect.h"
28
29
38
39uint32_t PatternStrength(uint8_t *, uint16_t);
40
41uint8_t PatternMatchDefaultMatcher(void);
42
43void PatternMatchPrepare(MpmCtx *, uint16_t);
45
46void PatternMatchDestroy(MpmCtx *, uint16_t);
47void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t);
48
50
53
55
60
61/**
62 * \brief Figure out the FP and their respective content ids for all the
63 * sigs in the engine.
64 *
65 * \param de_ctx Detection engine context.
66 *
67 * \retval 0 On success.
68 * \retval -1 On failure.
69 */
71
73 const DetectBufferMpmRegistry *mpm_reg, int list_id);
74
75/** \brief register an app layer keyword for mpm
76 * \param name buffer name
77 * \param direction SIG_FLAG_TOSERVER or SIG_FLAG_TOCLIENT
78 * \param priority mpm keyword priority
79 * \param PrefilterRegister Prefilter api registration function
80 * \param GetData callback to setup a InspectBuffer. May be NULL.
81 * \param alproto AppProto this MPM engine inspects
82 * \param tx_min_progress min tx progress needed to invoke this engine.
83 *
84 * \note direction must be set to either toserver or toclient.
85 * If both are needed, register the keyword twice.
86 */
87void DetectAppLayerMpmRegister(const char *name, int direction, int priority,
88 PrefilterRegisterFunc PrefilterRegister, InspectionBufferGetDataPtr GetData,
89 AppProto alproto, int tx_min_progress);
90void DetectAppLayerMpmRegisterSingle(const char *name, int direction, int priority,
92 AppProto alproto, int tx_min_progress);
93void DetectAppLayerMpmMultiRegister(const char *name, int direction, int priority,
95 AppProto alproto, int tx_min_progress);
98 const int id, const int parent_id,
99 DetectEngineTransforms *transforms);
100
101void DetectPktMpmRegister(const char *name, int priority, PrefilterRegisterFunc PrefilterRegister,
104 const int id, const int parent_id,
105 DetectEngineTransforms *transforms);
106
107void DetectFrameMpmRegister(const char *name, int direction, int priority,
108 int (*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx,
109 const DetectBufferMpmRegistry *mpm_reg, int list_id),
110 AppProto alproto, uint8_t type);
111void DetectFrameMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id,
112 DetectEngineTransforms *transforms);
113void DetectEngineFrameMpmRegister(DetectEngineCtx *de_ctx, const char *name, int direction,
114 int priority,
115 int (*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx,
116 const DetectBufferMpmRegistry *mpm_reg, int list_id),
117 AppProto alproto, uint8_t type);
118
119
121 const DetectBufferMpmRegistry *mpm_reg, int list_id);
122
129
131 uint32_t local_id; /**< used as index into thread inspect array */
132 void *txv;
133};
134
136
137bool DetectBufferToClient(const DetectEngineCtx *de_ctx, int buf_id, AppProto alproto);
138
139#endif /* SURICATA_DETECT_ENGINE_MPM_H */
uint16_t AppProto
uint16_t type
bool(* InspectionSingleBufferGetDataPtr)(const void *txv, const uint8_t flow_flags, const uint8_t **buf, uint32_t *buf_len)
InspectionBuffer *(* InspectionBufferGetDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id)
bool(* InspectionMultiBufferGetDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const void *txv, const uint8_t flow_flags, uint32_t local_id, const uint8_t **buf, uint32_t *buf_len)
void DetectMpmInitializeBuiltinMpms(DetectEngineCtx *de_ctx)
bool DetectBufferToClient(const DetectEngineCtx *de_ctx, int buf_id, AppProto alproto)
void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s)
int SignatureHasStreamContent(const Signature *)
check if a signature has patterns that are to be inspected against the stream payload (as opposed to ...
int DetectMpmPrepareBuiltinMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for builtin buffers that are in "single or "shared" mode.
void MpmStoreFree(DetectEngineCtx *)
Frees the hash table - DetectEngineCtx->mpm_hash_table, allocated by MpmStoreInit() function.
int SignatureHasPacketContent(const Signature *)
check if a signature has patterns that are to be inspected against a packets payload (as opposed to t...
void EngineAnalysisAddAllRulePatterns(DetectEngineCtx *de_ctx, const Signature *s)
add all patterns on our stats hash Used to fill the hash later used by DumpPatterns()
int DetectSetFastPatternAndItsId(DetectEngineCtx *de_ctx)
Figure out the FP and their respective content ids for all the sigs in the engine.
void DetectPktMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
void DetectFrameMpmRegister(const char *name, int direction, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id), AppProto alproto, uint8_t type)
register a MPM engine
void DetectMpmInitializeFrameMpms(DetectEngineCtx *de_ctx)
void DetectAppLayerMpmMultiRegister(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionMultiBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
int PatternMatchPrepareGroup(DetectEngineCtx *, SigGroupHead *)
Prepare the pattern matcher ctx in a sig group head.
void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t)
uint32_t PatternStrength(uint8_t *, uint16_t)
Predict a strength value for patterns.
int DetectMpmPrepareFrameMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
void DetectMpmInitializeAppMpms(DetectEngineCtx *de_ctx)
uint8_t PatternMatchDefaultMatcher(void)
Function to return the multi pattern matcher algorithm to be used by the engine, based on the mpm-alg...
void DetectMpmInitializePktMpms(DetectEngineCtx *de_ctx)
void DetectPktMpmRegister(const char *name, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionBufferGetPktDataPtr GetData)
void DetectAppLayerMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
int PrefilterGenericMpmFrameRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
MpmStore * MpmStorePrepareBuffer(DetectEngineCtx *de_ctx, SigGroupHead *sgh, enum MpmBuiltinBuffers buf)
Get MpmStore for a built-in buffer type.
void PatternMatchPrepare(MpmCtx *, uint16_t)
void DetectEngineFrameMpmRegister(DetectEngineCtx *de_ctx, const char *name, int direction, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id), AppProto alproto, uint8_t type)
void DetectFrameMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
int DetectMpmPreparePktMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
void PatternMatchDestroy(MpmCtx *, uint16_t)
int DetectMpmPrepareAppMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
void DetectAppLayerMpmRegister(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
register an app layer keyword for mpm
void MpmStoreReportStats(const DetectEngineCtx *de_ctx)
void PatternMatchThreadPrepare(MpmThreadCtx *, uint16_t type)
void DetectAppLayerMpmRegisterSingle(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionSingleBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
int MpmStoreInit(DetectEngineCtx *)
Initializes the MpmStore mpm hash table to be used by the detection engine context.
int(* PrefilterRegisterFunc)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
InspectionBuffer *(* InspectionBufferGetPktDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Packet *p, const int list_id)
Definition detect.h:478
MpmBuiltinBuffers
Definition detect.h:1497
DetectEngineCtx * de_ctx
one time registration of keywords at start up
Definition detect.h:762
main detection engine ctx
Definition detect.h:932
InspectionMultiBufferGetDataPtr GetData
const DetectEngineTransforms * transforms
Container for matching data for a signature group.
Definition detect.h:1629
Signature container.
Definition detect.h:668
const char * name