Rev 226 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 226 | Rev 1415 | ||
---|---|---|---|
Line 580... | Line 580... | ||
580 | 580 | ||
581 | function ipv6_normalize_range($ipOrCIDR) { |
581 | function ipv6_normalize_range($ipOrCIDR) { |
582 | # 2001:1800::1/21 |
582 | # 2001:1800::1/21 |
583 | # --> 2001:1800::/21 |
583 | # --> 2001:1800::/21 |
584 | 584 | ||
585 | # 2001:1af8:4100:a061:0001::1337 |
585 | # 2001:1af8:4900:a012:0002::1337 |
586 | # --> 2001:1af8:4100:a061:1::1337/128 |
586 | # --> 2001:1af8:4900:a012:2::1337/128 |
587 | 587 | ||
588 | $ary = ipv6_cidr_split($ipOrCIDR); |
588 | $ary = ipv6_cidr_split($ipOrCIDR); |
589 | $ipOrCIDR = $ary[0]; |
589 | $ipOrCIDR = $ary[0]; |
590 | $cidr_bits = $ary[1]; |
590 | $cidr_bits = $ary[1]; |
591 | if ($cidr_bits > IPV6_BITS) return false; // throw new Exception('CIDR bits > '.IPV6_BITS); |
591 | if ($cidr_bits > IPV6_BITS) return false; // throw new Exception('CIDR bits > '.IPV6_BITS); |
Line 748... | Line 748... | ||
748 | assert(ipv6_distance('2001:1af0::/28', '2001:1af8::/29') == -1); |
748 | assert(ipv6_distance('2001:1af0::/28', '2001:1af8::/29') == -1); |
749 | assert(ipv6_distance('2001:1af8::/29', '2001:1af8::/29') == 0); |
749 | assert(ipv6_distance('2001:1af8::/29', '2001:1af8::/29') == 0); |
750 | assert(ipv6_distance('2001:1af8::/30', '2001:1af8::/29') == 1); |
750 | assert(ipv6_distance('2001:1af8::/30', '2001:1af8::/29') == 1); |
751 | assert(ipv6_distance('2001:1af8::/31', '2001:1af8::/29') == 2); |
751 | assert(ipv6_distance('2001:1af8::/31', '2001:1af8::/29') == 2); |
752 | 752 | ||
753 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336/127', '2001:1af8:4100:a061:0001::1335/127') === false); |
753 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336/127', '2001:1af8:4900:a012:0002::1335/127') === false); |
754 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336/128', '2001:1af8:4100:a061:0001::1337/128') === false); |
754 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336/128', '2001:1af8:4900:a012:0002::1337/128') === false); |
755 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336', '2001:1af8:4100:a061:0001::1337') === false); |
755 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336', '2001:1af8:4900:a012:0002::1337') === false); |
756 | */ |
756 | */ |
757 | 757 | ||
758 | /* |
758 | /* |
759 | $test = '2001:1af8:4100:a061:0001::1337'; |
759 | $test = '2001:1af8:4100:a061:0001::1337'; |
760 | $x = ipv6_trackdown($test); |
760 | $x = ipv6_trackdown($test); |