suricata
detect-icmp-seq.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2020 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 the icmp_seq keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "debug.h"
28 #include "decode.h"
29 
30 #include "detect.h"
31 #include "detect-parse.h"
33 
34 #include "detect-icmp-seq.h"
35 
36 #include "util-byte.h"
37 #include "util-unittest.h"
38 #include "util-unittest-helper.h"
39 #include "util-debug.h"
40 
41 #define PARSE_REGEX "^\\s*(\"\\s*)?([0-9]+)(\\s*\")?\\s*$"
42 
43 static DetectParseRegex parse_regex;
44 
45 static int DetectIcmpSeqMatch(DetectEngineThreadCtx *, Packet *,
46  const Signature *, const SigMatchCtx *);
47 static int DetectIcmpSeqSetup(DetectEngineCtx *, Signature *, const char *);
48 #ifdef UNITTESTS
49 static void DetectIcmpSeqRegisterTests(void);
50 #endif
51 void DetectIcmpSeqFree(DetectEngineCtx *, void *);
52 static int PrefilterSetupIcmpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
53 static bool PrefilterIcmpSeqIsPrefilterable(const Signature *s);
54 
55 /**
56  * \brief Registration function for icmp_seq
57  */
59 {
60  sigmatch_table[DETECT_ICMP_SEQ].name = "icmp_seq";
61  sigmatch_table[DETECT_ICMP_SEQ].desc = "check for a ICMP sequence number";
62  sigmatch_table[DETECT_ICMP_SEQ].url = "/rules/header-keywords.html#icmp-seq";
63  sigmatch_table[DETECT_ICMP_SEQ].Match = DetectIcmpSeqMatch;
64  sigmatch_table[DETECT_ICMP_SEQ].Setup = DetectIcmpSeqSetup;
66 #ifdef UNITTESTS
67  sigmatch_table[DETECT_ICMP_SEQ].RegisterTests = DetectIcmpSeqRegisterTests;
68 #endif
69  sigmatch_table[DETECT_ICMP_SEQ].SupportsPrefilter = PrefilterIcmpSeqIsPrefilterable;
70  sigmatch_table[DETECT_ICMP_SEQ].SetupPrefilter = PrefilterSetupIcmpSeq;
71 
72  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
73 }
74 
75 static inline bool GetIcmpSeq(Packet *p, uint16_t *seq)
76 {
77  uint16_t seqn;
78 
79  if (PKT_IS_PSEUDOPKT(p))
80  return false;
81 
82  if (PKT_IS_ICMPV4(p)) {
83  switch (ICMPV4_GET_TYPE(p)){
84  case ICMP_ECHOREPLY:
85  case ICMP_ECHO:
86  case ICMP_TIMESTAMP:
87  case ICMP_TIMESTAMPREPLY:
88  case ICMP_INFO_REQUEST:
89  case ICMP_INFO_REPLY:
90  case ICMP_ADDRESS:
91  case ICMP_ADDRESSREPLY:
92  SCLogDebug("ICMPV4_GET_SEQ(p) %"PRIu16" (network byte order), "
93  "%"PRIu16" (host byte order)", ICMPV4_GET_SEQ(p),
95 
96  seqn = ICMPV4_GET_SEQ(p);
97  break;
98  default:
99  SCLogDebug("Packet has no seq field");
100  return false;
101  }
102  } else if (PKT_IS_ICMPV6(p)) {
103 
104  switch (ICMPV6_GET_TYPE(p)) {
105  case ICMP6_ECHO_REQUEST:
106  case ICMP6_ECHO_REPLY:
107  SCLogDebug("ICMPV6_GET_SEQ(p) %"PRIu16" (network byte order), "
108  "%"PRIu16" (host byte order)", ICMPV6_GET_SEQ(p),
109  SCNtohs(ICMPV6_GET_SEQ(p)));
110 
111  seqn = ICMPV6_GET_SEQ(p);
112  break;
113  default:
114  SCLogDebug("Packet has no seq field");
115  return false;
116  }
117  } else {
118  SCLogDebug("Packet not ICMPV4 nor ICMPV6");
119  return false;
120  }
121 
122  *seq = seqn;
123  return true;
124 }
125 
126 /**
127  * \brief This function is used to match icmp_seq rule option set on a packet
128  *
129  * \param t pointer to thread vars
130  * \param det_ctx pointer to the pattern matcher thread
131  * \param p pointer to the current packet
132  * \param m pointer to the sigmatch that we will cast into DetectIcmpSeqData
133  *
134  * \retval 0 no match
135  * \retval 1 match
136  */
137 static int DetectIcmpSeqMatch (DetectEngineThreadCtx *det_ctx, Packet *p,
138  const Signature *s, const SigMatchCtx *ctx)
139 {
140  uint16_t seqn;
141 
142  if (!GetIcmpSeq(p, &seqn))
143  return 0;
144 
145  const DetectIcmpSeqData *iseq = (const DetectIcmpSeqData *)ctx;
146  if (seqn == iseq->seq)
147  return 1;
148 
149  return 0;
150 }
151 
152 /**
153  * \brief This function is used to parse icmp_seq option passed via icmp_seq: keyword
154  *
155  * \param de_ctx Pointer to the detection engine context
156  * \param icmpseqstr Pointer to the user provided icmp_seq options
157  *
158  * \retval iseq pointer to DetectIcmpSeqData on success
159  * \retval NULL on failure
160  */
161 static DetectIcmpSeqData *DetectIcmpSeqParse (DetectEngineCtx *de_ctx, const char *icmpseqstr)
162 {
163  DetectIcmpSeqData *iseq = NULL;
164  char *substr[3] = {NULL, NULL, NULL};
165  int ret = 0, res = 0;
166  size_t pcre2_len;
167  int i;
168  const char *str_ptr;
169 
170  ret = DetectParsePcreExec(&parse_regex, icmpseqstr, 0, 0);
171  if (ret < 1 || ret > 4) {
172  SCLogError(SC_ERR_PCRE_MATCH,"Parse error %s", icmpseqstr);
173  goto error;
174  }
175 
176  for (i = 1; i < ret; i++) {
177  res = SC_Pcre2SubstringGet(parse_regex.match, i, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
178  if (res < 0) {
179  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_get_bynumber failed");
180  goto error;
181  }
182  substr[i-1] = (char *)str_ptr;
183  }
184 
185  iseq = SCMalloc(sizeof(DetectIcmpSeqData));
186  if (unlikely(iseq == NULL))
187  goto error;
188 
189  iseq->seq = 0;
190 
191  if (substr[0] != NULL && strlen(substr[0]) != 0) {
192  if (substr[2] == NULL) {
193  SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
194  goto error;
195  }
196  } else {
197  if (substr[2] != NULL) {
198  SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
199  goto error;
200  }
201  }
202 
203  uint16_t seq = 0;
204  if (StringParseUint16(&seq, 10, 0, substr[1]) < 0) {
205  SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp seq %s is not "
206  "valid", substr[1]);
207  goto error;
208  }
209  iseq->seq = htons(seq);
210 
211  for (i = 0; i < 3; i++) {
212  if (substr[i] != NULL)
213  pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
214  }
215 
216  return iseq;
217 
218 error:
219  for (i = 0; i < 3; i++) {
220  if (substr[i] != NULL)
221  pcre2_substring_free((PCRE2_UCHAR8 *)substr[i]);
222  }
223  if (iseq != NULL) DetectIcmpSeqFree(de_ctx, iseq);
224  return NULL;
225 
226 }
227 
228 /**
229  * \brief this function is used to add the parsed icmp_seq data into the current signature
230  *
231  * \param de_ctx pointer to the Detection Engine Context
232  * \param s pointer to the Current Signature
233  * \param icmpseqstr pointer to the user provided icmp_seq option
234  *
235  * \retval 0 on Success
236  * \retval -1 on Failure
237  */
238 static int DetectIcmpSeqSetup (DetectEngineCtx *de_ctx, Signature *s, const char *icmpseqstr)
239 {
240  DetectIcmpSeqData *iseq = NULL;
241  SigMatch *sm = NULL;
242 
243  iseq = DetectIcmpSeqParse(de_ctx, icmpseqstr);
244  if (iseq == NULL) goto error;
245 
246  sm = SigMatchAlloc();
247  if (sm == NULL) goto error;
248 
249  sm->type = DETECT_ICMP_SEQ;
250  sm->ctx = (SigMatchCtx *)iseq;
251 
253 
254  return 0;
255 
256 error:
257  if (iseq != NULL) DetectIcmpSeqFree(de_ctx, iseq);
258  if (sm != NULL) SCFree(sm);
259  return -1;
260 
261 }
262 
263 /**
264  * \brief this function will free memory associated with DetectIcmpSeqData
265  *
266  * \param ptr pointer to DetectIcmpSeqData
267  */
269 {
270  DetectIcmpSeqData *iseq = (DetectIcmpSeqData *)ptr;
271  SCFree(iseq);
272 }
273 
274 /* prefilter code */
275 
276 static void
277 PrefilterPacketIcmpSeqMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx)
278 {
279  const PrefilterPacketHeaderCtx *ctx = pectx;
280 
281  uint16_t seqn;
282 
283  if (!GetIcmpSeq(p, &seqn))
284  return;
285 
286  if (seqn == ctx->v1.u16[0])
287  {
288  SCLogDebug("packet matches ICMP SEQ %u", ctx->v1.u16[0]);
289  PrefilterAddSids(&det_ctx->pmq, ctx->sigs_array, ctx->sigs_cnt);
290  }
291 }
292 
293 static void
294 PrefilterPacketIcmpSeqSet(PrefilterPacketHeaderValue *v, void *smctx)
295 {
296  const DetectIcmpSeqData *a = smctx;
297  v->u16[0] = a->seq;
298 }
299 
300 static bool
301 PrefilterPacketIcmpSeqCompare(PrefilterPacketHeaderValue v, void *smctx)
302 {
303  const DetectIcmpSeqData *a = smctx;
304  if (v.u16[0] == a->seq)
305  return true;
306  return false;
307 }
308 
309 static int PrefilterSetupIcmpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh)
310 {
312  PrefilterPacketIcmpSeqSet,
313  PrefilterPacketIcmpSeqCompare,
314  PrefilterPacketIcmpSeqMatch);
315 }
316 
317 static bool PrefilterIcmpSeqIsPrefilterable(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_ICMP_SEQ:
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 DetectIcmpSeqParseTest01 is a test for setting a valid icmp_seq value
335  */
336 static int DetectIcmpSeqParseTest01 (void)
337 {
338  DetectIcmpSeqData *iseq = NULL;
339  iseq = DetectIcmpSeqParse(NULL, "300");
340  if (iseq != NULL && htons(iseq->seq) == 300) {
341  DetectIcmpSeqFree(NULL, iseq);
342  return 1;
343  }
344  return 0;
345 }
346 
347 /**
348  * \test DetectIcmpSeqParseTest02 is a test for setting a valid icmp_seq value
349  * with spaces all around
350  */
351 static int DetectIcmpSeqParseTest02 (void)
352 {
353  DetectIcmpSeqData *iseq = NULL;
354  iseq = DetectIcmpSeqParse(NULL, " 300 ");
355  if (iseq != NULL && htons(iseq->seq) == 300) {
356  DetectIcmpSeqFree(NULL, iseq);
357  return 1;
358  }
359  return 0;
360 }
361 
362 /**
363  * \test DetectIcmpSeqParseTest03 is a test for setting an invalid icmp_seq value
364  */
365 static int DetectIcmpSeqParseTest03 (void)
366 {
367  DetectIcmpSeqData *iseq = NULL;
368  iseq = DetectIcmpSeqParse(NULL, "badc");
369  if (iseq != NULL) {
370  DetectIcmpSeqFree(NULL, iseq);
371  return 0;
372  }
373  return 1;
374 }
375 
376 /**
377  * \test DetectIcmpSeqMatchTest01 is a test for checking the working of
378  * icmp_seq keyword by creating 2 rules and matching a crafted packet
379  * against them. Only the first one shall trigger.
380  */
381 static int DetectIcmpSeqMatchTest01 (void)
382 {
383  int result = 0;
384  Packet *p = NULL;
385  Signature *s = NULL;
386  ThreadVars th_v;
387  DetectEngineThreadCtx *det_ctx = NULL;
388 
389  memset(&th_v, 0, sizeof(th_v));
390 
391  p = UTHBuildPacket(NULL, 0, IPPROTO_ICMP);
392  p->icmpv4vars.seq = htons(2216);
393 
395  if (de_ctx == NULL) {
396  goto end;
397  }
398 
399  de_ctx->flags |= DE_QUIET;
400 
401  s = de_ctx->sig_list = SigInit(de_ctx, "alert icmp any any -> any any (icmp_seq:2216; sid:1;)");
402  if (s == NULL) {
403  goto end;
404  }
405 
406  s = s->next = SigInit(de_ctx, "alert icmp any any -> any any (icmp_seq:5000; sid:2;)");
407  if (s == NULL) {
408  goto end;
409  }
410 
412  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
413 
414  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
415  if (PacketAlertCheck(p, 1) == 0) {
416  printf("sid 1 did not alert, but should have: ");
417  goto cleanup;
418  } else if (PacketAlertCheck(p, 2)) {
419  printf("sid 2 alerted, but should not have: ");
420  goto cleanup;
421  }
422 
423  result = 1;
424 
425 cleanup:
428 
429  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
431 
432  UTHFreePackets(&p, 1);
433 end:
434  return result;
435 }
436 
437 static void DetectIcmpSeqRegisterTests (void)
438 {
439  UtRegisterTest("DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01);
440  UtRegisterTest("DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02);
441  UtRegisterTest("DetectIcmpSeqParseTest03", DetectIcmpSeqParseTest03);
442  UtRegisterTest("DetectIcmpSeqMatchTest01", DetectIcmpSeqMatchTest01);
443 }
444 #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
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
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-icmp-seq.c:41
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1191
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
SigGroupHead_
Container for matching data for a signature group.
Definition: detect.h:1346
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
seq
uint32_t seq
Definition: stream-tcp-private.h:2
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
SigInit
Signature * SigInit(DetectEngineCtx *, const char *)
Parses a signature and adds it to the Detection Engine Context.
Definition: detect-parse.c:2076
ICMPV6_GET_SEQ
#define ICMPV6_GET_SEQ(p)
Definition: decode-icmpv6.h:113
DetectEngineThreadCtx_::pmq
PrefilterRuleStore pmq
Definition: detect.h:1101
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:758
PrefilterPacketHeaderCtx_::sigs_array
SigIntId * sigs_array
Definition: detect-engine-prefilter-common.h:41
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2069
DE_QUIET
#define DE_QUIET
Definition: detect.h:294
UTHBuildPacket
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
Definition: util-unittest-helper.c:337
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
SigCleanSignatures
void SigCleanSignatures(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:41
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
util-unittest.h
util-unittest-helper.h
ICMP6_ECHO_REQUEST
#define ICMP6_ECHO_REQUEST
Definition: decode-icmpv6.h:43
ICMPV4_GET_SEQ
#define ICMPV4_GET_SEQ(p)
Definition: decode-icmpv4.h:247
SigTableElmt_::SetupPrefilter
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
Definition: detect.h:1189
Signature_::next
struct Signature_ * next
Definition: detect.h:590
PrefilterPacketHeaderCtx_
Definition: detect-engine-prefilter-common.h:33
decode.h
util-debug.h
SC_ERR_PCRE_MATCH
@ SC_ERR_PCRE_MATCH
Definition: util-error.h:32
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
ICMP6_ECHO_REPLY
#define ICMP6_ECHO_REPLY
Definition: decode-icmpv6.h:44
DetectEngineThreadCtx_
Definition: detect.h:1003
ICMPV4_GET_TYPE
#define ICMPV4_GET_TYPE(p)
Definition: decode-icmpv4.h:235
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
DetectIcmpSeqRegister
void DetectIcmpSeqRegister(void)
Registration function for icmp_seq.
Definition: detect-icmp-seq.c:58
DetectIcmpSeqData_
Definition: detect-icmp-seq.h:27
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
SC_ERR_INVALID_ARGUMENT
@ SC_ERR_INVALID_ARGUMENT
Definition: util-error.h:43
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:323
PKT_IS_ICMPV6
#define PKT_IS_ICMPV6(p)
Definition: decode.h:264
SigGroupCleanup
int SigGroupCleanup(DetectEngineCtx *de_ctx)
Definition: detect-engine-build.c:1999
Packet_
Definition: decode.h:414
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
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
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
DetectIcmpSeqData_::seq
uint16_t seq
Definition: detect-icmp-seq.h:28
Packet_::icmpv4vars
ICMPV4Vars icmpv4vars
Definition: decode.h:524
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:2773
SCNtohs
#define SCNtohs(x)
Definition: suricata-common.h:395
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
Definition: detect-engine.c:2981
DETECT_ICMP_SEQ
@ DETECT_ICMP_SEQ
Definition: detect-engine-register.h:48
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
DetectEngineCtx_::sig_list
Signature * sig_list
Definition: detect.h:764
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
PKT_IS_ICMPV4
#define PKT_IS_ICMPV4(p)
Definition: decode.h:263
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
SCFree
#define SCFree(p)
Definition: util-mem.h:61
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
ICMPV6_GET_TYPE
#define ICMPV6_GET_TYPE(p)
Definition: decode-icmpv6.h:102
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2024
PrefilterPacketHeaderValue
Definition: detect-engine-prefilter-common.h:21
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:759
detect-engine-prefilter-common.h
ICMPV4Vars_::seq
uint16_t seq
Definition: decode-icmpv4.h:187
SC_ERR_MISSING_QUOTE
@ SC_ERR_MISSING_QUOTE
Definition: util-error.h:150
SigMatchAppendSMToList
void SigMatchAppendSMToList(Signature *s, SigMatch *new, int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:349
debug.h
DetectIcmpSeqFree
void DetectIcmpSeqFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectIcmpSeqData
Definition: detect-icmp-seq.c:268
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1193
detect-icmp-seq.h
UTHFreePackets
void UTHFreePackets(Packet **p, int numpkts)
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.
Definition: util-unittest-helper.c:468