61 uint32_t a_ip1 =
SCNtohl(a->
ip.addr_data32[0]);
62 uint32_t a_ip2 =
SCNtohl(a->
ip2.addr_data32[0]);
63 uint32_t b_ip1 =
SCNtohl(b->
ip.addr_data32[0]);
64 uint32_t b_ip2 =
SCNtohl(b->
ip2.addr_data32[0]);
66 if (a_ip1 == b_ip1 && a_ip2 == b_ip2) {
69 }
else if (a_ip1 >= b_ip1 && a_ip1 <= b_ip2 && a_ip2 <= b_ip2) {
72 }
else if (a_ip1 <= b_ip1 && a_ip2 >= b_ip2) {
75 }
else if (a_ip1 < b_ip1 && a_ip2 < b_ip2 && a_ip2 >= b_ip1) {
78 }
else if (a_ip1 < b_ip1 && a_ip2 < b_ip2) {
81 }
else if (a_ip1 > b_ip1 && a_ip1 <= b_ip2 && a_ip2 > b_ip2) {
84 }
else if (a_ip1 > b_ip2) {
89 SCLogDebug(
"Internal Error: should be unreachable");
116 uint32_t a_ip1 =
SCNtohl(a->
ip.addr_data32[0]);
117 uint32_t a_ip2 =
SCNtohl(a->
ip2.addr_data32[0]);
118 uint32_t b_ip1 =
SCNtohl(b->
ip.addr_data32[0]);
119 uint32_t b_ip2 =
SCNtohl(b->
ip2.addr_data32[0]);
144 SCLogDebug(
"DetectAddressCutIPv4: r == ADDRESS_LE");
146 a->
ip.addr_data32[0] = htonl(a_ip1);
147 a->
ip2.addr_data32[0] = htonl(b_ip1 - 1);
149 b->
ip.addr_data32[0] = htonl(b_ip1);
150 b->
ip2.addr_data32[0] = htonl(a_ip2);
157 tmp_c->
ip.addr_data32[0] = htonl(a_ip2 + 1);
158 tmp_c->
ip2.addr_data32[0] = htonl(b_ip2);
167 SCLogDebug(
"DetectAddressCutIPv4: r == ADDRESS_GE");
169 a->
ip.addr_data32[0] = htonl(b_ip1);
170 a->
ip2.addr_data32[0] = htonl(a_ip1 - 1);
172 b->
ip.addr_data32[0] = htonl(a_ip1);
173 b->
ip2.addr_data32[0] = htonl(b_ip2);
180 tmp_c->
ip.addr_data32[0] = htonl(b_ip2 + 1);
181 tmp_c->
ip2.addr_data32[0] = htonl(a_ip2);
201 SCLogDebug(
"DetectAddressCutIPv4: r == ADDRESS_ES");
203 if (a_ip1 == b_ip1) {
206 a->
ip.addr_data32[0] = htonl(a_ip1);
207 a->
ip2.addr_data32[0] = htonl(a_ip2);
209 b->
ip.addr_data32[0] = htonl(a_ip2 + 1);
210 b->
ip2.addr_data32[0] = htonl(b_ip2);
212 }
else if (a_ip2 == b_ip2) {
215 a->
ip.addr_data32[0] = htonl(b_ip1);
216 a->
ip2.addr_data32[0] = htonl(a_ip1 - 1);
218 b->
ip.addr_data32[0] = htonl(a_ip1);
219 b->
ip2.addr_data32[0] = htonl(a_ip2);
224 a->
ip.addr_data32[0] = htonl(b_ip1);
225 a->
ip2.addr_data32[0] = htonl(a_ip1 - 1);
227 b->
ip.addr_data32[0] = htonl(a_ip1);
228 b->
ip2.addr_data32[0] = htonl(a_ip2);
235 tmp_c->
ip.addr_data32[0] = htonl(a_ip2 + 1);
236 tmp_c->
ip2.addr_data32[0] = htonl(b_ip2);
256 SCLogDebug(
"DetectAddressCutIPv4: r == ADDRESS_EB");
258 if (a_ip1 == b_ip1) {
261 a->
ip.addr_data32[0] = htonl(b_ip1);
262 a->
ip2.addr_data32[0] = htonl(b_ip2);
264 b->
ip.addr_data32[0] = htonl(b_ip2 + 1);
265 b->
ip2.addr_data32[0] = htonl(a_ip2);
266 }
else if (a_ip2 == b_ip2) {
269 a->
ip.addr_data32[0] = htonl(a_ip1);
270 a->
ip2.addr_data32[0] = htonl(b_ip1 - 1);
272 b->
ip.addr_data32[0] = htonl(b_ip1);
273 b->
ip2.addr_data32[0] = htonl(b_ip2);
277 a->
ip.addr_data32[0] = htonl(a_ip1);
278 a->
ip2.addr_data32[0] = htonl(b_ip1 - 1);
280 b->
ip.addr_data32[0] = htonl(b_ip1);
281 b->
ip2.addr_data32[0] = htonl(b_ip2);
288 tmp_c->
ip.addr_data32[0] = htonl(b_ip2 + 1);
289 tmp_c->
ip2.addr_data32[0] = htonl(a_ip2);
316 uint32_t next_ip = 0;
322 if (
SCNtohl(ag->
ip.addr_data32[0]) != 0x00000000)
327 if (
SCNtohl(ag->
ip2.addr_data32[0]) == 0xFFFFFFFF)
330 next_ip = htonl(
SCNtohl(ag->
ip2.addr_data32[0]) + 1);
333 for ( ; ag != NULL; ag = ag->
next) {
335 if (ag->
ip.addr_data32[0] != next_ip)
338 if (
SCNtohl(ag->
ip2.addr_data32[0]) == 0xFFFFFFFF)
341 next_ip = htonl(
SCNtohl(ag->
ip2.addr_data32[0]) + 1);
370 uint32_t a_ip1 =
SCNtohl(a->
ip.addr_data32[0]);
371 uint32_t a_ip2 =
SCNtohl(a->
ip2.addr_data32[0]);
377 if (a_ip1 != 0x00000000 && a_ip2 != 0xFFFFFFFF) {
378 a->
ip.addr_data32[0] = htonl(0x00000000);
379 a->
ip2.addr_data32[0] = htonl(a_ip1 - 1);
386 tmp_b->
ip.addr_data32[0] = htonl(a_ip2 + 1);
387 tmp_b->
ip2.addr_data32[0] = htonl(0xFFFFFFFF);
389 }
else if (a_ip1 == 0x00000000 && a_ip2 != 0xFFFFFFFF) {
390 a->
ip.addr_data32[0] = htonl(a_ip2 + 1);
391 a->
ip2.addr_data32[0] = htonl(0xFFFFFFFF);
392 }
else if (a_ip1 != 0x00000000 && a_ip2 == 0xFFFFFFFF) {
393 a->
ip.addr_data32[0] = htonl(0x00000000);
394 a->
ip2.addr_data32[0] = htonl(a_ip1 - 1);
409 static int DetectAddressIPv4TestAddressCmp01(
void)
419 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
420 a->ip.addr_data32[0] = in.s_addr;
421 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
422 a->ip2.addr_data32[0] = in.s_addr;
423 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
424 b->
ip.addr_data32[0] = in.s_addr;
425 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
426 b->
ip2.addr_data32[0] = in.s_addr;
429 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
430 a->ip.addr_data32[0] = in.s_addr;
431 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
432 a->ip2.addr_data32[0] = in.s_addr;
433 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
434 b->
ip.addr_data32[0] = in.s_addr;
435 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
436 b->
ip2.addr_data32[0] = in.s_addr;
439 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
440 a->ip.addr_data32[0] = in.s_addr;
441 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
442 a->ip2.addr_data32[0] = in.s_addr;
443 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
444 b->
ip.addr_data32[0] = in.s_addr;
445 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
446 b->
ip2.addr_data32[0] = in.s_addr;
449 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
450 a->ip.addr_data32[0] = in.s_addr;
451 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
452 a->ip2.addr_data32[0] = in.s_addr;
453 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
454 b->
ip.addr_data32[0] = in.s_addr;
455 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
456 b->
ip2.addr_data32[0] = in.s_addr;
459 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
460 a->ip.addr_data32[0] = in.s_addr;
461 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
462 a->ip2.addr_data32[0] = in.s_addr;
463 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
464 b->
ip.addr_data32[0] = in.s_addr;
465 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
466 b->
ip2.addr_data32[0] = in.s_addr;
469 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
470 a->ip.addr_data32[0] = in.s_addr;
471 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
472 a->ip2.addr_data32[0] = in.s_addr;
473 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
474 b->
ip.addr_data32[0] = in.s_addr;
475 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
476 b->
ip2.addr_data32[0] = in.s_addr;
479 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
480 a->ip.addr_data32[0] = in.s_addr;
481 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
482 a->ip2.addr_data32[0] = in.s_addr;
483 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
484 b->
ip.addr_data32[0] = in.s_addr;
485 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
486 b->
ip2.addr_data32[0] = in.s_addr;
489 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
490 a->ip.addr_data32[0] = in.s_addr;
491 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
492 a->ip2.addr_data32[0] = in.s_addr;
493 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
494 b->
ip.addr_data32[0] = in.s_addr;
495 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
496 b->
ip2.addr_data32[0] = in.s_addr;
499 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
500 a->ip.addr_data32[0] = in.s_addr;
501 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
502 a->ip2.addr_data32[0] = in.s_addr;
503 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
504 b->
ip.addr_data32[0] = in.s_addr;
505 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
506 b->
ip2.addr_data32[0] = in.s_addr;
509 FAIL_IF(inet_pton(AF_INET,
"1.2.3.5", &in) < 0);
510 a->ip.addr_data32[0] = in.s_addr;
511 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
512 a->ip2.addr_data32[0] = in.s_addr;
513 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
514 b->
ip.addr_data32[0] = in.s_addr;
515 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
516 b->
ip2.addr_data32[0] = in.s_addr;
519 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
520 a->ip.addr_data32[0] = in.s_addr;
521 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
522 a->ip2.addr_data32[0] = in.s_addr;
523 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
524 b->
ip.addr_data32[0] = in.s_addr;
525 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
526 b->
ip2.addr_data32[0] = in.s_addr;
529 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
530 a->ip.addr_data32[0] = in.s_addr;
531 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
532 a->ip2.addr_data32[0] = in.s_addr;
533 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
534 b->
ip.addr_data32[0] = in.s_addr;
535 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
536 b->
ip2.addr_data32[0] = in.s_addr;
539 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
540 a->ip.addr_data32[0] = in.s_addr;
541 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
542 a->ip2.addr_data32[0] = in.s_addr;
543 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
544 b->
ip.addr_data32[0] = in.s_addr;
545 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
546 b->
ip2.addr_data32[0] = in.s_addr;
549 FAIL_IF(inet_pton(AF_INET,
"170.170.170.169", &in) < 0);
550 a->ip.addr_data32[0] = in.s_addr;
551 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
552 a->ip2.addr_data32[0] = in.s_addr;
553 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
554 b->
ip.addr_data32[0] = in.s_addr;
555 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
556 b->
ip2.addr_data32[0] = in.s_addr;
559 FAIL_IF(inet_pton(AF_INET,
"170.170.170.169", &in) < 0);
560 a->ip.addr_data32[0] = in.s_addr;
561 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
562 a->ip2.addr_data32[0] = in.s_addr;
563 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
564 b->
ip.addr_data32[0] = in.s_addr;
565 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
566 b->
ip2.addr_data32[0] = in.s_addr;
569 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
570 a->ip.addr_data32[0] = in.s_addr;
571 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
572 a->ip2.addr_data32[0] = in.s_addr;
573 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
574 b->
ip.addr_data32[0] = in.s_addr;
575 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
576 b->
ip2.addr_data32[0] = in.s_addr;
579 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
580 a->ip.addr_data32[0] = in.s_addr;
581 FAIL_IF(inet_pton(AF_INET,
"185.185.185.185", &in) < 0);
582 a->ip2.addr_data32[0] = in.s_addr;
583 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
584 b->
ip.addr_data32[0] = in.s_addr;
585 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
586 b->
ip2.addr_data32[0] = in.s_addr;
590 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
591 a->ip.addr_data32[0] = in.s_addr;
592 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
593 a->ip2.addr_data32[0] = in.s_addr;
594 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
595 b->
ip.addr_data32[0] = in.s_addr;
596 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
597 b->
ip2.addr_data32[0] = in.s_addr;
601 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
602 a->ip.addr_data32[0] = in.s_addr;
603 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
604 a->ip2.addr_data32[0] = in.s_addr;
605 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
606 b->
ip.addr_data32[0] = in.s_addr;
607 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
608 b->
ip2.addr_data32[0] = in.s_addr;
611 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
612 a->ip.addr_data32[0] = in.s_addr;
613 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
614 a->ip2.addr_data32[0] = in.s_addr;
615 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
616 b->
ip.addr_data32[0] = in.s_addr;
617 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
618 b->
ip2.addr_data32[0] = in.s_addr;
621 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
622 a->ip.addr_data32[0] = in.s_addr;
623 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
624 a->ip2.addr_data32[0] = in.s_addr;
625 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
626 b->
ip.addr_data32[0] = in.s_addr;
627 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
628 b->
ip2.addr_data32[0] = in.s_addr;
631 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
632 a->ip.addr_data32[0] = in.s_addr;
633 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
634 a->ip2.addr_data32[0] = in.s_addr;
635 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
636 b->
ip.addr_data32[0] = in.s_addr;
637 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
638 b->
ip2.addr_data32[0] = in.s_addr;
641 FAIL_IF(inet_pton(AF_INET,
"128.128.128.128", &in) < 0);
642 a->ip.addr_data32[0] = in.s_addr;
643 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
644 a->ip2.addr_data32[0] = in.s_addr;
645 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
646 b->
ip.addr_data32[0] = in.s_addr;
647 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
648 b->
ip2.addr_data32[0] = in.s_addr;
651 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
652 a->ip.addr_data32[0] = in.s_addr;
653 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
654 a->ip2.addr_data32[0] = in.s_addr;
655 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
656 b->
ip.addr_data32[0] = in.s_addr;
657 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
658 b->
ip2.addr_data32[0] = in.s_addr;
661 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
662 a->ip.addr_data32[0] = in.s_addr;
663 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
664 a->ip2.addr_data32[0] = in.s_addr;
665 FAIL_IF(inet_pton(AF_INET,
"170.170.170.169", &in) < 0);
666 b->
ip.addr_data32[0] = in.s_addr;
667 FAIL_IF(inet_pton(AF_INET,
"180.180.180.180", &in) < 0);
668 b->
ip2.addr_data32[0] = in.s_addr;
671 FAIL_IF(inet_pton(AF_INET,
"170.170.170.169", &in) < 0);
672 a->ip.addr_data32[0] = in.s_addr;
673 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
674 a->ip2.addr_data32[0] = in.s_addr;
675 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
676 b->
ip.addr_data32[0] = in.s_addr;
677 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
678 b->
ip2.addr_data32[0] = in.s_addr;
681 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
682 a->ip.addr_data32[0] = in.s_addr;
683 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
684 a->ip2.addr_data32[0] = in.s_addr;
685 FAIL_IF(inet_pton(AF_INET,
"170.170.169.170", &in) < 0);
686 b->
ip.addr_data32[0] = in.s_addr;
687 FAIL_IF(inet_pton(AF_INET,
"192.168.1.1", &in) < 0);
688 b->
ip2.addr_data32[0] = in.s_addr;
691 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
692 a->ip.addr_data32[0] = in.s_addr;
693 FAIL_IF(inet_pton(AF_INET,
"200.200.200.200", &in) < 0);
694 a->ip2.addr_data32[0] = in.s_addr;
695 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
696 b->
ip.addr_data32[0] = in.s_addr;
697 FAIL_IF(inet_pton(AF_INET,
"185.185.185.185", &in) < 0);
698 b->
ip2.addr_data32[0] = in.s_addr;
701 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
702 a->ip.addr_data32[0] = in.s_addr;
703 FAIL_IF(inet_pton(AF_INET,
"200.200.200.200", &in) < 0);
704 a->ip2.addr_data32[0] = in.s_addr;
705 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
706 b->
ip.addr_data32[0] = in.s_addr;
707 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
708 b->
ip2.addr_data32[0] = in.s_addr;
711 FAIL_IF(inet_pton(AF_INET,
"182.168.1.2", &in) < 0);
712 a->ip.addr_data32[0] = in.s_addr;
713 FAIL_IF(inet_pton(AF_INET,
"200.200.200.200", &in) < 0);
714 a->ip2.addr_data32[0] = in.s_addr;
715 FAIL_IF(inet_pton(AF_INET,
"170.170.170.170", &in) < 0);
716 b->
ip.addr_data32[0] = in.s_addr;
717 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
718 b->
ip2.addr_data32[0] = in.s_addr;
726 static int DetectAddressIPv4IsCompleteIPSpace02(
void)
733 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
734 a->ip.addr_data32[0] = in.s_addr;
735 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
736 a->ip2.addr_data32[0] = in.s_addr;
739 FAIL_IF(inet_pton(AF_INET,
"0.0.0.1", &in) < 0);
740 a->ip.addr_data32[0] = in.s_addr;
741 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
742 a->ip2.addr_data32[0] = in.s_addr;
750 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
751 a->ip.addr_data32[0] = in.s_addr;
752 FAIL_IF(inet_pton(AF_INET,
"255.255.255.254", &in) < 0);
753 a->ip2.addr_data32[0] = in.s_addr;
761 static int DetectAddressIPv4IsCompleteIPSpace03(
void)
769 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
770 a->ip.addr_data32[0] = in.s_addr;
771 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
772 a->ip2.addr_data32[0] = in.s_addr;
779 FAIL_IF(inet_pton(AF_INET,
"1.2.3.5", &in) < 0);
780 temp->
ip.addr_data32[0] = in.s_addr;
781 FAIL_IF(inet_pton(AF_INET,
"126.36.62.61", &in) < 0);
782 temp->
ip2.addr_data32[0] = in.s_addr;
789 FAIL_IF(inet_pton(AF_INET,
"126.36.62.62", &in) < 0);
790 temp->
ip.addr_data32[0] = in.s_addr;
791 FAIL_IF(inet_pton(AF_INET,
"222.52.21.62", &in) < 0);
792 temp->
ip2.addr_data32[0] = in.s_addr;
799 FAIL_IF(inet_pton(AF_INET,
"222.52.21.63", &in) < 0);
800 temp->
ip.addr_data32[0] = in.s_addr;
801 FAIL_IF(inet_pton(AF_INET,
"255.255.255.254", &in) < 0);
802 temp->
ip2.addr_data32[0] = in.s_addr;
809 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
810 temp->
ip.addr_data32[0] = in.s_addr;
811 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
812 temp->
ip2.addr_data32[0] = in.s_addr;
820 static int DetectAddressIPv4IsCompleteIPSpace04(
void)
828 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
829 a->ip.addr_data32[0] = in.s_addr;
830 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
831 a->ip2.addr_data32[0] = in.s_addr;
838 FAIL_IF(inet_pton(AF_INET,
"1.2.3.5", &in) < 0);
839 temp->
ip.addr_data32[0] = in.s_addr;
840 FAIL_IF(inet_pton(AF_INET,
"126.36.62.61", &in) < 0);
841 temp->
ip2.addr_data32[0] = in.s_addr;
848 FAIL_IF(inet_pton(AF_INET,
"126.36.62.62", &in) < 0);
849 temp->
ip.addr_data32[0] = in.s_addr;
850 FAIL_IF(inet_pton(AF_INET,
"222.52.21.62", &in) < 0);
851 temp->
ip2.addr_data32[0] = in.s_addr;
858 FAIL_IF(inet_pton(AF_INET,
"222.52.21.64", &in) < 0);
859 temp->
ip.addr_data32[0] = in.s_addr;
860 FAIL_IF(inet_pton(AF_INET,
"255.255.255.254", &in) < 0);
861 temp->
ip2.addr_data32[0] = in.s_addr;
868 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
869 temp->
ip.addr_data32[0] = in.s_addr;
870 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
871 temp->
ip2.addr_data32[0] = in.s_addr;
879 static int DetectAddressIPv4CutNot05(
void)
887 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
888 a->ip.addr_data32[0] = in.s_addr;
889 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
890 a->ip2.addr_data32[0] = in.s_addr;
898 static int DetectAddressIPv4CutNot06(
void)
906 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
907 a->ip.addr_data32[0] = in.s_addr;
908 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
909 a->ip2.addr_data32[0] = in.s_addr;
912 FAIL_IF(inet_pton(AF_INET,
"1.2.3.5", &in) < 0);
914 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
922 static int DetectAddressIPv4CutNot07(
void)
930 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
931 a->ip.addr_data32[0] = in.s_addr;
932 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
933 a->ip2.addr_data32[0] = in.s_addr;
936 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
938 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
946 static int DetectAddressIPv4CutNot08(
void)
954 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
955 a->ip.addr_data32[0] = in.s_addr;
956 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
957 a->ip2.addr_data32[0] = in.s_addr;
960 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
962 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
966 FAIL_IF(inet_pton(AF_INET,
"1.2.3.5", &in) < 0);
968 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
976 static int DetectAddressIPv4CutNot09(
void)
984 FAIL_IF(inet_pton(AF_INET,
"1.2.3.4", &in) < 0);
985 a->ip.addr_data32[0] = in.s_addr;
986 FAIL_IF(inet_pton(AF_INET,
"192.168.1.2", &in) < 0);
987 a->ip2.addr_data32[0] = in.s_addr;
990 FAIL_IF(inet_pton(AF_INET,
"0.0.0.0", &in) < 0);
992 FAIL_IF(inet_pton(AF_INET,
"1.2.3.3", &in) < 0);
996 FAIL_IF(inet_pton(AF_INET,
"192.168.1.3", &in) < 0);
998 FAIL_IF(inet_pton(AF_INET,
"255.255.255.255", &in) < 0);
1012 DetectAddressIPv4TestAddressCmp01);
1014 DetectAddressIPv4IsCompleteIPSpace02);
1016 DetectAddressIPv4IsCompleteIPSpace03);
1018 DetectAddressIPv4IsCompleteIPSpace04);
1019 UtRegisterTest(
"DetectAddressIPv4CutNot05", DetectAddressIPv4CutNot05);
1020 UtRegisterTest(
"DetectAddressIPv4CutNot06", DetectAddressIPv4CutNot06);
1021 UtRegisterTest(
"DetectAddressIPv4CutNot07", DetectAddressIPv4CutNot07);
1022 UtRegisterTest(
"DetectAddressIPv4CutNot08", DetectAddressIPv4CutNot08);
1023 UtRegisterTest(
"DetectAddressIPv4CutNot09", DetectAddressIPv4CutNot09);