Revision 5050b792
Added by Phil Davis over 8 years ago
src/etc/inc/interfaces.inc | ||
---|---|---|
3850 | 3850 |
foreach ($stfbrbinarr as $bin) { |
3851 | 3851 |
$stfbrarr[] = dechex(bindec($bin)); |
3852 | 3852 |
} |
3853 |
$stfbrgw = Net_IPv6::compress(implode(":", $stfbrarr));
|
|
3853 |
$stfbrgw = text_to_compressed_ip6(implode(":", $stfbrarr));
|
|
3854 | 3854 |
|
3855 | 3855 |
/* convert the 128 bits for the broker address back into a valid IPv6 address */ |
3856 | 3856 |
$stflanarr = array(); |
... | ... | |
3859 | 3859 |
foreach ($stflanbinarr as $bin) { |
3860 | 3860 |
$stflanarr[] = dechex(bindec($bin)); |
3861 | 3861 |
} |
3862 |
$stflanpr = Net_IPv6::compress(implode(":", $stflanarr));
|
|
3862 |
$stflanpr = text_to_compressed_ip6(implode(":", $stflanarr));
|
|
3863 | 3863 |
$stflanarr[7] = 1; |
3864 |
$stflan = Net_IPv6::compress(implode(":", $stflanarr));
|
|
3864 |
$stflan = text_to_compressed_ip6(implode(":", $stflanarr));
|
|
3865 | 3865 |
|
3866 | 3866 |
/* setup the stf interface */ |
3867 | 3867 |
if (!is_module_loaded("if_stf")) { |
src/etc/inc/ipsec.inc | ||
---|---|---|
746 | 746 |
|
747 | 747 |
function ipsec_fixup_ip($ipaddr) { |
748 | 748 |
if (is_ipaddrv6($ipaddr) || is_subnetv6($ipaddr)) { |
749 |
return Net_IPv6::compress(Net_IPv6::uncompress($ipaddr));
|
|
749 |
return text_to_compressed_ip6($ipaddr);
|
|
750 | 750 |
} else { |
751 | 751 |
return $ipaddr; |
752 | 752 |
} |
src/etc/inc/openvpn.inc | ||
---|---|---|
1749 | 1749 |
// Is there a better way to do this math? |
1750 | 1750 |
$ipv6_arr = explode(':', $basev6); |
1751 | 1751 |
$last = hexdec(array_pop($ipv6_arr)); |
1752 |
$ipv6_1 = Net_IPv6::compress(Net_IPv6::uncompress(implode(':', $ipv6_arr) . ':' . dechex($last + 1)));
|
|
1753 |
$ipv6_2 = Net_IPv6::compress(Net_IPv6::uncompress(implode(':', $ipv6_arr) . ':' . dechex($last + 2)));
|
|
1752 |
$ipv6_1 = text_to_compressed_ip6(implode(':', $ipv6_arr) . ':' . dechex($last + 1));
|
|
1753 |
$ipv6_2 = text_to_compressed_ip6(implode(':', $ipv6_arr) . ':' . dechex($last + 2));
|
|
1754 | 1754 |
return array($ipv6_1, $ipv6_2); |
1755 | 1755 |
} |
1756 | 1756 |
|
src/etc/inc/pfsense-utils.inc | ||
---|---|---|
3135 | 3135 |
foreach ($ip6binarr as $binpart) { |
3136 | 3136 |
$ip6arr[] = dechex(bindec($binpart)); |
3137 | 3137 |
} |
3138 |
$ip6addr = Net_IPv6::compress(implode(":", $ip6arr));
|
|
3138 |
$ip6addr = text_to_compressed_ip6(implode(":", $ip6arr));
|
|
3139 | 3139 |
|
3140 | 3140 |
return($ip6addr); |
3141 | 3141 |
} |
... | ... | |
3217 | 3217 |
break; |
3218 | 3218 |
} |
3219 | 3219 |
|
3220 |
return Net_IPv6::compress(substr($prefix, 0, $prefix_len) .
|
|
3220 |
return text_to_compressed_ip6(substr($prefix, 0, $prefix_len) .
|
|
3221 | 3221 |
substr($suffix, $prefix_len)); |
3222 | 3222 |
} |
3223 | 3223 |
|
src/etc/inc/util.inc | ||
---|---|---|
373 | 373 |
/* same as gen_subnet() but accepts IPv6 only */ |
374 | 374 |
function gen_subnetv6($ipaddr, $bits) { |
375 | 375 |
if (is_ipaddrv6($ipaddr) && is_numericint($bits) && $bits <= 128) { |
376 |
return Net_IPv6::compress(Net_IPv6::getNetmask($ipaddr, $bits));
|
|
376 |
return text_to_compressed_ip6(Net_IPv6::getNetmask($ipaddr, $bits));
|
|
377 | 377 |
} |
378 | 378 |
return ""; |
379 | 379 |
} |
... | ... | |
450 | 450 |
return sprintf("%u", ip2long32($ip)); |
451 | 451 |
} |
452 | 452 |
|
453 |
/* |
|
454 |
* Convert textual IPv6 address string to compressed address |
|
455 |
*/ |
|
456 |
function text_to_compressed_ip6($text) { |
|
457 |
// Force re-compression by passing parameter 2 (force) true. |
|
458 |
// This ensures that supposedly-compressed formats are uncompressed |
|
459 |
// first then re-compressed into strictly correct form. |
|
460 |
// e.g. 2001:0:0:4:0:0:0:1 |
|
461 |
// 2001::4:0:0:0:1 is a strictly-incorrect compression, |
|
462 |
// but maybe the user entered it like that. |
|
463 |
// The "force" parameter will ensure it is returned as: |
|
464 |
// 2001:0:0:4::1 |
|
465 |
return Net_IPv6::compress($text, true); |
|
466 |
} |
|
467 |
|
|
453 | 468 |
/* Find out how many IPs are contained within a given IP range |
454 | 469 |
* e.g. 192.168.0.0 to 192.168.0.255 returns 256 |
455 | 470 |
*/ |
src/usr/local/www/services_dhcpv6.php | ||
---|---|---|
259 | 259 |
$_POST['prefixrange_length']) { |
260 | 260 |
$netmask = Net_IPv6::getNetmask($_POST['prefixrange_from'], |
261 | 261 |
$_POST['prefixrange_length']); |
262 |
$netmask = Net_IPv6::compress($netmask);
|
|
262 |
$netmask = text_to_compressed_ip6($netmask);
|
|
263 | 263 |
|
264 |
if ($netmask != Net_IPv6::compress(strtolower(
|
|
264 |
if ($netmask != text_to_compressed_ip6(strtolower(
|
|
265 | 265 |
$_POST['prefixrange_from']))) { |
266 | 266 |
$input_errors[] = sprintf(gettext( |
267 | 267 |
"Prefix Delegation From address is not a valid IPv6 Netmask for %s"), |
... | ... | |
270 | 270 |
|
271 | 271 |
$netmask = Net_IPv6::getNetmask($_POST['prefixrange_to'], |
272 | 272 |
$_POST['prefixrange_length']); |
273 |
$netmask = Net_IPv6::compress($netmask);
|
|
273 |
$netmask = text_to_compressed_ip6($netmask);
|
|
274 | 274 |
|
275 |
if ($netmask != Net_IPv6::compress(strtolower(
|
|
275 |
if ($netmask != text_to_compressed_ip6(strtolower(
|
|
276 | 276 |
$_POST['prefixrange_to']))) { |
277 | 277 |
$input_errors[] = sprintf(gettext( |
278 | 278 |
"Prefix Delegation To address is not a valid IPv6 Netmask for %s"), |
Also available in: Unified diff
Always force compress when calling Net_IPv6
(cherry picked from commit 587995fb57f91894d1f8eb6b296a9fe2fa111fac)