diff options
Diffstat (limited to 'usr/local/www/interfaces.php')
-rwxr-xr-x | usr/local/www/interfaces.php | 259 |
1 files changed, 236 insertions, 23 deletions
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 98d449b..da729ae 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -201,15 +201,38 @@ switch($wancfg['ipaddr']) { break; default: if(is_ipaddr($wancfg['ipaddr'])) { - $pconfig['type'] = "static"; + $pconfig['type'] = "staticv4"; $pconfig['ipaddr'] = $wancfg['ipaddr']; $pconfig['subnet'] = $wancfg['subnet']; $pconfig['gateway'] = $wancfg['gateway']; + if((is_ipaddr($wancfg['ipaddrv6'])) && (is_ipaddr($wancfg['ipaddr']))) { + $pconfig['type'] = "staticv4v6"; + } } else $pconfig['type'] = "none"; break; } +switch($wancfg['ipaddrv6']) { + case "dhcpv6": + $pconfig['type'] = "dhcpv6"; + break; + default: + /* if we have dual stack we need a combined type */ + if(is_ipaddr($wancfg['ipaddrv6'])) { + $pconfig['type'] = "staticv6"; + $pconfig['ipaddrv6'] = $wancfg['ipaddrv6']; + $pconfig['subnetv6'] = $wancfg['subnetv6']; + $pconfig['gatewayv6'] = $wancfg['gatewayv6']; + if((is_ipaddr($wancfg['ipaddrv6'])) && (is_ipaddr($wancfg['ipaddr']))) { + $pconfig['type'] = "staticv4v6"; + } + } + break; +} + +// print_r($pconfig); + $pconfig['blockpriv'] = isset($wancfg['blockpriv']); $pconfig['blockbogons'] = isset($wancfg['blockbogons']); $pconfig['spoofmac'] = $wancfg['spoofmac']; @@ -372,13 +395,23 @@ if ($_POST['apply']) { } } /* input validation */ - if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && $_POST['type'] != "static") + if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^static/", $_POST['type']))) $input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration."); switch(strtolower($_POST['type'])) { - case "static": + case "staticv4": $reqdfields = explode(" ", "ipaddr subnet gateway"); - $reqdfieldsn = array(gettext("IP address"),gettext("Subnet bit count"),gettext("Gateway")); + $reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway")); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + break; + case "staticv6": + $reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6"); + $reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway")); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + break; + case "staticv4v6": + $reqdfields = explode(" ", "ipaddr subnet gateway ipaddrv6 subnetv6 gatewayv6"); + $reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"),gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); break; case "none": @@ -390,6 +423,10 @@ if ($_POST['apply']) { } case "dhcp": break; + case "dhcpv6": + if (in_array($wancfg['ipaddrv6'], array("ppp", "pppoe", "pptp", "l2tp"))) + $input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}."); + break; case "ppp": $reqdfields = explode(" ", "port phone"); $reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number")); @@ -420,20 +457,29 @@ if ($_POST['apply']) { /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac'])); if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) - $input_errors[] = gettext("A valid IP address must be specified."); + $input_errors[] = gettext("A valid IPv4 address must be specified."); + if (($_POST['ipaddrv6'] && !is_ipaddr($_POST['ipaddrv6']))) + $input_errors[] = gettext("A valid IPv6 address must be specified."); if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) $input_errors[] = gettext("A valid subnet bit count must be specified."); + if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6']))) + $input_errors[] = gettext("A valid subnet bit count must be specified."); if (($_POST['alias-address'] && !is_ipaddr($_POST['alias-address']))) $input_errors[] = gettext("A valid alias IP address must be specified."); if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) $input_errors[] = gettext("A valid alias subnet bit count must be specified."); - if ($_POST['gateway'] != "none") { + if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) { $match = false; foreach($a_gateways as $gateway) { if(in_array($_POST['gateway'], $gateway)) { $match = true; } } + foreach($a_gateways as $gateway) { + if(in_array($_POST['gatewayv6'], $gateway)) { + $match = true; + } + } if(!$match) { $input_errors[] = gettext("A valid gateway must be specified."); } @@ -522,8 +568,12 @@ if ($_POST['apply']) { $ppp = array(); if ($wancfg['ipaddr'] != "ppp") unset($wancfg['ipaddr']); + if ($wancfg['ipaddrv6'] != "ppp") + unset($wancfg['ipaddrv6']); unset($wancfg['subnet']); unset($wancfg['gateway']); + unset($wancfg['subnetv6']); + unset($wancfg['gatewayv6']); unset($wancfg['dhcphostname']); unset($wancfg['pppoe_username']); unset($wancfg['pppoe_password']); @@ -535,7 +585,6 @@ if ($_POST['apply']) { if (isset($wancfg['pppoe']['pppoe-reset-type'])) unset($wancfg['pppoe']['pppoe-reset-type']); unset($wancfg['local']); - unset($wancfg['subnet']); unset($wancfg['remote']); unset($a_ppps[$pppid]['apn']); unset($a_ppps[$pppid]['phone']); @@ -561,7 +610,7 @@ if ($_POST['apply']) { } } if($skip == false) { - $gateway_item['gateway'] = gettext("dynamic"); + $gateway_item['gateway'] = "dynamic"; $gateway_item['descr'] = gettext("Interface") . $if . gettext("dynamic gateway"); $gateway_item['name'] = "GW_" . strtoupper($if); $gateway_item['interface'] = "{$if}"; @@ -571,12 +620,31 @@ if ($_POST['apply']) { } switch($_POST['type']) { - case "static": + case "staticv4": + $wancfg['ipaddr'] = $_POST['ipaddr']; + $wancfg['subnet'] = $_POST['subnet']; + if ($_POST['gateway'] != "none") { + $wancfg['gateway'] = $_POST['gateway']; + } + break; + case "staticv6": + $wancfg['ipaddrv6'] = $_POST['ipaddrv6']; + $wancfg['subnetv6'] = $_POST['subnetv6']; + if ($_POST['gatewayv6'] != "none") { + $wancfg['gatewayv6'] = $_POST['gatewayv6']; + } + break; + case "staticv4v6": $wancfg['ipaddr'] = $_POST['ipaddr']; $wancfg['subnet'] = $_POST['subnet']; if ($_POST['gateway'] != "none") { $wancfg['gateway'] = $_POST['gateway']; } + $wancfg['ipaddrv6'] = $_POST['ipaddrv6']; + $wancfg['subnetv6'] = $_POST['subnetv6']; + if ($_POST['gatewayv6'] != "none") { + $wancfg['gatewayv6'] = $_POST['gatewayv6']; + } break; case "dhcp": $wancfg['ipaddr'] = "dhcp"; @@ -587,6 +655,15 @@ if ($_POST['apply']) { $a_gateways[] = $gateway_item; } break; + case "dhcpv6": + $wancfg['ipaddrv6'] = "dhcpv6"; + $wancfg['dhcphostname'] = $_POST['dhcphostname']; + $wancfg['alias-address'] = $_POST['alias-address']; + $wancfg['alias-subnet'] = $_POST['alias-subnet']; + if($gateway_item) { + $a_gateways[] = $gateway_item; + } + break; case "carpdev-dhcp": $wancfg['ipaddr'] = "carpdev-dhcp"; $wancfg['dhcphostname'] = $_POST['dhcphostname']; @@ -883,7 +960,7 @@ $statusurl = "status_interfaces.php"; $closehead = false; include("head.inc"); -$types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP") /* , "carpdev-dhcp" => "CarpDev"*/); +$types = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "staticv6" => gettext("Static IPv6"), "staticv4v6" => gettext("Static IPv4 + IPv6"), "dhcp" => gettext("DHCP"), "dhcpv6" => gettext("DHCPv6"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP") /* , "carpdev-dhcp" => "CarpDev"*/); ?> @@ -896,28 +973,42 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" function updateType(t) { switch(t) { case "none": { - $('static','dhcp','pppoe','pptp', 'ppp').invoke('hide'); + $('staticv4','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide'); break; } - case "static": { - $('none','dhcp','pppoe','pptp', 'ppp').invoke('hide'); + case "staticv4": { + $('none','staticv6','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide'); + break; + } + case "staticv6": { + $('none','staticv4','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide'); + break; + } + case "staticv4v6": { + $('none','dhcp','dhcpv6','pppoe','pptp', 'ppp').invoke('hide'); + $('staticv4').show(); + $('staticv6').show(); break; } case "dhcp": { - $('none','static','pppoe','pptp', 'ppp').invoke('hide'); + $('none','staticv4','staticv6','dhcpv6','pppoe','pptp', 'ppp').invoke('hide'); + break; + } + case "dhcpv6": { + $('none','staticv4','staticv6','dhcp','pppoe','pptp', 'ppp').invoke('hide'); break; } case "ppp": { - $('none','static','dhcp','pptp', 'pppoe').invoke('hide'); + $('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'pppoe').invoke('hide'); country_list(); break; } case "pppoe": { - $('none','static','dhcp','pptp', 'ppp').invoke('hide'); + $('none','staticv4','staticv6','dhcp','dhcpv6','pptp', 'ppp').invoke('hide'); break; } case "pptp": { - $('none','static','dhcp','pppoe', 'ppp').invoke('hide'); + $('none','staticv4','staticv6','dhcp','dhcpv6','pppoe', 'ppp').invoke('hide'); break; } } @@ -1136,14 +1227,14 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" </tr> <tr style="display:none;" name="none" id="none"> </tr> - <tr style="display:none;" name="static" id="static"> + <tr style="display:none;" name="staticv4" id="staticv4"> <td colspan="2" style="padding:0px;"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("Static IP configuration"); ?></td> + <td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv4 configuration"); ?></td> </tr> <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("IP address"); ?></td> + <td width="22%" valign="top" class="vncellreq"><?=gettext("IPv4 address"); ?></td> <td width="78%" class="vtable"> <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>"> / @@ -1168,7 +1259,7 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" <?php if(count($a_gateways) > 0) { foreach ($a_gateways as $gateway) { - if($gateway['interface'] == $if) { + if(($gateway['interface'] == $if) && (is_ipaddrv4($gateway['gateway']))) { ?> <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>> <?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?> @@ -1209,7 +1300,7 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" <td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GW"?>"></td> </tr> <tr> - <td align="right"><font color="white"><?=gettext("Gateway IP:"); ?></td><td><input id="gatewayip" name="gatewayip"></td> + <td align="right"><font color="white"><?=gettext("Gateway IPv4:"); ?></td><td><input id="gatewayip" name="gatewayip"></td> </tr> <tr> <td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td> @@ -1239,11 +1330,114 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" </table> </td> </tr> + <tr style="display:none;" name="staticv6" id="staticv6"> + <td colspan="2" style="padding:0px;"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" valign="top" class="listtopic"><?=gettext("Static IPv6 configuration"); ?></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("IPv6 address"); ?></td> + <td width="78%" class="vtable"> + <input name="ipaddrv6" type="text" class="formfld unknown" id="ipaddrv6" size="20" value="<?=htmlspecialchars($pconfig['ipaddrv6']);?>"> + / + <select name="subnetv6" class="formselect" id="subnetv6"> + <?php + for ($i = 128; $i > 0; $i--) { + if($i <> 127) { + echo "<option value=\"{$i}\" "; + if ($i == $pconfig['subnetv6']) echo "selected"; + echo ">" . $i . "</option>"; + } + } + ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td> + <td width="78%" class="vtable"> + <select name="gatewayv6" class="formselect" id="gatewayv6"> + <option value="none" selected><?=gettext("None"); ?></option> + <?php + if(count($a_gateways) > 0) { + foreach ($a_gateways as $gateway) { + if(($gateway['interface'] == $if) && (is_ipaddrv6($gateway['gateway']))) { + ?> + <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gatewayv6']) echo "selected"; ?>> + <?=htmlspecialchars($gateway['name']) . " - " . htmlspecialchars($gateway['gateway']);?> + </option> + <?php + } + } + } + ?> + </select> + <br/> + <div id='addgwbox'> + <?=gettext("If this interface is an Internet connection, select an existing Gateway from the list or"); ?> <a OnClick="show_add_gateway();" href="#"><?=gettext("add a new one."); ?></a> + </div> + <div id='notebox'> + </div> + <div id="status"> + </div> + <div style="display:none" id="addgateway" name="addgateway"> + <p> + <table border="1" style="background:#990000; border-style: none none none none; width:225px;"> + <tr> + <td> + <table bgcolor="#990000" cellpadding="1" cellspacing="1"> + <tr><td> </td> + <tr> + <td colspan="2"><center><b><font color="white"><?=gettext("Add new v6 gateway:"); ?></font></b></center></td> + </tr> + <tr><td> </td> + <?php + if($if == "wan" || $if == "WAN") + $checked = " CHECKED"; + ?> + <tr> + <td width="45%" align="right"><font color="white"><?=gettext("Default v6 gateway:"); ?></td><td><input type="checkbox" id="defaultgwv6" name="defaultgwv6"<?=$checked?>></td> + </tr> + <tr> + <td align="right"><font color="white"><?=gettext("Gateway Name:"); ?></td><td><input id="name" name="name" value="<?=$wancfg['descr'] . "GWv6"?>"></td> + </tr> + <tr> + <td align="right"><font color="white"><?=gettext("Gateway IPv6:"); ?></td><td><input id="gatewayip" name="gatewayip"></td> + </tr> + <tr> + <td align="right"><font color="white"><?=gettext("Description:"); ?></td><td><input id="gatewaydescr" name="gatewaydescr"></td> + </tr> + <tr><td> </td> + <tr> + <td> </td> + <td> + <center> + <div id='savebuttondiv'> + <input type="hidden" name="addrtype" id="addrtype" value="IPv6" /> + <input id="gwsave" type="Button" value="<?=gettext("Save Gateway"); ?>" onClick='hide_add_gatewaysave();'> + <input id="gwcancel" type="Button" value="<?=gettext("Cancel"); ?>" onClick='hide_add_gateway();'> + </div> + </center> + </td> + </tr> + <tr><td> </td></tr> + </table> + </td> + </tr> + </table> + <p/> + </div> + </td> + </tr> + </table> + </td> + </tr> <tr style="display:none;" name="dhcp" id="dhcp"> <td colspan="2" style="padding: 0px;"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP client configuration"); ?></td> + <td colspan="2" valign="top" class="listtopic"><?=gettext("DHCPv4 client configuration"); ?></td> </tr> <tr> <td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td> @@ -1277,6 +1471,25 @@ $types = array("none" => gettext("None"), "static" => gettext("Static"), "dhcp" </table> </td> </tr> + <tr style="display:none;" name="dhcpv6" id="dhcpv6"> + <td colspan="2" style="padding: 0px;"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" valign="top" class="listtopic"><?=gettext("DHCPv6 client configuration"); ?></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Hostname"); ?></td> + <td width="78%" class="vtable"> + <input name="dhcphostname" type="text" class="formfld unknown" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>"> + <br> + <?=gettext("The value in this field is sent as the DHCPv6 client identifier " . + "and hostname when requesting a DHCPv6 lease. Some ISPs may require " . + "this (for client identification)."); ?> + </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"> |