40#define PARSE_REGEX "(.*),(.*)"
92 char *varname = NULL, *varcontent = NULL;
95 uint8_t *content = NULL;
98 pcre2_match_data *match = NULL;
101 SCLogError(
"\"%s\" is not a valid setting for pktvar.", rawstr);
106 res = pcre2_substring_get_bynumber(match, 1, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
108 SCLogError(
"pcre2_substring_get_bynumber failed");
111 varname = (
char *)str_ptr;
113 res = pcre2_substring_get_bynumber(match, 2, (PCRE2_UCHAR8 **)&str_ptr, &pcre2_len);
115 pcre2_substring_free((PCRE2_UCHAR8 *)varname);
116 SCLogError(
"pcre2_substring_get_bynumber failed");
119 varcontent = (
char *)str_ptr;
121 SCLogDebug(
"varname '%s', varcontent '%s'", varname, varcontent);
124 if (strlen(varcontent) >= 2 && varcontent[0] ==
'"' &&
125 varcontent[strlen(varcontent) - 1] ==
'"')
127 parse_content = varcontent + 1;
128 varcontent[strlen(varcontent) - 1] =
'\0';
130 parse_content = varcontent;
134 if (ret == -1 || content == NULL) {
135 pcre2_substring_free((PCRE2_UCHAR8 *)varname);
136 pcre2_substring_free((PCRE2_UCHAR8 *)varcontent);
139 pcre2_substring_free((PCRE2_UCHAR8 *)varcontent);
143 pcre2_substring_free((PCRE2_UCHAR8 *)varname);
151 pcre2_substring_free((PCRE2_UCHAR8 *)varname);
160 pcre2_match_data_free(match);
165 pcre2_match_data_free(match);
int DetectContentDataParse(const char *keyword, const char *contentstr, uint8_t **pstr, uint16_t *plen)
Parse a content string, ie "abc|DE|fgh".
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)
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
void DetectPktvarRegister(void)
PktVar * PktVarGet(Packet *p, uint32_t id)
main detection engine ctx
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
void(* Free)(DetectEngineCtx *, void *)
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define SCLogError(...)
Macro used to log ERROR messages.
#define SpmSearch(text, textlen, needle, needlelen)
void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type)
uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)