diff options
author | Ermal <eri@pfsense.org> | 2013-03-20 20:40:45 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2013-03-20 20:41:16 +0000 |
commit | 733c6f893e9c76cabcef917e785bc43626295ba6 (patch) | |
tree | f60a7332204fced7a77bbe10a350c8dbc40f7891 /etc | |
parent | a1776dcfabd3c1233c241164d28603ae95388c37 (diff) | |
download | pfsense-733c6f893e9c76cabcef917e785bc43626295ba6.zip pfsense-733c6f893e9c76cabcef917e785bc43626295ba6.tar.gz |
The default gateway for 6rd type is $prefix|$wanv4::$wanv4gw. Also add support for variable length v4 prefix for 6rd
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 17 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 6 |
2 files changed, 5 insertions, 18 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 93a7e08..545d236 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3322,23 +3322,10 @@ function interface_6rd_configure($interface = "wan", $wancfg) { $rd6prefixlen = $rd6prefix[1]; $rd6prefix = Net_IPv6::uncompress($rd6prefix[0]); - /* we need the hex form of the broker IPv4 address */ - $hexbrv4 = return_hex_ipv4($wancfg['gateway-6rd']); - /* binary presentation of the prefix for all 128 bits. */ $rd6prefixbin = convert_ipv6_to_128bit($rd6prefix); /* just save the left prefix length bits */ - $rd6brprefixbin = substr($rd6prefixbin, 0, $rd6prefixlen); - /* if the prefix length is not 32 bits we need to shave bits off from the left of the v4 address. */ - $rd6brprefixbin .= substr(sprintf("%032b", hexdec($hexbrv4)), $wancfg['prefix-6rd-v4plen'], 32); - /* fill out the rest with 0's */ - $rd6brprefixbin = str_pad($rd6brprefixbin, 128, "0", STR_PAD_RIGHT); - - /* convert the 128 bits for the broker address back into a valid IPv6 address */ - $rd6brgw = convert_128bit_to_ipv6($rd6brprefixbin); - - /* just save the left prefix length bits */ $rd6prefixbin = substr($rd6prefixbin, 0, $rd6prefixlen); /* if the prefix length is not 32 bits we need to shave bits off from the left of the v4 address. */ $rd6prefixbin .= substr(sprintf("%032b", hexdec($hexwanv4)), $wancfg['prefix-6rd-v4plen'], 32); @@ -3348,6 +3335,8 @@ function interface_6rd_configure($interface = "wan", $wancfg) { /* convert the 128 bits for the broker address back into a valid IPv6 address */ $rd6prefix = convert_128bit_to_ipv6($rd6prefixbin); + $rd6brgw = "{$rd6prefix}::{$wancfg['gateway-6rd']}"; + /* XXX: need to extend to support variable prefix size for v4 */ if (!is_module_loaded("if_stf")) mwexec("/sbin/kldload if_stf.ko"); @@ -3358,6 +3347,8 @@ function interface_6rd_configure($interface = "wan", $wancfg) { pfSense_interface_rename($tmpstfiface, $stfiface); pfSense_interface_flags($stfiface, IFF_LINK2); mwexec("/sbin/ifconfig {$stfiface} inet6 {$rd6prefix}/{$rd6prefixlen}"); + if ($wancfg['prefix-6rd-v4plen'] < 32) + mwexec("/sbin/ifconfig {$stfiface} stfv4net {$ip4address}/{$wancfg['prefix-6rd-v4plen']}"); if ($g['debug']) log_error("Created 6rd interface {$stfiface} {$rd6prefix}/{$rd6prefixlen}"); diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c5cce67..f172b58 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2531,11 +2531,7 @@ function return_hex_ipv4($ipv4) { /* we need the hex form of the interface IPv4 address */ $ip4arr = explode(".", $ipv4); - $hexwanv4 = ""; - foreach($ip4arr as $octet) - $hexwanv4 .= sprintf("%02x", $octet); - - return($hexwanv4); + return (sprintf("%02x%02x%02x%02x", $ip4arr[0], $ip4arr[1], $ip4arr[2], $ip4arr[3])); } function convert_ipv6_to_128bit($ipv6) { |