Go to the documentation of this file.
56 #define PARSE_REGEX "^([a-z]+)(?:,\\s*(.*))?"
59 #define MAX_TOKENS 100
69 static bool PrefilterFlowbitIsPrefilterable(
const Signature *s);
95 static bool DetectFlowbitIsPostmatch(uint8_t cmd)
114 static inline int DetectFlowbitValidateDo(
115 Signature *s, uint8_t cmd, uint8_t cmd2, uint32_t idx,
bool err)
117 bool postmatch = DetectFlowbitIsPostmatch(cmd);
126 if ((fd->
idx == idx) && (fd->
cmd == cmd)) {
128 SCLogError(
"invalid flowbit command combination in the same signature: isset and "
133 "inconsequential flowbit command combination in the same signature: %s and %s",
146 struct DetectFlowbitInvalidCmdMap_ {
152 struct DetectFlowbitInvalidCmdMap_ icmds_map[] = {
164 for (uint8_t i = 0; i <
ARRAY_SIZE(icmds_map); i++) {
165 if (fd->
cmd == icmds_map[i].cmd1) {
166 ret = DetectFlowbitValidateDo(
167 s, icmds_map[i].cmd2, icmds_map[i].cmd1, fd->
idx, icmds_map[i].err);
171 }
else if (fd->
cmd == icmds_map[i].cmd2) {
172 ret = DetectFlowbitValidateDo(
173 s, icmds_map[i].cmd1, icmds_map[i].cmd2, fd->
idx, icmds_map[i].err);
187 char *saveptr = NULL;
190 while ((token = strtok_r(arrptr,
"|", &saveptr))) {
192 while(isspace((
unsigned char)*token))
196 char *end = token + strlen(token) - 1;
197 while(end > token && isspace((
unsigned char)*end))
201 if (strchr(token,
' ') != NULL) {
202 SCLogError(
"Spaces are not allowed in flowbit names.");
208 "maximum allowed: %d.",
299 return DetectFlowbitMatchIsset(
p,fd);
301 return DetectFlowbitMatchIsnotset(
p,fd);
303 int r = DetectFlowbitMatchSet(
p, fd);
306 SCLogDebug(
"flowbit set, appending to work queue");
312 return DetectFlowbitMatchUnset(
p, fd);
321 static int DetectFlowbitParse(
const char *
str,
char *cmd,
int cmd_len,
char *
name,
326 pcre2_match_data *match = NULL;
329 if (count != 2 && count != 3) {
330 SCLogError(
"\"%s\" is not a valid setting for flowbits.",
str);
335 rc = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)cmd, &pcre2len);
337 SCLogError(
"pcre2_substring_copy_bynumber failed");
343 rc = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)
name, &pcre2len);
345 SCLogError(
"pcre2_substring_copy_bynumber failed");
350 while (strlen(
name) > 0 && isblank(
name[strlen(
name) - 1])) {
354 if (strchr(
name,
'|') == NULL) {
356 for (
size_t i = 0; i < strlen(
name); i++) {
357 if (isblank(
name[i])) {
358 SCLogError(
"spaces not allowed in flowbit names");
365 pcre2_match_data_free(match);
370 pcre2_match_data_free(match);
379 char fb_cmd_str[16] =
"", fb_name[256] =
"";
381 if (!DetectFlowbitParse(rawstr, fb_cmd_str,
sizeof(fb_cmd_str), fb_name,
386 if (strcmp(fb_cmd_str,
"noalert") == 0) {
387 if (strlen(fb_name) != 0)
391 }
else if (strcmp(fb_cmd_str,
"isset") == 0) {
393 }
else if (strcmp(fb_cmd_str,
"isnotset") == 0) {
395 }
else if (strcmp(fb_cmd_str,
"set") == 0) {
397 }
else if (strcmp(fb_cmd_str,
"unset") == 0) {
400 SCLogError(
"ERROR: flowbits action \"%s\" is not supported.", fb_cmd_str);
410 if (strlen(fb_name) == 0)
418 if (strchr(fb_name,
'|') != NULL) {
419 int retval = FlowbitOrAddData(
de_ctx, cd, fb_name);
428 cd->
idx = varname_id;
433 SCLogDebug(
"idx %" PRIu32
", cmd %s, name %s",
434 cd->
idx, fb_cmd_str, strlen(fb_name) ? fb_name :
"(none)");
437 if (DetectFlowbitValidate(s, cd) != 0) {
521 struct FBAnalyze *array, uint32_t elements);
523 static void FBAnalyzerArrayFree(
struct FBAnalyze *array,
const uint32_t array_size)
526 for (uint32_t i = 0; i < array_size; i++) {
527 SCFree(array[i].set_sids);
528 SCFree(array[i].unset_sids);
529 SCFree(array[i].isset_sids);
530 SCFree(array[i].isnotset_sids);
536 static void FBAnalyzerFree(
struct FBAnalyzer *fba)
538 if (fba && fba->
array) {
546 static bool CheckExpand(
const uint32_t sids_idx, uint32_t **sids, uint32_t *sids_size)
548 if (sids_idx >= *sids_size) {
549 const uint32_t old_size = *sids_size;
550 const uint32_t new_size =
MAX(2 * old_size,
MAX_SIDS);
552 void *ptr =
SCRealloc(*sids, new_size *
sizeof(uint32_t));
555 *sids_size = new_size;
649 SCLogError(
"Unable to allocate flowbit analyze array");
656 (uint64_t)(array_size *
sizeof(
struct FBAnalyze)));
662 int r = DetectFlowbitsAnalyzeSignature(s, &fba);
664 FBAnalyzerFree(&fba);
670 for (uint32_t i = 0; i < array_size; i++) {
675 bool to_state =
false;
682 "set. Checked in %u and %u other sigs",
688 SCLogDebug(
"flowbit %s/%u: isset in state, set not in state", varname, i);
697 SCLogDebug(
"flowbit %s/%u: isset not in state, set in state", varname, i);
701 SCLogDebug(
"ALL flowbit %s/%u: sets %u unsets %u isnotsets %u issets %u", varname, i,
705 SCLogDebug(
"STATE flowbit %s/%u: sets %u unsets %u isnotsets %u issets %u", varname, i,
711 SCLogDebug(
"SET flowbit %s/%u: SID %u", varname, i,
717 SCLogDebug(
"GET flowbit %s/%u: SID %u", varname, i, s->
id);
723 if (sids_array_size == 0)
729 SCCalloc(sids_array_size,
sizeof(uint32_t));
731 SCLogError(
"Failed to allocate memory for rule_state_dependant_ids");
738 SCLogError(
"Failed to allocate memory for rule_state_variable_idx");
742 SCLogDebug(
"alloc'ed array for rule dependency and fbs idx array, sid %u, "
743 "sizes are %u and %u",
747 uint32_t new_array_size =
750 new_array_size *
sizeof(uint32_t));
751 if (tmp_ptr == NULL) {
752 SCLogError(
"Failed to allocate memory for rule_state_variable_idx");
757 SCLogDebug(
"realloc'ed array for rule dependency, sid %u, new size is %u",
761 new_fb_array_size *
sizeof(uint32_t));
762 if (tmp_fb_ptr == NULL) {
763 SCLogError(
"Failed to reallocate memory for rule_state_variable_idx");
768 "realloc'ed array for flowbits ids, new size is %u", new_fb_array_size);
786 SCLogDebug(
"made SID %u stateful because it depends on "
787 "stateful rules that set flowbit %s", s->
id, varname);
793 DetectFlowbitsAnalyzeDump(
de_ctx, array, array_size);
796 FBAnalyzerFree(&fba);
799 FBAnalyzerFree(&fba);
804 static struct FBAnalyzer DetectFlowbitsAnalyzeForGroup(
816 SCLogError(
"Unable to allocate flowbit analyze array");
820 "fb analyzer array size: %" PRIu64, (uint64_t)(array_size *
sizeof(
struct FBAnalyze)));
825 for (uint32_t i = 0; i < sgh->init->sig_cnt; i++) {
826 const Signature *s = sgh->init->match_array[i];
829 int r = DetectFlowbitsAnalyzeSignature(s, &fba);
831 FBAnalyzerFree(&fba);
837 for (uint32_t i = 0; i < array_size; i++) {
842 bool to_state =
false;
845 SCLogDebug(
"flowbit %s/%u: isset in state, set not in state", varname, i);
853 SCLogDebug(
"flowbit %s/%u: isset not in state, set in state", varname, i);
857 SCLogDebug(
"ALL flowbit %s/%u: sets %u unsets %u isnotsets %u issets %u", varname, i,
861 SCLogDebug(
"STATE flowbit %s/%u: sets %u unsets %u isnotsets %u issets %u", varname, i,
867 SCLogDebug(
"SET flowbit %s/%u: SID %u", varname, i,
872 SCLogDebug(
"GET flowbit %s/%u: SID %u", varname, i, s->
id);
876 SCLogDebug(
"made SID %u stateful because it depends on "
877 "stateful rules that set flowbit %s",
888 struct FBAnalyze *array, uint32_t elements)
890 SCJsonBuilder *js = SCJbNewObject();
894 SCJbOpenArray(js,
"flowbits");
895 for (uint32_t x = 0; x < elements; x++) {
903 SCJbSetString(js,
"name", varname);
904 SCJbSetUint(js,
"internal_id", x);
912 SCJbOpenArray(js,
"sets");
915 SCJbAppendUint(js, s->
id);
921 SCJbOpenArray(js,
"isset");
924 SCJbAppendUint(js, s->
id);
930 SCJbOpenArray(js,
"isnotset");
933 SCJbAppendUint(js, s->
id);
939 SCJbOpenArray(js,
"unset");
942 SCJbAppendUint(js, s->
id);
951 const char *filename =
"flowbits.json";
953 char log_path[PATH_MAX] =
"";
954 snprintf(log_path,
sizeof(log_path),
"%s/%s", log_dir, filename);
957 FILE *fp = fopen(log_path,
"w");
959 fwrite(SCJbPtr(js), SCJbLen(js), 1, fp);
968 static bool PrefilterFlowbitIsPrefilterable(
const Signature *s)
978 SCLogDebug(
"sid:%u: FLOWBITS ISSET can prefilter", s->
id);
995 uint32_t rule_id_size;
996 uint32_t rule_id_cnt;
1003 else if (a->id < b->id)
1018 static void PrefilterFlowbitFree(
void *vctx)
1023 PFB_RB_REMOVE(&
ctx->fb_tree, rec);
1036 if (
p->
flow == NULL) {
1045 memset(&lookup, 0,
sizeof(lookup));
1046 lookup.id = gv->idx;
1051 SCLogDebug(
"flowbit %u not in the tree", lookup.id);
1053 SCLogDebug(
"flowbit %u found in the tree: %u", lookup.id, b->id);
1055 PrefilterAddSids(&det_ctx->
pmq, b->
rule_id, b->rule_id_cnt);
1057 for (uint32_t x = 0; x < b->rule_id_cnt; x++) {
1066 static void PrefilterFlowbitPostRuleMatch(
1072 if (
p->
flow == NULL) {
1082 memset(&lookup, 0,
sizeof(lookup));
1083 lookup.id = w->
value;
1087 SCLogDebug(
"flowbit %u not in the tree", lookup.id);
1089 SCLogDebug(
"flowbit %u found in the tree: %u. Adding %u sids", lookup.id, b->id,
1091 PrefilterAddSids(&det_ctx->
pmq, b->
rule_id, b->rule_id_cnt);
1094 for (uint32_t x = 0; x < b->rule_id_cnt; x++) {
1104 #define BLOCK_SIZE 8
1106 static int AddBitAndSid(
1110 memset(&x, 0,
sizeof(x));
1119 add->id = flowbit_id;
1126 add->rule_id_cnt = 1;
1130 SCLogDebug(
"not found, so added (res %p)", res);
1137 SCLogDebug(
"found! pfb %p id %u", pfb, pfb->id);
1139 if (pfb->rule_id_cnt < pfb->rule_id_size) {
1160 if (AddBitAndSid(
ctx, s, fb->
idx) < 0) {
1166 if (AddBitAndSid(
ctx, s, fb->
or_list[i]) < 0) {
1174 static uint32_t NextMultiple(
const uint32_t v,
const uint32_t
m)
1176 return v + (
m - v %
m);
1200 SCLogDebug(
"flowbit: %u => rejected sid %u (iid:%u). No prefilter or prefilter not "
1201 "flowbits (%p, %s, %d)",
1211 if (fs_fb->
idx != fb->
idx) {
1213 "flowbit: %u => rejected sid %u (iid:%u). Sig prefilters on different bit %u",
1214 fb->
idx, s->
id, sig_iid, fs_fb->
idx);
1219 for (uint32_t x = 0; x < add->rule_id_cnt; x++) {
1220 if (add->
rule_id[x] == sig_iid) {
1226 if (add->rule_id_cnt < add->rule_id_size) {
1227 add->
rule_id[add->rule_id_cnt++] = sig_iid;
1236 add->
rule_id[add->rule_id_cnt++] = sig_iid;
1239 SCLogDebug(
"flowbit: %u => accepted sid %u (iid:%u)", fb->
idx, s->
id, sig_iid);
1256 memset(&x, 0,
sizeof(x));
1272 if (AddIssetSidsForBit(
de_ctx, fba, fb, add) != 1) {
1279 SCLogDebug(
"not found, so added (res %p)", res);
1282 SCLogDebug(
"found! pfb %p id %u", pfb, pfb->id);
1284 int r = AddIssetSidsForBit(
de_ctx, fba, fb, pfb);
1287 }
else if (r == 0) {
1309 SCLogDebug(
"sgh %p: setting up prefilter", sgh);
1313 struct FBAnalyzer fb_analysis = DetectFlowbitsAnalyzeForGroup(
de_ctx, sgh);
1314 if (fb_analysis.
array == NULL)
1317 for (uint32_t i = 0; i < sgh->
init->
sig_cnt; i++) {
1335 "DETECT_SM_LIST_POSTMATCH: sid %u DETECT_FLOWBITS set %u", s->
id, fb->
idx);
1343 SCLogDebug(
"flowbit %u not supported: unset in use", fb->
idx);
1347 if (set_ctx == NULL) {
1348 set_ctx =
SCCalloc(1,
sizeof(*set_ctx));
1349 if (set_ctx == NULL)
1354 if (AddBitSet(
de_ctx, &fb_analysis, set_ctx, fb, s) == 1) {
1369 SCLogDebug(
"no prefilter or prefilter not flowbits");
1376 SCLogDebug(
"flowbit %u not supported: unset in use", fb->
idx);
1384 if (isset_ctx == NULL) {
1385 isset_ctx =
SCCalloc(1,
sizeof(*isset_ctx));
1386 if (isset_ctx == NULL)
1389 if (AddBitsAndSid(
de_ctx, isset_ctx, fb, s) < 0) {
1395 static const char *g_prefilter_flowbits_isset =
"flowbits:isset";
1396 if (isset_ctx != NULL) {
1399 isset_ctx, PrefilterFlowbitFree, g_prefilter_flowbits_isset);
1403 static const char *g_prefilter_flowbits_set =
"flowbits:set";
1405 PrefilterFlowbitFree, g_prefilter_flowbits_set);
1409 PrefilterFlowbitFree(set_ctx);
1411 SCLogDebug(
"set: NO prefilter engine added");
1413 }
else if (set_ctx != NULL) {
1414 PrefilterFlowbitFree(set_ctx);
1416 FBAnalyzerFree(&fb_analysis);
1421 PrefilterFlowbitFree(set_ctx);
1424 PrefilterFlowbitFree(isset_ctx);
1426 FBAnalyzerFree(&fb_analysis);
1432 static int FlowBitsTestParse01(
void)
1434 char command[16] =
"",
name[16] =
"";
1437 FAIL_IF(!DetectFlowbitParse(
"noalert", command,
sizeof(command),
name,
1439 FAIL_IF(strcmp(command,
"noalert") != 0);
1442 FAIL_IF(!DetectFlowbitParse(
"set,flowbit", command,
sizeof(command),
name,
1444 FAIL_IF(strcmp(command,
"set") != 0);
1448 FAIL_IF(!DetectFlowbitParse(
"set, flowbit", command,
sizeof(command),
name,
1450 FAIL_IF(strcmp(command,
"set") != 0);
1454 FAIL_IF(!DetectFlowbitParse(
"set,flowbit ", command,
sizeof(command),
name,
1456 FAIL_IF(strcmp(command,
"set") != 0);
1460 FAIL_IF(!DetectFlowbitParse(
"set, flowbit ", command,
sizeof(command),
name,
1462 FAIL_IF(strcmp(command,
"set") != 0);
1466 FAIL_IF(DetectFlowbitParse(
"set,namewith space", command,
sizeof(command),
1479 static int FlowBitsTestSig01(
void)
1489 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Noalert\"; flowbits:noalert,wrongusage; content:\"GET \"; sid:1;)");
1504 static int FlowBitsTestSig02(
void)
1517 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"isset rule need an option\"; flowbits:isset; content:\"GET \"; sid:1;)");
1520 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"isnotset rule need an option\"; flowbits:isnotset; content:\"GET \"; sid:2;)");
1523 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"set rule need an option\"; flowbits:set; content:\"GET \"; sid:3;)");
1526 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"unset rule need an option\"; flowbits:unset; content:\"GET \"; sid:4;)");
1529 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"!set is not an option\"; flowbits:!set,myerr; content:\"GET \"; sid:6;)");
1545 static int FlowBitsTestSig03(
void)
1555 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Unknown cmd\"; flowbits:wrongcmd; content:\"GET \"; sid:1;)");
1570 static int FlowBitsTestSig04(
void)
1580 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"isset option\"; flowbits:isset,fbt; content:\"GET \"; sid:1;)");
1598 static int FlowBitsTestSig05(
void)
1608 s =
de_ctx->
sig_list =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Noalert\"; flowbits:noalert; content:\"GET \"; sid:1;)");
1624 static int FlowBitsTestSig06(
void)
1626 uint8_t *buf = (uint8_t *)
1627 "GET /one/ HTTP/1.1\r\n"
1628 "Host: one.example.org\r\n"
1630 uint16_t buflen = strlen((
char *)buf);
1644 memset(&f, 0,
sizeof(
Flow));
1676 for ( ; gv != NULL; gv = gv->
next) {
1699 static int FlowBitsTestSig07(
void)
1701 uint8_t *buf = (uint8_t *)
1702 "GET /one/ HTTP/1.1\r\n"
1703 "Host: one.example.org\r\n"
1705 uint16_t buflen = strlen((
char *)buf);
1719 memset(&f, 0,
sizeof(
Flow));
1740 s = s->
next =
SigInit(
de_ctx,
"alert ip any any -> any any (msg:\"Flowbit unset\"; flowbits:unset,myflow2; sid:11;)");
1753 for ( ; gv != NULL; gv = gv->
next) {
uint16_t cnts[DETECT_FLOWBITS_CMD_MAX]
uint32_t rule_state_dependant_sids_idx
uint32_t isnotset_sids_idx
SCMutex g_flowbits_dump_write_m
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
#define DETECT_FLOWBITS_CMD_MAX
SigTableElmt * sigmatch_table
void PostRuleMatchWorkQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, const int type, const uint32_t value)
void(* Free)(DetectEngineCtx *, void *)
#define DETECT_TABLE_PACKET_FILTER_FLAG
Container for matching data for a signature group.
void FlowBitsRegisterTests(void)
this function registers unit tests for FlowBits
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
uint64_t PcapPacketCntGet(const Packet *p)
bool is_rule_state_dependant
struct HtpBodyChunk_ * next
#define DETECT_FLOWBITS_CMD_ISNOTSET
int PrefilterAppendEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, PrefilterPktFn PrefilterFunc, SignatureMask mask, enum SignatureHookPkt hook, void *pectx, void(*FreeFunc)(void *pectx), const char *name)
SCEnumCharMap flowbit_cmds[]
int DetectFlowbitsAnalyze(DetectEngineCtx *de_ctx)
main detection engine ctx
@ SIGNATURE_HOOK_PKT_NOT_SET
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
#define FLOW_PKT_TOSERVER
const char * VarNameStoreSetupLookup(const uint32_t id, const enum VarTypes type)
#define DETECT_TABLE_APP_TD_FLAG
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
#define SCMUTEX_INITIALIZER
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
#define DETECT_FLOWBITS_CMD_ISSET
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
struct PrefilterEngineFlowbits __attribute__
#define DETECT_TABLE_APP_FILTER_FLAG
RB_HEAD(PFB, PrefilterFlowbit)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int FlowBitSet(Flow *f, uint32_t idx)
add a flowbit to the flow
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define DETECT_TABLE_PACKET_TD_FLAG
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
void FlowBitUnset(Flow *f, uint32_t idx)
@ DETECT_SM_LIST_POSTMATCH
#define FLOW_INITIALIZE(f)
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
struct GenericVar_ * next
#define PASS
Pass the test.
#define SCMutexUnlock(mut)
#define SIG_MASK_REQUIRE_FLOW
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
#define RB_FOREACH_SAFE(x, name, head, y)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Per thread variable structure.
uint32_t rule_state_flowbits_ids_size
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type)
void PacketFree(Packet *p)
Return a malloced packet.
#define SCLogWarning(...)
Macro used to log WARNING messages.
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
SigGroupHeadInitData * init
void DetectFlowbitFree(DetectEngineCtx *, void *)
void DetectFlowbitsRegister(void)
#define SIGMATCH_IPONLY_COMPAT
const char * SCConfigGetLogDirectory(void)
RB_GENERATE(PFB, PrefilterFlowbit, rb, PrefilterFlowbitCompare)
SignatureInitData * init_data
uint32_t * rule_state_dependant_sids_array
Data structures and function prototypes for keeping state for the detection engine.
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
uint32_t rule_state_dependant_sids_size
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
void StatsThreadInit(StatsThreadContext *stats)
#define SCRealloc(ptr, sz)
#define SIG_FLAG_INIT_STATE_MATCH
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
const char * SCMapEnumValueToName(int enum_value, SCEnumCharMap *table)
Maps an enum value to a string name, from the supplied table.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
uint16_t state_cnts[DETECT_FLOWBITS_CMD_MAX]
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
PostRuleMatchWorkQueueItem * q
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
int PrefilterAppendPostRuleEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh, void(*PrefilterPostRuleFunc)(DetectEngineThreadCtx *det_ctx, const void *pectx, Packet *p, Flow *f), void *pectx, void(*FreeFunc)(void *pectx), const char *name)
int FlowBitIsset(Flow *f, uint32_t idx)
#define SCLogError(...)
Macro used to log ERROR messages.
#define DETECT_TABLE_PACKET_PRE_STREAM_FLAG
bool(* SupportsPrefilter)(const Signature *s)
#define DETECT_FLOWBITS_CMD_UNSET
a single match condition for a signature
uint32_t isnotset_sids_size
DetectEngineCtx * DetectEngineCtxInit(void)
int DetectFlowbitMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define SIGMATCH_SUPPORT_FIREWALL
uint32_t * rule_state_flowbits_ids_array
void StatsThreadCleanup(StatsThreadContext *stats)
#define FLOW_PKT_TOSERVER_FIRST
bool rule_engine_analysis_set
#define DEBUG_VALIDATE_BUG_ON(exp)
#define SIG_FLAG_PREFILTER
bool post_rule_match_prefilter
RB_PROTOTYPE(PFB, PrefilterFlowbit, rb, PrefilterFlowbitCompare)
PostRuleMatchWorkQueue post_rule_work_queue
int FlowBitIsnotset(Flow *f, uint32_t idx)
#define DETECT_FLOWBITS_CMD_SET
void(* RegisterTests)(void)