Go to the documentation of this file.
37 #define PARSE_REGEX "^\\s*(src_ip|dest_ip)\\s*$"
44 static void DetectTargetRegisterTests (
void);
82 static int DetectTargetParse(
Signature *s,
const char *targetstr)
87 pcre2_match_data *match = NULL;
90 SCLogError(
"pcre_exec parse error, ret %" PRId32
", string %s", ret, targetstr);
94 pcre2len =
sizeof(value);
95 int res = pcre2_substring_copy_bynumber(match, 1, (PCRE2_UCHAR8 *)value, &pcre2len);
97 SCLogError(
"pcre2_substring_copy_bynumber failed");
102 if (!strcmp(value,
"src_ip")) {
104 SCLogError(
"Conflicting values of target keyword");
108 }
else if (!strcmp(value,
"dest_ip")) {
110 SCLogError(
"Conflicting values of target keyword");
115 SCLogError(
"only 'src_ip' and 'dest_ip' are supported as target value");
118 pcre2_match_data_free(match);
123 pcre2_match_data_free(match);
141 int ret = DetectTargetParse(s, targetstr);
150 static int DetectTargetSignatureTest01(
void)
165 static void DetectTargetRegisterTests(
void)
168 DetectTargetSignatureTest01);
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define SIG_FLAG_DEST_IS_TARGET
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
void DetectTargetRegister(void)
Registration function for target keyword.
#define PASS
Pass the test.
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
#define PARSE_REGEX
Regex for parsing our keyword options.
#define SIG_FLAG_SRC_IS_TARGET
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define SCLogError(...)
Macro used to log ERROR messages.
DetectEngineCtx * DetectEngineCtxInit(void)
void(* RegisterTests)(void)