summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/util.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-01-22 14:13:50 +0545
committerPhil Davis <phil.davis@inf.org>2017-01-22 14:13:50 +0545
commit587995fb57f91894d1f8eb6b296a9fe2fa111fac (patch)
tree0a81b86bd2f2f48358b735eeb6dab3f3d644c574 /src/etc/inc/util.inc
parentb2bb49709d6d1cb845f2c7caf40bebe375ecb2d7 (diff)
downloadpfsense-587995fb57f91894d1f8eb6b296a9fe2fa111fac.zip
pfsense-587995fb57f91894d1f8eb6b296a9fe2fa111fac.tar.gz
Always force compress when calling Net_IPv6
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r--src/etc/inc/util.inc19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index 2176423..da79d22 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -268,7 +268,7 @@ function gen_subnetv4($ipaddr, $bits) {
/* same as gen_subnet() but accepts IPv6 only */
function gen_subnetv6($ipaddr, $bits) {
if (is_ipaddrv6($ipaddr) && is_numericint($bits) && $bits <= 128) {
- return Net_IPv6::compress(Net_IPv6::getNetmask($ipaddr, $bits));
+ return text_to_compressed_ip6(Net_IPv6::getNetmask($ipaddr, $bits));
}
return "";
}
@@ -396,7 +396,22 @@ function bin_to_ip6($bin) {
* Convert IPv6 binary to compressed address
*/
function bin_to_compressed_ip6($bin) {
- return Net_IPv6::compress(bin_to_ip6($bin));
+ return text_to_compressed_ip6(bin_to_ip6($bin));
+}
+
+/*
+ * Convert textual IPv6 address string to compressed address
+ */
+function text_to_compressed_ip6($text) {
+ // Force re-compression by passing parameter 2 (force) true.
+ // This ensures that supposedly-compressed formats are uncompressed
+ // first then re-compressed into strictly correct form.
+ // e.g. 2001:0:0:4:0:0:0:1
+ // 2001::4:0:0:0:1 is a strictly-incorrect compression,
+ // but maybe the user entered it like that.
+ // The "force" parameter will ensure it is returned as:
+ // 2001:0:0:4::1
+ return Net_IPv6::compress($text, true);
}
/* Find out how many IPs are contained within a given IP range
OpenPOWER on IntegriCloud