summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/interfaces.inc233
-rw-r--r--etc/inc/pfsense-utils.inc43
-rw-r--r--etc/inc/services.inc45
-rwxr-xr-xusr/local/www/interfaces.php203
4 files changed, 353 insertions, 171 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 429290a..b28c2da 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -1123,6 +1123,7 @@ function interface_bring_down($interface = "wan", $destroy = false) {
}
break;
case "6rd":
+ $realif = "srd0";
if(does_interface_exist("$realif")) {
mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true);
if ($destroy == true)
@@ -1130,6 +1131,7 @@ function interface_bring_down($interface = "wan", $destroy = false) {
}
break;
case "6to4":
+ $realif = "stf0";
if(does_interface_exist("$realif")) {
mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true);
if ($destroy == true)
@@ -1164,7 +1166,7 @@ function interface_bring_down($interface = "wan", $destroy = false) {
}
if ($destroy == true) {
- if (preg_match("/^vip|^tun|^ovpn|^gif|^gre|^lagg|^bridge|vlan/i", $realif))
+ if (preg_match("/^vip|^tun|^ovpn|^gif|^gre|^lagg|^bridge|vlan|^stf|^srd/i", $realif))
pfSense_interface_destroy($realif);
}
@@ -2881,6 +2883,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
case '6to4':
interface_6to4_configure($interface);
break;
+ case 'track6':
+ interface_track6_configure($interface);
+ break;
default:
if (is_ipaddr($wancfg['ipaddrv6']) && $wancfg['subnetv6'] <> "") {
pfSense_interface_setaddress($realif, "{$wancfg['ipaddrv6']}/{$wancfg['subnetv6']}");
@@ -2959,7 +2964,157 @@ function interface_carpdev_dhcp_configure($interface = "wan") {
return 0;
}
-function interface_6rd_configure($interface = "wan"){
+function interface_track6_configure($interface = "lan") {
+ global $config, $g;
+ $iflist = get_configured_interface_with_descr(false, true);
+
+ $wancfg = $config['interfaces'][$interface];
+ $wanif = $wancfg['if'];
+ if (empty($wancfg))
+ $wancfg = array();
+
+ $wanif = get_real_interface($interface);
+
+ /* If the interface is not configured via another, exit */
+ if(!$wancfg['track6-interface'] <> "") {
+ return(false);
+ }
+ log_error("Interface {$interface} configured via {$wancfg['track6-interface']} type {$config['interfaces'][$wancfg['track6-interface']]['ipaddrv6']}");
+
+
+ switch($config['interfaces'][$wancfg['track6-interface']]['ipaddrv6']) {
+ case "6to4":
+ interface_track6_6to4_configure($interface);
+ break;
+ case "6rd":
+ interface_track6_6rd_configure($interface);
+ break;
+ case "dhcp6":
+ interface_track6_dhcp6_configure($interface);
+ break;
+ default:
+ log_error("Interface {$interface} configured via {$wancfg['track6-interface']} but unknown type {$config['interfaces'][$wancfg['track6-interface']]['ipaddrv6']}");
+ break;
+ }
+ return 0;
+}
+
+
+function interface_track6_6rd_configure($interface = "lan") {
+ global $config, $g;
+ $iflist = get_configured_interface_with_descr(false, true);
+
+ $lancfg = $config['interfaces'][$interface];
+ $lanif = $lancfg['if'];
+ if (empty($lancfg))
+ $lancfg = array();
+
+ $lanif = get_real_interface($interface);
+
+ /* If the interface is not configured via another, exit */
+ if(!$lancfg['track6-interface'] <> "") {
+ return(false);
+ }
+ if(!is_numeric($lancfg['track6-prefix-id']))
+ $lancfg['track6-prefix-id'] = 0;
+
+ $wancfg = $config['interfaces'][$lancfg['track6-interface']];
+ $wanif = $wancfg['if'];
+ if (empty($wancfg))
+ $wancfg = array();
+
+ $ip4address = find_interface_ip($wanif);
+ if((!is_ipaddrv4($ip4address)) || (is_private_ip($ip4address))) {
+ log_error("The interface IPv4 '{$ip4address}' address on interface '{$wanif}' is not public, not configuring 6RD tunnel");
+ return false;
+ }
+ $hexwanv4 = return_hex_ipv4($ip4address);
+
+ /* create the long prefix notation for math, save the prefix length */
+ $rd6prefix = explode("/", $wancfg['prefix-6rd']);
+ $rd6prefixlen = $rd6prefix[1];
+ $rd6prefix = Net_IPv6::uncompress($rd6prefix[0]);
+
+ /* binary presentation of the prefix for all 128 bits. */
+ $rd6lanbin = convert_ipv6_to_128bit($rd6prefix);
+
+ /* just save the left prefix length bits */
+ $rd6lanbin = substr($rd6lanbin, 0, $rd6prefixlen);
+ /* add the v4 address, offset n bits from the left */
+ $rd6lanbin .= substr(sprintf("%032b", hexdec($hexwanv4)), (0 + $wancfg['prefix-6rd-v4plen']), 32);
+
+ /* add the custom prefix id, max 32bits long? (64 bits - (prefixlen + (32 - v4plen)) */
+ /* 64 - (37 + (32 - 17)) = 8 == /52 */
+ $restbits = 64 - ($rd6prefixlen + (32 - $wancfg['prefix-6rd-v4plen']));
+ // echo "64 - (prefixlen {$rd6prefixlen} + v4len (32 - {$wancfg['prefix-6rd-v4plen']})) = {$restbits} \n";
+ $rd6lanbin .= substr(sprintf("%032b", str_pad($lancfg['track6-prefix-id'], 32, "0", STR_PAD_LEFT)), (32 - $restbits), 32);
+ /* fill the rest out with zeros */
+ $rd6lanbin = str_pad($rd6lanbin, 128, "0", STR_PAD_RIGHT);;
+
+ /* convert the 128 bits for the lan address back into a valid IPv6 address */
+ $rd6lan = convert_128bit_to_ipv6($rd6lanbin) ."1";
+
+ log_error("rd6 {$interface} with ipv6 address {$rd6lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}");
+ mwexec("/sbin/ifconfig {$lanif} inet6 {$rd6lan} prefixlen 64");
+ return 0;
+}
+
+function interface_track6_6to4_configure($interface = "lan") {
+ global $config, $g;
+ $iflist = get_configured_interface_with_descr(false, true);
+
+ $lancfg = $config['interfaces'][$interface];
+ $lanif = $lancfg['if'];
+ if (empty($lancfg))
+ $lancfg = array();
+
+ $lanif = get_real_interface($interface);
+
+ /* If the interface is not configured via another, exit */
+ if(!$lancfg['track6-interface'] <> "") {
+ return(false);
+ }
+ if(!is_numeric($lancfg['track6-prefix-id']))
+ $lancfg['track6-prefix-id'] = 0;
+
+ $wancfg = $config['interfaces'][$lancfg['track6-interface']];
+ $wanif = $wancfg['if'];
+ if (empty($wancfg))
+ $wancfg = array();
+
+ $ip4address = find_interface_ip($wanif);
+ if((!is_ipaddrv4($ip4address)) || (is_private_ip($ip4address))) {
+ log_error("The interface IPv4 '{$ip4address}' address on interface '{$wanif}' is not public, not configuring 6RD tunnel");
+ return false;
+ }
+ $hexwanv4 = return_hex_ipv4($ip4address);
+
+ /* create the long prefix notation for math, save the prefix length */
+ $sixto4prefix = "2002::";
+ $sixto4prefixlen = 16;
+ $sixto4prefix = Net_IPv6::uncompress($sixto4prefix);
+
+ /* binary presentation of the prefix for all 128 bits. */
+ $sixto4lanbin = convert_ipv6_to_128bit($sixto4prefix);
+
+ /* just save the left prefix length bits */
+ $sixto4lanbin = substr($sixto4lanbin, 0, $sixto4prefixlen);
+ /* add the v4 address */
+ $sixto4lanbin .= sprintf("%032b", hexdec($hexwanv4));
+ /* add the custom prefix id */
+ $sixto4lanbin .= sprintf("%016b", $lancfg['track6-prefix-id']);
+ /* fill the rest out with zeros */
+ $sixto4lanbin = str_pad($sixto4lanbin, 128, "0", STR_PAD_RIGHT);;
+
+ /* convert the 128 bits for the lan address back into a valid IPv6 address */
+ $sixto4lan = convert_128bit_to_ipv6($sixto4lanbin) ."1";
+
+ log_error("sixto4 {$interface} with ipv6 address {$sixto4lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}");
+ mwexec("/sbin/ifconfig {$lanif} inet6 {$sixto4lan} prefixlen 64");
+ return 0;
+}
+
+function interface_6rd_configure($interface = "wan") {
global $config, $g;
$iflist = get_configured_interface_with_descr(false, true);
@@ -2978,88 +3133,42 @@ function interface_6rd_configure($interface = "wan"){
log_error("The interface IPv4 '{$ip4address}' address on interface '{$wanif}' is not public, not configuring 6RD tunnel");
return false;
}
+ $hexwanv4 = return_hex_ipv4($ip4address);
if(!is_numeric($wancfg['prefix-6rd-v4plen']))
- $v4prefixlen = 0;
- else
- $v4prefixlen = $wancfg['prefix-6rd-v4plen'];
+ $wancfg['prefix-6rd-v4plen'] = 0;
/* create the long prefix notation for math, save the prefix length */
$rd6prefix = explode("/", $wancfg['prefix-6rd']);
$rd6prefixlen = $rd6prefix[1];
$rd6prefix = Net_IPv6::uncompress($rd6prefix[0]);
- $rd6arr = explode(":", $rd6prefix);
-
- /* we need the hex form of the interface IPv4 address */
- $ip4arr = explode(".", $ip4address);
- $hexwanv4 = "";
- foreach($ip4arr as $octet)
- $hexwanv4 .= sprintf("%02x", $octet);
/* we need the hex form of the broker IPv4 address */
- $ip4arr = explode(".", $wancfg['gateway-6rd']);
- $hexbrv4 = "";
- foreach($ip4arr as $octet)
- $hexbrv4 .= sprintf("%02x", $octet);
+ $hexbrv4 = return_hex_ipv4($wancfg['gateway-6rd']);
/* binary presentation of the prefix for all 128 bits. */
- $rd6prefixbin = "";
- foreach($rd6arr as $element) {
- $rd6prefixbin .= sprintf("%016b", hexdec($element));
- }
+ $rd6prefixbin = convert_ipv6_to_128bit($rd6prefix);
+
/* just save the left prefix length bits */
- $rd6prefixstartbin = substr($rd6prefixbin, 0, $rd6prefixlen);
-
+ $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. */
- $rd6brokerbin = substr(sprintf("%032b", hexdec($hexbrv4)), $v4prefixlen, 32);
- $rd6brokerbin = str_pad($rd6prefixstartbin . $rd6brokerbin, 128, "0", STR_PAD_RIGHT);;
-
- /* for the local subnet too. */
- $rd6lanbin = substr(sprintf("%032b", hexdec($hexwanv4)), $v4prefixlen, 32);
- $rd6lanbin = str_pad($rd6prefixstartbin . $rd6lanbin, 128, "0", STR_PAD_RIGHT);;
-
- /* convert the 128 bits for the broker address back into a valid IPv6 address */
- $rd6brarr = array();
- $rd6brbinarr = array();
- $rd6brbinarr = str_split($rd6brokerbin, 16);
- foreach($rd6brbinarr as $bin)
- $rd6brarr[] = dechex(bindec($bin));
- $rd6brarr[7] = 1;
- $rd6brgw = Net_IPv6::compress(implode(":", $rd6brarr));
+ $rd6prefixbin .= substr(sprintf("%032b", hexdec($hexbrv4)), $wancfg['prefix-6rd-v4plen'], 32);
+ /* fill out the rest with 0's */
+ $rd6prefixbin = str_pad($rd6prefixbin, 128, "0", STR_PAD_RIGHT);;
/* convert the 128 bits for the broker address back into a valid IPv6 address */
- $rd6lanarr = array();
- $rd6lanbinarr = array();
- $rd6lanbinarr = str_split($rd6lanbin, 16);
- foreach($rd6lanbinarr as $bin)
- $rd6lanarr[] = dechex(bindec($bin));
- $rd6lanpr = Net_IPv6::compress(implode(":", $rd6lanarr));
- $rd6lanarr[7] = 1;
- $rd6lan = Net_IPv6::compress(implode(":", $rd6lanarr));
+ $rd6brgw = convert_128bit_to_ipv6($rd6prefixbin);
/* setup the stf interface */
mwexec("/sbin/ifconfig srd0 destroy");
mwexec("/sbin/ifconfig srd0 create");
- mwexec("/sbin/ifconfig srd0 v4plen {$v4prefixlen} pfix {$rd6prefix} plen {$rd6prefixlen} braddr {$wancfg['gateway-6rd']}");
- mwexec("/sbin/ifconfig srd0 inet6 {$rd6lanpr} prefixlen 128");
+ mwexec("/sbin/ifconfig srd0 v4plen {$wancfg['prefix-6rd-v4plen']} pfix {$rd6prefix} plen {$rd6prefixlen} braddr {$wancfg['gateway-6rd']}");
- log_error("Created 6rd interface srd0 v4plen {$v4prefixlen} pfix {$rd6prefix} plen {$rd6prefixlen} braddr {$wancfg['gateway-6rd']}");
- log_error("Set IPv6 address inet6 {$rd6lanpr} prefixlen 128 for srd0");
-
- /* Example 6RD setup steps
- # ifconfig srd0 create
- # ifconfig srd0
- srd0: flags=0<> metric 0 mtu 1280
- srd: v4plen 0 pfix :: plen 0 braddr 0.0.0.0
- # ifconfig srd0 up
- # ifconfig srd0 v4plen 20 pfix fc00:0:0:1000:: plen 52 braddr 10.0.0.1
- # ifconfig srd0
- srd0: flags=1<UP> metric 0 mtu 1280
- srd: v4plen 20 pfix fc00:0:0:1000:: plen 52 braddr 10.0.0.1
- */
+ log_error("Created 6rd interface srd0 v4plen {$wancfg['prefix-6rd-v4plen']} pfix {$rd6prefix} plen {$rd6prefixlen} braddr {$wancfg['gateway-6rd']}");
/* write out a default router file */
- file_put_contents("{$g['tmp_path']}/{$wanif}_routerv6", "::1 -ifp srd0\n");
+ file_put_contents("{$g['tmp_path']}/{$wanif}_routerv6", "{$rd6brgw}\n");
+ file_put_contents("{$g['tmp_path']}/{$wanif}_defaultgwv6", "{$rd6brgw}\n");
return 0;
}
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 7d5b458..a72c05a 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -2310,4 +2310,47 @@ function get_locale_list() {
asort($locales);
return $locales;
}
+
+function return_hex_ipv4($ipv4) {
+ if(!is_ipaddrv4($ipv4))
+ return(false);
+
+ /* we need the hex form of the interface IPv4 address */
+ $ip4arr = explode(".", $ipv4);
+ $hexwanv4 = "";
+ foreach($ip4arr as $octet)
+ $hexwanv4 .= sprintf("%02x", $octet);
+
+ return($hexwanv4);
+}
+
+function convert_ipv6_to_128bit($ipv6) {
+ if(!is_ipaddrv6($ipv6))
+ return(false);
+
+ $ip6arr = array();
+ $ip6prefix = Net_IPv6::uncompress($ipv6);
+ $ip6arr = explode(":", $ip6prefix);
+ /* binary presentation of the prefix for all 128 bits. */
+ $ip6prefixbin = "";
+ foreach($ip6arr as $element) {
+ $ip6prefixbin .= sprintf("%016b", hexdec($element));
+ }
+ return($ip6prefixbin);
+}
+
+function convert_128bit_to_ipv6($ip6bin) {
+ if(strlen($ip6bin) <> 128)
+ return(false);
+
+ $ip6arr = array();
+ $ip6binarr = array();
+ $ip6binarr = str_split($ip6bin, 16);
+ foreach($ip6binarr as $binpart)
+ $ip6arr[] = dechex(bindec($binpart));
+ $ip6addr = Net_IPv6::compress(implode(":", $ip6arr));
+
+ return($ip6addr);
+}
+
?>
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index d6c6a66..7a0b725 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -40,7 +40,7 @@
*/
function strify($str) {
- return '"' . $str . '"';
+ return '"' . $str . '"';
};
@@ -86,11 +86,11 @@ function services_radvd_configure() {
foreach ($dhcpdv6cfg as $dhcpv6if => $dhcpv6ifconf) {
if(!isset($config['interfaces'][$dhcpv6if]['enable']))
continue;
-
+
/* are router advertisements enabled? */
if($dhcpv6ifconf['mode'] == "disabled")
continue;
-
+
$realif = get_real_interface($dhcpv6if);
$ifcfgipv6 = get_interface_ipv6($dhcpv6if);
@@ -102,7 +102,7 @@ function services_radvd_configure() {
$subnetmaskv6 = gen_subnet_mask($ifcfgsnv6);
$radvdifs[] = $realif;
-
+
$radvdconf .= "# Generated for DHCPv6 Server $dhcpv6if\n";
$radvdconf .= "interface {$realif} {\n";
$radvdconf .= "\tAdvSendAdvert on;\n";
@@ -174,9 +174,8 @@ function services_radvd_configure() {
/* handle DHCP-PD prefixes and 6RD dynamic interfaces */
foreach ($Iflist as $if => $ifdescr) {
- if((!is_numeric($config['interfaces'][$if]['dhcp6-pd-sla-id'])) && (!is_numeric($config['interfaces'][$if]['prefix-6rd-id'])))
+ if(!isset($config['interfaces'][$if]['track6-interface']))
continue;
-
if(!isset($config['interfaces'][$if]['enable']))
continue;
@@ -192,40 +191,16 @@ function services_radvd_configure() {
$ifcfgsnv6 = get_interface_subnetv6($if);
$subnetv6 = gen_subnetv6($ifcfgipv6, $ifcfgsnv6);
$subnetmaskv6 = gen_subnet_mask($ifcfgsnv6);
+ $trackif = $config['interfaces'][$if]['track6-interface'];
$radvdifs[] = $realif;
- $autotype = "DHCP-PD";
- /* 6rd on this interface? */
- if(is_numeric($config['interfaces'][$if]['prefix-6rd-id'])) {
- /* find the interface which has the 6RD prefix defined and it's IPv4 address */
- foreach($Iflist as $rdif => $rdifdescr) {
- if($config['interfaces'][$rdif]['ipaddrv6'] == "6rd") {
- $realrdif = get_real_interface("$rdif");
- $ip4address = find_interface_ip($realrdif);
- log_error("radvd config found 6RD if {$rdif} address {$ip4address} for interface {$if}");
- if((!is_ipaddrv4($ip4address)) || (is_private_ip($ip4address))) {
- log_error("The interface IPv4 '{$ip4address}' address on interface '{$rdif}' is not public, not configuring 6RD prefix on {$if}");
- // continue;
- }
- /* calculate the IPv6 prefix from the public IPv4 address */
- $ip4arr = explode(".", $ip4address);
- $rd6prefix = explode("/", $config['interfaces'][$rdif]['prefix-6rd']);
- $rd6prefix = explode(":", $rd6prefix[0]);
- $rd6lanprefixlen = 64;
- $rd6lanprefix = sprintf("{$rd6prefix[0]}:{$rd6prefix[1]}:%02x%02x:%02x%02x::", $ip4arr[0], $ip4arr[1], $ip4arr[2], $ip4arr[3]);
- $ifcfgsnv6 = "{$rd6lanprefixlen}";
- $subnetv6 = "{$rd6lanprefix}";
- $autotype = "6rd";
- break;
- }
- }
- }
-
- log_error("configuring interface {$if} for type {$autotype} radvd subnet {$subnetv6}/{$ifcfgsnv6}");
+ $autotype = $config['interfaces'][$trackif]['ipaddrv6'];
+
+ log_error("configuring RA on {$if} for type {$autotype} radvd subnet {$subnetv6}/{$ifcfgsnv6}");
$dnslist = array();
if(is_ipaddrv6($subnetv6)) {
- $radvdconf .= "# Generated for DHCP-PD delegation $if\n";
+ $radvdconf .= "# Generated config for {$autotype} delegation from {$trackif} on {$if}\n";
$radvdconf .= "interface {$realif} {\n";
$radvdconf .= "\tAdvSendAdvert on;\n";
$radvdconf .= "\tMinRtrAdvInterval 3;\n";
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index b0594df..6435ea6 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -223,6 +223,11 @@ switch($wancfg['ipaddrv6']) {
case "6to4":
$pconfig['type6'] = "6to4";
break;
+ case "track6":
+ $pconfig['type6'] = "track6";
+ $pconfig['track6-interface'] = $wancfg['track6-interface'];
+ $pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
+ break;
case "6rd":
$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
if($wancfg['prefix-6rd-v4plen'] == "")
@@ -237,8 +242,6 @@ switch($wancfg['ipaddrv6']) {
$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
$pconfig['subnetv6'] = $wancfg['subnetv6'];
$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
- $pconfig['dhcp6-pd-sla-id'] = $wancfg['dhcp6-pd-sla-id'];
- $pconfig['prefix-6rd-id'] = $wancfg['prefix-6rd-id'];
} else
$pconfig['type6'] = "none";
break;
@@ -507,6 +510,11 @@ if ($_POST['apply']) {
if (in_array($wancfg['ipaddrv6'], array()))
$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
break;
+ case "track6":
+ /* needs to check if $track6-prefix-id is used on another interface */
+ if (in_array($wancfg['ipaddrv6'], array()))
+ $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']);
+ break;
}
@@ -644,13 +652,13 @@ if ($_POST['apply']) {
unset($wancfg['subnetv6']);
unset($wancfg['gatewayv6']);
unset($wancfg['dhcphostname']);
- unset($wancfg['dhcp6-pd-sla-id']);
unset($wancfg['dhcp6-duid']);
unset($wancfg['dhcp6-ia-pd-len']);
+ unset($wancfg['track6-interface']);
+ unset($wancfg['track6-prefix-id']);
unset($wancfg['prefix-6rd']);
unset($wancfg['prefix-6rd-v4plen']);
unset($wancfg['gateway-6rd']);
- unset($wancfg['prefix-6rd-id']);
unset($wancfg['pppoe_password']);
unset($wancfg['pptp_username']);
unset($wancfg['pptp_password']);
@@ -676,21 +684,31 @@ if ($_POST['apply']) {
/* for dynamic interfaces we tack a gateway item onto the array to prevent system
* log messages from appearing. They can also manually add these items */
/* 1st added gateway gets a default bit */
- /* FIXME: Add address family check here! */
+ /* FIXME: Add address family check here! IPv6 needs a gateway bit too */
if(!empty($a_gateways)) {
$gateway_item = array();
/* check for duplicates */
$skip = false;
foreach($a_gateways as $item) {
- if(($item['interface'] == "$if") && (preg_match("/dynamic/", $item['gateway']))) {
- $skip = true;
+ if(($item['interface'] == "$if") && (trim($item['gateway']) == "dynamic")) {
+ $skip4 = true;
+ }
+ if(($item['interface'] == "$if") && (trim($item['gateway']) == "dynamic6")) {
+ $skip6 = true;
}
}
- if($skip == false) {
+ if($skip4 == false) {
$gateway_item['gateway'] = "dynamic";
- $gateway_item['descr'] = sprintf(gettext("Interface %s dynamic gateway"),$if);
+ $gateway_item['descr'] = sprintf(gettext("Interface %s dynamic IPv4 gateway"),$if);
$gateway_item['name'] = "GW_" . strtoupper($if);
$gateway_item['interface'] = "{$if}";
+ $gateway_item['family'] = "inet";
+ } elseif($skip6 == false) {
+ $gateway_item['gateway'] = "dynamic6";
+ $gateway_item['descr'] = sprintf(gettext("Interface %s dynamic IPv6 gateway"),$if);
+ $gateway_item['name'] = "GW_" . strtoupper($if) ."_v6";
+ $gateway_item['interface'] = "{$if}";
+ $gateway_item['family'] = "inet6";
} else {
unset($gateway_item);
}
@@ -801,8 +819,6 @@ if ($_POST['apply']) {
case "staticv6":
$wancfg['ipaddrv6'] = $_POST['ipaddrv6'];
$wancfg['subnetv6'] = $_POST['subnetv6'];
- $wancfg['dhcp6-pd-sla-id'] = $_POST['dhcp6-pd-sla-id'];
- $wancfg['prefix-6rd-id'] = $_POST['prefix-6rd-id'];
if ($_POST['gatewayv6'] != "none") {
$wancfg['gatewayv6'] = $_POST['gatewayv6'];
}
@@ -827,6 +843,11 @@ if ($_POST['apply']) {
case "6to4":
$wancfg['ipaddrv6'] = "6to4";
break;
+ case "track6":
+ $wancfg['ipaddrv6'] = "track6";
+ $wancfg['track6-interface'] = $_POST['track6-interface'];
+ $wancfg['track6-prefix-id'] = $_POST['track6-prefix-id'];
+ break;
case "none":
break;
}
@@ -1079,7 +1100,7 @@ $statusurl = "status_interfaces.php";
$closehead = false;
include("head.inc");
$types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP") /* , "carpdev-dhcp" => "CarpDev"*/);
-$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6rd"), "6to4" => gettext("6to4"));
+$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCP6"), "6rd" => gettext("6rd"), "6to4" => gettext("6to4"), "track6" => gettext("Track Interface"));
?>
@@ -1126,23 +1147,27 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
function updateTypeSix(t) {
switch(t) {
case "none": {
- jQuery('#staticv6, #dhcp6, #6rd, #6to4').hide();
+ jQuery('#staticv6, #dhcp6, #6rd, #6to4, #track6').hide();
break;
}
case "staticv6": {
- jQuery('#none, #dhcp6, #6rd, #6to4').hide();
+ jQuery('#none, #dhcp6, #6rd, #6to4, #track6').hide();
break;
}
case "dhcp6": {
- jQuery('#none, #staticv6, #6rd, #6to4').hide();
+ jQuery('#none, #staticv6, #6rd, #6to4, #track6').hide();
break;
}
case "6rd": {
- jQuery('#none, #dhcp6, #staticv6, #6to4').hide();
+ jQuery('#none, #dhcp6, #staticv6, #6to4, #track6').hide();
break;
}
case "6to4": {
- jQuery('#none, #dhcp6, #staticv6, #6rd').hide();
+ jQuery('#none, #dhcp6, #staticv6, #6rd, #track6').hide();
+ break;
+ }
+ case "track6": {
+ jQuery('#none, #dhcp6, #staticv6, #6rd, #6to4').hide();
break;
}
}
@@ -1621,63 +1646,6 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
</div>
</td>
</tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation ID"); ?></td>
- <td width="78%" class="vtable">
- <select name="dhcp6-pd-sla-id" class="formselect" id="dhcp6-pd-sla-id">
- <?php
- // Needs to check if the ID is not used on another interface
- foreach($ifdescrs as $pdif => $pddescr) {
- if(is_numeric($config['interfaces'][$pdif]['dhcp6-ia-pd-len'])) {
- $pdlen = $config['interfaces'][$pdif]['dhcp6-ia-pd-len'];
- continue;
- }
- }
-
- if($pconfig['dhcp6-pd-sla-id'] == "none")
- $selected = "selected";
- echo "<option value=\"none\" {$selected}>". gettext("None") ."</option>\n";
- $numbers = pow(2, $pdlen);
- for($i = 0;$i < $numbers; $i++) {
- echo "<option value=\"{$i}\" ";
- if ("$i" == $pconfig['dhcp6-pd-sla-id']) {
- echo "selected";
- }
- echo ">" . dechex($i) . "</option>";
- }
- ?>
- </select>
- <?=gettext("This ID sets the delegated DHCP-PD prefix number which will be used to setup the interface.");?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("6RD Rapid Deployment network ID"); ?></td>
- <td width="78%" class="vtable">
- <select name="prefix-6rd-id" class="formselect" id="prefix-6rd-id">
- <?php
- // Needs to check if the ID is not used on another interface
- foreach($ifdescrs as $rdif => $rddescr) {
- if(is_numeric($config['interfaces'][$rdif]['prefix-6rd-v4plen'])) {
- $rdlen = $config['interfaces'][$rdif]['prefix-6rd-v4plen'];
- continue;
- }
- }
- if($pconfig['prefix-6rd-id'] == "none")
- $selected = "selected";
- echo "<option value=\"none\" {$selected}>". gettext("None") ."</option>\n";
- $numbers = pow(2, $rdlen);
- for($i = 0;$i < $numbers; $i++) {
- echo "<option value=\"{$i}\" ";
- if ("$i" == $pconfig['prefix-6rd-id']) {
- echo "selected";
- }
- echo ">" . dechex($i) . "</option>";
- }
- ?>
- </select>
- <?=gettext("This ID sets the 6RD network prefix which will be used to setup the interface.");?>
- </td>
- </tr>
</table>
</td>
</tr>
@@ -1736,6 +1704,7 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP6 client configuration"); ?></td>
</tr>
+ <!--- Leave commented out for now
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Unique Identifier (DUID)"); ?></td>
<td width="78%" class="vtable">
@@ -1751,6 +1720,7 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
</td>
</tr>
+ -->
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("DHCPv6 Prefix Delegation size"); ?></td>
<td width="78%" class="vtable">
@@ -1814,6 +1784,91 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
</table>
</td>
</tr>
+ <tr style="display:none;" name="track6" id="track6">
+ <td colspan="2" style="padding: 0px;">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Track IPv6 Interface"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Interface"); ?></td>
+ <td width="78%" class="vtable">
+ <select name='track6-interface' class='formselect' >
+ <?php
+ $interfaces = get_configured_interface_with_descr(false, true);
+ $dynv6ifs = array();
+ foreach ($interfaces as $iface => $ifacename) {
+ switch($config['interfaces'][$iface]['ipaddrv6']) {
+ case "6to4":
+ case "6rd":
+ case "dhcp6":
+ $dynv6ifs[$iface] = $ifacename;
+ break;
+ default:
+ continue;
+ }
+ }
+ foreach($dynv6ifs as $iface => $ifacename) {
+ echo "<option value=\"{$iface}\"";
+ if ($iface == $pconfig['track6-interface'])
+ echo " selected";
+ echo ">" . htmlspecialchars($ifacename) . "</option>";
+ }
+ ?>
+ </select> <br>
+ <br>
+ <?=gettext("This selects the dynamic IPv6 WAN interface to track for configuration") ?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Prefix ID"); ?></td>
+ <td width="78%" class="vtable">
+ <select name="track6-prefix-id" class="formselect" id="track6-prefix-id">
+ <?php
+ /* DHCP-PD is variable, calculate from the prefix-len on the WAN interface */
+ /* 6rd is variable, calculate from 64 - (v6 prefixlen - (32 - v4 prefixlen)) */
+ /* 6to4 is 16 bits, e.g. 65535 */
+
+ switch($config['interfaces'][$pconfig['track6-interface']]['ipaddrv6']) {
+ case "6to4":
+ $pdlen = 16;
+ break;
+ case "6rd":
+ $rd6cfg = $config['interfaces'][$pconfig['track6-interface']];
+ $rd6plen = explode("/", $rd6cfg['prefix-6rd']);
+ $pdlen = (64 - ($rd6plen[1] + (32 - $rd6cfg['prefix-6rd-v4plen'])));
+ break;
+ case "dhcp6":
+ $dhcp6cfg = $config['interfaces'][$pconfig['track6-interface']];
+ $pdlen = $dhcp6cfg['dhcp6-ia-pd-len'];
+ break;
+ default:
+ $pdlen = 0;
+ break;
+ }
+ print_r($pconfig['track6-interface']);
+ if($pconfig['track6-prefix-id'] == "none")
+ $selected = "selected";
+ echo "<option value=\"none\" {$selected}>". gettext("None") ."</option>\n";
+ $numbers = pow(2, $pdlen);
+ for($i = 0;$i < $numbers; $i++) {
+ echo "<option value=\"{$i}\" ";
+ if ("$i" == $pconfig['track6-prefix-id']) {
+ echo "selected";
+ }
+ echo ">" . dechex($i) . "</option>\n";
+ }
+ ?>
+ </select>
+ <?=gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?>
+ </td>
+ </tr>
+ </td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
<tr style="display:none;" name="ppp" id="ppp">
<td colspan="2" style="padding: 0px;">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
OpenPOWER on IntegriCloud