Rev 51 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 51 | Rev 88 | ||
---|---|---|---|
Line 572... | Line 572... | ||
572 | 572 | ||
573 | function ipv6_normalize_range($ipOrCIDR) { |
573 | function ipv6_normalize_range($ipOrCIDR) { |
574 | # 2001:1800::1/21 |
574 | # 2001:1800::1/21 |
575 | # --> 2001:1800::/21 |
575 | # --> 2001:1800::/21 |
576 | 576 | ||
577 | # 2001:1af8:4100:a061:0001::1337 |
577 | # 2001:1af8:4900:a012:0002::1337 |
578 | # --> 2001:1af8:4100:a061:1::1337/128 |
578 | # --> 2001:1af8:4900:a012:2::1337/128 |
579 | 579 | ||
580 | $ary = ipv6_cidr_split($ipOrCIDR); |
580 | $ary = ipv6_cidr_split($ipOrCIDR); |
581 | $ipOrCIDR = $ary[0]; |
581 | $ipOrCIDR = $ary[0]; |
582 | $cidr_bits = $ary[1]; |
582 | $cidr_bits = $ary[1]; |
583 | if ($cidr_bits > IPV6_BITS) return false; // throw new Exception('CIDR bits > '.IPV6_BITS); |
583 | if ($cidr_bits > IPV6_BITS) return false; // throw new Exception('CIDR bits > '.IPV6_BITS); |
Line 740... | Line 740... | ||
740 | assert(ipv6_distance('2001:1af0::/28', '2001:1af8::/29') == -1); |
740 | assert(ipv6_distance('2001:1af0::/28', '2001:1af8::/29') == -1); |
741 | assert(ipv6_distance('2001:1af8::/29', '2001:1af8::/29') == 0); |
741 | assert(ipv6_distance('2001:1af8::/29', '2001:1af8::/29') == 0); |
742 | assert(ipv6_distance('2001:1af8::/30', '2001:1af8::/29') == 1); |
742 | assert(ipv6_distance('2001:1af8::/30', '2001:1af8::/29') == 1); |
743 | assert(ipv6_distance('2001:1af8::/31', '2001:1af8::/29') == 2); |
743 | assert(ipv6_distance('2001:1af8::/31', '2001:1af8::/29') == 2); |
744 | 744 | ||
745 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336/127', '2001:1af8:4100:a061:0001::1335/127') === false); |
745 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336/127', '2001:1af8:4900:a012:0002::1335/127') === false); |
746 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336/128', '2001:1af8:4100:a061:0001::1337/128') === false); |
746 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336/128', '2001:1af8:4900:a012:0002::1337/128') === false); |
747 | assert(ipv6_distance('2001:1af8:4100:a061:0001::1336', '2001:1af8:4100:a061:0001::1337') === false); |
747 | assert(ipv6_distance('2001:1af8:4900:a012:0002::1336', '2001:1af8:4900:a012:0002::1337') === false); |
748 | */ |
748 | */ |
749 | 749 | ||
750 | /* |
750 | /* |
751 | $test = '2001:1af8:4100:a061:0001::1337'; |
751 | $test = '2001:1af8:4900:a012:0002::1337'; |
752 | $x = ipv6_trackdown($test); |
752 | $x = ipv6_trackdown($test); |
753 | foreach ($x as &$cidr) { |
753 | foreach ($x as &$cidr) { |
754 | $min = ipv6_cidr_min_ip($cidr); |
754 | $min = ipv6_cidr_min_ip($cidr); |
755 | $max = ipv6_cidr_max_ip($cidr); |
755 | $max = ipv6_cidr_max_ip($cidr); |
756 | echo "$cidr ($min - $max)\n"; |
756 | echo "$cidr ($min - $max)\n"; |