suricata
detect-xbits.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 Victor Julien <victor@inliniac.net>
22  *
23  * Implements the xbits keyword
24  */
25 
26 #include "suricata-common.h"
27 #include "decode.h"
28 #include "detect.h"
29 #include "threads.h"
30 #include "flow.h"
31 #include "flow-util.h"
32 #include "detect-xbits.h"
33 #include "detect-hostbits.h"
34 #include "util-spm.h"
35 #include "util-byte.h"
36 
37 #include "detect-engine-sigorder.h"
38 
39 #include "app-layer-parser.h"
40 
41 #include "detect-parse.h"
42 #include "detect-engine.h"
43 #include "detect-engine-mpm.h"
44 #include "detect-engine-state.h"
45 
46 #include "flow-bit.h"
47 #include "host-bit.h"
48 #include "ippair-bit.h"
49 #include "util-var-name.h"
50 #include "util-unittest.h"
51 #include "util-debug.h"
52 
53 /*
54  xbits:set,bitname,track ip_pair,expire 60
55  */
56 
57 #define PARSE_REGEX "^([a-z]+)" "(?:,\\s*([^,]+))?" "(?:,\\s*(?:track\\s+([^,]+)))" "(?:,\\s*(?:expire\\s+([^,]+)))?"
58 static DetectParseRegex parse_regex;
59 
60 static int DetectXbitMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *);
61 static int DetectXbitSetup (DetectEngineCtx *, Signature *, const char *);
62 #ifdef UNITTESTS
63 static void XBitsRegisterTests(void);
64 #endif
65 static void DetectXbitFree (DetectEngineCtx *, void *);
66 
68 {
69  sigmatch_table[DETECT_XBITS].name = "xbits";
70  sigmatch_table[DETECT_XBITS].desc = "operate on bits";
71  sigmatch_table[DETECT_XBITS].url = "/rules/xbits.html";
72  sigmatch_table[DETECT_XBITS].Match = DetectXbitMatch;
73  sigmatch_table[DETECT_XBITS].Setup = DetectXbitSetup;
74  sigmatch_table[DETECT_XBITS].Free = DetectXbitFree;
75 #ifdef UNITTESTS
76  sigmatch_table[DETECT_XBITS].RegisterTests = XBitsRegisterTests;
77 #endif
78  /* this is compatible to ip-only signatures */
80 
81  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
82 }
83 
84 static int DetectIPPairbitMatchToggle (Packet *p, const DetectXbitsData *fd)
85 {
86  IPPair *pair = IPPairGetIPPairFromHash(&p->src, &p->dst);
87  if (pair == NULL)
88  return 0;
89 
90  IPPairBitToggle(pair,fd->idx,p->ts.tv_sec + fd->expire);
91  IPPairRelease(pair);
92  return 1;
93 }
94 
95 /* return true even if bit not found */
96 static int DetectIPPairbitMatchUnset (Packet *p, const DetectXbitsData *fd)
97 {
98  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
99  if (pair == NULL)
100  return 1;
101 
102  IPPairBitUnset(pair,fd->idx);
103  IPPairRelease(pair);
104  return 1;
105 }
106 
107 static int DetectIPPairbitMatchSet (Packet *p, const DetectXbitsData *fd)
108 {
109  IPPair *pair = IPPairGetIPPairFromHash(&p->src, &p->dst);
110  if (pair == NULL)
111  return 0;
112 
113  IPPairBitSet(pair, fd->idx, p->ts.tv_sec + fd->expire);
114  IPPairRelease(pair);
115  return 1;
116 }
117 
118 static int DetectIPPairbitMatchIsset (Packet *p, const DetectXbitsData *fd)
119 {
120  int r = 0;
121  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
122  if (pair == NULL)
123  return 0;
124 
125  r = IPPairBitIsset(pair,fd->idx,p->ts.tv_sec);
126  IPPairRelease(pair);
127  return r;
128 }
129 
130 static int DetectIPPairbitMatchIsnotset (Packet *p, const DetectXbitsData *fd)
131 {
132  int r = 0;
133  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
134  if (pair == NULL)
135  return 1;
136 
137  r = IPPairBitIsnotset(pair,fd->idx,p->ts.tv_sec);
138  IPPairRelease(pair);
139  return r;
140 }
141 
142 static int DetectXbitMatchIPPair(Packet *p, const DetectXbitsData *xd)
143 {
144  switch (xd->cmd) {
146  return DetectIPPairbitMatchIsset(p,xd);
148  return DetectIPPairbitMatchIsnotset(p,xd);
150  return DetectIPPairbitMatchSet(p,xd);
152  return DetectIPPairbitMatchUnset(p,xd);
154  return DetectIPPairbitMatchToggle(p,xd);
155  }
156  return 0;
157 }
158 
159 /*
160  * returns 0: no match
161  * 1: match
162  * -1: error
163  */
164 
165 static int DetectXbitMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx)
166 {
167  const DetectXbitsData *fd = (const DetectXbitsData *)ctx;
168  if (fd == NULL)
169  return 0;
170 
171  switch (fd->type) {
172  case VAR_TYPE_HOST_BIT:
173  return DetectXbitMatchHost(p, (const DetectXbitsData *)fd);
174  break;
175  case VAR_TYPE_IPPAIR_BIT:
176  return DetectXbitMatchIPPair(p, (const DetectXbitsData *)fd);
177  break;
178  default:
179  break;
180  }
181  return 0;
182 }
183 
184 /** \internal
185  * \brief parse xbits rule options
186  * \retval 0 ok
187  * \retval -1 bad
188  * \param[out] cdout return DetectXbitsData structure or NULL if noalert
189  */
190 static int DetectXbitParse(DetectEngineCtx *de_ctx,
191  const char *rawstr, DetectXbitsData **cdout)
192 {
193  DetectXbitsData *cd = NULL;
194  uint8_t fb_cmd = 0;
195  uint8_t hb_dir = 0;
196  int ret = 0, res = 0;
197  size_t pcre2len;
198  char fb_cmd_str[16] = "", fb_name[256] = "";
199  char hb_dir_str[16] = "";
200  enum VarTypes var_type = VAR_TYPE_NOT_SET;
201  uint32_t expire = DETECT_XBITS_EXPIRE_DEFAULT;
202 
203  ret = DetectParsePcreExec(&parse_regex, rawstr, 0, 0);
204  if (ret != 2 && ret != 3 && ret != 4 && ret != 5) {
205  SCLogError(SC_ERR_PCRE_MATCH, "\"%s\" is not a valid setting for xbits.", rawstr);
206  return -1;
207  }
208  SCLogDebug("ret %d, %s", ret, rawstr);
209  pcre2len = sizeof(fb_cmd_str);
210  res = pcre2_substring_copy_bynumber(
211  parse_regex.match, 1, (PCRE2_UCHAR8 *)fb_cmd_str, &pcre2len);
212  if (res < 0) {
213  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
214  return -1;
215  }
216 
217  if (ret >= 3) {
218  pcre2len = sizeof(fb_name);
219  res = pcre2_substring_copy_bynumber(
220  parse_regex.match, 2, (PCRE2_UCHAR8 *)fb_name, &pcre2len);
221  if (res < 0) {
222  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
223  return -1;
224  }
225  if (ret >= 4) {
226  pcre2len = sizeof(hb_dir_str);
227  res = pcre2_substring_copy_bynumber(
228  parse_regex.match, 3, (PCRE2_UCHAR8 *)hb_dir_str, &pcre2len);
229  if (res < 0) {
230  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
231  return -1;
232  }
233  SCLogDebug("hb_dir_str %s", hb_dir_str);
234  if (strlen(hb_dir_str) > 0) {
235  if (strcmp(hb_dir_str, "ip_src") == 0) {
236  hb_dir = DETECT_XBITS_TRACK_IPSRC;
237  var_type = VAR_TYPE_HOST_BIT;
238  } else if (strcmp(hb_dir_str, "ip_dst") == 0) {
239  hb_dir = DETECT_XBITS_TRACK_IPDST;
240  var_type = VAR_TYPE_HOST_BIT;
241  } else if (strcmp(hb_dir_str, "ip_pair") == 0) {
242  hb_dir = DETECT_XBITS_TRACK_IPPAIR;
243  var_type = VAR_TYPE_IPPAIR_BIT;
244  } else {
245  // TODO
246  return -1;
247  }
248  }
249 
250  if (ret >= 5) {
251  char expire_str[16] = "";
252  pcre2len = sizeof(expire_str);
253  res = pcre2_substring_copy_bynumber(
254  parse_regex.match, 4, (PCRE2_UCHAR8 *)expire_str, &pcre2len);
255  if (res < 0) {
256  SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre2_substring_copy_bynumber failed");
257  return -1;
258  }
259  SCLogDebug("expire_str %s", expire_str);
260  if (StringParseUint32(&expire, 10, 0, (const char *)expire_str) < 0) {
261  SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for "
262  "expire: \"%s\"", expire_str);
263  return -1;
264  }
265  if (expire == 0) {
266  SCLogError(SC_ERR_INVALID_VALUE, "expire must be bigger than 0");
267  return -1;
268  }
269  SCLogDebug("expire %d", expire);
270  }
271  }
272  }
273 
274  if (strcmp(fb_cmd_str,"noalert") == 0) {
275  fb_cmd = DETECT_XBITS_CMD_NOALERT;
276  } else if (strcmp(fb_cmd_str,"isset") == 0) {
277  fb_cmd = DETECT_XBITS_CMD_ISSET;
278  } else if (strcmp(fb_cmd_str,"isnotset") == 0) {
279  fb_cmd = DETECT_XBITS_CMD_ISNOTSET;
280  } else if (strcmp(fb_cmd_str,"set") == 0) {
281  fb_cmd = DETECT_XBITS_CMD_SET;
282  } else if (strcmp(fb_cmd_str,"unset") == 0) {
283  fb_cmd = DETECT_XBITS_CMD_UNSET;
284  } else if (strcmp(fb_cmd_str,"toggle") == 0) {
285  fb_cmd = DETECT_XBITS_CMD_TOGGLE;
286  } else {
287  SCLogError(SC_ERR_UNKNOWN_VALUE, "xbits action \"%s\" is not supported.", fb_cmd_str);
288  return -1;
289  }
290 
291  switch (fb_cmd) {
293  if (strlen(fb_name) != 0)
294  return -1;
295  /* return ok, cd is NULL. Flag sig. */
296  *cdout = NULL;
297  return 0;
298  }
304  if (strlen(fb_name) == 0)
305  return -1;
306  break;
307  }
308 
309  cd = SCMalloc(sizeof(DetectXbitsData));
310  if (unlikely(cd == NULL))
311  return -1;
312 
313  cd->idx = VarNameStoreSetupAdd(fb_name, var_type);
314  cd->cmd = fb_cmd;
315  cd->tracker = hb_dir;
316  cd->type = var_type;
317  cd->expire = expire;
318 
319  SCLogDebug("idx %" PRIu32 ", cmd %s, name %s",
320  cd->idx, fb_cmd_str, strlen(fb_name) ? fb_name : "(none)");
321 
322  *cdout = cd;
323  return 0;
324 }
325 
326 int DetectXbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
327 {
328  SigMatch *sm = NULL;
329  DetectXbitsData *cd = NULL;
330 
331  int result = DetectXbitParse(de_ctx, rawstr, &cd);
332  if (result < 0) {
333  return -1;
334  /* noalert doesn't use a cd/sm struct. It flags the sig. We're done. */
335  } else if (result == 0 && cd == NULL) {
336  s->flags |= SIG_FLAG_NOALERT;
337  return 0;
338  }
339 
340  /* Okay so far so good, lets get this into a SigMatch
341  * and put it in the Signature. */
342  sm = SigMatchAlloc();
343  if (sm == NULL)
344  goto error;
345 
346  sm->type = DETECT_XBITS;
347  sm->ctx = (void *)cd;
348 
349  switch (cd->cmd) {
350  /* case DETECT_XBITS_CMD_NOALERT can't happen here */
351 
354  /* checks, so packet list */
356  break;
357 
361  /* modifiers, only run when entire sig has matched */
363  break;
364  }
365 
366  return 0;
367 
368 error:
369  if (cd != NULL)
370  SCFree(cd);
371  return -1;
372 }
373 
374 static void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr)
375 {
376  DetectXbitsData *fd = (DetectXbitsData *)ptr;
377 
378  if (fd == NULL)
379  return;
380 
381  SCFree(fd);
382 }
383 
384 #ifdef UNITTESTS
385 
386 static void XBitsTestSetup(void)
387 {
388  StorageInit();
389  HostBitInitCtx();
391  StorageFinalize();
392  HostInitConfig(true);
393  IPPairInitConfig(true);
394 }
395 
396 static void XBitsTestShutdown(void)
397 {
398  HostCleanup();
399  IPPairCleanup();
400  StorageCleanup();
401 }
402 
403 
404 static int XBitsTestParse01(void)
405 {
406  DetectEngineCtx *de_ctx = NULL;
409  de_ctx->flags |= DE_QUIET;
410  DetectXbitsData *cd = NULL;
411 
412 #define BAD_INPUT(str) \
413  FAIL_IF_NOT(DetectXbitParse(de_ctx, (str), &cd) == -1);
414 
415  BAD_INPUT("alert");
416  BAD_INPUT("n0alert");
417  BAD_INPUT("nOalert");
418  BAD_INPUT("set,abc,track nonsense, expire 3600");
419  BAD_INPUT("set,abc,track ip_source, expire 3600");
420  BAD_INPUT("set,abc,track ip_src, expire -1");
421  BAD_INPUT("set,abc,track ip_src, expire 0");
422 
423 #undef BAD_INPUT
424 
425 #define GOOD_INPUT(str, command, trk, typ, exp) \
426  FAIL_IF_NOT(DetectXbitParse(de_ctx, (str), &cd) == 0); \
427  FAIL_IF_NULL(cd); \
428  FAIL_IF_NOT(cd->cmd == (command)); \
429  FAIL_IF_NOT(cd->tracker == (trk)); \
430  FAIL_IF_NOT(cd->type == (typ)); \
431  FAIL_IF_NOT(cd->expire == (exp)); \
432  DetectXbitFree(NULL, cd); \
433  cd = NULL;
434 
435  GOOD_INPUT("set,abc,track ip_pair",
439  GOOD_INPUT("set,abc,track ip_pair, expire 3600",
442  3600);
443  GOOD_INPUT("set,abc,track ip_src, expire 1234",
446  1234);
447 
448 #undef GOOD_INPUT
449 
451  PASS;
452 }
453 
454 /**
455  * \test
456  */
457 
458 static int XBitsTestSig01(void)
459 {
460  uint8_t *buf = (uint8_t *)
461  "GET /one/ HTTP/1.1\r\n"
462  "Host: one.example.org\r\n"
463  "\r\n";
464  uint16_t buflen = strlen((char *)buf);
465  Packet *p = PacketGetFromAlloc();
466  FAIL_IF_NULL(p);
467  Signature *s = NULL;
468  ThreadVars th_v;
469  DetectEngineThreadCtx *det_ctx = NULL;
470  DetectEngineCtx *de_ctx = NULL;
471 
472  memset(&th_v, 0, sizeof(th_v));
473  p->src.family = AF_INET;
474  p->dst.family = AF_INET;
475  p->payload = buf;
476  p->payload_len = buflen;
477  p->proto = IPPROTO_TCP;
478 
479  XBitsTestSetup();
480 
483  de_ctx->flags |= DE_QUIET;
484 
486  "alert ip any any -> any any (xbits:set,abc,track ip_pair; content:\"GET \"; sid:1;)");
487  FAIL_IF_NULL(s);
488 
490  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
491  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
492  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
494  XBitsTestShutdown();
495  SCFree(p);
496  StatsThreadCleanup(&th_v);
498  PASS;
499 }
500 
501 /**
502  * \test various options
503  *
504  * \retval 1 on succces
505  * \retval 0 on failure
506  */
507 
508 static int XBitsTestSig02(void)
509 {
510  Signature *s = NULL;
511  DetectEngineCtx *de_ctx = NULL;
514  de_ctx->flags |= DE_QUIET;
515 
517  "alert ip any any -> any any (xbits:isset,abc,track ip_src; content:\"GET \"; sid:1;)");
518  FAIL_IF_NULL(s);
519 
521  "alert ip any any -> any any (xbits:isnotset,abc,track ip_dst; content:\"GET \"; sid:2;)");
522  FAIL_IF_NULL(s);
523 
525  "alert ip any any -> any any (xbits:set,abc,track ip_pair; content:\"GET \"; sid:3;)");
526  FAIL_IF_NULL(s);
527 
529  "alert ip any any -> any any (xbits:unset,abc,track ip_src; content:\"GET \"; sid:4;)");
530  FAIL_IF_NULL(s);
531 
533  "alert ip any any -> any any (xbits:toggle,abc,track ip_dst; content:\"GET \"; sid:5;)");
534  FAIL_IF_NULL(s);
535 
537  "alert ip any any -> any any (xbits:!set,abc,track ip_dst; content:\"GET \"; sid:6;)");
538  FAIL_IF_NOT_NULL(s);
539 
541  PASS;
542 }
543 
544 /**
545  * \brief this function registers unit tests for XBits
546  */
547 static void XBitsRegisterTests(void)
548 {
549  UtRegisterTest("XBitsTestParse01", XBitsTestParse01);
550  UtRegisterTest("XBitsTestSig01", XBitsTestSig01);
551  UtRegisterTest("XBitsTestSig02", XBitsTestSig02);
552 }
553 #endif /* UNITTESTS */
IPPairBitUnset
void IPPairBitUnset(IPPair *h, uint32_t idx)
Definition: ippair-bit.c:139
util-byte.h
DetectParseRegex::match
pcre2_match_data * match
Definition: detect-parse.h:45
SigTableElmt_::url
const char * url
Definition: detect.h:1270
Packet_::proto
uint8_t proto
Definition: decode.h:449
detect-engine.h
FAIL_IF_NULL
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
DetectXbitsRegister
void DetectXbitsRegister(void)
Definition: detect-xbits.c:67
IPPairInitConfig
void IPPairInitConfig(bool quiet)
initialize the configuration
Definition: ippair.c:169
SigTableElmt_::desc
const char * desc
Definition: detect.h:1269
DetectXbitsData_::expire
uint32_t expire
Definition: detect-xbits.h:46
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, const char *str, int start_offset, int options)
Definition: detect-parse.c:2474
SC_ERR_INVALID_VALUE
@ SC_ERR_INVALID_VALUE
Definition: util-error.h:160
StorageInit
void StorageInit(void)
Definition: util-storage.c:67
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1257
flow-util.h
DetectParseRegex
Definition: detect-parse.h:42
IPPairRelease
void IPPairRelease(IPPair *h)
Definition: ippair.c:521
SigTableElmt_::name
const char * name
Definition: detect.h:1267
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
Packet_::payload
uint8_t * payload
Definition: decode.h:567
ippair-bit.h
threads.h
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1261
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:811
DetectXbitsData_::cmd
uint8_t cmd
Definition: detect-xbits.h:44
IPPairBitSet
void IPPairBitSet(IPPair *h, uint32_t idx, uint32_t expire)
Definition: ippair-bit.c:131
DetectEngineCtxFree
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Definition: detect-engine.c:2433
StorageCleanup
void StorageCleanup(void)
Definition: util-storage.c:75
flow-bit.h
util-var-name.h
DETECT_XBITS_TRACK_IPDST
#define DETECT_XBITS_TRACK_IPDST
Definition: detect-xbits.h:36
DE_QUIET
#define DE_QUIET
Definition: detect.h:295
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1790
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:1252
HostBitInitCtx
void HostBitInitCtx(void)
Definition: host-bit.c:49
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:568
DetectXbitsData_
Definition: detect-xbits.h:42
util-unittest.h
VAR_TYPE_NOT_SET
@ VAR_TYPE_NOT_SET
Definition: util-var.h:28
GOOD_INPUT
#define GOOD_INPUT(str, command, trk, typ, exp)
DETECT_SM_LIST_POSTMATCH
@ DETECT_SM_LIST_POSTMATCH
Definition: detect.h:98
DetectXbitMatchHost
int DetectXbitMatchHost(Packet *p, const DetectXbitsData *xd)
Definition: detect-hostbits.c:245
detect-xbits.h
DETECT_XBITS_CMD_ISNOTSET
#define DETECT_XBITS_CMD_ISNOTSET
Definition: detect-xbits.h:30
DETECT_XBITS_EXPIRE_DEFAULT
#define DETECT_XBITS_EXPIRE_DEFAULT
Definition: detect-xbits.h:40
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
IPPairBitToggle
void IPPairBitToggle(IPPair *h, uint32_t idx, uint32_t expire)
Definition: ippair-bit.c:147
IPPairCleanup
void IPPairCleanup(void)
Cleanup the ippair engine.
Definition: ippair.c:341
DetectEngineThreadCtx_
Definition: detect.h:1060
SC_ERR_UNKNOWN_VALUE
@ SC_ERR_UNKNOWN_VALUE
Definition: util-error.h:159
res
PoolThreadReserved res
Definition: stream-tcp-private.h:0
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2597
HostCleanup
void HostCleanup(void)
Cleanup the host engine.
Definition: host.c:346
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
BAD_INPUT
#define BAD_INPUT(str)
DETECT_XBITS_TRACK_IPPAIR
#define DETECT_XBITS_TRACK_IPPAIR
Definition: detect-xbits.h:37
StringParseUint32
int StringParseUint32(uint32_t *res, int base, size_t len, const char *str)
Definition: util-byte.c:313
IPPairGetIPPairFromHash
IPPair * IPPairGetIPPairFromHash(Address *a, Address *b)
Definition: ippair.c:545
DETECT_SM_LIST_MATCH
@ DETECT_SM_LIST_MATCH
Definition: detect.h:89
app-layer-parser.h
DETECT_XBITS
@ DETECT_XBITS
Definition: detect-engine-register.h:239
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:324
IPPairBitIsnotset
int IPPairBitIsnotset(IPPair *h, uint32_t idx, uint32_t ts)
Definition: ippair-bit.c:171
DetectXbitsData_::type
enum VarTypes type
Definition: detect-xbits.h:48
Signature_::flags
uint32_t flags
Definition: detect.h:549
Packet_
Definition: decode.h:427
StorageFinalize
int StorageFinalize(void)
Definition: util-storage.c:139
detect-engine-state.h
Data structures and function prototypes for keeping state for the detection engine.
SigTableElmt_::Match
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition: detect.h:1235
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:1948
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:316
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:2420
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3142
Packet_::ts
struct timeval ts
Definition: decode.h:470
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
Definition: detect-engine.c:3354
SigMatch_::type
uint16_t type
Definition: detect.h:322
IPPair_
Definition: ippair.h:58
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:73
util-spm.h
DetectXbitsData_::idx
uint32_t idx
Definition: detect-xbits.h:43
VarNameStoreSetupAdd
uint32_t VarNameStoreSetupAdd(const char *name, const enum VarTypes type)
add to staging or return existing id if already in there
Definition: util-var-name.c:323
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
SIG_FLAG_NOALERT
#define SIG_FLAG_NOALERT
Definition: detect.h:216
detect-hostbits.h
VAR_TYPE_HOST_BIT
@ VAR_TYPE_HOST_BIT
Definition: util-var.h:39
IPPairBitInitCtx
void IPPairBitInitCtx(void)
Definition: ippair-bit.c:49
PacketGetFromAlloc
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition: decode.c:173
detect-engine-sigorder.h
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
DetectXbitsData_::tracker
uint8_t tracker
Definition: detect-xbits.h:45
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DETECT_XBITS_TRACK_IPSRC
#define DETECT_XBITS_TRACK_IPSRC
Definition: detect-xbits.h:35
detect-parse.h
Signature_
Signature container.
Definition: detect.h:548
SigMatch_
a single match condition for a signature
Definition: detect.h:321
DETECT_XBITS_CMD_NOALERT
#define DETECT_XBITS_CMD_NOALERT
Definition: detect-xbits.h:32
DETECT_XBITS_CMD_ISSET
#define DETECT_XBITS_CMD_ISSET
Definition: detect-xbits.h:31
DetectEngineCtxInit
DetectEngineCtx * DetectEngineCtxInit(void)
Definition: detect-engine.c:2394
VarTypes
VarTypes
Definition: util-var.h:27
Address_::family
char family
Definition: decode.h:123
Packet_::dst
Address dst
Definition: decode.h:432
IPPairLookupIPPairFromHash
IPPair * IPPairLookupIPPairFromHash(Address *a, Address *b)
look up a ippair in the hash
Definition: ippair.c:644
HostInitConfig
void HostInitConfig(bool quiet)
initialize the configuration
Definition: host.c:175
IPPairBitIsset
int IPPairBitIsset(IPPair *h, uint32_t idx, uint32_t ts)
Definition: ippair-bit.c:157
DETECT_XBITS_CMD_SET
#define DETECT_XBITS_CMD_SET
Definition: detect-xbits.h:27
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:812
DETECT_XBITS_CMD_TOGGLE
#define DETECT_XBITS_CMD_TOGGLE
Definition: detect-xbits.h:28
flow.h
DETECT_XBITS_CMD_UNSET
#define DETECT_XBITS_CMD_UNSET
Definition: detect-xbits.h:29
VAR_TYPE_IPPAIR_BIT
@ VAR_TYPE_IPPAIR_BIT
Definition: util-var.h:43
StatsReleaseResources
void StatsReleaseResources()
Releases the resources alloted by the Stats API.
Definition: counters.c:1249
StatsThreadCleanup
void StatsThreadCleanup(ThreadVars *tv)
Definition: counters.c:1290
SIGMATCH_IPONLY_COMPAT
#define SIGMATCH_IPONLY_COMPAT
Definition: detect.h:1455
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:431
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-xbits.c:57
host-bit.h
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1259