summaryrefslogtreecommitdiffstats
path: root/etc/inc/interfaces.inc
diff options
context:
space:
mode:
authorErmal LUÇI <eri@pfsense.org>2015-02-02 17:46:01 +0100
committerErmal LUÇI <eri@pfsense.org>2015-02-02 17:46:12 +0100
commitcd214f4b2801381304209dcf2b92066b6f12589e (patch)
treefd3dd5ebdb2580001de6dcadfa2a13ba30cbcca3 /etc/inc/interfaces.inc
parent42275e694fb857c8c6b938740564cfeefe336b84 (diff)
downloadpfsense-cd214f4b2801381304209dcf2b92066b6f12589e.zip
pfsense-cd214f4b2801381304209dcf2b92066b6f12589e.tar.gz
Properly calculate the 6rd default gateway honoring netmasks other than /32
Diffstat (limited to 'etc/inc/interfaces.inc')
-rw-r--r--etc/inc/interfaces.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 39c54a3..9f823c8 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -3290,7 +3290,11 @@ function interface_6rd_configure($interface = "wan", $wancfg) {
$rd6prefix = explode("/", $wancfg['prefix-6rd']);
$rd6prefixlen = $rd6prefix[1];
$brgw = explode('.', $wancfg['gateway-6rd']);
- $rd6brgw = rtrim($rd6prefix[0], ':') . ':' . dechex($brgw[0]) . dechex($brgw[1]) . ':' . dechex($brgw[2]) . dechex($brgw[3]) . '::';
+ $rd6brgw = substr(Net_IPv6::_ip2Bin($rd6prefix[0]), 0, $rd6prefixlen);
+ $rd6brgw .= str_pad(decbin($brgw[0]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[1]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[2]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[3]), 8, '0', STR_PAD_LEFT);
+ if (strlen($rd6brgw) < 128)
+ $rd6brgw = str_pad($rd6brgw, 128, '0', STR_PAD_RIGHT);
+ $rd6brgw = Net_IPv6::compress(Net_IPv6::_bin2Ip($rd6brgw));
unset($brgw);
$rd6prefix = Net_IPv6::uncompress($rd6prefix[0]);
OpenPOWER on IntegriCloud