suricata
detect-hostbits.c
Go to the documentation of this file.
1/* Copyright (C) 2007-2022 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 hostbits keyword
24 */
25
26#include "suricata-common.h"
27#include "decode.h"
28#include "action-globals.h"
29#include "detect.h"
30#include "threads.h"
31#include "flow.h"
32#include "flow-util.h"
33#include "detect-hostbits.h"
34#include "util-spm.h"
35
37
38#include "app-layer-parser.h"
39
40#include "detect-parse.h"
41#include "detect-engine.h"
42#include "detect-engine-mpm.h"
43#include "detect-engine-state.h"
44#include "detect-engine-build.h"
45
46#include "flow-bit.h"
47#include "host-bit.h"
48#include "util-var-name.h"
49#include "util-unittest.h"
50#include "util-debug.h"
51
52/*
53 hostbits:isset,bitname;
54 hostbits:set,bitname;
55
56 hostbits:set,bitname,src;
57 hostbits:set,bitname,dst;
58TODO:
59 hostbits:set,bitname,both;
60
61 hostbits:set,bitname,src,3600;
62 hostbits:set,bitname,dst,60;
63 hostbits:set,bitname,both,120;
64 */
65
66#define PARSE_REGEX \
67 "^([a-z]+)" /* Action */ \
68 "(?:\\s*,\\s*([^\\s,]+))?(?:\\s*)?" /* Name. */ \
69 "(?:\\s*,\\s*([^,\\s]+))?(?:\\s*)?" /* Direction. */ \
70 "(.+)?" /* Any remaining data. */
71static DetectParseRegex parse_regex;
72
73static int DetectHostbitMatch (DetectEngineThreadCtx *, Packet *,
74 const Signature *, const SigMatchCtx *);
75static int DetectHostbitSetup (DetectEngineCtx *, Signature *, const char *);
76void DetectHostbitFree (DetectEngineCtx *, void *);
77#ifdef UNITTESTS
78void HostBitsRegisterTests(void);
79#endif
80
82{
84 sigmatch_table[DETECT_HOSTBITS].desc = "operate on host flag";
85// sigmatch_table[DETECT_HOSTBITS].url = "/rules/flow-keywords.html#flowbits";
86 sigmatch_table[DETECT_HOSTBITS].Match = DetectHostbitMatch;
87 sigmatch_table[DETECT_HOSTBITS].Setup = DetectHostbitSetup;
89#ifdef UNITTESTS
91#endif
92 /* this is compatible to ip-only signatures */
94
96}
97
98static int DetectHostbitMatchToggle (Packet *p, const DetectXbitsData *fd)
99{
100 switch (fd->tracker) {
102 if (p->host_src == NULL) {
104 if (p->host_src == NULL)
105 return 0;
106 }
107 else
108 HostLock(p->host_src);
109
112 break;
114 if (p->host_dst == NULL) {
116 if (p->host_dst == NULL)
117 return 0;
118 }
119 else
120 HostLock(p->host_dst);
121
124 break;
125 }
126 return 1;
127}
128
129/* return true even if bit not found */
130static int DetectHostbitMatchUnset (Packet *p, const DetectXbitsData *fd)
131{
132 switch (fd->tracker) {
134 if (p->host_src == NULL) {
136 if (p->host_src == NULL)
137 return 1;
138 } else
139 HostLock(p->host_src);
140
141 HostBitUnset(p->host_src,fd->idx);
143 break;
145 if (p->host_dst == NULL) {
147 if (p->host_dst == NULL)
148 return 1;
149 } else
150 HostLock(p->host_dst);
151
152 HostBitUnset(p->host_dst,fd->idx);
154 break;
155 }
156 return 1;
157}
158
159static int DetectHostbitMatchSet (Packet *p, const DetectXbitsData *fd)
160{
161 switch (fd->tracker) {
163 if (p->host_src == NULL) {
165 if (p->host_src == NULL)
166 return 0;
167 } else
168 HostLock(p->host_src);
169
170 HostBitSet(p->host_src, fd->idx, SCTIME_ADD_SECS(p->ts, fd->expire));
172 break;
174 if (p->host_dst == NULL) {
176 if (p->host_dst == NULL)
177 return 0;
178 } else
179 HostLock(p->host_dst);
180
181 HostBitSet(p->host_dst, fd->idx, SCTIME_ADD_SECS(p->ts, fd->expire));
183 break;
184 }
185 return 1;
186}
187
188static int DetectHostbitMatchIsset (Packet *p, const DetectXbitsData *fd)
189{
190 int r = 0;
191 switch (fd->tracker) {
193 if (p->host_src == NULL) {
195 if (p->host_src == NULL)
196 return 0;
197 } else
198 HostLock(p->host_src);
199
200 r = HostBitIsset(p->host_src, fd->idx, p->ts);
202 return r;
204 if (p->host_dst == NULL) {
206 if (p->host_dst == NULL)
207 return 0;
208 } else
209 HostLock(p->host_dst);
210
211 r = HostBitIsset(p->host_dst, fd->idx, p->ts);
213 return r;
214 }
215 return 0;
216}
217
218static int DetectHostbitMatchIsnotset (Packet *p, const DetectXbitsData *fd)
219{
220 int r = 0;
221 switch (fd->tracker) {
223 if (p->host_src == NULL) {
225 if (p->host_src == NULL)
226 return 1;
227 } else
228 HostLock(p->host_src);
229
230 r = HostBitIsnotset(p->host_src, fd->idx, p->ts);
232 return r;
234 if (p->host_dst == NULL) {
236 if (p->host_dst == NULL)
237 return 1;
238 } else
239 HostLock(p->host_dst);
240
241 r = HostBitIsnotset(p->host_dst, fd->idx, p->ts);
243 return r;
244 }
245 return 0;
246}
247
249{
250 switch (xd->cmd) {
252 return DetectHostbitMatchIsset(p,xd);
254 return DetectHostbitMatchIsnotset(p,xd);
256 return DetectHostbitMatchSet(p,xd);
258 return DetectHostbitMatchUnset(p,xd);
260 return DetectHostbitMatchToggle(p,xd);
261 default:
262 SCLogError("unknown cmd %" PRIu32 "", xd->cmd);
263 return 0;
264 }
265
266 return 0;
267}
268
269/*
270 * returns 0: no match
271 * 1: match
272 * -1: error
273 */
274
275static int DetectHostbitMatch (DetectEngineThreadCtx *det_ctx, Packet *p,
276 const Signature *s, const SigMatchCtx *ctx)
277{
278 const DetectXbitsData *xd = (const DetectXbitsData *)ctx;
279 if (xd == NULL)
280 return 0;
281
282 return DetectXbitMatchHost(p, xd);
283}
284
285static int DetectHostbitParse(const char *str, char *cmd, int cmd_len,
286 char *name, int name_len, char *dir, int dir_len)
287{
288 int rc;
289 size_t pcre2len;
290
291 pcre2_match_data *match = NULL;
292 int count = DetectParsePcreExec(&parse_regex, &match, str, 0, 0);
293 if (count != 2 && count != 3 && count != 4) {
294 SCLogError("\"%s\" is not a valid setting for hostbits.", str);
295 goto error;
296 }
297
298 pcre2len = cmd_len;
299 rc = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)cmd, &pcre2len);
300 if (rc < 0) {
301 SCLogError("pcre2_substring_copy_bynumber failed");
302 goto error;
303 }
304
305 if (count >= 3) {
306 pcre2len = name_len;
307 rc = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)name, &pcre2len);
308 if (rc < 0) {
309 SCLogError("pcre2_substring_copy_bynumber failed");
310 goto error;
311 }
312 if (count >= 4) {
313 pcre2len = dir_len;
314 rc = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)dir, &pcre2len);
315 if (rc < 0) {
316 SCLogError("pcre2_substring_copy_bynumber failed");
317 goto error;
318 }
319 }
320 }
321
322 pcre2_match_data_free(match);
323 return 1;
324
325error:
326 if (match) {
327 pcre2_match_data_free(match);
328 }
329 return 0;
330}
331
332int DetectHostbitSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
333{
334 DetectXbitsData *cd = NULL;
335 uint8_t fb_cmd = 0;
336 uint8_t hb_dir = 0;
337 char fb_cmd_str[16] = "", fb_name[256] = "";
338 char hb_dir_str[16] = "";
339
340 if (!DetectHostbitParse(rawstr, fb_cmd_str, sizeof(fb_cmd_str),
341 fb_name, sizeof(fb_name), hb_dir_str, sizeof(hb_dir_str))) {
342 return -1;
343 }
344
345 if (strlen(hb_dir_str) > 0) {
346 if (strcmp(hb_dir_str, "src") == 0)
348 else if (strcmp(hb_dir_str, "dst") == 0)
350 else if (strcmp(hb_dir_str, "both") == 0) {
351 //hb_dir = DETECT_XBITS_TRACK_IPBOTH;
352 SCLogError("'both' not implemented");
353 goto error;
354 } else {
355 // TODO
356 goto error;
357 }
358 }
359
360 if (strcmp(fb_cmd_str,"noalert") == 0) {
362 } else if (strcmp(fb_cmd_str,"isset") == 0) {
363 fb_cmd = DETECT_XBITS_CMD_ISSET;
364 } else if (strcmp(fb_cmd_str,"isnotset") == 0) {
366 } else if (strcmp(fb_cmd_str,"set") == 0) {
367 fb_cmd = DETECT_XBITS_CMD_SET;
368 } else if (strcmp(fb_cmd_str,"unset") == 0) {
369 fb_cmd = DETECT_XBITS_CMD_UNSET;
370 } else if (strcmp(fb_cmd_str,"toggle") == 0) {
372 } else {
373 SCLogError("ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
374 goto error;
375 }
376
377 switch (fb_cmd) {
379 if (strlen(fb_name) != 0)
380 goto error;
381 s->action &= ~ACTION_ALERT;
382 return 0;
388 default:
389 if (strlen(fb_name) == 0)
390 goto error;
391 break;
392 }
393
394 cd = SCMalloc(sizeof(DetectXbitsData));
395 if (unlikely(cd == NULL))
396 goto error;
397
399 cd->cmd = fb_cmd;
400 cd->tracker = hb_dir;
402 cd->expire = 300;
403
404 SCLogDebug("idx %" PRIu32 ", cmd %s, name %s",
405 cd->idx, fb_cmd_str, strlen(fb_name) ? fb_name : "(none)");
406
407 /* Okay so far so good, lets get this into a SigMatch
408 * and put it in the Signature. */
409
410 switch (fb_cmd) {
411 /* case DETECT_XBITS_CMD_NOALERT can't happen here */
412
415 /* checks, so packet list */
417 DETECT_SM_LIST_MATCH) == NULL) {
418 goto error;
419 }
420 break;
421
425 /* modifiers, only run when entire sig has matched */
427 DETECT_SM_LIST_POSTMATCH) == NULL) {
428 goto error;
429 }
430 break;
431
432 // suppress coverity warning as scan-build-7 warns w/o this.
433 // coverity[deadcode : FALSE]
434 default:
435 goto error;
436 }
437
438 return 0;
439
440error:
441 if (cd != NULL)
442 SCFree(cd);
443 return -1;
444}
445
447{
448 DetectXbitsData *fd = (DetectXbitsData *)ptr;
449
450 if (fd == NULL)
451 return;
453
454 SCFree(fd);
455}
456
457#ifdef UNITTESTS
458
459static void HostBitsTestSetup(void)
460{
461 StorageInit();
464 HostInitConfig(true);
465}
466
467static void HostBitsTestShutdown(void)
468{
469 HostCleanup();
471}
472
473static int HostBitsTestParse01(void)
474{
475 char cmd[16] = "", name[256] = "", dir[16] = "";
476
477 /* No direction. */
478 FAIL_IF(!DetectHostbitParse("isset,name", cmd, sizeof(cmd), name,
479 sizeof(name), dir, sizeof(dir)));
480 FAIL_IF(strcmp(cmd, "isset") != 0);
481 FAIL_IF(strcmp(name, "name") != 0);
482 FAIL_IF(strlen(dir));
483
484 /* No direction, leading space. */
485 *cmd = '\0';
486 *name = '\0';
487 *dir = '\0';
488 FAIL_IF(!DetectHostbitParse("isset, name", cmd, sizeof(cmd), name,
489 sizeof(name), dir, sizeof(dir)));
490 FAIL_IF(strcmp(cmd, "isset") != 0);
491 FAIL_IF(strcmp(name, "name") != 0);
492
493 /* No direction, trailing space. */
494 *cmd = '\0';
495 *name = '\0';
496 *dir = '\0';
497 FAIL_IF(!DetectHostbitParse("isset,name ", cmd, sizeof(cmd), name,
498 sizeof(name), dir, sizeof(dir)));
499 FAIL_IF(strcmp(cmd, "isset") != 0);
500 FAIL_IF(strcmp(name, "name") != 0);
501
502 /* No direction, leading and trailing space. */
503 *cmd = '\0';
504 *name = '\0';
505 *dir = '\0';
506 FAIL_IF(!DetectHostbitParse("isset, name ", cmd, sizeof(cmd), name,
507 sizeof(name), dir, sizeof(dir)));
508 FAIL_IF(strcmp(cmd, "isset") != 0);
509 FAIL_IF(strcmp(name, "name") != 0);
510
511 /* With direction. */
512 *cmd = '\0';
513 *name = '\0';
514 *dir = '\0';
515 FAIL_IF(!DetectHostbitParse("isset,name,src", cmd, sizeof(cmd), name,
516 sizeof(name), dir, sizeof(dir)));
517 FAIL_IF(strcmp(cmd, "isset") != 0);
518 FAIL_IF(strcmp(name, "name") != 0);
519 FAIL_IF(strcmp(dir, "src") != 0);
520
521 /* With direction - leading and trailing spaces on name. */
522 *cmd = '\0';
523 *name = '\0';
524 *dir = '\0';
525 FAIL_IF(!DetectHostbitParse("isset, name ,src", cmd, sizeof(cmd), name,
526 sizeof(name), dir, sizeof(dir)));
527 FAIL_IF(strcmp(cmd, "isset") != 0);
528 FAIL_IF(strcmp(name, "name") != 0);
529 FAIL_IF(strcmp(dir, "src") != 0);
530
531 /* With direction - space around direction. */
532 *cmd = '\0';
533 *name = '\0';
534 *dir = '\0';
535 FAIL_IF(!DetectHostbitParse("isset, name , src ", cmd, sizeof(cmd), name,
536 sizeof(name), dir, sizeof(dir)));
537 FAIL_IF(strcmp(cmd, "isset") != 0);
538 FAIL_IF(strcmp(name, "name") != 0);
539 FAIL_IF(strcmp(dir, "src") != 0);
540
541 /* Name with space, no direction - should fail. */
542 *cmd = '\0';
543 *name = '\0';
544 *dir = '\0';
545 FAIL_IF(DetectHostbitParse("isset, name withspace ", cmd, sizeof(cmd), name,
546 sizeof(name), dir, sizeof(dir)));
547
548 PASS;
549}
550
551/**
552 * \test HostBitsTestSig01 is a test for a valid noalert flowbits option
553 *
554 * \retval 1 on success
555 * \retval 0 on failure
556 */
557
558static int HostBitsTestSig01(void)
559{
560 uint8_t *buf = (uint8_t *)
561 "GET /one/ HTTP/1.1\r\n"
562 "Host: one.example.org\r\n"
563 "\r\n";
564 uint16_t buflen = strlen((char *)buf);
566 FAIL_IF_NULL(p);
567 Signature *s = NULL;
568 ThreadVars th_v;
569 DetectEngineThreadCtx *det_ctx = NULL;
570 DetectEngineCtx *de_ctx = NULL;
571
572 memset(&th_v, 0, sizeof(th_v));
573 p->src.family = AF_INET;
574 p->dst.family = AF_INET;
575 p->payload = buf;
576 p->payload_len = buflen;
577 p->proto = IPPROTO_TCP;
578
579 HostBitsTestSetup();
580
583
585
586 s = de_ctx->sig_list = SigInit(de_ctx,"alert ip any any -> any any (hostbits:set,abc; content:\"GET \"; sid:1;)");
587 FAIL_IF_NULL(s);
588
590 DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
591
592 SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
593
594 DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
596 PacketFree(p);
597 HostBitsTestShutdown();
598 PASS;
599}
600
601/**
602 * \test various options
603 *
604 * \retval 1 on success
605 * \retval 0 on failure
606 */
607
608static int HostBitsTestSig02(void)
609{
610 Signature *s = NULL;
611 ThreadVars th_v;
612 DetectEngineCtx *de_ctx = NULL;
613
614 memset(&th_v, 0, sizeof(th_v));
615
618
620
622 "alert ip any any -> any any (hostbits:isset,abc,src; content:\"GET \"; sid:1;)");
623 FAIL_IF_NULL(s);
624
626 "alert ip any any -> any any (hostbits:isnotset,abc,dst; content:\"GET \"; sid:2;)");
627 FAIL_IF_NULL(s);
628
630 "alert ip any any -> any any (hostbits:!isset,abc,dst; content:\"GET \"; sid:3;)");
632
633/* TODO reenable after both is supported
634 s = DetectEngineAppendSig(de_ctx,
635 "alert ip any any -> any any (hostbits:set,abc,both; content:\"GET \"; sid:3;)");
636 FAIL_IF_NULL(s);
637*/
639 "alert ip any any -> any any (hostbits:unset,abc,src; content:\"GET \"; sid:4;)");
640 FAIL_IF_NULL(s);
641
643 "alert ip any any -> any any (hostbits:toggle,abc,dst; content:\"GET \"; sid:5;)");
644 FAIL_IF_NULL(s);
645
647 PASS;
648}
649
650/**
651 * \test HostBitsTestSig03 is a test check idx value
652 *
653 * \retval 1 on success
654 * \retval 0 on failure
655 */
656
657static int HostBitsTestSig03(void)
658{
659 uint8_t *buf = (uint8_t *)
660 "GET /one/ HTTP/1.1\r\n"
661 "Host: one.example.org\r\n"
662 "\r\n";
663 uint16_t buflen = strlen((char *)buf);
665 if (unlikely(p == NULL))
666 return 0;
667 Signature *s = NULL;
668 ThreadVars th_v;
669 DetectEngineThreadCtx *det_ctx = NULL;
670 DetectEngineCtx *de_ctx = NULL;
671 int idx = 0;
672
673 memset(&th_v, 0, sizeof(th_v));
674 p->src.family = AF_INET;
675 p->dst.family = AF_INET;
676 p->payload = buf;
677 p->payload_len = buflen;
678 p->proto = IPPROTO_TCP;
679
680 HostBitsTestSetup();
681
684
686
687 s = de_ctx->sig_list = SigInit(de_ctx,"alert ip any any -> any any (msg:\"isset option\"; hostbits:isset,fbt; content:\"GET \"; sid:1;)");
688 FAIL_IF_NULL(s);
689
691 FAIL_IF(idx == 0);
692
694 DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
695
696 SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
697
698 DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
700 HostBitsTestShutdown();
701
702 SCFree(p);
703 PASS;
704}
705
706/**
707 * \brief this function registers unit tests for HostBits
708 */
710{
711 UtRegisterTest("HostBitsTestParse01", HostBitsTestParse01);
712 UtRegisterTest("HostBitsTestSig01", HostBitsTestSig01);
713 UtRegisterTest("HostBitsTestSig02", HostBitsTestSig02);
714 UtRegisterTest("HostBitsTestSig03", HostBitsTestSig03);
715}
716#endif /* UNITTESTS */
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
@ DETECT_HOSTBITS
DetectEngineCtx * DetectEngineCtxInit(void)
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
Data structures and function prototypes for keeping state for the detection engine.
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
void DetectHostbitFree(DetectEngineCtx *, void *)
int DetectXbitMatchHost(Packet *p, const DetectXbitsData *xd)
void HostBitsRegisterTests(void)
this function registers unit tests for HostBits
void DetectHostbitsRegister(void)
#define PARSE_REGEX
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
SigTableElmt * sigmatch_table
#define DETECT_XBITS_CMD_NOALERT
#define DETECT_XBITS_CMD_TOGGLE
#define DETECT_XBITS_TRACK_IPSRC
#define DETECT_XBITS_TRACK_IPDST
#define DETECT_XBITS_CMD_SET
#define DETECT_XBITS_CMD_ISNOTSET
#define DETECT_XBITS_CMD_UNSET
#define DETECT_XBITS_CMD_ISSET
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Definition detect.c:2420
#define SIGMATCH_IPONLY_COMPAT
Definition detect.h:1653
#define DE_QUIET
Definition detect.h:330
@ DETECT_SM_LIST_MATCH
Definition detect.h:117
@ DETECT_SM_LIST_POSTMATCH
Definition detect.h:127
DetectEngineCtx * de_ctx
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Definition decode.c:258
void PacketFree(Packet *p)
Return a malloced packet.
Definition decode.c:219
struct Thresholds ctx
void HostBitSet(Host *h, uint32_t idx, SCTime_t expire)
Definition host-bit.c:131
void HostBitUnset(Host *h, uint32_t idx)
Definition host-bit.c:139
int HostBitIsnotset(Host *h, uint32_t idx, SCTime_t ts)
Definition host-bit.c:170
void HostBitToggle(Host *h, uint32_t idx, SCTime_t expire)
Definition host-bit.c:147
int HostBitIsset(Host *h, uint32_t idx, SCTime_t ts)
Definition host-bit.c:157
void HostBitInitCtx(void)
Definition host-bit.c:49
void HostCleanup(void)
Cleanup the host engine.
Definition host.c:332
Host * HostLookupHostFromHash(Address *a)
look up a host in the hash
Definition host.c:585
void HostInitConfig(bool quiet)
initialize the configuration
Definition host.c:168
void HostLock(Host *h)
Definition host.c:467
Host * HostGetHostFromHash(Address *a)
Definition host.c:486
void HostUnlock(Host *h)
Definition host.c:472
char family
Definition decode.h:113
main detection engine ctx
Definition detect.h:932
uint8_t flags
Definition detect.h:934
Signature * sig_list
Definition detect.h:941
enum VarTypes type
SCTime_t ts
Definition decode.h:555
Address src
Definition decode.h:505
struct Host_ * host_dst
Definition decode.h:623
uint8_t * payload
Definition decode.h:605
uint16_t payload_len
Definition decode.h:606
Address dst
Definition decode.h:506
struct Host_ * host_src
Definition decode.h:622
uint8_t proto
Definition decode.h:523
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition detect.h:351
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition detect.h:1441
void(* Free)(DetectEngineCtx *, void *)
Definition detect.h:1446
uint16_t flags
Definition detect.h:1450
const char * desc
Definition detect.h:1461
void(* RegisterTests)(void)
Definition detect.h:1448
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition detect.h:1421
const char * name
Definition detect.h:1459
Signature container.
Definition detect.h:668
uint8_t action
Definition detect.h:683
Per thread variable structure.
Definition threadvars.h:58
#define str(s)
const char * name
#define SCLogDebug(...)
Definition util-debug.h:275
#define SCLogError(...)
Macro used to log ERROR messages.
Definition util-debug.h:267
#define SCMalloc(sz)
Definition util-mem.h:47
#define SCFree(p)
Definition util-mem.h:61
#define unlikely(expr)
void StorageCleanup(void)
int StorageFinalize(void)
void StorageInit(void)
#define SCTIME_ADD_SECS(ts, s)
Definition util-time.h:64
void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type)
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
@ VAR_TYPE_HOST_BIT
Definition util-var.h:41