suricata
detect-fragoffset.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2021 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 Breno Silva <breno.silva@gmail.com>
22  *
23  * Implements fragoffset keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "debug.h"
28 #include "decode.h"
29 #include "decode-ipv4.h"
30 #include "decode-ipv6.h"
31 
32 #include "detect.h"
33 #include "detect-parse.h"
35 
36 #include "detect-fragoffset.h"
37 
38 #include "util-byte.h"
39 #include "util-unittest.h"
40 #include "util-debug.h"
41 
42 #define PARSE_REGEX "^\\s*(?:(<|>))?\\s*([0-9]+)"
43 
44 static DetectParseRegex parse_regex;
45 
46 static int DetectFragOffsetMatch(DetectEngineThreadCtx *,
47  Packet *, const Signature *, const SigMatchCtx *);
48 static int DetectFragOffsetSetup(DetectEngineCtx *, Signature *, const char *);
49 #ifdef UNITTESTS
51 #endif
53 
54 static int PrefilterSetupFragOffset(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
55 static bool PrefilterFragOffsetIsPrefilterable(const Signature *s);
56 
57 /**
58  * \brief Registration function for fragoffset
59  */
61 {
62  sigmatch_table[DETECT_FRAGOFFSET].name = "fragoffset";
63  sigmatch_table[DETECT_FRAGOFFSET].desc = "match on specific decimal values of the IP fragment offset field";
64  sigmatch_table[DETECT_FRAGOFFSET].url = "/rules/header-keywords.html#fragoffset";
65  sigmatch_table[DETECT_FRAGOFFSET].Match = DetectFragOffsetMatch;
66  sigmatch_table[DETECT_FRAGOFFSET].Setup = DetectFragOffsetSetup;
68 #ifdef UNITTESTS
70 #endif
71  sigmatch_table[DETECT_FRAGOFFSET].SupportsPrefilter = PrefilterFragOffsetIsPrefilterable;
72  sigmatch_table[DETECT_FRAGOFFSET].SetupPrefilter = PrefilterSetupFragOffset;
73 
74  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
75 }
76 
77 static inline int FragOffsetMatch(const uint16_t poffset, const uint8_t mode,
78  const uint16_t doffset)
79 {
80  switch (mode) {
81  case FRAG_LESS:
82  if (poffset < doffset)
83  return 1;
84  break;
85  case FRAG_MORE:
86  if (poffset > doffset)
87  return 1;
88  break;
89  default:
90  if (poffset == doffset)
91  return 1;
92  }
93  return 0;
94 }
95 
96 /**
97  * \brief This function is used to match fragoffset rule option set on a packet
98  *
99  * \param t pointer to thread vars
100  * \param det_ctx pointer to the pattern matcher thread
101  * \param p pointer to the current packet
102  * \param m pointer to the sigmatch that we will cast into DetectFragOffsetData
103  *
104  * \retval 0 no match or frag is not set
105  * \retval 1 match
106  *
107  */
108 static int DetectFragOffsetMatch (DetectEngineThreadCtx *det_ctx,
109  Packet *p, const Signature *s, const SigMatchCtx *ctx)
110 {
111  uint16_t frag = 0;
112  const DetectFragOffsetData *fragoff = (const DetectFragOffsetData *)ctx;
113 
114  if (PKT_IS_PSEUDOPKT(p))
115  return 0;
116 
117  if (PKT_IS_IPV4(p)) {
118  frag = IPV4_GET_IPOFFSET(p);
119  } else if (PKT_IS_IPV6(p)) {
120  if (IPV6_EXTHDR_ISSET_FH(p)) {
121  frag = IPV6_EXTHDR_GET_FH_OFFSET(p);
122  } else {
123  return 0;
124  }
125  } else {
126  SCLogDebug("No IPv4 or IPv6 packet");
127  return 0;
128  }
129 
130  return FragOffsetMatch(frag, fragoff->mode, fragoff->frag_off);;
131 }
132 
133 /**
134  * \brief This function is used to parse fragoffset option passed via fragoffset: keyword
135  *
136  * \param de_ctx Pointer to the detection engine context
137  * \param fragoffsetstr Pointer to the user provided fragoffset options
138  *
139  * \retval fragoff pointer to DetectFragOffsetData on success
140  * \retval NULL on failure
141  */
142 static DetectFragOffsetData *DetectFragOffsetParse (DetectEngineCtx *de_ctx, const char *fragoffsetstr)
143 {
144  DetectFragOffsetData *fragoff = NULL;
145  char *substr[3] = {NULL, NULL, NULL};
146  int ret = 0, res = 0;
147  size_t pcre2_len;
148  int i;
149  const char *str_ptr;
150  char *mode = NULL;
151 
152  ret = DetectParsePcreExec(&parse_regex, fragoffsetstr, 0, 0);
153  if (ret < 1 || ret > 4) {
154  SCLogError(SC_ERR_PCRE_MATCH,"Parse error %s", fragoffsetstr);
155  goto error;
156  }
157 
158  for (i = 1; i < ret; i++) {
159  res = SC_Pcre2SubstringGet(parse_regex.match, i, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
160  if (res < 0) {
161  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
162  goto error;
163  }
164  substr[i-1] = (char *)str_ptr;
165  }
166 
167  fragoff = SCMalloc(sizeof(DetectFragOffsetData));
168  if (unlikely(fragoff == NULL))
169  goto error;
170 
171  fragoff->frag_off = 0;
172  fragoff->mode = 0;
173 
174  mode = substr[0];
175 
176  if(mode != NULL) {
177 
178  while(*mode != '\0') {
179  switch(*mode) {
180  case '>':
181  fragoff->mode = FRAG_MORE;
182  break;
183  case '<':
184  fragoff->mode = FRAG_LESS;
185  break;
186  }
187  mode++;
188  }
189  }
190 
191  if (StringParseUint16(&fragoff->frag_off, 10, 0, substr[1]) < 0) {
192  SCLogError(SC_ERR_INVALID_ARGUMENT, "specified frag offset %s is not "
193  "valid", substr[1]);
194  goto error;
195  }
196 
197  for (i = 0; i < 3; i++) {
198  if (substr[i] != NULL)
199  pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
200  }
201 
202  return fragoff;
203 
204 error:
205  for (i = 0; i < 3; i++) {
206  if (substr[i] != NULL)
207  pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
208  }
209  if (fragoff != NULL) DetectFragOffsetFree(de_ctx, fragoff);
210  return NULL;
211 
212 }
213 
214 /**
215  * \brief this function is used to add the parsed fragoffset data into the current signature
216  *
217  * \param de_ctx pointer to the Detection Engine Context
218  * \param s pointer to the Current Signature
219  * \param fragoffsetstr pointer to the user provided fragoffset option
220  *
221  * \retval 0 on Success
222  * \retval -1 on Failure
223  */
224 static int DetectFragOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *fragoffsetstr)
225 {
226  DetectFragOffsetData *fragoff = NULL;
227  SigMatch *sm = NULL;
228 
229  fragoff = DetectFragOffsetParse(de_ctx, fragoffsetstr);
230  if (fragoff == NULL) goto error;
231 
232  sm = SigMatchAlloc();
233  if (sm == NULL) goto error;
234 
235  sm->type = DETECT_FRAGOFFSET;
236  sm->ctx = (SigMatchCtx *)fragoff;
237 
240 
241  return 0;
242 
243 error:
244  if (fragoff != NULL) DetectFragOffsetFree(de_ctx, fragoff);
245  if (sm != NULL) SCFree(sm);
246  return -1;
247 
248 }
249 
250 /**
251  * \brief this function will free memory associated with DetectFragOffsetData
252  *
253  * \param ptr pointer to DetectFragOffsetData
254  */
256 {
257  DetectFragOffsetData *fragoff = (DetectFragOffsetData *)ptr;
258  SCFree(fragoff);
259 }
260 
261 static void
262 PrefilterPacketFragOffsetMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
263 {
264  if (PKT_IS_PSEUDOPKT(p))
265  return;
266 
267  uint16_t frag;
268 
269  if (PKT_IS_IPV4(p)) {
270  frag = IPV4_GET_IPOFFSET(p);
271  } else if (PKT_IS_IPV6(p)) {
272  if (IPV6_EXTHDR_ISSET_FH(p)) {
273  frag = IPV6_EXTHDR_GET_FH_OFFSET(p);
274  } else {
275  return;
276  }
277  } else {
278  SCLogDebug("No IPv4 or IPv6 packet");
279  return;
280  }
281 
282  const PrefilterPacketHeaderCtx *ctx = pectx;
283  if (FragOffsetMatch(frag, ctx->v1.u8[0], ctx->v1.u16[1]))
284  {
285  PrefilterAddSids(&det_ctx->pmq, ctx->sigs_array, ctx->sigs_cnt);
286  }
287 }
288 
289 static void
290 PrefilterPacketFragOffsetSet(PrefilterPacketHeaderValue *v, void *smctx)
291 {
292  const DetectFragOffsetData *fb = smctx;
293  v->u8[0] = fb->mode;
294  v->u16[1] = fb->frag_off;
295 }
296 
297 static bool
298 PrefilterPacketFragOffsetCompare(PrefilterPacketHeaderValue v, void *smctx)
299 {
300  const DetectFragOffsetData *fb = smctx;
301  if (v.u8[0] == fb->mode &&
302  v.u16[1] == fb->frag_off)
303  {
304  return true;
305  }
306  return false;
307 }
308 
309 static int PrefilterSetupFragOffset(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
310 {
312  PrefilterPacketFragOffsetSet,
313  PrefilterPacketFragOffsetCompare,
314  PrefilterPacketFragOffsetMatch);
315 }
316 
317 static bool PrefilterFragOffsetIsPrefilterable(const Signature *s)
318 {
319  const SigMatch *sm;
320  for (sm = s->init_data->smlists[DETECT_SM_LIST_MATCH] ; sm != NULL; sm = sm->next) {
321  switch (sm->type) {
322  case DETECT_FRAGOFFSET:
323  return true;
324  }
325  }
326  return false;
327 }
328 
329 #ifdef UNITTESTS
330 #include "detect-engine.h"
331 #include "detect-engine-mpm.h"
332 
333 /**
334  * \test DetectFragOffsetParseTest01 is a test for setting a valid fragoffset value
335  */
336 static int DetectFragOffsetParseTest01 (void)
337 {
338  DetectFragOffsetData *fragoff = DetectFragOffsetParse(NULL, "300");
339 
340  FAIL_IF_NULL(fragoff);
341  FAIL_IF_NOT(fragoff->frag_off == 300);
342 
343  DetectFragOffsetFree(NULL, fragoff);
344 
345  PASS;
346 }
347 
348 /**
349  * \test DetectFragOffsetParseTest02 is a test for setting a valid fragoffset value
350  * with spaces all around
351  */
352 static int DetectFragOffsetParseTest02 (void)
353 {
354  DetectFragOffsetData *fragoff = DetectFragOffsetParse(NULL, ">300");
355 
356  FAIL_IF_NULL(fragoff);
357  FAIL_IF_NOT(fragoff->frag_off == 300);
358  FAIL_IF_NOT(fragoff->mode == FRAG_MORE);
359 
360  DetectFragOffsetFree(NULL, fragoff);
361 
362  PASS;
363 }
364 
365 /**
366  * \test DetectFragOffsetParseTest03 is a test for setting an invalid fragoffset value
367  */
368 static int DetectFragOffsetParseTest03 (void)
369 {
370  DetectFragOffsetData *fragoff = DetectFragOffsetParse(NULL, "badc");
371 
372  FAIL_IF_NOT_NULL(fragoff);
373 
374  PASS;
375 }
376 
377 /**
378  * \test DetectFragOffsetMatchTest01 is a test for checking the working of
379  * fragoffset keyword by creating 2 rules and matching a crafted packet
380  * against them. Only the first one shall trigger.
381  */
382 static int DetectFragOffsetMatchTest01 (void)
383 {
385 
386  FAIL_IF_NULL(p);
387  Signature *s = NULL;
389  ThreadVars th_v;
390  DetectEngineThreadCtx *det_ctx = NULL;
391  IPV4Hdr ip4h;
392 
393  memset(p, 0, SIZE_OF_PACKET);
394  memset(&ip4h, 0, sizeof(IPV4Hdr));
395  memset(&dtv, 0, sizeof(DecodeThreadVars));
396  memset(&th_v, 0, sizeof(ThreadVars));
397 
399 
400  p->src.family = AF_INET;
401  p->dst.family = AF_INET;
402  p->src.addr_data32[0] = 0x01020304;
403  p->dst.addr_data32[0] = 0x04030201;
404 
405  ip4h.s_ip_src.s_addr = p->src.addr_data32[0];
406  ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
407  ip4h.ip_off = 0x2222;
408  p->ip4h = &ip4h;
409 
412 
413  de_ctx->flags |= DE_QUIET;
414 
415  s = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (fragoffset:546; sid:1;)");
416  FAIL_IF_NULL(s);
417 
418  s = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (fragoffset:5000; sid:2;)");
419  FAIL_IF_NULL(s);
420 
422  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
423 
424  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
425 
426  FAIL_IF(PacketAlertCheck(p, 1) == 0);
427  FAIL_IF(PacketAlertCheck(p, 2));
428 
429  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
431 
432  FlowShutdown();
433 
434  SCFree(p);
435  PASS;
436 }
437 
439 {
440  UtRegisterTest("DetectFragOffsetParseTest01", DetectFragOffsetParseTest01);
441  UtRegisterTest("DetectFragOffsetParseTest02", DetectFragOffsetParseTest02);
442  UtRegisterTest("DetectFragOffsetParseTest03", DetectFragOffsetParseTest03);
443  UtRegisterTest("DetectFragOffsetMatchTest01", DetectFragOffsetMatchTest01);
444 }
445 #endif /* UNITTESTS */
util-byte.h
DetectParseRegex::match
pcre2_match_data * match
Definition: detect-parse.h:45
SigTableElmt_::url
const char * url
Definition: detect.h:1204
detect-engine.h
StringParseUint16
int StringParseUint16(uint16_t *res, int base, uint16_t len, const char *str)
Definition: util-byte.c:336
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
DetectFragOffsetRegisterTests
void DetectFragOffsetRegisterTests(void)
Definition: detect-fragoffset.c:438
SigTableElmt_::desc
const char * desc
Definition: detect.h:1203
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, const char *str, int start_offset, int options)
Definition: detect-parse.c:2435
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1191
IPV6_EXTHDR_GET_FH_OFFSET
#define IPV6_EXTHDR_GET_FH_OFFSET(p)
Definition: decode-ipv6.h:128
DetectParseRegex
Definition: detect-parse.h:42
SigTableElmt_::name
const char * name
Definition: detect.h:1201
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1201
PKT_IS_IPV6
#define PKT_IS_IPV6(p)
Definition: decode.h:260
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1346
IPV4_GET_IPOFFSET
#define IPV4_GET_IPOFFSET(p)
Definition: decode-ipv4.h:135
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
UtRegisterTest
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
Definition: util-unittest.c:103
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
IPV6_EXTHDR_ISSET_FH
#define IPV6_EXTHDR_ISSET_FH(p)
Definition: decode-ipv6.h:239
PacketAlertCheck
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
Definition: detect-engine-alert.c:138
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1101
DetectFragOffsetRegister
void DetectFragOffsetRegister(void)
Registration function for fragoffset.
Definition: detect-fragoffset.c:60
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:758
PrefilterPacketHeaderCtx_::sigs_array
SigIntId * sigs_array
Definition: detect-engine-prefilter-common.h:41
FRAG_MORE
#define FRAG_MORE
Definition: detect-fragoffset.h:28
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2069
PrefilterPacketHeaderValue::u8
uint8_t u8[16]
Definition: detect-engine-prefilter-common.h:22
DE_QUIET
#define DE_QUIET
Definition: detect.h:294
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1653
PrefilterPacketHeaderCtx_::sigs_cnt
uint32_t sigs_cnt
Definition: detect-engine-prefilter-common.h:40
SC_ERR_PCRE_GET_SUBSTRING
@ SC_ERR_PCRE_GET_SUBSTRING
Definition: util-error.h:34
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1186
PrefilterPacketHeaderValue::u16
uint16_t u16[8]
Definition: detect-engine-prefilter-common.h:23
FRAG_LESS
#define FRAG_LESS
Definition: detect-fragoffset.h:27
util-unittest.h
FAIL_IF_NOT
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
Definition: util-unittest.h:82
SigTableElmt_::SetupPrefilter
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
Definition: detect.h:1189
FlowInitConfig
void FlowInitConfig(bool quiet)
initialize the configuration
Definition: flow.c:523
DetectFragOffsetFree
void DetectFragOffsetFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectFragOffsetData
Definition: detect-fragoffset.c:255
decode-ipv6.h
PrefilterPacketHeaderCtx_
Definition: detect-engine-prefilter-common.h:33
decode.h
FAIL_IF_NOT_NULL
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
Definition: util-unittest.h:96
util-debug.h
SC_ERR_PCRE_MATCH
@ SC_ERR_PCRE_MATCH
Definition: util-error.h:32
PASS
#define PASS
Pass the test.
Definition: util-unittest.h:105
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectEngineThreadCtx_
Definition: detect.h:1003
res
PoolThreadReserved res
Definition: stream-tcp-private.h:0
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2558
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
SigMatch_::next
struct SigMatch_ * next
Definition: detect.h:324
DETECT_SM_LIST_MATCH
@ DETECT_SM_LIST_MATCH
Definition: detect.h:89
SC_Pcre2SubstringGet
int SC_Pcre2SubstringGet(pcre2_match_data *match_data, uint32_t number, PCRE2_UCHAR **bufferptr, PCRE2_SIZE *bufflen)
Definition: detect-parse.c:2546
SIZE_OF_PACKET
#define SIZE_OF_PACKET
Definition: decode.h:634
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:323
Signature_::flags
uint32_t flags
Definition: detect.h:518
Packet_
Definition: decode.h:414
Packet_::ip4h
IPV4Hdr * ip4h
Definition: decode.h:509
Signature_::init_data
SignatureInitData * init_data
Definition: detect.h:587
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1169
SignatureInitData_::smlists
struct SigMatch_ ** smlists
Definition: detect.h:511
SigMatchAlloc
SigMatch * SigMatchAlloc(void)
Definition: detect-parse.c:235
detect-fragoffset.h
DetectFragOffsetData_::mode
uint8_t mode
Definition: detect-fragoffset.h:32
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:1932
SigMatch_::type
uint8_t type
Definition: detect.h:321
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:30
PrefilterPacketHeaderCtx_::v1
PrefilterPacketHeaderValue v1
Definition: detect-engine-prefilter-common.h:34
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:315
IPV4Hdr_
Definition: decode-ipv4.h:71
decode-ipv4.h
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *de_ctx, const char *sigstr)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2381
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:2773
FAIL_IF
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
Definition: util-unittest.h:71
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
Definition: detect-engine.c:2981
FlowShutdown
void FlowShutdown(void)
shutdown the flow engine
Definition: flow.c:651
DETECT_FRAGOFFSET
@ DETECT_FRAGOFFSET
Definition: detect-engine-register.h:42
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:73
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
PrefilterSetupPacketHeader
int PrefilterSetupPacketHeader(DetectEngineCtx *de_ctx, SigGroupHead *sgh, int sm_type, void(*Set)(PrefilterPacketHeaderValue *v, void *), bool(*Compare)(PrefilterPacketHeaderValue v, void *), void(*Match)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx))
Definition: detect-engine-prefilter-common.c:417
DetectFragOffsetData_
Definition: detect-fragoffset.h:30
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-fragoffset.c:42
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:638
SigTableElmt_::SupportsPrefilter
bool(* SupportsPrefilter)(const Signature *s)
Definition: detect.h:1188
detect-parse.h
Signature_
Signature container.
Definition: detect.h:517
SigMatch_
a single match condition for a signature
Definition: detect.h:320
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2024
Address_::family
char family
Definition: decode.h:120
Packet_::dst
Address dst
Definition: decode.h:419
FLOW_QUIET
#define FLOW_QUIET
Definition: flow.h:42
DetectFragOffsetData_::frag_off
uint16_t frag_off
Definition: detect-fragoffset.h:31
PrefilterPacketHeaderValue
Definition: detect-engine-prefilter-common.h:21
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:759
detect-engine-prefilter-common.h
IPV4Hdr_::ip_off
uint16_t ip_off
Definition: decode-ipv4.h:76
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:259
SigMatchAppendSMToList
void SigMatchAppendSMToList(Signature *s, SigMatch *new, int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:349
Packet_::src
Address src
Definition: decode.h:418
debug.h
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1193
SIG_FLAG_REQUIRE_PACKET
#define SIG_FLAG_REQUIRE_PACKET
Definition: detect.h:223