function build_ipv6interface_list() { global $config, $section; $list = array('' => ''); $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] = array('name' => $ifacename, 'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1); break; default: continue; } } foreach ($dynv6ifs as $iface => $ifacedata) { $list[$iface] = $ifacedata['name']; $section->addInput(new Form_Input('ipv6-num-prefix-ids-' . $iface, null, 'hidden', $ifacedata['ipv6_num_prefix_ids'])); } return $list; }
<tr> <td width="22%" valign="top" class="vncell"><?php echo gettext("IPv6 Interface"); ?> </td> <td width="78%" class="vtable"> <select name="track6-interface" id='track6-interface' class='formselect' onchange="update_track6_prefix();"> <?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] = array('name' => $ifacename, 'ipv6_num_prefix_ids' => pow(2, calculate_ipv6_delegation_length($iface)) - 1); break; default: continue; } } $rowIndex = 0; foreach ($dynv6ifs as $iface => $ifacedata) { $rowIndex++; echo "<option value=\"{$iface}\""; if ($iface == $pconfig['track6-interface']) { echo " selected=\"selected\""; } echo ">" . htmlspecialchars($ifacedata['name']) . "</option>"; } if ($rowIndex == 0) {
$toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); } else { $toapplylist = array(); } $toapplylist[$if]['ifcfg'] = $wancfg; $toapplylist[$if]['ppps'] = $a_ppps; /* we need to be able remove IP aliases for IPv6 */ file_put_contents('/tmp/.interfaces.apply', serialize($toapplylist)); header("Location: interfaces.php?if={$if}"); exit; } else { if ($_POST) { unset($input_errors); $pconfig = $_POST; if (isset($_POST['track6-interface'])) { $ipv6_delegation_length = calculate_ipv6_delegation_length($_POST['track6-interface']); $ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length); } if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) { $pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16); } else { $pconfig['track6-prefix-id'] = 0; } /* filter out spaces from descriptions */ $_POST['descr'] = remove_bad_chars($_POST['descr']); /* okay first of all, cause we are just hiding the PPPoE HTML * fields releated to PPPoE resets, we are going to unset $_POST * vars, if the reset feature should not be used. Otherwise the * data validation procedure below, may trigger a false error * message. */
if (empty($pconfig['track6-prefix-id'])) { $pconfig['track6-prefix-id'] = 0; } $track6_prefix_id_hex = !empty($pconfig['track6-prefix-id--hex']) ? $pconfig['track6-prefix-id--hex'] : sprintf("%x", $pconfig['track6-prefix-id']); ?> <input name="track6-prefix-id--hex" type="text" id="track6-prefix-id--hex" value="<?php echo $track6_prefix_id_hex; ?> " /> <div class="hidden" for="help_for_track6-prefix-id"> <?php echo gettext("The value in this field is the (Delegated) IPv6 prefix id. This determines the configurable network ID based on the dynamic IPv6 connection"); ?> <br /> <?php echo sprintf(gettext("Enter a hexadecimal value between %x and %x here, default value is 0."), 0, pow(2, calculate_ipv6_delegation_length($pconfig['track6-interface'])) - 1); ?> </div> </td> </tr> </tbody> </table> </div> </div> <?php /* Wireless interface? */ if (isset($a_interfaces[$if]['wireless'])) { ?> <!-- Section : Wireless --> <div class="tab-content content-box col-xs-12 __mb"> <div class="table-responsive">
<br> <?php echo gettext("This selects the dynamic IPv6 WAN interface to track for configuration"); ?> <br /> </td> </tr> <tr> <td width="22%" valign="top" class="vncell"><?php echo gettext("IPv6 Prefix ID"); ?> </td> <td width="78%" class="vtable"> <select name="track6-prefix-id" class="formselect" id="track6-prefix-id"> <?php $pdlen = calculate_ipv6_delegation_length($pconfig['track6-interface']); $numbers = pow(2, $pdlen); if ($pconfig['track6-prefix-id'] == "none") { $selected = "selected"; } echo "<option value=\"none\" {$selected}>" . gettext("None") . "</option>\n"; $choices = array(); for ($i = 0; $i < $numbers; $i++) { if ("{$i}" == $pconfig['track6-prefix-id']) { $selected = "selected"; } else { $selected = ""; } $choices[] = sprintf("<option value=\"%d\" {$selected}>%0x</option>", $i, $i); } echo implode("\n", $choices);