60 static bool DetectPortIsValidRange(
char *, uint16_t *);
108 for (cur =
head; cur != NULL; cur = cur->
next) {
116 SCLogDebug(
"= list end (cnt %" PRIu32
")", cnt);
131 for (cur =
head; cur != NULL; ) {
167 for (cur = *
head; cur != NULL; cur = cur->
next) {
185 if (cur->
next == NULL) {
197 if (cur->
prev != NULL)
214 r = DetectPortCut(
de_ctx, cur,
new, &c);
266 uint16_t a_port1 = a->
port;
267 uint16_t a_port2 = a->
port2;
268 uint16_t b_port1 = b->
port;
269 uint16_t b_port2 = b->
port2;
292 a->
port2 = b_port1 - 1;
303 tmp_c->
port = a_port2 + 1;
304 tmp_c->
port2 = b_port2;
318 a->
port2 = a_port1 - 1;
329 tmp_c->
port = b_port2 + 1;
330 tmp_c->
port2 = a_port2;
364 if (a_port1 == b_port1) {
369 b->
port = a_port2 + 1;
375 }
else if (a_port2 == b_port2) {
378 a->
port2 = a_port1 - 1;
397 a->
port2 = a_port1 - 1;
408 tmp_c->
port = a_port2 + 1;
409 tmp_c->
port2 = b_port2;
443 if (a_port1 == b_port1) {
448 b->
port = b_port2 + 1;
459 }
else if (a_port2 == b_port2) {
463 a->
port2 = b_port1 - 1;
474 a->
port2 = b_port1 - 1;
485 tmp_c->
port = b_port2 + 1;
486 tmp_c->
port2 = a_port2;
515 uint16_t a_port1 = a->
port;
516 uint16_t a_port2 = a->
port2;
521 if (a_port1 != 0x0000 && a_port2 != 0xFFFF) {
523 a->
port2 = a_port1 - 1;
526 tmp_b = DetectPortInit();
531 tmp_b->
port = a_port2 + 1;
532 tmp_b->
port2 = 0xFFFF;
535 }
else if (a_port1 == 0x0000 && a_port2 != 0xFFFF) {
536 a->
port = a_port2 + 1;
539 }
else if (a_port1 != 0x0000 && a_port2 == 0xFFFF) {
541 a->
port2 = a_port1 - 1;
568 uint16_t a_port1 = a->
port;
569 uint16_t a_port2 = a->
port2;
570 uint16_t b_port1 = b->
port;
571 uint16_t b_port2 = b->
port2;
574 if (a_port1 == b_port1 && a_port2 == b_port2) {
578 }
else if (a_port1 >= b_port1 && a_port1 <= b_port2 && a_port2 <= b_port2) {
582 }
else if (a_port1 <= b_port1 && a_port2 >= b_port2) {
585 }
else if (a_port1 < b_port1 && a_port2 < b_port2 && a_port2 >= b_port1) {
588 }
else if (a_port1 < b_port1 && a_port2 < b_port2) {
591 }
else if (a_port1 > b_port1 && a_port1 <= b_port2 && a_port2 > b_port2) {
594 }
else if (a_port1 > b_port2) {
640 static int DetectPortMatch(
DetectPort *dp, uint16_t port)
642 if (port >= dp->
port &&
683 if (DetectPortMatch(p, port) == 1) {
708 while (item != NULL && it != NULL) {
718 if (!(item == NULL && it == NULL)) {
756 bool port_any =
false;
775 if (DetectPortCutNot(ad, &ad2) < 0) {
783 if (DetectPortParseInsert(
head, ad2) < 0) {
784 if (ad2 != NULL)
SCFree(ad2);
790 r = DetectPortParseInsert(
head, ad);
795 if (r == 1 && port_any) {
796 SCLogDebug(
"inserting 0:65535 as port is \"any\"");
802 if (DetectPortParseInsert(
head, ad_any) < 0)
809 SCLogError(
"DetectPortParseInsertString error");
841 const char *
s,
int negate,
842 ResolvedVariablesList *var_list,
int recur)
846 int o_set = 0, n_set = 0, d_set = 0;
849 size_t size = strlen(
s);
851 const char *rule_var_port = NULL;
856 "limit reached (max 64)");
862 for (u = 0, x = 0; u < size && x <
sizeof(
address); u++) {
869 if (range == 1 &&
s[u] ==
'!') {
870 SCLogError(
"Can't have a negated value in a range.");
872 }
else if (!o_set &&
s[u] ==
'!') {
876 }
else if (
s[u] ==
'[') {
882 }
else if (
s[u] ==
']') {
889 negate? negate: n_set, var_list, recur);
897 }
else if (depth == 0 &&
s[u] ==
',') {
900 }
else if (d_set == 1) {
901 char *temp_rule_var_port = NULL,
902 *alloc_rule_var_port = NULL;
908 if (rule_var_port == NULL)
910 if (strlen(rule_var_port) == 0) {
912 "to nothing. This is likely a misconfiguration. "
913 "Note that a negated port needs to be quoted, "
914 "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.",
918 if (negate == 1 || n_set == 1) {
919 alloc_rule_var_port =
SCMalloc(strlen(rule_var_port) + 3);
920 if (
unlikely(alloc_rule_var_port == NULL))
922 snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3,
923 "[%s]", rule_var_port);
925 alloc_rule_var_port =
SCStrdup(rule_var_port);
926 if (
unlikely(alloc_rule_var_port == NULL))
929 temp_rule_var_port = alloc_rule_var_port;
930 r = DetectPortParseDo(
de_ctx,
head, nhead, temp_rule_var_port,
931 (negate + n_set) % 2, var_list, recur);
933 SCFree(alloc_rule_var_port);
938 SCFree(alloc_rule_var_port);
943 if (negate == 0 && n_set == 0) {
955 }
else if (depth == 0 &&
s[u] ==
'$') {
957 }
else if (depth == 0 && u == size-1) {
968 "groups declaration. This is likely a misconfiguration.");
974 char *temp_rule_var_port = NULL,
975 *alloc_rule_var_port = NULL;
979 if (rule_var_port == NULL)
981 if (strlen(rule_var_port) == 0) {
983 "to nothing. This is likely a misconfiguration. "
984 "Note that a negated port needs to be quoted, "
985 "\"!$HTTP_PORTS\" instead of !$HTTP_PORTS. See issue #295.",
989 if ((negate + n_set) % 2) {
990 alloc_rule_var_port =
SCMalloc(strlen(rule_var_port) + 3);
991 if (
unlikely(alloc_rule_var_port == NULL))
993 snprintf(alloc_rule_var_port, strlen(rule_var_port) + 3,
994 "[%s]", rule_var_port);
996 alloc_rule_var_port =
SCStrdup(rule_var_port);
997 if (
unlikely(alloc_rule_var_port == NULL))
1000 temp_rule_var_port = alloc_rule_var_port;
1001 r = DetectPortParseDo(
de_ctx,
head, nhead, temp_rule_var_port,
1002 (negate + n_set) % 2, var_list, recur);
1003 SCFree(alloc_rule_var_port);
1009 if (!((negate + n_set) % 2)) {
1018 }
else if (depth == 1 &&
s[u] ==
',') {
1025 "properly closed in \"%s\", %d missing closing brackets (]). "
1026 "Note: problem might be in a variable.",
1029 }
else if (depth < 0) {
1031 "properly opened in \"%s\", %d missing opening brackets ([). "
1032 "Note: problem might be in a variable.",
1047 static int DetectPortIsCompletePortSpace(
DetectPort *p)
1049 uint16_t next_port = 0;
1054 if (p->
port != 0x0000)
1059 if (p->
port2 == 0xFFFF)
1062 next_port = p->
port2 + 1;
1065 for ( ; p != NULL; p = p->
next) {
1066 if (p->
port != next_port)
1069 if (p->
port2 == 0xFFFF)
1072 next_port = p->
port2 + 1;
1095 if (DetectPortIsCompletePortSpace(*nhead) == 1) {
1096 SCLogError(
"Complete port space is negated");
1105 if (*
head == NULL && *nhead != NULL) {
1107 r = DetectPortParseInsertString(
de_ctx,
head,
"0:65535");
1114 for (ag = *nhead; ag != NULL; ag = ag->
next) {
1122 r = DetectPortParseInsert(
head, ad);
1130 for (ag = *nhead; ag != NULL; ag = ag->
next) {
1134 for (ag2 = *
head; ag2 != NULL; ) {
1140 if (ag2->
prev != NULL)
1142 if (ag2->
next != NULL)
1156 for (ag2 = *
head; ag2 != NULL; ag2 = ag2->
next) {
1161 if (*
head == NULL) {
1162 SCLogError(
"no ports left after merging ports with negated ports");
1175 SCLogDebug(
"Testing port conf vars for any misconfigured values");
1180 if (port_vars_node == NULL) {
1194 if (seq_node->
val == NULL) {
1195 SCLogError(
"Port var \"%s\" probably has a sequence(something "
1196 "in brackets) value set without any quotes. Please "
1197 "quote it using \"..\".",
1203 int r = DetectPortParseDo(NULL, &gh, &ghn, seq_node->
val,
1210 SCLogError(
"failed to parse port var \"%s\" with value \"%s\". "
1211 "Please check its syntax",
1212 seq_node->
name, seq_node->
val);
1216 if (DetectPortIsCompletePortSpace(ghn)) {
1217 SCLogError(
"Port var - \"%s\" has the complete Port range negated "
1218 "with its value \"%s\". Port space range is NIL. "
1219 "Probably have a !any or a port range that supplies "
1220 "a NULL address range",
1221 seq_node->
name, seq_node->
val);
1265 if (DetectPortParseMergeNotPorts(
de_ctx,
head, &nhead) < 0)
1291 while (isspace(*
str))
1293 if (strlen(
str) >= 16)
1302 char *port = portstr;
1305 if (port[0] ==
'!') {
1311 if ((port2 = strchr(port,
':')) != NULL) {
1316 if (strcmp(port,
"") != 0) {
1317 if (!DetectPortIsValidRange(port, &dp->
port))
1323 if (strcmp(port2,
"") != 0) {
1324 if (!DetectPortIsValidRange(port2, &dp->
port2))
1334 if (strcasecmp(port,
"any") == 0) {
1338 if (!DetectPortIsValidRange(port, &dp->
port))
1362 static bool DetectPortIsValidRange(
char *port, uint16_t *port_val)
1384 static uint32_t DetectPortHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
1389 uint32_t hash = ((uint32_t)p->
port << 16) | p->
port2;
1408 static char DetectPortCompareFunc(
void *data1, uint16_t len1,
1409 void *data2, uint16_t len2)
1414 if (data1 == NULL || data2 == NULL)
1423 static void DetectPortHashFreeFunc(
void *ptr)
1441 DetectPortCompareFunc,
1442 DetectPortHashFreeFunc);
1521 if (*
head != NULL) {
1522 for (cur = *
head; cur != NULL; cur = cur->
next) {
1539 dp->
prev = prev_cur;
1540 if (prev_cur != NULL)
1541 prev_cur->
next = dp;
1553 static int PortTestParse01 (
void)
1565 static int PortTestParse02 (
void)
1579 static int PortTestParse03 (
void)
1593 static int PortTestParse04 (
void)
1606 static int PortTestParse05 (
void)
1624 static int PortTestParse07 (
void)
1644 static int PortTestParse08 (
void)
1658 static int PortTestParse09 (
void)
1676 static int PortTestParse10 (
void)
1679 int r =
DetectPortParse(NULL,&dd,
"77777777777777777777777777777777777777777777");
1687 static int PortTestParse11 (
void)
1699 static int PortTestParse12 (
void)
1711 static int PortTestParse13 (
void)
1722 static int PortTestParse14 (
void)
1726 int r = DetectPortParseInsertString(NULL, &dd,
"0:100");
1728 r = DetectPortParseInsertString(NULL, &dd,
"1000:65535");
1744 static int PortTestParse15 (
void)
1761 static int PortTestParse16 (
void)
1765 [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\
1767 ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\
1773 [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\
1775 ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\
1784 static int PortTestFunctions01(
void)
1796 if (!(
head->port == 101))
1798 if (!(
head->port2 == 999))
1804 if (r != 0 || dp1->
next != NULL)
1806 if (!(dp1->
port == 2000))
1808 if (!(dp1->
port2 == 3000))
1812 r = PortTestDetectPortAdd(&
head, dp1);
1815 if (!(
head->port == 101))
1817 if (!(
head->port2 == 999))
1825 if (!DetectPortMatch(
head, 150))
1827 if (DetectPortMatch(
head->
next, 1500))
1829 if ((DetectPortMatch(
head, 3500)))
1831 if ((DetectPortMatch(
head, 50)))
1846 static int PortTestFunctions02(
void)
1859 if (r != 0 || dp1->
next == NULL)
1863 r = DetectPortParseMergeNotPorts(NULL, &
head, &dp1);
1868 if (r != 0 || dp2->
next == NULL)
1872 r = DetectPortParseMergeNotPorts(NULL, &
head, &dp2);
1876 if (!(
head->port == 200))
1878 if (!(
head->port2 == 300))
1896 static int PortTestFunctions03(
void)
1912 DetectPortCut(NULL, dp1, dp2, &dp3);
1916 if (!(dp1->
port == 200))
1918 if (!(dp1->
port2 == 249))
1920 if (!(dp2->
port == 250))
1922 if (!(dp2->
port2 == 300))
1931 DetectPortCut(NULL, dp1, dp2, &dp3);
1934 if (!(dp1->
port == 0))
1936 if (!(dp1->
port2 == 249))
1938 if (!(dp2->
port == 250))
1940 if (!(dp2->
port2 == 500))
1942 if (!(dp3->
port == 501))
1944 if (!(dp3->
port2 == 750))
1962 static int PortTestFunctions04(
void)
1972 dp2 = DetectPortInit();
1975 DetectPortCutNot(dp1, &dp2);
1979 if (!(dp1->
port == 0))
1981 if (!(dp1->
port2 == 199))
1983 if (!(dp2->
port == 301))
1985 if (!(dp2->
port2 == 65535))
2000 static int PortTestFunctions05(
void)
2010 memset(
s,0x00,
sizeof(
s));
2017 printf(
"r != 0 but %d: ", r);
2024 printf(
"r != 0 but %d: ", r);
2042 for ( ; x != NULL; x = x->
next) {
2052 printf(
"sig %d part of 'one', but it shouldn't: ", sig);
2057 printf(
"sig %d part of 'one', but it shouldn't: ", sig);
2062 printf(
"sig %d part of 'two', but it shouldn't: ", sig);
2078 static int PortTestFunctions06(
void)
2088 memset(
s,0x00,
sizeof(
s));
2095 printf(
"r != 0 but %d: ", r);
2102 printf(
"r != 0 but %d: ", r);
2120 for ( ; x != NULL; x = x->
next) {
2130 printf(
"sig %d part of 'one', but it shouldn't: ", sig);
2135 printf(
"sig %d part of 'one', but it shouldn't: ", sig);
2140 printf(
"sig %d part of 'two', but it shouldn't: ", sig);
2156 static int PortTestFunctions07(
void)
2190 static int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize,
const char *sig,
2205 static int PortTestMatchRealWrp(
const char *sig, uint32_t sid)
2211 uint8_t raw_eth_pkt[] = {
2212 0x00,0x50,0x56,0xea,0x00,0xbd,0x00,0x0c,
2213 0x29,0x40,0xc8,0xb5,0x08,0x00,0x45,0x00,
2214 0x01,0xa8,0xb9,0xbb,0x40,0x00,0x40,0x06,
2215 0xe0,0xbf,0xc0,0xa8,0x1c,0x83,0xc0,0xa8,
2216 0x01,0x01,0xb9,0x0a,0x00,0x50,0x6f,0xa2,
2217 0x92,0xed,0x7b,0xc1,0xd3,0x4d,0x50,0x18,
2218 0x16,0xd0,0xa0,0x6f,0x00,0x00,0x47,0x45,
2219 0x54,0x20,0x2f,0x20,0x48,0x54,0x54,0x50,
2220 0x2f,0x31,0x2e,0x31,0x0d,0x0a,0x48,0x6f,
2221 0x73,0x74,0x3a,0x20,0x31,0x39,0x32,0x2e,
2222 0x31,0x36,0x38,0x2e,0x31,0x2e,0x31,0x0d,
2223 0x0a,0x55,0x73,0x65,0x72,0x2d,0x41,0x67,
2224 0x65,0x6e,0x74,0x3a,0x20,0x4d,0x6f,0x7a,
2225 0x69,0x6c,0x6c,0x61,0x2f,0x35,0x2e,0x30,
2226 0x20,0x28,0x58,0x31,0x31,0x3b,0x20,0x55,
2227 0x3b,0x20,0x4c,0x69,0x6e,0x75,0x78,0x20,
2228 0x78,0x38,0x36,0x5f,0x36,0x34,0x3b,0x20,
2229 0x65,0x6e,0x2d,0x55,0x53,0x3b,0x20,0x72,
2230 0x76,0x3a,0x31,0x2e,0x39,0x2e,0x30,0x2e,
2231 0x31,0x34,0x29,0x20,0x47,0x65,0x63,0x6b,
2232 0x6f,0x2f,0x32,0x30,0x30,0x39,0x30,0x39,
2233 0x30,0x32,0x31,0x37,0x20,0x55,0x62,0x75,
2234 0x6e,0x74,0x75,0x2f,0x39,0x2e,0x30,0x34,
2235 0x20,0x28,0x6a,0x61,0x75,0x6e,0x74,0x79,
2236 0x29,0x20,0x46,0x69,0x72,0x65,0x66,0x6f,
2237 0x78,0x2f,0x33,0x2e,0x30,0x2e,0x31,0x34,
2238 0x0d,0x0a,0x41,0x63,0x63,0x65,0x70,0x74,
2239 0x3a,0x20,0x74,0x65,0x78,0x74,0x2f,0x68,
2240 0x74,0x6d,0x6c,0x2c,0x61,0x70,0x70,0x6c,
2241 0x69,0x63,0x61,0x74,0x69,0x6f,0x6e,0x2f,
2242 0x78,0x68,0x74,0x6d,0x6c,0x2b,0x78,0x6d,
2243 0x6c,0x2c,0x61,0x70,0x70,0x6c,0x69,0x63,
2244 0x61,0x74,0x69,0x6f,0x6e,0x2f,0x78,0x6d,
2245 0x6c,0x3b,0x71,0x3d,0x30,0x2e,0x39,0x2c,
2246 0x2a,0x2f,0x2a,0x3b,0x71,0x3d,0x30,0x2e,
2247 0x38,0x0d,0x0a,0x41,0x63,0x63,0x65,0x70,
2248 0x74,0x2d,0x4c,0x61,0x6e,0x67,0x75,0x61,
2249 0x67,0x65,0x3a,0x20,0x65,0x6e,0x2d,0x75,
2250 0x73,0x2c,0x65,0x6e,0x3b,0x71,0x3d,0x30,
2251 0x2e,0x35,0x0d,0x0a,0x41,0x63,0x63,0x65,
2252 0x70,0x74,0x2d,0x45,0x6e,0x63,0x6f,0x64,
2253 0x69,0x6e,0x67,0x3a,0x20,0x67,0x7a,0x69,
2254 0x70,0x2c,0x64,0x65,0x66,0x6c,0x61,0x74,
2255 0x65,0x0d,0x0a,0x41,0x63,0x63,0x65,0x70,
2256 0x74,0x2d,0x43,0x68,0x61,0x72,0x73,0x65,
2257 0x74,0x3a,0x20,0x49,0x53,0x4f,0x2d,0x38,
2258 0x38,0x35,0x39,0x2d,0x31,0x2c,0x75,0x74,
2259 0x66,0x2d,0x38,0x3b,0x71,0x3d,0x30,0x2e,
2260 0x37,0x2c,0x2a,0x3b,0x71,0x3d,0x30,0x2e,
2261 0x37,0x0d,0x0a,0x4b,0x65,0x65,0x70,0x2d,
2262 0x41,0x6c,0x69,0x76,0x65,0x3a,0x20,0x33,
2263 0x30,0x30,0x0d,0x0a,0x43,0x6f,0x6e,0x6e,
2264 0x65,0x63,0x74,0x69,0x6f,0x6e,0x3a,0x20,
2265 0x6b,0x65,0x65,0x70,0x2d,0x61,0x6c,0x69,
2266 0x76,0x65,0x0d,0x0a,0x0d,0x0a };
2269 return PortTestMatchReal(raw_eth_pkt, (uint16_t)
sizeof(raw_eth_pkt),
2276 static int PortTestMatchReal01(
void)
2279 const char *sig =
"alert tcp any any -> any 80 (msg:\"Nothing..\"; content:\"GET\"; sid:1;)";
2280 return PortTestMatchRealWrp(sig, 1);
2286 static int PortTestMatchReal02(
void)
2288 const char *sig =
"alert tcp any 47370 -> any any (msg:\"Nothing..\";"
2289 " content:\"GET\"; sid:1;)";
2290 return PortTestMatchRealWrp(sig, 1);
2296 static int PortTestMatchReal03(
void)
2298 const char *sig =
"alert tcp any 47370 -> any 80 (msg:\"Nothing..\";"
2299 " content:\"GET\"; sid:1;)";
2300 return PortTestMatchRealWrp(sig, 1);
2306 static int PortTestMatchReal04(
void)
2308 const char *sig =
"alert tcp any any -> any !80 (msg:\"Nothing..\";"
2309 " content:\"GET\"; sid:1;)";
2310 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2316 static int PortTestMatchReal05(
void)
2318 const char *sig =
"alert tcp any !47370 -> any any (msg:\"Nothing..\";"
2319 " content:\"GET\"; sid:1;)";
2320 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2326 static int PortTestMatchReal06(
void)
2328 const char *sig =
"alert tcp any !47370 -> any !80 (msg:\"Nothing..\";"
2329 " content:\"GET\"; sid:1;)";
2330 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2336 static int PortTestMatchReal07(
void)
2338 const char *sig =
"alert tcp any any -> any 70:100 (msg:\"Nothing..\";"
2339 " content:\"GET\"; sid:1;)";
2340 return PortTestMatchRealWrp(sig, 1);
2346 static int PortTestMatchReal08(
void)
2348 const char *sig =
"alert tcp any 47000:50000 -> any any (msg:\"Nothing..\";"
2349 " content:\"GET\"; sid:1;)";
2350 return PortTestMatchRealWrp(sig, 1);
2356 static int PortTestMatchReal09(
void)
2358 const char *sig =
"alert tcp any 47000:50000 -> any 70:100 (msg:\"Nothing..\";"
2359 " content:\"GET\"; sid:1;)";
2360 return PortTestMatchRealWrp(sig, 1);
2366 static int PortTestMatchReal10(
void)
2368 const char *sig =
"alert tcp any any -> any !70:100 (msg:\"Nothing..\";"
2369 " content:\"GET\"; sid:1;)";
2370 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2376 static int PortTestMatchReal11(
void)
2378 const char *sig =
"alert tcp any !47000:50000 -> any any (msg:\"Nothing..\";"
2379 " content:\"GET\"; sid:1;)";
2380 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2386 static int PortTestMatchReal12(
void)
2388 const char *sig =
"alert tcp any !47000:50000 -> any !70:100 (msg:\"Nothing..\";"
2389 " content:\"GET\"; sid:1;)";
2390 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2396 static int PortTestMatchReal13(
void)
2398 const char *sig =
"alert tcp any 47000:50000 -> any !81: (msg:\"Nothing..\";"
2399 " content:\"GET\"; sid:1;)";
2400 return PortTestMatchRealWrp(sig, 1);
2406 static int PortTestMatchReal14(
void)
2408 const char *sig =
"alert tcp any !48000:50000 -> any :100 (msg:\"Nothing..\";"
2409 " content:\"GET\"; sid:1;)";
2410 return PortTestMatchRealWrp(sig, 1);
2416 static int PortTestMatchReal15(
void)
2418 const char *sig =
"alert tcp any :50000 -> any 81:100 (msg:\"Nothing..\";"
2419 " content:\"GET\"; sid:1;)";
2420 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2426 static int PortTestMatchReal16(
void)
2428 const char *sig =
"alert tcp any 100: -> any ![0:79,81:65535] (msg:\"Nothing..\";"
2429 " content:\"GET\"; sid:1;)";
2430 return PortTestMatchRealWrp(sig, 1);
2436 static int PortTestMatchReal17(
void)
2438 const char *sig =
"alert tcp any ![0:39999,48000:50000] -> any ![0:80,82:65535] "
2439 "(msg:\"Nothing..\"; content:\"GET\"; sid:1;)";
2440 return (PortTestMatchRealWrp(sig, 1) == 0)? 1 : 0;
2446 static int PortTestMatchReal18(
void)
2448 const char *sig =
"alert tcp any ![0:39999,48000:50000] -> any 80 (msg:\"Nothing"
2449 " at all\"; content:\"GET\"; sid:1;)";
2450 return PortTestMatchRealWrp(sig, 1);
2456 static int PortTestMatchReal19(
void)
2458 const char *sig =
"alert tcp any any -> any 80 (msg:\"Nothing..\";"
2459 " content:\"GET\"; sid:1;)";
2460 return PortTestMatchRealWrp(sig, 1);
2463 static int PortTestMatchDoubleNegation(
void)
2468 if (DetectPortParseDo(NULL, &
head, &nhead,
"![!80]", 0, NULL, 0) == -1)
2471 result = (
head != NULL);
2472 result = (nhead == NULL);
2479 static int DetectPortParseDoTest(
void)
2485 const char *
str =
"[30:50, !45]";
2486 int r = DetectPortParseDo(
de_ctx, &
head, &nhead,
str, 0, NULL, 0);
2501 static int DetectPortParseDoTest2(
void)
2507 const char *
str =
"[30:50, !45]";
2508 int r = DetectPortParseDo(
de_ctx, &
head, &nhead,
str, 0, NULL, 0);
2516 static int PortParseTestLessThan14Spaces(
void)
2518 const char *
str =
" 45";
2528 static int PortParseTest14Spaces(
void)
2530 const char *
str =
" 45";
2540 static int PortParseTestMoreThan14Spaces(
void)
2542 const char *
str =
" 45";
2594 UtRegisterTest(
"PortTestMatchDoubleNegation", PortTestMatchDoubleNegation);
2596 UtRegisterTest(
"DetectPortParseDoTest2", DetectPortParseDoTest2);
2597 UtRegisterTest(
"PortParseTestLessThan14Spaces", PortParseTestLessThan14Spaces);
2599 UtRegisterTest(
"PortParseTestMoreThan14Spaces", PortParseTestMoreThan14Spaces);