diff options
author | smos <seth.mos@dds.nl> | 2012-04-08 20:34:24 +0200 |
---|---|---|
committer | smos <seth.mos@dds.nl> | 2012-04-08 20:36:19 +0200 |
commit | 8b198c649f906d78f9feb95fae1054aafa84022f (patch) | |
tree | 7f4d1a739976c3ab079f064ed7962f19010a49cf /usr | |
parent | e7a9f730eec287c5d01b6c76d70d6606bd606e99 (diff) | |
download | pfsense-8b198c649f906d78f9feb95fae1054aafa84022f.zip pfsense-8b198c649f906d78f9feb95fae1054aafa84022f.tar.gz |
Prevent duplicate 6rd or 6to4 interfaces, these conflict and both use the stf0 adapter. Only 1 can be active.
Move piece of code into function, we need it more places, tighten rules for proto 41 traffic.
Attempt to micro optimize the select box for large amounts of choices. Chrome likes this approach better.
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/interfaces.php | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index b1d6a92..fc3b1cc 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -500,20 +500,32 @@ if ($_POST['apply']) { } case "dhcp6": 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']); + $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']); break; case "6rd": + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && (($_POST['ipaddrv6'] == $_POST['type6']) || ($_POST['ipaddrv6'] == "6to4")) ) { + $input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6to4."),$_POST['type6']); + break; + } + } 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']); + $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']); break; case "6to4": + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && (($_POST['ipaddrv6'] == $_POST['type6']) || ($_POST['ipaddrv6'] == "6rd")) ) { + $input_errors[] = sprintf(gettext("You can only have one interface configured as %s or 6rd."),$_POST['type6']); + break; + } + } 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']); + $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']); 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']); + $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type6']); break; } @@ -1823,38 +1835,28 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), <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; + if((count($dynv6ifs) == 1) && (!isset($pconfig['track6-interface']))) { + foreach($dynv6ifs as $trackif => $trackdescr) break; + $pdlen = calculate_ipv6_delegation_length($trackif); + } else { + $pdlen = calculate_ipv6_delegation_length($pconfig['track6-interface']); } - print_r($pconfig['track6-interface']); + + $numbers = pow(2, $pdlen); if($pconfig['track6-prefix-id'] == "none") $selected = "selected"; echo "<option value=\"none\" {$selected}>". gettext("None") ."</option>\n"; - $numbers = pow(2, $pdlen); + $choices = array(); for($i = 0;$i < $numbers; $i++) { - echo "<option value=\"{$i}\" "; - if ("$i" == $pconfig['track6-prefix-id']) { - echo "selected"; - } - echo ">" . dechex($i) . "</option>\n"; + if ("$i" == $pconfig['track6-prefix-id']) + $selected = "selected"; + else + $selected = ""; + + $choices[] = sprintf("<option value=\"%d\" $selected>%0x</option>", $i, $i); } + echo implode("\n", $choices); ?> </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"); ?> |