44 #define PARSE_REGEX "^\\s*([!])?\\s*([0-9]{1,9}+)\\s*$"
52 static void DetectWindowRegisterTests(
void);
91 if (!(PacketIsTCP(p)) || wd == NULL) {
118 pcre2_match_data *match = NULL;
120 if (ret < 1 || ret > 3) {
121 SCLogError(
"pcre_exec parse error, ret %" PRId32
", string %s", ret, windowstr);
130 char copy_str[128] =
"";
131 pcre2len =
sizeof(copy_str);
134 SCLogError(
"pcre2_substring_copy_bynumber failed");
139 if (copy_str[0] ==
'!')
145 pcre2len =
sizeof(copy_str);
146 res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)copy_str, &pcre2len);
148 SCLogError(
"pcre2_substring_copy_bynumber failed");
160 pcre2_match_data_free(match);
165 pcre2_match_data_free(match);
187 wd = DetectWindowParse(
de_ctx, windowstr);
188 if (wd == NULL)
goto error;
225 static int DetectWindowTestParse01 (
void)
228 wd = DetectWindowParse(NULL,
"35402");
239 static int DetectWindowTestParse02 (
void)
242 wd = DetectWindowParse(NULL,
"!35402");
254 static int DetectWindowTestParse03 (
void)
257 wd = DetectWindowParse(NULL,
"");
267 static int DetectWindowTestParse04 (
void)
270 wd = DetectWindowParse(NULL,
"1235402");
280 static int DetectWindowTestPacket01 (
void)
282 uint8_t *buf = (uint8_t *)
"Hi all!";
283 uint16_t buflen = strlen((
char *)buf);
289 FAIL_IF(p[0] == NULL || p[1] == NULL || p[2] == NULL);
298 sigs[0]=
"alert tcp any any -> any any (msg:\"Testing window 1\"; window:40; sid:1;)";
299 sigs[1]=
"alert tcp any any -> any any (msg:\"Testing window 2\"; window:41; sid:2;)";
301 uint32_t sid[2] = {1, 2};
303 uint32_t results[3][2] = {
319 void DetectWindowRegisterTests(
void)
321 UtRegisterTest(
"DetectWindowTestParse01", DetectWindowTestParse01);
322 UtRegisterTest(
"DetectWindowTestParse02", DetectWindowTestParse02);
323 UtRegisterTest(
"DetectWindowTestParse03", DetectWindowTestParse03);
324 UtRegisterTest(
"DetectWindowTestParse04", DetectWindowTestParse04);
325 UtRegisterTest(
"DetectWindowTestPacket01", DetectWindowTestPacket01);