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 #include "detect-engine-build.h"
46 
47 #include "flow-bit.h"
48 #include "host-bit.h"
49 #include "ippair-bit.h"
50 #include "util-var-name.h"
51 #include "util-unittest.h"
52 #include "util-debug.h"
53 
54 /*
55  xbits:set,bitname,track ip_pair,expire 60
56  */
57 
58 #define PARSE_REGEX "^([a-z]+)" "(?:,\\s*([^,]+))?" "(?:,\\s*(?:track\\s+([^,]+)))" "(?:,\\s*(?:expire\\s+([^,]+)))?"
59 static DetectParseRegex parse_regex;
60 
61 static int DetectXbitMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *);
62 static int DetectXbitSetup (DetectEngineCtx *, Signature *, const char *);
63 #ifdef UNITTESTS
64 static void XBitsRegisterTests(void);
65 #endif
66 static void DetectXbitFree (DetectEngineCtx *, void *);
67 
69 {
70  sigmatch_table[DETECT_XBITS].name = "xbits";
71  sigmatch_table[DETECT_XBITS].desc = "operate on bits";
72  sigmatch_table[DETECT_XBITS].url = "/rules/xbits.html";
73  sigmatch_table[DETECT_XBITS].Match = DetectXbitMatch;
74  sigmatch_table[DETECT_XBITS].Setup = DetectXbitSetup;
75  sigmatch_table[DETECT_XBITS].Free = DetectXbitFree;
76 #ifdef UNITTESTS
77  sigmatch_table[DETECT_XBITS].RegisterTests = XBitsRegisterTests;
78 #endif
79  /* this is compatible to ip-only signatures */
81 
82  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
83 }
84 
85 static int DetectIPPairbitMatchToggle (Packet *p, const DetectXbitsData *fd)
86 {
87  IPPair *pair = IPPairGetIPPairFromHash(&p->src, &p->dst);
88  if (pair == NULL)
89  return 0;
90 
91  IPPairBitToggle(pair, fd->idx, SCTIME_SECS(p->ts) + fd->expire);
92  IPPairRelease(pair);
93  return 1;
94 }
95 
96 /* return true even if bit not found */
97 static int DetectIPPairbitMatchUnset (Packet *p, const DetectXbitsData *fd)
98 {
99  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
100  if (pair == NULL)
101  return 1;
102 
103  IPPairBitUnset(pair,fd->idx);
104  IPPairRelease(pair);
105  return 1;
106 }
107 
108 static int DetectIPPairbitMatchSet (Packet *p, const DetectXbitsData *fd)
109 {
110  IPPair *pair = IPPairGetIPPairFromHash(&p->src, &p->dst);
111  if (pair == NULL)
112  return 0;
113 
114  IPPairBitSet(pair, fd->idx, SCTIME_SECS(p->ts) + fd->expire);
115  IPPairRelease(pair);
116  return 1;
117 }
118 
119 static int DetectIPPairbitMatchIsset (Packet *p, const DetectXbitsData *fd)
120 {
121  int r = 0;
122  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
123  if (pair == NULL)
124  return 0;
125 
126  r = IPPairBitIsset(pair, fd->idx, SCTIME_SECS(p->ts));
127  IPPairRelease(pair);
128  return r;
129 }
130 
131 static int DetectIPPairbitMatchIsnotset (Packet *p, const DetectXbitsData *fd)
132 {
133  int r = 0;
134  IPPair *pair = IPPairLookupIPPairFromHash(&p->src, &p->dst);
135  if (pair == NULL)
136  return 1;
137 
138  r = IPPairBitIsnotset(pair, fd->idx, SCTIME_SECS(p->ts));
139  IPPairRelease(pair);
140  return r;
141 }
142 
143 static int DetectXbitMatchIPPair(Packet *p, const DetectXbitsData *xd)
144 {
145  switch (xd->cmd) {
147  return DetectIPPairbitMatchIsset(p,xd);
149  return DetectIPPairbitMatchIsnotset(p,xd);
151  return DetectIPPairbitMatchSet(p,xd);
153  return DetectIPPairbitMatchUnset(p,xd);
155  return DetectIPPairbitMatchToggle(p,xd);
156  }
157  return 0;
158 }
159 
160 /*
161  * returns 0: no match
162  * 1: match
163  * -1: error
164  */
165 
166 static int DetectXbitMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx)
167 {
168  const DetectXbitsData *fd = (const DetectXbitsData *)ctx;
169  if (fd == NULL)
170  return 0;
171 
172  switch (fd->type) {
173  case VAR_TYPE_HOST_BIT:
174  return DetectXbitMatchHost(p, (const DetectXbitsData *)fd);
175  break;
176  case VAR_TYPE_IPPAIR_BIT:
177  return DetectXbitMatchIPPair(p, (const DetectXbitsData *)fd);
178  break;
179  default:
180  break;
181  }
182  return 0;
183 }
184 
185 /** \internal
186  * \brief parse xbits rule options
187  * \retval 0 ok
188  * \retval -1 bad
189  * \param[out] cdout return DetectXbitsData structure or NULL if noalert
190  */
191 static int DetectXbitParse(DetectEngineCtx *de_ctx,
192  const char *rawstr, DetectXbitsData **cdout)
193 {
194  DetectXbitsData *cd = NULL;
195  uint8_t fb_cmd = 0;
196  uint8_t hb_dir = 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  pcre2_match_data *match = NULL;
204  int ret = DetectParsePcreExec(&parse_regex, &match, rawstr, 0, 0);
205  if (ret != 2 && ret != 3 && ret != 4 && ret != 5) {
206  SCLogError("\"%s\" is not a valid setting for xbits.", rawstr);
207  if (match) {
208  pcre2_match_data_free(match);
209  }
210  return -1;
211  }
212  SCLogDebug("ret %d, %s", ret, rawstr);
213  pcre2len = sizeof(fb_cmd_str);
214  int res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)fb_cmd_str, &pcre2len);
215  if (res < 0) {
216  SCLogError("pcre2_substring_copy_bynumber failed");
217  pcre2_match_data_free(match);
218  return -1;
219  }
220 
221  if (ret >= 3) {
222  pcre2len = sizeof(fb_name);
223  res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)fb_name, &pcre2len);
224  if (res < 0) {
225  SCLogError("pcre2_substring_copy_bynumber failed");
226  pcre2_match_data_free(match);
227  return -1;
228  }
229  if (ret >= 4) {
230  pcre2len = sizeof(hb_dir_str);
231  res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)hb_dir_str, &pcre2len);
232  if (res < 0) {
233  SCLogError("pcre2_substring_copy_bynumber failed");
234  pcre2_match_data_free(match);
235  return -1;
236  }
237  SCLogDebug("hb_dir_str %s", hb_dir_str);
238  if (strlen(hb_dir_str) > 0) {
239  if (strcmp(hb_dir_str, "ip_src") == 0) {
240  hb_dir = DETECT_XBITS_TRACK_IPSRC;
241  var_type = VAR_TYPE_HOST_BIT;
242  } else if (strcmp(hb_dir_str, "ip_dst") == 0) {
243  hb_dir = DETECT_XBITS_TRACK_IPDST;
244  var_type = VAR_TYPE_HOST_BIT;
245  } else if (strcmp(hb_dir_str, "ip_pair") == 0) {
246  hb_dir = DETECT_XBITS_TRACK_IPPAIR;
247  var_type = VAR_TYPE_IPPAIR_BIT;
248  } else {
249  // TODO
250  pcre2_match_data_free(match);
251  return -1;
252  }
253  }
254 
255  if (ret >= 5) {
256  char expire_str[16] = "";
257  pcre2len = sizeof(expire_str);
258  res = pcre2_substring_copy_bynumber(
259  match, 4, (PCRE2_UCHAR8 *)expire_str, &pcre2len);
260  if (res < 0) {
261  SCLogError("pcre2_substring_copy_bynumber failed");
262  pcre2_match_data_free(match);
263  return -1;
264  }
265  SCLogDebug("expire_str %s", expire_str);
266  if (StringParseUint32(&expire, 10, 0, (const char *)expire_str) < 0) {
267  SCLogError("Invalid value for "
268  "expire: \"%s\"",
269  expire_str);
270  pcre2_match_data_free(match);
271  return -1;
272  }
273  if (expire == 0) {
274  SCLogError("expire must be bigger than 0");
275  pcre2_match_data_free(match);
276  return -1;
277  }
278  SCLogDebug("expire %d", expire);
279  }
280  }
281  }
282 
283  pcre2_match_data_free(match);
284  if (strcmp(fb_cmd_str,"noalert") == 0) {
285  fb_cmd = DETECT_XBITS_CMD_NOALERT;
286  } else if (strcmp(fb_cmd_str,"isset") == 0) {
287  fb_cmd = DETECT_XBITS_CMD_ISSET;
288  } else if (strcmp(fb_cmd_str,"isnotset") == 0) {
289  fb_cmd = DETECT_XBITS_CMD_ISNOTSET;
290  } else if (strcmp(fb_cmd_str,"set") == 0) {
291  fb_cmd = DETECT_XBITS_CMD_SET;
292  } else if (strcmp(fb_cmd_str,"unset") == 0) {
293  fb_cmd = DETECT_XBITS_CMD_UNSET;
294  } else if (strcmp(fb_cmd_str,"toggle") == 0) {
295  fb_cmd = DETECT_XBITS_CMD_TOGGLE;
296  } else {
297  SCLogError("xbits action \"%s\" is not supported.", fb_cmd_str);
298  return -1;
299  }
300 
301  switch (fb_cmd) {
303  if (strlen(fb_name) != 0)
304  return -1;
305  /* return ok, cd is NULL. Flag sig. */
306  *cdout = NULL;
307  return 0;
308  }
314  if (strlen(fb_name) == 0)
315  return -1;
316  break;
317  }
318 
319  cd = SCMalloc(sizeof(DetectXbitsData));
320  if (unlikely(cd == NULL))
321  return -1;
322 
323  cd->idx = VarNameStoreRegister(fb_name, var_type);
324  cd->cmd = fb_cmd;
325  cd->tracker = hb_dir;
326  cd->type = var_type;
327  cd->expire = expire;
328 
329  SCLogDebug("idx %" PRIu32 ", cmd %s, name %s",
330  cd->idx, fb_cmd_str, strlen(fb_name) ? fb_name : "(none)");
331 
332  *cdout = cd;
333  return 0;
334 }
335 
336 int DetectXbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
337 {
338  DetectXbitsData *cd = NULL;
339 
340  int result = DetectXbitParse(de_ctx, rawstr, &cd);
341  if (result < 0) {
342  return -1;
343  } else if (cd == NULL) {
344  /* noalert doesn't use a cd/sm struct. It flags the sig. We're done. */
345  s->flags |= SIG_FLAG_NOALERT;
346  return 0;
347  }
348 
349  /* Okay so far so good, lets get this into a SigMatch
350  * and put it in the Signature. */
351  switch (cd->cmd) {
352  /* case DETECT_XBITS_CMD_NOALERT can't happen here */
355  /* checks, so packet list */
357  de_ctx, s, DETECT_XBITS, (SigMatchCtx *)cd, DETECT_SM_LIST_MATCH) == NULL) {
358  SCFree(cd);
359  return -1;
360  }
361  break;
362 
363  // all other cases
364  // DETECT_XBITS_CMD_SET, DETECT_XBITS_CMD_UNSET, DETECT_XBITS_CMD_TOGGLE:
365  default:
366  /* modifiers, only run when entire sig has matched */
368  DETECT_SM_LIST_POSTMATCH) == NULL) {
369  SCFree(cd);
370  return -1;
371  }
372  break;
373  }
374 
375  return 0;
376 }
377 
378 static void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr)
379 {
380  DetectXbitsData *fd = (DetectXbitsData *)ptr;
381 
382  if (fd == NULL)
383  return;
384  VarNameStoreUnregister(fd->idx, fd->type);
385 
386  SCFree(fd);
387 }
388 
389 #ifdef UNITTESTS
390 
391 static void XBitsTestSetup(void)
392 {
393  StorageInit();
394  HostBitInitCtx();
396  StorageFinalize();
397  HostInitConfig(true);
398  IPPairInitConfig(true);
399 }
400 
401 static void XBitsTestShutdown(void)
402 {
403  HostCleanup();
404  IPPairCleanup();
405  StorageCleanup();
406 }
407 
408 
409 static int XBitsTestParse01(void)
410 {
411  DetectEngineCtx *de_ctx = NULL;
414  de_ctx->flags |= DE_QUIET;
415  DetectXbitsData *cd = NULL;
416 
417 #define BAD_INPUT(str) \
418  FAIL_IF_NOT(DetectXbitParse(de_ctx, (str), &cd) == -1);
419 
420  BAD_INPUT("alert");
421  BAD_INPUT("n0alert");
422  BAD_INPUT("nOalert");
423  BAD_INPUT("set,abc,track nonsense, expire 3600");
424  BAD_INPUT("set,abc,track ip_source, expire 3600");
425  BAD_INPUT("set,abc,track ip_src, expire -1");
426  BAD_INPUT("set,abc,track ip_src, expire 0");
427 
428 #undef BAD_INPUT
429 
430 #define GOOD_INPUT(str, command, trk, typ, exp) \
431  FAIL_IF_NOT(DetectXbitParse(de_ctx, (str), &cd) == 0); \
432  FAIL_IF_NULL(cd); \
433  FAIL_IF_NOT(cd->cmd == (command)); \
434  FAIL_IF_NOT(cd->tracker == (trk)); \
435  FAIL_IF_NOT(cd->type == (typ)); \
436  FAIL_IF_NOT(cd->expire == (exp)); \
437  DetectXbitFree(NULL, cd); \
438  cd = NULL;
439 
440  GOOD_INPUT("set,abc,track ip_pair",
444  GOOD_INPUT("set,abc,track ip_pair, expire 3600",
447  3600);
448  GOOD_INPUT("set,abc,track ip_src, expire 1234",
451  1234);
452 
453 #undef GOOD_INPUT
454 
456  PASS;
457 }
458 
459 /**
460  * \test
461  */
462 
463 static int XBitsTestSig01(void)
464 {
465  uint8_t *buf = (uint8_t *)
466  "GET /one/ HTTP/1.1\r\n"
467  "Host: one.example.org\r\n"
468  "\r\n";
469  uint16_t buflen = strlen((char *)buf);
470  Packet *p = PacketGetFromAlloc();
471  FAIL_IF_NULL(p);
472  Signature *s = NULL;
473  ThreadVars th_v;
474  DetectEngineThreadCtx *det_ctx = NULL;
475  DetectEngineCtx *de_ctx = NULL;
476 
477  memset(&th_v, 0, sizeof(th_v));
478  p->src.family = AF_INET;
479  p->dst.family = AF_INET;
480  p->payload = buf;
481  p->payload_len = buflen;
482  p->proto = IPPROTO_TCP;
483 
484  XBitsTestSetup();
485 
488  de_ctx->flags |= DE_QUIET;
489 
491  "alert ip any any -> any any (xbits:set,abc,track ip_pair; content:\"GET \"; sid:1;)");
492  FAIL_IF_NULL(s);
493 
495  DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
496  SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
497  DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
499  XBitsTestShutdown();
500  SCFree(p);
501  StatsThreadCleanup(&th_v);
503  PASS;
504 }
505 
506 /**
507  * \test various options
508  *
509  * \retval 1 on success
510  * \retval 0 on failure
511  */
512 
513 static int XBitsTestSig02(void)
514 {
515  Signature *s = NULL;
516  DetectEngineCtx *de_ctx = NULL;
519  de_ctx->flags |= DE_QUIET;
520 
522  "alert ip any any -> any any (xbits:isset,abc,track ip_src; content:\"GET \"; sid:1;)");
523  FAIL_IF_NULL(s);
524 
526  "alert ip any any -> any any (xbits:isnotset,abc,track ip_dst; content:\"GET \"; sid:2;)");
527  FAIL_IF_NULL(s);
528 
530  "alert ip any any -> any any (xbits:set,abc,track ip_pair; content:\"GET \"; sid:3;)");
531  FAIL_IF_NULL(s);
532 
534  "alert ip any any -> any any (xbits:unset,abc,track ip_src; content:\"GET \"; sid:4;)");
535  FAIL_IF_NULL(s);
536 
538  "alert ip any any -> any any (xbits:toggle,abc,track ip_dst; content:\"GET \"; sid:5;)");
539  FAIL_IF_NULL(s);
540 
542  "alert ip any any -> any any (xbits:!set,abc,track ip_dst; content:\"GET \"; sid:6;)");
543  FAIL_IF_NOT_NULL(s);
544 
546  PASS;
547 }
548 
549 /**
550  * \brief this function registers unit tests for XBits
551  */
552 static void XBitsRegisterTests(void)
553 {
554  UtRegisterTest("XBitsTestParse01", XBitsTestParse01);
555  UtRegisterTest("XBitsTestSig01", XBitsTestSig01);
556  UtRegisterTest("XBitsTestSig02", XBitsTestSig02);
557 }
558 #endif /* UNITTESTS */
IPPairBitUnset
void IPPairBitUnset(IPPair *h, uint32_t idx)
Definition: ippair-bit.c:139
util-byte.h
StatsReleaseResources
void StatsReleaseResources(void)
Releases the resources allotted by the Stats API.
Definition: counters.c:1282
SigTableElmt_::url
const char * url
Definition: detect.h:1311
Packet_::proto
uint8_t proto
Definition: decode.h:504
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:68
IPPairInitConfig
void IPPairInitConfig(bool quiet)
initialize the configuration
Definition: ippair.c:162
SigTableElmt_::desc
const char * desc
Definition: detect.h:1310
DetectXbitsData_::expire
uint32_t expire
Definition: detect-xbits.h:44
StorageInit
void StorageInit(void)
Definition: util-storage.c:68
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1298
flow-util.h
DetectParseRegex
Definition: detect-parse.h:62
IPPairRelease
void IPPairRelease(IPPair *h)
Definition: ippair.c:511
SigTableElmt_::name
const char * name
Definition: detect.h:1308
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:269
Packet_::payload
uint8_t * payload
Definition: decode.h:588
ippair-bit.h
threads.h
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1302
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:848
DetectXbitsData_::cmd
uint8_t cmd
Definition: detect-xbits.h:42
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:2588
StorageCleanup
void StorageCleanup(void)
Definition: util-storage.c:76
flow-bit.h
util-var-name.h
DETECT_XBITS_TRACK_IPDST
#define DETECT_XBITS_TRACK_IPDST
Definition: detect-xbits.h:35
DE_QUIET
#define DE_QUIET
Definition: detect.h:324
SigMatchSignatures
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition: detect.c:1899
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:2663
VarNameStoreRegister
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
Definition: util-var-name.c:155
DetectEngineAppendSig
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Definition: detect-parse.c:2609
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1293
HostBitInitCtx
void HostBitInitCtx(void)
Definition: host-bit.c:49
Packet_::payload_len
uint16_t payload_len
Definition: decode.h:589
DetectXbitsData_
Definition: detect-xbits.h:40
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:124
DetectXbitMatchHost
int DetectXbitMatchHost(Packet *p, const DetectXbitsData *xd)
Definition: detect-hostbits.c:247
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:38
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
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:334
DetectEngineThreadCtx_
Definition: detect.h:1104
Packet_::ts
SCTime_t ts
Definition: decode.h:530
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2789
HostCleanup
void HostCleanup(void)
Cleanup the host engine.
Definition: host.c:336
detect-engine-mpm.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
BAD_INPUT
#define BAD_INPUT(str)
VarNameStoreUnregister
void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type)
Definition: util-var-name.c:201
DETECT_XBITS_TRACK_IPPAIR
#define DETECT_XBITS_TRACK_IPPAIR
Definition: detect-xbits.h:36
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:530
DETECT_SM_LIST_MATCH
@ DETECT_SM_LIST_MATCH
Definition: detect.h:114
app-layer-parser.h
DETECT_XBITS
@ DETECT_XBITS
Definition: detect-engine-register.h:262
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:46
Signature_::flags
uint32_t flags
Definition: detect.h:603
Packet_
Definition: decode.h:482
detect-engine-build.h
StorageFinalize
int StorageFinalize(void)
Definition: util-storage.c:138
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:1276
SigGroupBuild
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Definition: detect-engine-build.c:2150
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:345
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
Definition: detect-engine.c:3299
suricata-common.h
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
Definition: detect-engine.c:3513
IPPair_
Definition: ippair.h:58
sigmatch_table
SigTableElmt sigmatch_table[DETECT_TBLSIZE]
Definition: detect-parse.c:127
util-spm.h
SCTIME_SECS
#define SCTIME_SECS(t)
Definition: util-time.h:57
DetectXbitsData_::idx
uint32_t idx
Definition: detect-xbits.h:41
SIG_FLAG_NOALERT
#define SIG_FLAG_NOALERT
Definition: detect.h:243
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:232
detect-engine-sigorder.h
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
DetectXbitsData_::tracker
uint8_t tracker
Definition: detect-xbits.h:43
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
DETECT_XBITS_TRACK_IPSRC
#define DETECT_XBITS_TRACK_IPSRC
Definition: detect-xbits.h:34
detect-parse.h
Signature_
Signature container.
Definition: detect.h:602
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:2549
VarTypes
VarTypes
Definition: util-var.h:27
Address_::family
char family
Definition: decode.h:118
Packet_::dst
Address dst
Definition: decode.h:487
IPPairLookupIPPairFromHash
IPPair * IPPairLookupIPPairFromHash(Address *a, Address *b)
look up a ippair in the hash
Definition: ippair.c:629
HostInitConfig
void HostInitConfig(bool quiet)
initialize the configuration
Definition: host.c:168
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
SigMatchAppendSMToList
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:436
DetectEngineCtx_::flags
uint8_t flags
Definition: detect.h:850
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
StatsThreadCleanup
void StatsThreadCleanup(ThreadVars *tv)
Definition: counters.c:1323
SIGMATCH_IPONLY_COMPAT
#define SIGMATCH_IPONLY_COMPAT
Definition: detect.h:1490
Packet_::src
Address src
Definition: decode.h:486
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-xbits.c:58
host-bit.h
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1300