diff options
author | Renato Botelho <renato@netgate.com> | 2016-02-19 10:49:27 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-02-19 10:57:32 -0200 |
commit | 6c8beed3454f3b262dbf7380f9ff94cdede24bdf (patch) | |
tree | dfd633ed6e8fe81a3df1c7f84c90109ec685a17f /src | |
parent | 15db02a6abe5c0af41174c08a41a50e3c9eb9018 (diff) | |
download | pfsense-6c8beed3454f3b262dbf7380f9ff94cdede24bdf.zip pfsense-6c8beed3454f3b262dbf7380f9ff94cdede24bdf.tar.gz |
Ticket #3029
Fix DHCPv6 GUI to work with PD length != 64
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 36 | ||||
-rw-r--r-- | src/usr/local/www/services_dhcpv6.php | 18 | ||||
-rw-r--r-- | src/usr/local/www/services_dhcpv6_edit.php | 12 |
3 files changed, 58 insertions, 8 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 6848bb8..416a89c 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -2871,6 +2871,42 @@ function merge_ipv6_delegated_prefix($prefix, $suffix, $len = 64) { substr($suffix, $prefix_len)); } +function dhcpv6_pd_str_help($pdlen) { + $result = ''; + + switch ($pdlen) { + case 48: + $result = '::xxxx:xxxx:xxxx:xxxx:xxxx'; + break; + case 52: + $result = '::xxx:xxxx:xxxx:xxxx:xxxx'; + break; + case 56: + $result = '::xx:xxxx:xxxx:xxxx:xxxx'; + break; + case 60: + $result = '::x:xxxx:xxxx:xxxx:xxxx'; + break; + /* + * XXX 63, 62 and 61 should use same mask of 60 but it would + * we let user chose this bit it can end up out of PD network + * + * Leave this with the same of 64 for now until we find a way to + * let user chose it. The side-effect is users with PD with one + * of these lengths will not be able to setup DHCP server range + * for full PD size, only for last /64 network + */ + case 61: + case 62: + case 63: + case 64: + $result = '::xxxx:xxxx:xxxx:xxxx'; + break; + } + + return $result; +} + function huawei_rssi_to_string($rssi) { $dbm = array(); $i = 0; diff --git a/src/usr/local/www/services_dhcpv6.php b/src/usr/local/www/services_dhcpv6.php index ea80ac4..0a9b2e8 100644 --- a/src/usr/local/www/services_dhcpv6.php +++ b/src/usr/local/www/services_dhcpv6.php @@ -153,8 +153,12 @@ if (is_array($config['dhcpdv6'][$if])) { } if ($config['interfaces'][$if]['ipaddrv6'] == 'track6') { + $trackifname = $config['interfaces'][$if]['track6-interface']; + $trackcfg = $config['interfaces'][$trackifname]; + $ifcfgsn = 64 - $trackcfg['dhcp6-ia-pd-len']; $ifcfgip = '::'; - $ifcfgsn = 64; + + $str_help_mask = dhcpv6_pd_str_help($ifcfgsn); } else { $ifcfgip = get_interface_ipv6($if); $ifcfgsn = get_interface_subnetv6($if); @@ -244,16 +248,20 @@ if ($_POST) { if (!is_ipaddrv6($_POST['range_from'])) { $input_errors[] = gettext("A valid range must be specified."); } elseif ($config['interfaces'][$if]['ipaddrv6'] == 'track6' && - !Net_IPv6::isInNetmask($_POST['range_from'], '::', 64)) { - $input_errors[] = gettext("The prefix (upper 64 bits) must be zero. Use the form ::x:x:x:x"); + !Net_IPv6::isInNetmask($_POST['range_from'], '::', $ifcfgsn)) { + $input_errors[] = sprintf(gettext( + "The prefix (upper %s bits) must be zero. Use the form %s"), + $ifcfgsn, $str_help_mask); } } if ($_POST['range_to']) { if (!is_ipaddrv6($_POST['range_to'])) { $input_errors[] = gettext("A valid range must be specified."); } elseif ($config['interfaces'][$if]['ipaddrv6'] == 'track6' && - !Net_IPv6::isInNetmask($_POST['range_to'], '::', 64)) { - $input_errors[] = gettext("The prefix (upper 64 bits) must be zero. Use the form ::x:x:x:x"); + !Net_IPv6::isInNetmask($_POST['range_to'], '::', $ifcfgsn)) { + $input_errors[] = sprintf(gettext( + "The prefix (upper %s bits) must be zero. Use the form %s"), + $ifcfgsn, $str_help_mask); } } if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway']))) { diff --git a/src/usr/local/www/services_dhcpv6_edit.php b/src/usr/local/www/services_dhcpv6_edit.php index b26ba9d..31e759b 100644 --- a/src/usr/local/www/services_dhcpv6_edit.php +++ b/src/usr/local/www/services_dhcpv6_edit.php @@ -158,9 +158,15 @@ if ($_POST) { if ($_POST['ipaddrv6']) { if (!is_ipaddrv6($_POST['ipaddrv6'])) { $input_errors[] = gettext("A valid IPv6 address must be specified."); - } elseif ($config['interfaces'][$if]['ipaddrv6'] == 'track6' && - !Net_IPv6::isInNetmask($_POST['ipaddrv6'], '::', 64)) { - $input_errors[] = gettext("The prefix (upper 64 bits) must be zero. Use the form ::x:x:x:x"); + } elseif ($config['interfaces'][$if]['ipaddrv6'] == 'track6') { + $trackifname = $config['interfaces'][$if]['track6-interface']; + $trackcfg = $config['interfaces'][$trackifname]; + $pdlen = 64 - $trackcfg['dhcp6-ia-pd-len']; + if (!Net_IPv6::isInNetmask($_POST['ipaddrv6'], '::', $pdlen)) { + $input_errors[] = sprintf(gettext( + "The prefix (upper %s bits) must be zero. Use the form %s"), + $pdlen, dhcpv6_pd_str_help($ifcfgsn)); + } } } |