From c581beafac253fc2e86b9ab49bf1035ea4d95ab9 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 21 Dec 2015 22:34:40 +0100 Subject: [PATCH] (legacy) work in progress refactoring interfaces.inc --- src/www/interfaces.php | 6856 +++++++++++++++++++--------------------- 1 file changed, 3234 insertions(+), 3622 deletions(-) diff --git a/src/www/interfaces.php b/src/www/interfaces.php index a99c4cb78..d4425e8e7 100644 --- a/src/www/interfaces.php +++ b/src/www/interfaces.php @@ -1,34 +1,34 @@ - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2010 Erik Fonnesbeck + Copyright (C) 2008-2010 Ermal Luçi + Copyright (C) 2004-2008 Scott Ullrich + Copyright (C) 2006 Daniel S. Haischt + Copyright (C) 2003-2004 Manuel Kasper + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); @@ -46,199 +46,198 @@ require_once("unbound.inc"); /*************************************************************************************************************** * imported from xmlparse_attr.inc ***************************************************************************************************************/ -/* The following items will be treated as arrays in regdomain.xml */ -function listtags_rd() { - $ret = explode(" ", - "band country flags freqband netband rd" - ); - return $ret; -} function startElement_attr($parser, $name, $attrs) { - global $parsedcfg, $depth, $curpath, $havedata, $listtags, $parsedattrs; + global $parsedcfg, $depth, $curpath, $havedata, $listtags, $parsedattrs; - array_push($curpath, strtolower($name)); + array_push($curpath, strtolower($name)); - $ptr =& $parsedcfg; - if (!empty($attrs)) { - $attrptr =& $parsedattrs; - $writeattrs = true; - } - foreach ($curpath as $path) { - $ptr =& $ptr[$path]; - if (isset($writeattrs)) - $attrptr =& $attrptr[$path]; - } + $ptr =& $parsedcfg; + if (!empty($attrs)) { + $attrptr =& $parsedattrs; + $writeattrs = true; + } + foreach ($curpath as $path) { + $ptr =& $ptr[$path]; + if (isset($writeattrs)) { + $attrptr =& $attrptr[$path]; + } + } - /* is it an element that belongs to a list? */ - if (in_array(strtolower($name), $listtags)) { + /* is it an element that belongs to a list? */ + if (in_array(strtolower($name), $listtags)) { + /* is there an array already? */ + if (!is_array($ptr)) { + /* make an array */ + $ptr = array(); + } - /* is there an array already? */ - if (!is_array($ptr)) { - /* make an array */ - $ptr = array(); - } + array_push($curpath, count($ptr)); - array_push($curpath, count($ptr)); + if (isset($writeattrs)) { + if (!is_array($attrptr)) { + $attrptr = array(); + } + $attrptr[count($ptr)] = $attrs; + } + } else if (isset($ptr)) { + /* multiple entries not allowed for this element, bail out */ + die(sprintf(gettext('XML error: %s at line %d cannot occur more than once') . "\n", + $name, + xml_get_current_line_number($parser))); + } else if (isset($writeattrs)) { + $attrptr = $attrs; + } - if (isset($writeattrs)) { - if (!is_array($attrptr)) - $attrptr = array(); - $attrptr[count($ptr)] = $attrs; - } - - } else if (isset($ptr)) { - /* multiple entries not allowed for this element, bail out */ - die(sprintf(gettext('XML error: %s at line %d cannot occur more than once') . "\n", - $name, - xml_get_current_line_number($parser))); - } else if (isset($writeattrs)) { - $attrptr = $attrs; - } - - $depth++; - $havedata = $depth; + $depth++; + $havedata = $depth; } function endElement_attr($parser, $name) { - global $depth, $curpath, $parsedcfg, $havedata, $listtags; + global $depth, $curpath, $parsedcfg, $havedata, $listtags; - if ($havedata == $depth) { - $ptr =& $parsedcfg; - foreach ($curpath as $path) { - $ptr =& $ptr[$path]; - } - $ptr = ""; - } + if ($havedata == $depth) { + $ptr =& $parsedcfg; + foreach ($curpath as $path) { + $ptr =& $ptr[$path]; + } + $ptr = ""; + } - array_pop($curpath); + array_pop($curpath); - if (in_array(strtolower($name), $listtags)) - array_pop($curpath); + if (in_array(strtolower($name), $listtags)) { + array_pop($curpath); + } - $depth--; + $depth--; } function cData_attr($parser, $data) { - global $depth, $curpath, $parsedcfg, $havedata; + global $depth, $curpath, $parsedcfg, $havedata; - $data = trim($data, "\t\n\r"); + $data = trim($data, "\t\n\r"); - if ($data != "") { - $ptr =& $parsedcfg; - foreach ($curpath as $path) { - $ptr =& $ptr[$path]; - } + if ($data != "") { + $ptr =& $parsedcfg; + foreach ($curpath as $path) { + $ptr =& $ptr[$path]; + } - if (is_string($ptr)) { - $ptr .= html_entity_decode($data); - } else { - if (trim($data, " ") != "") { - $ptr = html_entity_decode($data); - $havedata++; - } - } - } + if (is_string($ptr)) { + $ptr .= html_entity_decode($data); + } else { + if (trim($data, " ") != "") { + $ptr = html_entity_decode($data); + $havedata++; + } + } + } } function parse_xml_regdomain(&$rdattributes, $rdfile = '', $rootobj = 'regulatory-data') { - global $listtags; + global $listtags; - if (empty($rdfile)) { - $rdfile = '/etc/regdomain.xml'; - } + if (empty($rdfile)) { + $rdfile = '/etc/regdomain.xml'; + } - $listtags = listtags_rd(); - $parsed_xml = array(); + $listtags = explode(" ", "band country flags freqband netband rd"); + $parsed_xml = array(); - if (file_exists('/tmp/regdomain.cache')) { - $parsed_xml = unserialize(file_get_contents('/tmp/regdomain.cache')); - if (!empty($parsed_xml)) { - $rdmain = $parsed_xml['main']; - $rdattributes = $parsed_xml['attributes']; - } - } - if (empty($parsed_xml) && file_exists('/etc/regdomain.xml')) { - $rdmain = parse_xml_config_raw_attr($rdfile, $rootobj, $rdattributes); + if (file_exists('/tmp/regdomain.cache')) { + $parsed_xml = unserialize(file_get_contents('/tmp/regdomain.cache')); + if (!empty($parsed_xml)) { + $rdmain = $parsed_xml['main']; + $rdattributes = $parsed_xml['attributes']; + } + } + if (empty($parsed_xml) && file_exists('/etc/regdomain.xml')) { + $rdmain = parse_xml_config_raw_attr($rdfile, $rootobj, $rdattributes); - // unset parts that aren't used before making cache - foreach ($rdmain['regulatory-domains']['rd'] as $rdkey => $rdentry) { - if (isset($rdmain['regulatory-domains']['rd'][$rdkey]['netband'])) - unset($rdmain['regulatory-domains']['rd'][$rdkey]['netband']); - if (isset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband'])) - unset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband']); - } - if (isset($rdmain['shared-frequency-bands'])) - unset($rdmain['shared-frequency-bands']); - if (isset($rdattributes['shared-frequency-bands'])) - unset($rdattributes['shared-frequency-bands']); + // unset parts that aren't used before making cache + foreach ($rdmain['regulatory-domains']['rd'] as $rdkey => $rdentry) { + if (isset($rdmain['regulatory-domains']['rd'][$rdkey]['netband'])) { + unset($rdmain['regulatory-domains']['rd'][$rdkey]['netband']); + } + if (isset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband'])) { + unset($rdattributes['regulatory-domains']['rd'][$rdkey]['netband']); + } + } + if (isset($rdmain['shared-frequency-bands'])) { + unset($rdmain['shared-frequency-bands']); + } + if (isset($rdattributes['shared-frequency-bands'])) { + unset($rdattributes['shared-frequency-bands']); + } - $parsed_xml = array('main' => $rdmain, 'attributes' => $rdattributes); - $rdcache = fopen('/tmp/regdomain.cache', 'w'); - fwrite($rdcache, serialize($parsed_xml)); - fclose($rdcache); - } + $parsed_xml = array('main' => $rdmain, 'attributes' => $rdattributes); + $rdcache = fopen('/tmp/regdomain.cache', 'w'); + fwrite($rdcache, serialize($parsed_xml)); + fclose($rdcache); + } - return $rdmain; + return $rdmain; } function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isstring = "false") { + global $depth, $curpath, $parsedcfg, $havedata, $listtags, $parsedattrs; + $parsedcfg = array(); + $curpath = array(); + $depth = 0; + $havedata = 0; - global $depth, $curpath, $parsedcfg, $havedata, $listtags, $parsedattrs; - $parsedcfg = array(); - $curpath = array(); - $depth = 0; - $havedata = 0; + if (isset($parsed_attributes)) { + $parsedattrs = array(); + } - if (isset($parsed_attributes)) - $parsedattrs = array(); + $xml_parser = xml_parser_create(); - $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement_attr", "endElement_attr"); + xml_set_character_data_handler($xml_parser, "cData_attr"); + xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1); - xml_set_element_handler($xml_parser, "startElement_attr", "endElement_attr"); - xml_set_character_data_handler($xml_parser, "cData_attr"); - xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1); + if (!($fp = fopen($cffile, "r"))) { + log_error(gettext("Error: could not open XML input") . "\n"); + if (isset($parsed_attributes)) { + $parsed_attributes = array(); + unset($parsedattrs); + } + return -1; + } - if (!($fp = fopen($cffile, "r"))) { - log_error(gettext("Error: could not open XML input") . "\n"); - if (isset($parsed_attributes)) { - $parsed_attributes = array(); - unset($parsedattrs); - } - return -1; - } + while ($data = fread($fp, 4096)) { + if (!xml_parse($xml_parser, $data, feof($fp))) { + log_error(sprintf(gettext('XML error: %s at line %d') . "\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + if (isset($parsed_attributes)) { + $parsed_attributes = array(); + unset($parsedattrs); + } + return -1; + } + } + xml_parser_free($xml_parser); - while ($data = fread($fp, 4096)) { - if (!xml_parse($xml_parser, $data, feof($fp))) { - log_error(sprintf(gettext('XML error: %s at line %d') . "\n", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser))); - if (isset($parsed_attributes)) { - $parsed_attributes = array(); - unset($parsedattrs); - } - return -1; - } - } - xml_parser_free($xml_parser); + if (!$parsedcfg[$rootobj]) { + log_error(sprintf(gettext("XML error: no %s object found!") . "\n", $rootobj)); + if (isset($parsed_attributes)) { + $parsed_attributes = array(); + unset($parsedattrs); + } + return -1; + } - if (!$parsedcfg[$rootobj]) { - log_error(sprintf(gettext("XML error: no %s object found!") . "\n", $rootobj)); - if (isset($parsed_attributes)) { - $parsed_attributes = array(); - unset($parsedattrs); - } - return -1; - } + if (isset($parsed_attributes)) { + if ($parsedattrs[$rootobj]) { + $parsed_attributes = $parsedattrs[$rootobj]; + } + unset($parsedattrs); + } - if (isset($parsed_attributes)) { - if ($parsedattrs[$rootobj]) - $parsed_attributes = $parsedattrs[$rootobj]; - unset($parsedattrs); - } - - return $parsedcfg[$rootobj]; + return $parsedcfg[$rootobj]; } /*************************************************************************************************************** @@ -246,1382 +245,1091 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst ***************************************************************************************************************/ function get_wireless_modes($interface) { - /* return wireless modes and channels */ - $wireless_modes = array(); + /* return wireless modes and channels */ + $wireless_modes = array(); - $cloned_interface = get_real_interface($interface); + $cloned_interface = get_real_interface($interface); - if($cloned_interface && is_interface_wireless($cloned_interface)) { - $chan_list = "/sbin/ifconfig {$cloned_interface} list chan"; - $stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'"; - $format_list = "/usr/bin/awk '{print \$5 \" \" \$6 \",\" \$1}'"; + if ($cloned_interface && is_interface_wireless($cloned_interface)) { + $chan_list = "/sbin/ifconfig {$cloned_interface} list chan"; + $stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'"; + $format_list = "/usr/bin/awk '{print \$5 \" \" \$6 \",\" \$1}'"; - $interface_channels = ""; - exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels); - $interface_channel_count = count($interface_channels); + $interface_channels = ""; + exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels); + $interface_channel_count = count($interface_channels); - $c = 0; - while ($c < $interface_channel_count) { - $channel_line = explode(",", $interface_channels["$c"]); - $wireless_mode = trim($channel_line[0]); - $wireless_channel = trim($channel_line[1]); - if(trim($wireless_mode) != "") { - /* if we only have 11g also set 11b channels */ - if($wireless_mode == "11g") { - if(!isset($wireless_modes["11b"])) - $wireless_modes["11b"] = array(); - } else if($wireless_mode == "11g ht") { - if(!isset($wireless_modes["11b"])) - $wireless_modes["11b"] = array(); - if(!isset($wireless_modes["11g"])) - $wireless_modes["11g"] = array(); - $wireless_mode = "11ng"; - } else if($wireless_mode == "11a ht") { - if(!isset($wireless_modes["11a"])) - $wireless_modes["11a"] = array(); - $wireless_mode = "11na"; - } - $wireless_modes["$wireless_mode"]["$c"] = $wireless_channel; - } - $c++; - } - } - return($wireless_modes); + $c = 0; + while ($c < $interface_channel_count) { + $channel_line = explode(",", $interface_channels["$c"]); + $wireless_mode = trim($channel_line[0]); + $wireless_channel = trim($channel_line[1]); + if (trim($wireless_mode) != "") { + /* if we only have 11g also set 11b channels */ + if ($wireless_mode == "11g") { + if (!isset($wireless_modes["11b"])) { + $wireless_modes["11b"] = array(); + } + } else if ($wireless_mode == "11g ht") { + if (!isset($wireless_modes["11b"])) { + $wireless_modes["11b"] = array(); + } elseif (!isset($wireless_modes["11g"])) { + $wireless_modes["11g"] = array(); + } + $wireless_mode = "11ng"; + } else if ($wireless_mode == "11a ht") { + if (!isset($wireless_modes["11a"])) { + $wireless_modes["11a"] = array(); + } + $wireless_mode = "11na"; + } + $wireless_modes["$wireless_mode"]["$c"] = $wireless_channel; + } + $c++; + } + } + return($wireless_modes); } /* return channel numbers, frequency, max txpower, and max regulation txpower */ function get_wireless_channel_info($interface) { - $wireless_channels = array(); + $wireless_channels = array(); - $cloned_interface = get_real_interface($interface); + $cloned_interface = get_real_interface($interface); + if ($cloned_interface && is_interface_wireless($cloned_interface)) { + $chan_list = "/sbin/ifconfig {$cloned_interface} list txpower"; + $stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'"; + $format_list = "/usr/bin/awk '{print \$1 \",\" \$3 \" \" \$4 \",\" \$5 \",\" \$7}'"; - if($cloned_interface && is_interface_wireless($cloned_interface)) { - $chan_list = "/sbin/ifconfig {$cloned_interface} list txpower"; - $stack_list = "/usr/bin/awk -F\"Channel \" '{ gsub(/\\*/, \" \"); print \$2 \"\\\n\" \$3 }'"; - $format_list = "/usr/bin/awk '{print \$1 \",\" \$3 \" \" \$4 \",\" \$5 \",\" \$7}'"; + $interface_channels = ""; + exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels); - $interface_channels = ""; - exec("$chan_list | $stack_list | sort -u | $format_list 2>&1", $interface_channels); - - foreach ($interface_channels as $channel_line) { - $channel_line = explode(",", $channel_line); - if(!isset($wireless_channels[$channel_line[0]])) - $wireless_channels[$channel_line[0]] = $channel_line; - } - } - return($wireless_channels); + foreach ($interface_channels as $channel_line) { + $channel_line = explode(",", $channel_line); + if (!isset($wireless_channels[$channel_line[0]])) { + $wireless_channels[$channel_line[0]] = $channel_line; + } + } + } + return($wireless_channels); } -$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php'); + // Get configured interface list $ifdescrs = get_configured_interface_with_descr(false, true); -$if = "wan"; -if ($_REQUEST['if']) - $if = $_REQUEST['if']; - -if (empty($ifdescrs[$if])) { - header("Location: interfaces.php"); - exit; +// reference to interface section +if (empty($config['interfaces']) || !is_array($config['interfaces'])) { + $config['interfaces'] = array(); } +$a_interfaces = &$config['interfaces']; -define("CRON_MONTHLY_PATTERN", "0 0 1 * *"); -define("CRON_WEEKLY_PATTERN", "0 0 * * 0"); -define("CRON_DAILY_PATTERN", "0 0 * * *"); -define("CRON_HOURLY_PATTERN", "0 * * * *"); - -if (!is_array($pconfig)) { - $pconfig = array(); +if (empty($config['ppps']['ppp']) || !is_array($config['ppps']['ppp'])) { + $config['ppps'] = array(); + $config['ppps']['ppp'] = array(); } - -if (!is_array($config['ppps'])) { - $config['ppps'] = array(); -} - -if (!is_array($config['ppps']['ppp'])) { - $config['ppps']['ppp'] = array(); -} - $a_ppps = &$config['ppps']['ppp']; -function remove_bad_chars($string) -{ - return preg_replace('/[^a-z_0-9]/i','',$string); -} -if (!is_array($config['gateways'])) { - $config['gateways'] = array(); -} - -if (!is_array($config['gateways']['gateway_item'])) { - $config['gateways']['gateway_item'] = array(); -} - -$a_gateways = &$config['gateways']['gateway_item']; - -$wancfg = &$config['interfaces'][$if]; -$old_wancfg = $wancfg; -$old_wancfg['realif'] = get_real_interface($if); -$old_ppps = $a_ppps; -// Populate page descr if it does not exist. -if ($if == "wan" && !$wancfg['descr']) - $wancfg['descr'] = "WAN"; -else if ($if == "lan" && !$wancfg['descr']) - $wancfg['descr'] = "LAN"; - -foreach ($a_ppps as $pppid => $ppp) { - if ($wancfg['if'] == $ppp['if']) - break; -} - -$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled="disabled"' : ''; - -if ($wancfg['if'] == $a_ppps[$pppid]['if']) { - $pconfig['pppid'] = $pppid; - $pconfig['ptpid'] = $a_ppps[$pppid]['ptpid']; - $pconfig['port'] = $a_ppps[$pppid]['ports']; - if ($a_ppps[$pppid]['type'] == "ppp") { - $pconfig['username'] = $a_ppps[$pppid]['username']; - $pconfig['password'] = base64_decode($a_ppps[$pppid]['password']); - - $pconfig['phone'] = $a_ppps[$pppid]['phone']; - $pconfig['apn'] = $a_ppps[$pppid]['apn']; - } - else if ($a_ppps[$pppid]['type'] == "pppoe") { - $pconfig['pppoe_username'] = $a_ppps[$pppid]['username']; - $pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']); - $pconfig['provider'] = $a_ppps[$pppid]['provider']; - $pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); - $pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout']; - - /* ================================================ */ - /* = force a connection reset at a specific time? = */ - /* ================================================ */ - - if (isset($a_ppps[$pppid]['pppoe-reset-type'])) { - $pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type']; - $itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']); - if ($itemhash) - $cronitem = $itemhash['ITEM']; - if (isset($cronitem)) { - $resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}"; - } else { - $resetTime = NULL; - } - //log_error("ResetTime:".$resetTime); - if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") { - if ($cronitem) { - $pconfig['pppoe_pr_custom'] = true; - $pconfig['pppoe_resetminute'] = $cronitem['minute']; - $pconfig['pppoe_resethour'] = $cronitem['hour']; - if ($cronitem['mday'] <> "*" && $cronitem['month'] <> "*") - $pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y"); - } - } else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") { - $pconfig['pppoe_pr_preset'] = true; - switch ($resetTime) { - case CRON_MONTHLY_PATTERN: - $pconfig['pppoe_monthly'] = true; - break; - case CRON_WEEKLY_PATTERN: - $pconfig['pppoe_weekly'] = true; - break; - case CRON_DAILY_PATTERN: - $pconfig['pppoe_daily'] = true; - break; - case CRON_HOURLY_PATTERN: - $pconfig['pppoe_hourly'] = true; - break; - } - } - }// End force pppoe reset at specific time - }// End if type == pppoe - else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp"){ - $pconfig['pptp_username'] = $a_ppps[$pppid]['username']; - $pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']); - $pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']); - $pconfig['pptp_subnet'] = explode(",",$a_ppps[$pppid]['subnet']); - $pconfig['pptp_remote'] = explode(",",$a_ppps[$pppid]['gateway']); - $pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); - $pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout']; - } -} else { - $pconfig['ptpid'] = interfaces_ptpid_next(); - $pppid = count($a_ppps); -} -$pconfig['dhcphostname'] = $wancfg['dhcphostname']; -$pconfig['alias-address'] = $wancfg['alias-address']; -$pconfig['alias-subnet'] = $wancfg['alias-subnet']; -$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom']; - -$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout']; -$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry']; -$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout']; -$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot']; -$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff']; -$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval']; - -$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values']; - -$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options']; -$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options']; -$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options']; -$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers']; - -$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced']; -$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override']; -$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path']; - -$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options']; -$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options']; -$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable']; -$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script']; - -$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable']; -$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address']; -$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id']; -$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime']; -$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime']; - -$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']; -$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix']; -$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id']; -$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']; -$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']; - -$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id']; -$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len']; - -$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname']; -$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol']; -$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm']; -$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm']; - -$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname']; -$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm']; -$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid']; -$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret']; -$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire']; - -$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced']; -$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override']; -$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path']; - -$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']); -$pconfig['descr'] = remove_bad_chars($wancfg['descr']); -$pconfig['enable'] = isset($wancfg['enable']); - -if (isset($config['aliases']['alias'])) { - foreach($config['aliases']['alias'] as $alias) { - if($alias['name'] == $wancfg['descr']) { - $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$wancfg['descr']); - } - } -} - -switch($wancfg['ipaddr']) { - case "dhcp": - $pconfig['type'] = "dhcp"; - break; - case "pppoe": - case "pptp": - case "l2tp": - case "ppp": - $pconfig['type'] = $wancfg['ipaddr']; - break; - default: - if(is_ipaddrv4($wancfg['ipaddr'])) { - $pconfig['type'] = "staticv4"; - $pconfig['ipaddr'] = $wancfg['ipaddr']; - $pconfig['subnet'] = $wancfg['subnet']; - $pconfig['gateway'] = $wancfg['gateway']; - } else - $pconfig['type'] = "none"; - break; -} - -switch($wancfg['ipaddrv6']) { - case "slaac": - $pconfig['type6'] = "slaac"; - break; - case "dhcp6": - $pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid']; - if(!isset($wancfg['dhcp6-ia-pd-len'])) - $wancfg['dhcp6-ia-pd-len'] = "none"; - $pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len']; - $pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']); - $pconfig['type6'] = "dhcp6"; - $pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']); - $pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']); - break; - case "6to4": - $pconfig['type6'] = "6to4"; - break; - case "track6": - $pconfig['type6'] = "track6"; - $pconfig['track6-interface'] = $wancfg['track6-interface']; - if ($wancfg['track6-prefix-id'] == "") - $pconfig['track6-prefix-id'] = 0; - else - $pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id']; - $pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']); - break; - case "6rd": - $pconfig['prefix-6rd'] = $wancfg['prefix-6rd']; - if($wancfg['prefix-6rd-v4plen'] == "") - $wancfg['prefix-6rd-v4plen'] = "0"; - $pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen']; - $pconfig['type6'] = "6rd"; - $pconfig['gateway-6rd'] = $wancfg['gateway-6rd']; - break; - default: - if(is_ipaddrv6($wancfg['ipaddrv6'])) { - $pconfig['type6'] = "staticv6"; - $pconfig['ipaddrv6'] = $wancfg['ipaddrv6']; - $pconfig['subnetv6'] = $wancfg['subnetv6']; - $pconfig['gatewayv6'] = $wancfg['gatewayv6']; - } else - $pconfig['type6'] = "none"; - break; -} - -// print_r($pconfig); - -$pconfig['blockpriv'] = isset($wancfg['blockpriv']); -$pconfig['blockbogons'] = isset($wancfg['blockbogons']); -$pconfig['spoofmac'] = $wancfg['spoofmac']; -$pconfig['mtu'] = $wancfg['mtu']; -$pconfig['mss'] = $wancfg['mss']; - -/* Wireless interface? */ -if (isset($wancfg['wireless'])) { - /* Sync first to be sure it displays the actual settings that will be used */ - interface_sync_wireless_clones($wancfg, false); - /* Get wireless modes */ - $wlanif = get_real_interface($if); - if (!does_interface_exist($wlanif)) - interface_wireless_clone($wlanif, $wancfg); - $wlanbaseif = interface_get_wireless_base($wancfg['if']); - preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split); - $wl_modes = get_wireless_modes($if); - $wl_chaninfo = get_wireless_channel_info($if); - $wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2]; - $wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna", - "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout")); - $wl_regdomain_xml_attr = array(); - $wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr); - $wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd']; - $wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd']; - $wl_countries = &$wl_regdomain_xml['country-codes']['country']; - $wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country']; - $pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]); - $pconfig['standard'] = $wancfg['wireless']['standard']; - $pconfig['mode'] = $wancfg['wireless']['mode']; - $pconfig['protmode'] = $wancfg['wireless']['protmode']; - $pconfig['ssid'] = $wancfg['wireless']['ssid']; - $pconfig['channel'] = $wancfg['wireless']['channel']; - $pconfig['txpower'] = $wancfg['wireless']['txpower']; - $pconfig['diversity'] = $wancfg['wireless']['diversity']; - $pconfig['txantenna'] = $wancfg['wireless']['txantenna']; - $pconfig['rxantenna'] = $wancfg['wireless']['rxantenna']; - $pconfig['distance'] = $wancfg['wireless']['distance']; - $pconfig['regdomain'] = $wancfg['wireless']['regdomain']; - $pconfig['regcountry'] = $wancfg['wireless']['regcountry']; - $pconfig['reglocation'] = $wancfg['wireless']['reglocation']; - $pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']); - if (isset($wancfg['wireless']['puren']['enable'])) - $pconfig['puremode'] = '11n'; - else if (isset($wancfg['wireless']['pureg']['enable'])) - $pconfig['puremode'] = '11g'; - else - $pconfig['puremode'] = 'any'; - $pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']); - $pconfig['authmode'] = $wancfg['wireless']['authmode']; - $pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']); - $pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr']; - $pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port']; - $pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret']; - $pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2']; - $pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2']; - $pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2']; - if (is_array($wancfg['wireless']['wpa'])) { - $pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode']; - $pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl']; - $pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']); - $pconfig['auth_algs'] = $wancfg['wireless']['wpa']['auth_algs']; - $pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode']; - $pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt']; - $pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise']; - $pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey']; - $pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey']; - $pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']); - $pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase']; - $pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']); - $pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']); - $pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw']; - $pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']); - } - $pconfig['wep_enable'] = isset($wancfg['wireless']['wep']['enable']); - $pconfig['mac_acl'] = $wancfg['wireless']['mac_acl']; - if (is_array($wancfg['wireless']['wep']) && is_array($wancfg['wireless']['wep']['key'])) { - $i = 1; - foreach ($wancfg['wireless']['wep']['key'] as $wepkey) { - $pconfig['key' . $i] = $wepkey['value']; - if (isset($wepkey['txkey'])) - $pconfig['txkey'] = $i; - $i++; - } - if (!isset($wepkey['txkey'])) - $pconfig['txkey'] = 1; - } -} - -$ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']); -$ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length); - -if ($_POST['apply']) { - unset($input_errors); - if (!is_subsystem_dirty('interfaces')) { - $intput_errors[] = gettext("You have already applied your settings!"); - } else { - clear_subsystem_dirty('interfaces'); - - if (file_exists('/tmp/.interfaces.apply')) { - $toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); - foreach ($toapplylist as $ifapply => $ifcfgo) { - if (isset($config['interfaces'][$ifapply]['enable'])) { - interface_bring_down($ifapply, false, $ifcfgo); - interface_configure($ifapply, true); - } else - interface_bring_down($ifapply, true, $ifcfgo); - } - } - /* restart snmp so that it binds to correct address */ - services_snmpd_configure(); - - /* sync filter configuration */ - setup_gateways_monitor(); - - clear_subsystem_dirty('interfaces'); - - filter_configure(); - - enable_rrd_graphing(); - - if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) - clear_subsystem_dirty('staticroutes'); - } - @unlink('/tmp/.interfaces.apply'); - header("Location: interfaces.php?if={$if}"); - exit; -} else if ($_POST && $_POST['enable'] != "yes") { - unset($wancfg['enable']); - if (isset($wancfg['wireless'])) - interface_sync_wireless_clones($wancfg, false); - write_config("Interface {$_POST['descr']}({$if}) is now disabled."); - mark_subsystem_dirty('interfaces'); - if (file_exists('/tmp/.interfaces.apply')) { - $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($_POST['pppoe-reset-type'])) { - unset($_POST['pppoe_pr_type']); - unset($_POST['pppoe_resethour']); - unset($_POST['pppoe_resetminute']); - unset($_POST['pppoe_resetdate']); - unset($_POST['pppoe_pr_preset_val']); - } - /* description unique? */ - foreach ($ifdescrs as $ifent => $ifdescr) { - if ($if != $ifent && $ifdescr == $_POST['descr']) { - $input_errors[] = gettext("An interface with the specified description already exists."); - break; - } - } - /* input validation */ - if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $_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."); - if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $_POST['type6']))) - $input_errors[] = gettext("The DHCPv6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration."); - - switch(strtolower($_POST['type'])) { - case "staticv4": - $reqdfields = explode(" ", "ipaddr subnet gateway"); - $reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway")); - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - break; - case "none": - if(is_array($config['virtualip']['vip'])) { - foreach ($config['virtualip']['vip'] as $vip) { - if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) - $input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration."); - } - } - case "dhcp": - if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) - $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$_POST['type']); - break; - case "ppp": - $reqdfields = explode(" ", "port phone"); - $reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number")); - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - break; - case "pppoe": - if ($_POST['pppoe_dialondemand']) { - $reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout"); - $reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value")); - } else { - $reqdfields = explode(" ", "pppoe_username pppoe_password"); - $reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password")); - } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - break; - case "pptp": - if ($_POST['pptp_dialondemand']) { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout"); - $reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value")); - } else { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote"); - $reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address")); - } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - break; - case "l2tp": - if ($_POST['pptp_dialondemand']) { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout"); - $reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value")); - } else { - $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote"); - $reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address")); - } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - break; - } - switch(strtolower($_POST['type6'])) { - 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 "none": - if (isset($config['virtualip']['vip'])) { - foreach ($config['virtualip']['vip'] as $vip) { - if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) - $input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration."); - } - } - 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['type6']); - break; - case "6rd": - foreach ($ifdescrs as $ifent => $ifdescr) { - if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) { - if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) { - $input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix."); - 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['type6']); - break; - case "6to4": - foreach ($ifdescrs as $ifent => $ifdescr) { - if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) { - $input_errors[] = sprintf(gettext("You can only have one interface configured as 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['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['type6']); - - if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) { - $input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID."); - } else { - $track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16); - if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) { - $input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range."); - } - } - break; - } - - - /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ - $staticroutes = get_staticroutes(true); - $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac'])); - if ($_POST['ipaddr']) { - if (!is_ipaddrv4($_POST['ipaddr'])) - $input_errors[] = gettext("A valid IPv4 address must be specified."); - else { - if (is_ipaddr_configured($_POST['ipaddr'], $if, true)) - $input_errors[] = gettext("This IPv4 address is being used by another interface or VIP."); - - /* Do not accept network or broadcast address, except if subnet is 31 or 32 */ - if ($_POST['subnet'] < 31) { - if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) - $input_errors[] = gettext("This IPv4 address is the network address and cannot be used"); - else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet'])) - $input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used"); - } - - foreach ($staticroutes as $route_subnet) { - list($network, $subnet) = explode("/", $route_subnet); - if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) { - $input_errors[] = gettext("This IPv4 address conflicts with a Static Route."); - break; - } - unset($network, $subnet); - } - } - } - if ($_POST['ipaddrv6']) { - if (!is_ipaddrv6($_POST['ipaddrv6'])) - $input_errors[] = gettext("A valid IPv6 address must be specified."); - else { - if (is_ipaddr_configured($_POST['ipaddrv6'], $if, true)) - $input_errors[] = gettext("This IPv6 address is being used by another interface or VIP."); - - foreach ($staticroutes as $route_subnet) { - list($network, $subnet) = explode("/", $route_subnet); - if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) { - $input_errors[] = gettext("This IPv6 address conflicts with a Static Route."); - break; - } - unset($network, $subnet); - } - } - } - 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_ipaddrv4($_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['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) - $input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from."); - 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."); - } - } - if (($_POST['provider'] && !is_domain($_POST['provider']))) - $input_errors[] = gettext("The service name contains invalid characters."); - if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) - $input_errors[] = gettext("The idle timeout value must be an integer."); - if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) && - $_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) - $input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23)."); - if ($_POST['pppoe_resetminute'] <> "" && !is_numericint($_POST['pppoe_resetminute']) && - $_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) - $input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59)."); - if ($_POST['pppoe_resetdate'] <> "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) - $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy)."); - if (($_POST['pptp_local'] && !is_ipaddrv4($_POST['pptp_local']))) - $input_errors[] = gettext("A valid PPTP local IP address must be specified."); - if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) - $input_errors[] = gettext("A valid PPTP subnet bit count must be specified."); - if (($_POST['pptp_remote'] && !is_ipaddrv4($_POST['pptp_remote']) && !is_hostname($_POST['gateway'][$iface]))) - $input_errors[] = gettext("A valid PPTP remote IP address must be specified."); - if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) - $input_errors[] = gettext("The idle timeout value must be an integer."); - if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) - $input_errors[] = gettext("A valid MAC address must be specified."); - if ($_POST['mtu']) { - if ($_POST['mtu'] < 576 || $_POST['mtu'] > 9000) - $input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000."); - - if (stristr($wancfg['if'], "_vlan")) { - $realhwif_array = get_parent_interface($wancfg['if']); - // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling - $parent_realhwif = $realhwif_array[0]; - $parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif); - if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) { - if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) - $input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface."); - } +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + if (!empty($_GET['if']) && !empty($a_interfaces[$_GET['if']])) { + $if = $_GET['if']; } else { - foreach ($config['interfaces'] as $idx => $ifdata) { - if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) - continue; - - $realhwif_array = get_parent_interface($ifdata['if']); - // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling - $parent_realhwif = $realhwif_array[0]; - - if ($parent_realhwif != $wancfg['if']) - continue; - - if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu']) - $input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']); - } - } - } - if ($_POST['mss'] && ($_POST['mss'] < 576)) - $input_errors[] = gettext("The MSS must be greater than 576 bytes."); - /* Wireless interface? */ - if (isset($wancfg['wireless'])) { - $reqdfields = array("mode"); - $reqdfieldsn = array(gettext("Mode")); - if ($_POST['mode'] == 'hostap') { - $reqdfields[] = "ssid"; - $reqdfieldsn[] = gettext("SSID"); - } - do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - check_wireless_mode(); - /* loop through keys and enforce size */ - for ($i = 1; $i <= 4; $i++) { - if ($_POST['key' . $i]) { - /* 64 bit */ - if (strlen($_POST['key' . $i]) == 5) - continue; - if (strlen($_POST['key' . $i]) == 10) { - /* hex key */ - if (stristr($_POST['key' . $i], "0x") == false) { - $_POST['key' . $i] = "0x" . $_POST['key' . $i]; - } - continue; - } - if (strlen($_POST['key' . $i]) == 12) { - /* hex key */ - if(stristr($_POST['key' . $i], "0x") == false) { - $_POST['key' . $i] = "0x" . $_POST['key' . $i]; - } - continue; - } - /* 128 bit */ - if (strlen($_POST['key' . $i]) == 13) - continue; - if (strlen($_POST['key' . $i]) == 26) { - /* hex key */ - if (stristr($_POST['key' . $i], "0x") == false) - $_POST['key' . $i] = "0x" . $_POST['key' . $i]; - continue; - } - if(strlen($_POST['key' . $i]) == 28) - continue; - $input_errors[] = gettext("Invalid WEP key size. Sizes should be 40 (64) bit keys or 104 (128) bit."); - break; - } + // no interface provided, redirect to interface assignments + header("Location: interfaces_assign.php"); + exit; } - if ($_POST['passphrase']) { - $passlen = strlen($_POST['passphrase']); - if ($passlen < 8 || $passlen > 63) - $input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters."); - } - } - if (!$input_errors) { - if ($wancfg['ipaddr'] != $_POST['type']) { - if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) { - $wancfg['if'] = $a_ppps[$pppid]['ports']; - unset($a_ppps[$pppid]); - } else if ($wancfg['ipaddr'] == "dhcp") { - kill_dhclient_process($wancfg['if']); - } - if ($wancfg['ipaddrv6'] == "dhcp6") { - $pid = find_dhcp6c_process($wancfg['if']); - if ($pid) { - exec('/bin/kill ' . $pid); - } - } - } - $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['dhcprejectfrom']); - unset($wancfg['dhcp6-duid']); - unset($wancfg['dhcp6-ia-pd-len']); - unset($wancfg['dhcp6-ia-pd-send-hint']); - unset($wancfg['dhcp6prefixonly']); - unset($wancfg['dhcp6usev4iface']); - unset($wancfg['track6-interface']); - unset($wancfg['track6-prefix-id']); - unset($wancfg['prefix-6rd']); - unset($wancfg['prefix-6rd-v4plen']); - unset($wancfg['gateway-6rd']); + $pconfig = array(); + $std_copy_fieldnames = array( + "if", "descr", "dhcphostname", "alias-address", "alias-subnet", "dhcprejectfrom", "ipaddr", "subnet", "gateway", + "ipaddrv6", + "adv_dhcp_pt_timeout", "adv_dhcp_pt_retry", "adv_dhcp_pt_select_timeout", "adv_dhcp_pt_reboot", + "adv_dhcp_pt_backoff_cutoff", "adv_dhcp_pt_initial_interval", "adv_dhcp_pt_values", + "adv_dhcp_send_options", "adv_dhcp_request_options", "adv_dhcp_required_options", "adv_dhcp_option_modifiers", + "adv_dhcp_config_advanced", "adv_dhcp_config_file_override", "adv_dhcp_config_file_override_path", + "adv_dhcp6_interface_statement_send_options", "adv_dhcp6_interface_statement_request_options", + "adv_dhcp6_interface_statement_information_only_enable", "adv_dhcp6_interface_statement_script", + "adv_dhcp6_id_assoc_statement_address_enable", "adv_dhcp6_id_assoc_statement_address", "adv_dhcp6_id_assoc_statement_address_id", + "adv_dhcp6_id_assoc_statement_address_pltime", "adv_dhcp6_id_assoc_statement_address_vltime", + "adv_dhcp6_id_assoc_statement_prefix_enable", "adv_dhcp6_id_assoc_statement_prefix", "adv_dhcp6_id_assoc_statement_prefix_id", + "adv_dhcp6_id_assoc_statement_prefix_pltime", "adv_dhcp6_id_assoc_statement_prefix_vltime", + "adv_dhcp6_prefix_interface_statement_sla_id", "adv_dhcp6_prefix_interface_statement_sla_len", + "adv_dhcp6_authentication_statement_authname", "adv_dhcp6_authentication_statement_protocol", "adv_dhcp6_authentication_statement_algorithm", + "adv_dhcp6_authentication_statement_rdm", "adv_dhcp6_key_info_statement_keyname", "adv_dhcp6_key_info_statement_realm", + "adv_dhcp6_key_info_statement_keyid", "adv_dhcp6_key_info_statement_secret", "adv_dhcp6_key_info_statement_expire", + "adv_dhcp6_config_advanced", "adv_dhcp6_config_file_override", "adv_dhcp6_config_file_override_path", + "spoofmac", "mtu", "mss", + "dhcp6-ia-pd-len", "track6-interface", "track6-prefix-id", "prefix-6rd", "prefix-6rd-v4plen", "gateway-6rd", + "ipaddrv6", "subnetv6", "gatewayv6" + ); + foreach ($std_copy_fieldnames as $fieldname) { + $pconfig[$fieldname] = isset($a_interfaces[$if][$fieldname]) ? $a_interfaces[$if][$fieldname] : null; + } + $pconfig['enable'] = isset($a_interfaces[$if]['enable']); + $pconfig['blockpriv'] = isset($a_interfaces[$if]['blockpriv']); + $pconfig['blockbogons'] = isset($a_interfaces[$if]['blockbogons']); + $pconfig['dhcp6-ia-pd-send-hint'] = isset($a_interfaces[$if]['dhcp6-ia-pd-send-hint']); + $pconfig['dhcp6prefixonly'] = isset($a_interfaces[$if]['dhcp6prefixonly']); + $pconfig['dhcp6usev4iface'] = isset($a_interfaces[$if]['dhcp6usev4iface']); + $pconfig['track6-prefix-id--hex'] = sprintf("%x", empty($pconfig['track6-prefix-id']) ? 0 :$pconfig['track6-prefix-id']); - unset($wancfg['adv_dhcp_pt_timeout']); - unset($wancfg['adv_dhcp_pt_retry']); - unset($wancfg['adv_dhcp_pt_select_timeout']); - unset($wancfg['adv_dhcp_pt_reboot']); - unset($wancfg['adv_dhcp_pt_backoff_cutoff']); - unset($wancfg['adv_dhcp_pt_initial_interval']); + // ipv4 type (from ipaddr) + if (is_ipaddrv4($pconfig['ipaddr'])) { + $pconfig['type'] = "staticv4"; + } else { + if (empty($pconfig['ipaddr'])) { + $pconfig['type'] = "none"; + } else { + $pconfig['type'] = $pconfig['ipaddr']; + } + $pconfig['ipaddr'] = null; + } - unset($wancfg['adv_dhcp_pt_values']); + // ipv6 type (from ipaddrv6) + if (is_ipaddrv6($pconfig['ipaddrv6'])) { + $pconfig['type6'] = "staticv6"; + } else { + if (empty($pconfig['ipaddrv6'])) { + $pconfig['type6'] = "none"; + } else { + $pconfig['type6'] = $pconfig['ipaddrv6']; + } + $pconfig['ipaddrv6'] = null; + } - unset($wancfg['adv_dhcp_send_options']); - unset($wancfg['adv_dhcp_request_options']); - unset($wancfg['adv_dhcp_required_options']); - unset($wancfg['adv_dhcp_option_modifiers']); + /* + locate PPP details (if any) + */ + $pppid = count($a_ppps); + foreach ($a_ppps as $key => $ppp) { + if ($a_interfaces[$if]['if'] == $ppp['if']) { + $pppid = $key; + break; + } + } - unset($wancfg['adv_dhcp_config_advanced']); - unset($wancfg['adv_dhcp_config_file_override']); - unset($wancfg['adv_dhcp_config_file_override_path']); + $std_ppp_copy_fieldnames = array( + "ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "pppoe-reset-type", "localip", - unset($wancfg['adv_dhcp6_interface_statement_send_options']); - unset($wancfg['adv_dhcp6_interface_statement_request_options']); - unset($wancfg['adv_dhcp6_interface_statement_information_only_enable']); - unset($wancfg['adv_dhcp6_interface_statement_script']); + ); + foreach ($std_ppp_copy_fieldnames as $fieldname) { + $pconfig[$fieldname] = isset($a_ppps[$pppid][$fieldname]) ? $a_ppps[$pppid][$fieldname] : null; + } - unset($wancfg['adv_dhcp6_id_assoc_statement_address_enable']); - unset($wancfg['adv_dhcp6_id_assoc_statement_address']); - unset($wancfg['adv_dhcp6_id_assoc_statement_address_id']); - unset($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']); - unset($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']); + $pconfig['password'] = base64_decode($a_ppps[$pppid]['password']); // ppp password field + $pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); + $pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); + $pconfig['pppoe_password'] = $pconfig['password']; // pppoe password field + $pconfig["pppoe_username"] = $pconfig['username']; + $pconfig['pppoe_idletimeout'] = $pconfig['idletimeout']; - unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_enable']); - unset($wancfg['adv_dhcp6_id_assoc_statement_prefix']); - unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_id']); - unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']); - unset($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']); + $pconfig['pptp_username'] = $pconfig['username']; + $pconfig['pptp_password'] = $pconfig['password']; + $pconfig['pptp_subnet'] = $a_ppps[$pppid]['subnet']; + $pconfig['pptp_remote'] = $a_ppps[$pppid]['gateway']; + $pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout']; - unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']); - unset($wancfg['adv_dhcp6_prefix_interface_statement_sla_len']); + if (isset($a_ppps[$pppid])) { + $pconfig['pppid'] = $pppid; + $itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']); + if (!empty($itemhash)) { + $cronitem = $itemhash['ITEM']; + $pconfig['pppoe_resetminute'] = $cronitem['minute']; + $pconfig['pppoe_resethour'] = $cronitem['hour']; + $pconfig['pppoe_resetmday'] = $cronitem['mday']; + $pconfig['pppoe_resetmonth'] = $cronitem['month']; + $pconfig['pppoe_resetwday'] = $cronitem['wday']; + } + } else { + $pconfig['ptpid'] = interfaces_ptpid_next(); + $pppid = count($a_ppps); + } - unset($wancfg['adv_dhcp6_authentication_statement_authname']); - unset($wancfg['adv_dhcp6_authentication_statement_protocol']); - unset($wancfg['adv_dhcp6_authentication_statement_algorithm']); - unset($wancfg['adv_dhcp6_authentication_statement_rdm']); + /* + Wireless interface + */ + if (isset($a_interfaces[$if]['wireless'])) { + /* Sync first to be sure it displays the actual settings that will be used */ + interface_sync_wireless_clones($a_interfaces[$if], false); + /* Get wireless modes */ + $wlanif = get_real_interface($if); + if (!does_interface_exist($wlanif)) { + interface_wireless_clone($wlanif, $a_interfaces[$if]); + } + $wlanbaseif = interface_get_wireless_base($a_interfaces[$if]['if']); + preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split); + $wl_modes = get_wireless_modes($if); + $wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2]; + $wl_sysctl = get_sysctl(array("{$wl_sysctl_prefix}.diversity", "{$wl_sysctl_prefix}.txantenna", "{$wl_sysctl_prefix}.rxantenna", + "{$wl_sysctl_prefix}.slottime", "{$wl_sysctl_prefix}.acktimeout", "{$wl_sysctl_prefix}.ctstimeout")); + $wl_regdomain_xml_attr = array(); + $wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr); + $wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd']; + $wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd']; + $wl_countries = &$wl_regdomain_xml['country-codes']['country']; + $wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country']; + $std_wl_copy_fieldnames = array( + 'standard', 'mode','protmode', 'ssid', 'channel', 'txpower', 'diversity', 'txantenna', 'rxantenna', 'distance', + 'regdomain', 'regcountry', 'reglocation', 'authmode', 'auth_server_addr', 'auth_server_port', 'auth_server_shared_secret', + 'auth_server_addr2', 'auth_server_port2', 'auth_server_shared_secret2', 'mac_acl' + ); + foreach ($std_wl_copy_fieldnames as $fieldname) { + $pconfig[$fieldname] = isset($a_interfaces[$if]['wireless'][$fieldname]) ? $a_interfaces[$if]['wireless'][$fieldname] : null; + } + $pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]); + $pconfig['wme_enable'] = isset($a_interfaces[$if]['wireless']['wme']['enable']); + $pconfig['apbridge_enable'] = isset($a_interfaces[$if]['wireless']['apbridge']['enable']); + $pconfig['hidessid_enable'] = isset($a_interfaces[$if]['wireless']['hidessid']['enable']); + $pconfig['wep_enable'] = isset($a_interfaces[$if]['wireless']['wep']['enable']); - unset($wancfg['adv_dhcp6_key_info_statement_keyname']); - unset($wancfg['adv_dhcp6_key_info_statement_realm']); - unset($wancfg['adv_dhcp6_key_info_statement_keyid']); - unset($wancfg['adv_dhcp6_key_info_statement_secret']); - unset($wancfg['adv_dhcp6_key_info_statement_expire']); + if (isset($a_interfaces[$if]['wireless']['puren']['enable'])) { + $pconfig['puremode'] = '11n'; + } elseif (isset($a_interfaces[$if]['wireless']['pureg']['enable'])) { + $pconfig['puremode'] = '11g'; + } else { + $pconfig['puremode'] = 'any'; + } - unset($wancfg['adv_dhcp6_config_advanced']); - unset($wancfg['adv_dhcp6_config_file_override']); - unset($wancfg['adv_dhcp6_config_file_override_path']); - - unset($wancfg['pppoe_password']); - unset($wancfg['pptp_username']); - unset($wancfg['pptp_password']); - unset($wancfg['provider']); - unset($wancfg['ondemand']); - unset($wancfg['timeout']); - if (empty($wancfg['pppoe']['pppoe-reset-type'])) - unset($wancfg['pppoe']['pppoe-reset-type']); - unset($wancfg['local']); - - unset($wancfg['remote']); - unset($a_ppps[$pppid]['apn']); - unset($a_ppps[$pppid]['phone']); - unset($a_ppps[$pppid]['localip']); - unset($a_ppps[$pppid]['subnet']); - unset($a_ppps[$pppid]['gateway']); - unset($a_ppps[$pppid]['pppoe-reset-type']); - unset($a_ppps[$pppid]['provider']); - - $wancfg['descr'] = remove_bad_chars($_POST['descr']); - $wancfg['enable'] = $_POST['enable'] == "yes" ? true : false; - - /* let return_gateways_array() do the magic on dynamic interfaces for us */ - switch($_POST['type']) { - case "staticv4": - $wancfg['ipaddr'] = $_POST['ipaddr']; - $wancfg['subnet'] = $_POST['subnet']; - if ($_POST['gateway'] != "none") { - $wancfg['gateway'] = $_POST['gateway']; - } - break; - case "dhcp": - $wancfg['ipaddr'] = "dhcp"; - $wancfg['dhcphostname'] = $_POST['dhcphostname']; - $wancfg['alias-address'] = $_POST['alias-address']; - $wancfg['alias-subnet'] = $_POST['alias-subnet']; - $wancfg['dhcprejectfrom'] = $_POST['dhcprejectfrom']; - - $wancfg['adv_dhcp_pt_timeout'] = $_POST['adv_dhcp_pt_timeout']; - $wancfg['adv_dhcp_pt_retry'] = $_POST['adv_dhcp_pt_retry']; - $wancfg['adv_dhcp_pt_select_timeout'] = $_POST['adv_dhcp_pt_select_timeout']; - $wancfg['adv_dhcp_pt_reboot'] = $_POST['adv_dhcp_pt_reboot']; - $wancfg['adv_dhcp_pt_backoff_cutoff'] = $_POST['adv_dhcp_pt_backoff_cutoff']; - $wancfg['adv_dhcp_pt_initial_interval'] = $_POST['adv_dhcp_pt_initial_interval']; - - $wancfg['adv_dhcp_pt_values'] = $_POST['adv_dhcp_pt_values']; - - $wancfg['adv_dhcp_send_options'] = $_POST['adv_dhcp_send_options']; - $wancfg['adv_dhcp_request_options'] = $_POST['adv_dhcp_request_options']; - $wancfg['adv_dhcp_required_options'] = $_POST['adv_dhcp_required_options']; - $wancfg['adv_dhcp_option_modifiers'] = $_POST['adv_dhcp_option_modifiers']; - - $wancfg['adv_dhcp_config_advanced'] = $_POST['adv_dhcp_config_advanced']; - $wancfg['adv_dhcp_config_file_override'] = $_POST['adv_dhcp_config_file_override']; - $wancfg['adv_dhcp_config_file_override_path'] = $_POST['adv_dhcp_config_file_override_path']; - - $wancfg['dhcp_plus'] = $_POST['dhcp_plus'] == "yes" ? true : false; - if($gateway_item) { - $a_gateways[] = $gateway_item; - } - break; - case "ppp": - $a_ppps[$pppid]['ptpid'] = $_POST['ptpid']; - $a_ppps[$pppid]['type'] = $_POST['type']; - $a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid']; - $a_ppps[$pppid]['ports'] = $_POST['port']; - $a_ppps[$pppid]['username'] = $_POST['username']; - $a_ppps[$pppid]['password'] = base64_encode($_POST['password']); - $a_ppps[$pppid]['phone'] = $_POST['phone']; - $a_ppps[$pppid]['apn'] = $_POST['apn']; - $wancfg['if'] = $_POST['type'] . $_POST['ptpid']; - $wancfg['ipaddr'] = $_POST['type']; - unset($a_ppps[$pppid]['ondemand']); - unset($a_ppps[$pppid]['idletimeout']); - break; - - case "pppoe": - $a_ppps[$pppid]['ptpid'] = $_POST['ptpid']; - $a_ppps[$pppid]['type'] = $_POST['type']; - $a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid']; - if (isset($_POST['ppp_port'])) - $a_ppps[$pppid]['ports'] = $_POST['ppp_port']; - else - $a_ppps[$pppid]['ports'] = $wancfg['if']; - $a_ppps[$pppid]['username'] = $_POST['pppoe_username']; - $a_ppps[$pppid]['password'] = base64_encode($_POST['pppoe_password']); - if (isset($_POST['provider'])) - $a_ppps[$pppid]['provider'] = $_POST['provider']; - else - $a_ppps[$pppid]['provider'] = true; - $a_ppps[$pppid]['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false; - if (isset($_POST['pppoe_idletimeout'])) - $a_ppps[$pppid]['idletimeout'] = $_POST['pppoe_idletimeout']; - else - unset($a_ppps[$pppid]['idletimeout']); - - if (isset($_POST['pppoe-reset-type'])) - $a_ppps[$pppid]['pppoe-reset-type'] = $_POST['pppoe-reset-type']; - else - unset($a_ppps[$pppid]['pppoe-reset-type']); - $wancfg['if'] = $_POST['type'].$_POST['ptpid']; - $wancfg['ipaddr'] = $_POST['type']; - if($gateway_item) { - $a_gateways[] = $gateway_item; - } - - break; - case "pptp": - case "l2tp": - $a_ppps[$pppid]['ptpid'] = $_POST['ptpid']; - $a_ppps[$pppid]['type'] = $_POST['type']; - $a_ppps[$pppid]['if'] = $_POST['type'].$_POST['ptpid']; - if (isset($_POST['ppp_port'])) - $a_ppps[$pppid]['ports'] = $_POST['ppp_port']; - else - $a_ppps[$pppid]['ports'] = $wancfg['if']; - $a_ppps[$pppid]['username'] = $_POST['pptp_username']; - $a_ppps[$pppid]['password'] = base64_encode($_POST['pptp_password']); - $a_ppps[$pppid]['localip'] = $_POST['pptp_local']; - $a_ppps[$pppid]['subnet'] = $_POST['pptp_subnet']; - $a_ppps[$pppid]['gateway'] = $_POST['pptp_remote']; - $a_ppps[$pppid]['ondemand'] = $_POST['pptp_dialondemand'] ? true : false; - if (isset($_POST['pptp_idletimeout'])) - $a_ppps[$pppid]['idletimeout'] = $_POST['pptp_idletimeout']; - else - unset($a_ppps[$pppid]['idletimeout']); - $wancfg['if'] = $_POST['type'].$_POST['ptpid']; - $wancfg['ipaddr'] = $_POST['type']; - if($gateway_item) { - $a_gateways[] = $gateway_item; - } - break; - case "none": - break; - } - switch($_POST['type6']) { - case "staticv6": - $wancfg['ipaddrv6'] = $_POST['ipaddrv6']; - $wancfg['subnetv6'] = $_POST['subnetv6']; - if ($_POST['gatewayv6'] != "none") { - $wancfg['gatewayv6'] = $_POST['gatewayv6']; - } - break; - case "slaac": - $wancfg['ipaddrv6'] = "slaac"; - break; - case "dhcp6": - $wancfg['ipaddrv6'] = "dhcp6"; - $wancfg['dhcp6-duid'] = $_POST['dhcp6-duid']; - $wancfg['dhcp6-ia-pd-len'] = $_POST['dhcp6-ia-pd-len']; - if($_POST['dhcp6-ia-pd-send-hint'] == "yes") - $wancfg['dhcp6-ia-pd-send-hint'] = true; - if($_POST['dhcp6prefixonly'] == "yes") - $wancfg['dhcp6prefixonly'] = true; - if($_POST['dhcp6usev4iface'] == "yes") - $wancfg['dhcp6usev4iface'] = true; - - $wancfg['adv_dhcp6_interface_statement_send_options'] = $_POST['adv_dhcp6_interface_statement_send_options']; - $wancfg['adv_dhcp6_interface_statement_request_options'] = $_POST['adv_dhcp6_interface_statement_request_options']; - $wancfg['adv_dhcp6_interface_statement_information_only_enable'] = $_POST['adv_dhcp6_interface_statement_information_only_enable']; - $wancfg['adv_dhcp6_interface_statement_script'] = $_POST['adv_dhcp6_interface_statement_script']; - - $wancfg['adv_dhcp6_id_assoc_statement_address_enable'] = $_POST['adv_dhcp6_id_assoc_statement_address_enable']; - $wancfg['adv_dhcp6_id_assoc_statement_address'] = $_POST['adv_dhcp6_id_assoc_statement_address']; - $wancfg['adv_dhcp6_id_assoc_statement_address_id'] = $_POST['adv_dhcp6_id_assoc_statement_address_id']; - $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_pltime']; - $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_address_vltime']; - - $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_enable']; - $wancfg['adv_dhcp6_id_assoc_statement_prefix'] = $_POST['adv_dhcp6_id_assoc_statement_prefix']; - $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_id']; - $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_pltime']; - $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $_POST['adv_dhcp6_id_assoc_statement_prefix_vltime']; - - $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_id']; - $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] = $_POST['adv_dhcp6_prefix_interface_statement_sla_len']; - - $wancfg['adv_dhcp6_authentication_statement_authname'] = $_POST['adv_dhcp6_authentication_statement_authname']; - $wancfg['adv_dhcp6_authentication_statement_protocol'] = $_POST['adv_dhcp6_authentication_statement_protocol']; - $wancfg['adv_dhcp6_authentication_statement_algorithm'] = $_POST['adv_dhcp6_authentication_statement_algorithm']; - $wancfg['adv_dhcp6_authentication_statement_rdm'] = $_POST['adv_dhcp6_authentication_statement_rdm']; - - $wancfg['adv_dhcp6_key_info_statement_keyname'] = $_POST['adv_dhcp6_key_info_statement_keyname']; - $wancfg['adv_dhcp6_key_info_statement_realm'] = $_POST['adv_dhcp6_key_info_statement_realm']; - $wancfg['adv_dhcp6_key_info_statement_keyid'] = $_POST['adv_dhcp6_key_info_statement_keyid']; - $wancfg['adv_dhcp6_key_info_statement_secret'] = $_POST['adv_dhcp6_key_info_statement_secret']; - $wancfg['adv_dhcp6_key_info_statement_expire'] = $_POST['adv_dhcp6_key_info_statement_expire']; - - $wancfg['adv_dhcp6_config_advanced'] = $_POST['adv_dhcp6_config_advanced']; - $wancfg['adv_dhcp6_config_file_override'] = $_POST['adv_dhcp6_config_file_override']; - $wancfg['adv_dhcp6_config_file_override_path'] = $_POST['adv_dhcp6_config_file_override_path']; - - if($gateway_item) { - $a_gateways[] = $gateway_item; - } - break; - case "6rd": - $wancfg['ipaddrv6'] = "6rd"; - $wancfg['prefix-6rd'] = $_POST['prefix-6rd']; - $wancfg['prefix-6rd-v4plen'] = $_POST['prefix-6rd-v4plen']; - $wancfg['gateway-6rd'] = $_POST['gateway-6rd']; - if($gateway_item) { - $a_gateways[] = $gateway_item; - } - break; - case "6to4": - $wancfg['ipaddrv6'] = "6to4"; - break; - case "track6": - $wancfg['ipaddrv6'] = "track6"; - $wancfg['track6-interface'] = $_POST['track6-interface']; - if ($_POST['track6-prefix-id--hex'] === "") - $wancfg['track6-prefix-id'] = 0; - else if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) - $wancfg['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16); - else - $wancfg['track6-prefix-id'] = 0; - break; - case "none": - break; - } - handle_pppoe_reset($_POST); - - if($_POST['blockpriv'] == "yes") { - $wancfg['blockpriv'] = true; - } else { - unset($wancfg['blockpriv']); - } - if($_POST['blockbogons'] == "yes") { - $wancfg['blockbogons'] = true; - } else { - unset($wancfg['blockbogons']); - } - $wancfg['spoofmac'] = $_POST['spoofmac']; - if (empty($_POST['mtu'])) { - unset($wancfg['mtu']); - } else { - $wancfg['mtu'] = $_POST['mtu']; - } - if (empty($_POST['mss'])) { - unset($wancfg['mss']); - } else { - $wancfg['mss'] = $_POST['mss']; - } - if (empty($_POST['mediaopt'])) { - unset($wancfg['media']); - unset($wancfg['mediaopt']); - } else { - $mediaopts = explode(' ', $_POST['mediaopt']); - if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; } - if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; } - else { unset($wancfg['mediaopt']); } - } - if (isset($wancfg['wireless'])) { - handle_wireless_post(); + if (isset($a_interfaces[$if]['wireless']['wpa']) && is_array($a_interfaces[$if]['wireless']['wpa'])) { + $std_wl_wpa_copy_fieldnames = array( + 'debug_mode', 'macaddr_acl', 'auth_algs', 'wpa_mode', 'wpa_key_mgmt', 'wpa_pairwise', + 'wpa_group_rekey', 'wpa_gmk_rekey', 'passphrase', 'ext_wpa_sw' + ); + foreach ($std_wl_copy_fieldnames as $fieldname) { + $pconfig[$fieldname] = isset($a_interfaces[$if]['wireless']['wpa'][$fieldname]) ? $a_interfaces[$if]['wireless']['wpa'][$fieldname] : null; + } + $pconfig['ieee8021x'] = isset($a_interfaces[$if]['wireless']['wpa']['ieee8021x']['enable']); + $pconfig['rsn_preauth'] = isset($a_interfaces[$if]['wireless']['wpa']['rsn_preauth']); + $pconfig['mac_acl_enable'] = isset($a_interfaces[$if]['wireless']['wpa']['mac_acl_enable']); + $pconfig['wpa_strict_rekey'] = isset($a_interfaces[$if]['wireless']['wpa']['wpa_strict_rekey']); + $pconfig['wpa_enable'] = isset($a_interfaces[$if]['wireless']['wpa']['enable']); + } + if (is_array($a_interfaces[$if]['wireless']['wep']) && is_array($a_interfaces[$if]['wireless']['wep']['key'])) { + $i = 1; + foreach ($a_interfaces[$if]['wireless']['wep']['key'] as $wepkey) { + $pconfig['key' . $i] = $wepkey['value']; + if (isset($wepkey['txkey'])) { + $pconfig['txkey'] = $i; + } + $i++; + } + if (!isset($wepkey['txkey'])) { + $pconfig['txkey'] = 1; + } + } + } +} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { + $pconfig = $_POST; + $input_errors = array(); + if (!empty($_POST['if']) && !empty($a_interfaces[$_POST['if']])) { + $if = $_POST['if']; + // read physcial interface name from config.xml + $pconfig['if'] = $a_interfaces[$if]['if']; } - write_config(); + if (!empty($pconfig['apply'])) { + if (!is_subsystem_dirty('interfaces')) { + $intput_errors[] = gettext("You have already applied your settings!"); + } else { + clear_subsystem_dirty('interfaces'); - if (file_exists('/tmp/.interfaces.apply')) { - $toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); - } else { - $toapplylist = array(); - } - $toapplylist[$if]['ifcfg'] = $old_wancfg; - $toapplylist[$if]['ppps'] = $old_ppps; - file_put_contents('/tmp/.interfaces.apply', serialize($toapplylist)); + if (file_exists('/tmp/.interfaces.apply')) { + $toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); + foreach ($toapplylist as $ifapply => $ifcfgo) { + if (isset($config['interfaces'][$ifapply]['enable'])) { + interface_bring_down($ifapply, false, $ifcfgo); + interface_configure($ifapply, true); + } else { + interface_bring_down($ifapply, true, $ifcfgo); + } + } + } + /* restart snmp so that it binds to correct address */ + services_snmpd_configure(); + /* sync filter configuration */ + setup_gateways_monitor(); + filter_configure(); + enable_rrd_graphing(); + if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) { + clear_subsystem_dirty('staticroutes'); + } + } + @unlink('/tmp/.interfaces.apply'); + header("Location: interfaces.php?if={$if}"); + exit; + } elseif (empty($pconfig['enable'])) { + if (isset($a_interfaces[$if]['enable'])) { + unset($a_interfaces[$if]['enable']); + } + if (isset($a_interfaces[$if]['wireless'])) { + interface_sync_wireless_clones($a_interfaces[$if], false); + } - mark_subsystem_dirty('interfaces'); + write_config("Interface {$pconfig['descr']}({$if}) is now disabled."); + mark_subsystem_dirty('interfaces'); + if (file_exists('/tmp/.interfaces.apply')) { + $toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); + } else { + $toapplylist = array(); + } + $toapplylist[$if]['ifcfg'] = $a_interfaces[$if]; + $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 { + // locate sequence in ppp list + $pppid = count($a_ppps); + foreach ($a_ppps as $key => $ppp) { + if ($a_interfaces[$if]['if'] == $ppp['if']) { + $pppid = $key; + break; + } + } - /* regenerate cron settings/crontab file */ - configure_cron(); + $old_ppps = $a_ppps; - header("Location: interfaces.php?if={$if}"); - exit; - } + // perform validations + if (isset($config['aliases']['alias'])) { + foreach($config['aliases']['alias'] as $alias) { + if ($alias['name'] == $pconfig['descr']) { + $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."),$pconfig['descr']); + } + } + } + /* description unique? */ + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && $ifdescr == $pconfig['descr']) { + $input_errors[] = gettext("An interface with the specified description already exists."); + break; + } + } + /* input validation */ + if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^staticv4/", $pconfig['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."); + } + if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (! preg_match("/^staticv6/", $pconfig['type6']))) { + $input_errors[] = gettext("The DHCPv6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration."); + } -} // end if($_POST) + switch (strtolower($pconfig['type'])) { + case "staticv4": + $reqdfields = explode(" ", "ipaddr subnet gateway"); + $reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway")); + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + case "none": + if (is_array($config['virtualip']['vip'])) { + foreach ($config['virtualip']['vip'] as $vip) { + if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) { + $input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration."); + } + } + } + case "dhcp": + if (in_array($a_interfaces[$if]['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) { + $input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."),$pconfig['type']); + } + break; + case "ppp": + $reqdfields = explode(" ", "ports phone"); + $reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number")); + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + case "pppoe": + if (!empty($pconfig['pppoe_dialondemand'])) { + $reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout"); + $reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value")); + } else { + $reqdfields = explode(" ", "pppoe_username pppoe_password"); + $reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password")); + } + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + case "pptp": + if (!empty($pconfig['pptp_dialondemand'])) { + $reqdfields = explode(" ", "pptp_username pptp_password localip pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout"); + $reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value")); + } else { + $reqdfields = explode(" ", "pptp_username pptp_password localip pptp_subnet pptp_remote"); + $reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address")); + } + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + case "l2tp": + if (!empty($pconfig['pptp_dialondemand'])) { + $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote pptp_dialondemand pptp_idletimeout"); + $reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value")); + } else { + $reqdfields = explode(" ", "pptp_username pptp_password pptp_remote"); + $reqdfieldsn = array(gettext("L2TP username"),gettext("L2TP password"),gettext("L2TP remote IP address")); + } + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + } + switch (strtolower($pconfig['type6'])) { + case "staticv6": + $reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6"); + $reqdfieldsn = array(gettext("IPv6 address"),gettext("Subnet bit count"),gettext("Gateway")); + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + break; + case "none": + if (isset($config['virtualip']['vip'])) { + foreach ($config['virtualip']['vip'] as $vip) { + if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) { + $input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration."); + } + } + } + break; + case "6rd": + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $pconfig['type6'])) { + if ($config[interfaces][$ifent]['prefix-6rd'] == $pconfig['prefix-6rd']) { + $input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix."); + break; + } + } + } + break; + case "6to4": + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $pconfig['type6'])) { + $input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."), $pconfig['type6']); + break; + } + } + break; + case "track6": + if (!empty($pconfig['track6-prefix-id--hex']) && !is_numeric("0x" . $pconfig['track6-prefix-id--hex'])) { + $input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID."); + } elseif (!empty($pconfig['track6-interface'])) { + $ipv6_delegation_length = calculate_ipv6_delegation_length($pconfig['track6-interface']); + $ipv6_num_prefix_ids = pow(2, $ipv6_delegation_length); + $track6_prefix_id = intval($pconfig['track6-prefix-id--hex'], 16); + if ($track6_prefix_id < 0 || $track6_prefix_id >= $ipv6_num_prefix_ids) { + $input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range."); + } + } + break; + } -function handle_wireless_post() { - global $_POST, $config, $g, $wancfg, $if, $wl_countries_attr, $wlanbaseif; - if (!is_array($wancfg['wireless'])) - $wancfg['wireless'] = array(); - $wancfg['wireless']['standard'] = $_POST['standard']; - $wancfg['wireless']['mode'] = $_POST['mode']; - $wancfg['wireless']['protmode'] = $_POST['protmode']; - $wancfg['wireless']['ssid'] = $_POST['ssid']; - $wancfg['wireless']['channel'] = $_POST['channel']; - $wancfg['wireless']['authmode'] = $_POST['authmode']; - $wancfg['wireless']['txpower'] = $_POST['txpower']; - $wancfg['wireless']['distance'] = $_POST['distance']; - $wancfg['wireless']['regdomain'] = $_POST['regdomain']; - $wancfg['wireless']['regcountry'] = $_POST['regcountry']; - $wancfg['wireless']['reglocation'] = $_POST['reglocation']; - if (!empty($wancfg['wireless']['regdomain']) && !empty($wancfg['wireless']['regcountry'])) { - foreach($wl_countries_attr as $wl_country) { - if ($wancfg['wireless']['regcountry'] == $wl_country['ID']) { - $wancfg['wireless']['regdomain'] = $wl_country['rd'][0]['REF']; - break; - } - } - } - if (!is_array($wancfg['wireless']['wpa'])) - $wancfg['wireless']['wpa'] = array(); - $wancfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl']; - $wancfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs']; - $wancfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode']; - $wancfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt']; - $wancfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise']; - $wancfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey']; - $wancfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey']; - $wancfg['wireless']['wpa']['passphrase'] = $_POST['passphrase']; - $wancfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw']; - $wancfg['wireless']['auth_server_addr'] = $_POST['auth_server_addr']; - $wancfg['wireless']['auth_server_port'] = $_POST['auth_server_port']; - $wancfg['wireless']['auth_server_shared_secret'] = $_POST['auth_server_shared_secret']; - $wancfg['wireless']['auth_server_addr2'] = $_POST['auth_server_addr2']; - $wancfg['wireless']['auth_server_port2'] = $_POST['auth_server_port2']; - $wancfg['wireless']['auth_server_shared_secret2'] = $_POST['auth_server_shared_secret2']; - if ($_POST['persistcommonwireless'] == "yes") { - if (!is_array($config['wireless'])) - $config['wireless'] = array(); - if (!is_array($config['wireless']['interfaces'])) - $config['wireless']['interfaces'] = array(); - if (!is_array($config['wireless']['interfaces'][$wlanbaseif])) - $config['wireless']['interfaces'][$wlanbaseif] = array(); - } else if (isset($config['wireless']['interfaces'][$wlanbaseif])) - unset($config['wireless']['interfaces'][$wlanbaseif]); - if (isset($_POST['diversity']) && is_numeric($_POST['diversity'])) - $wancfg['wireless']['diversity'] = $_POST['diversity']; - else if (isset($wancfg['wireless']['diversity'])) - unset($wancfg['wireless']['diversity']); - if (isset($_POST['txantenna']) && is_numeric($_POST['txantenna'])) - $wancfg['wireless']['txantenna'] = $_POST['txantenna']; - else if (isset($wancfg['wireless']['txantenna'])) - unset($wancfg['wireless']['txantenna']); - if (isset($_POST['rxantenna']) && is_numeric($_POST['rxantenna'])) - $wancfg['wireless']['rxantenna'] = $_POST['rxantenna']; - else if (isset($wancfg['wireless']['rxantenna'])) - unset($wancfg['wireless']['rxantenna']); - if ($_POST['hidessid_enable'] == "yes") - $wancfg['wireless']['hidessid']['enable'] = true; - else if (isset($wancfg['wireless']['hidessid']['enable'])) - unset($wancfg['wireless']['hidessid']['enable']); - if ($_POST['mac_acl_enable'] == "yes") - $wancfg['wireless']['wpa']['mac_acl_enable'] = true; - else if (isset($wancfg['wireless']['wpa']['mac_acl_enable'])) - unset($wancfg['wireless']['wpa']['mac_acl_enable']); - if ($_POST['rsn_preauth'] == "yes") - $wancfg['wireless']['wpa']['rsn_preauth'] = true; - else - unset($wancfg['wireless']['wpa']['rsn_preauth']); - if ($_POST['ieee8021x'] == "yes") - $wancfg['wireless']['wpa']['ieee8021x']['enable'] = true; - else if (isset($wancfg['wireless']['wpa']['ieee8021x']['enable'])) - unset($wancfg['wireless']['wpa']['ieee8021x']['enable']); - if ($_POST['wpa_strict_rekey'] == "yes") - $wancfg['wireless']['wpa']['wpa_strict_rekey'] = true; - else if (isset($wancfg['wireless']['wpa']['wpa_strict_rekey'])) - unset($wancfg['wireless']['wpa']['wpa_strict_rekey']); - if ($_POST['debug_mode'] == "yes") - $wancfg['wireless']['wpa']['debug_mode'] = true; - else if (isset($wancfg['wireless']['wpa']['debug_mode'])) - sunset($wancfg['wireless']['wpa']['debug_mode']); - if ($_POST['wpa_enable'] == "yes") - $wancfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true; - else if (isset($wancfg['wireless']['wpa']['enable'])) - unset($wancfg['wireless']['wpa']['enable']); - if ($_POST['wep_enable'] == "yes") { - if (!is_array($wancfg['wireless']['wep'])) - $wancfg['wireless']['wep'] = array(); - $wancfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true; - } else if (isset($wancfg['wireless']['wep'])) - unset($wancfg['wireless']['wep']); - if ($_POST['wme_enable'] == "yes") { - if (!is_array($wancfg['wireless']['wme'])) - $wancfg['wireless']['wme'] = array(); - $wancfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true; - } else if (isset($wancfg['wireless']['wme']['enable'])) - unset($wancfg['wireless']['wme']['enable']); - if ($_POST['puremode'] == "11g") { - if (!is_array($wancfg['wireless']['pureg'])) - $wancfg['wireless']['pureg'] = array(); - $wancfg['wireless']['pureg']['enable'] = true; - } else if ($_POST['puremode'] == "11n") { - if (!is_array($wancfg['wireless']['puren'])) - $wancfg['wireless']['puren'] = array(); - $wancfg['wireless']['puren']['enable'] = true; - } else { - if (isset($wancfg['wireless']['pureg'])) - unset($wancfg['wireless']['pureg']); - if (isset($wancfg['wireless']['puren'])) - unset($wancfg['wireless']['puren']); - } - if ($_POST['apbridge_enable'] == "yes") { - if (!is_array($wancfg['wireless']['apbridge'])) - $wancfg['wireless']['apbridge'] = array(); - $wancfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true; - } else if (isset($wancfg['wireless']['apbridge']['enable'])) - unset($wancfg['wireless']['apbridge']['enable']); - if ($_POST['standard'] == "11g Turbo" || $_POST['standard'] == "11a Turbo") { - if (!is_array($wancfg['wireless']['turbo'])) - $wancfg['wireless']['turbo'] = array(); - $wancfg['wireless']['turbo']['enable'] = true; - } else if (isset($wancfg['wireless']['turbo']['enable'])) - unset($wancfg['wireless']['turbo']['enable']); - $wancfg['wireless']['wep']['key'] = array(); - for ($i = 1; $i <= 4; $i++) { - if ($_POST['key' . $i]) { - $newkey = array(); - $newkey['value'] = $_POST['key' . $i]; - if ($_POST['txkey'] == $i) - $newkey['txkey'] = true; - $wancfg['wireless']['wep']['key'][] = $newkey; - } - } - interface_sync_wireless_clones($wancfg, true); + /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ + $staticroutes = get_staticroutes(true); + if (!empty($pconfig['ipaddr'])) { + if (!is_ipaddrv4($pconfig['ipaddr'])) { + $input_errors[] = gettext("A valid IPv4 address must be specified."); + } else { + if (is_ipaddr_configured($pconfig['ipaddr'], $if, true)) { + $input_errors[] = gettext("This IPv4 address is being used by another interface or VIP."); + } + /* Do not accept network or broadcast address, except if subnet is 31 or 32 */ + if ($pconfig['subnet'] < 31) { + if ($pconfig['ipaddr'] == gen_subnet($pconfig['ipaddr'], $pconfig['subnet'])) { + $input_errors[] = gettext("This IPv4 address is the network address and cannot be used"); + } elseif ($pconfig['ipaddr'] == gen_subnet_max($pconfig['ipaddr'], $pconfig['subnet'])) { + $input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used"); + } + } + + foreach ($staticroutes as $route_subnet) { + list($network, $subnet) = explode("/", $route_subnet); + if ($pconfig['subnet'] == $subnet && $network == gen_subnet($pconfig['ipaddr'], $pconfig['subnet'])) { + $input_errors[] = gettext("This IPv4 address conflicts with a Static Route."); + break; + } + unset($network, $subnet); + } + } + } + if (!empty($pconfig['ipaddrv6'])) { + if (!is_ipaddrv6($pconfig['ipaddrv6'])) { + $input_errors[] = gettext("A valid IPv6 address must be specified."); + } else { + if (is_ipaddr_configured($pconfig['ipaddrv6'], $if, true)) { + $input_errors[] = gettext("This IPv6 address is being used by another interface or VIP."); + } + + foreach ($staticroutes as $route_subnet) { + list($network, $subnet) = explode("/", $route_subnet); + if ($pconfig['subnetv6'] == $subnet && $network == gen_subnetv6($pconfig['ipaddrv6'], $pconfig['subnetv6'])) { + $input_errors[] = gettext("This IPv6 address conflicts with a Static Route."); + break; + } + unset($network, $subnet); + } + } + } + if (!empty($pconfig['subnet']) && !is_numeric($pconfig['subnet'])) { + $input_errors[] = gettext("A valid subnet bit count must be specified."); + } + if (!empty($pconfig['subnetv6']) && !is_numeric($pconfig['subnetv6'])) { + $input_errors[] = gettext("A valid subnet bit count must be specified."); + } + if (!empty($pconfig['alias-address']) && !is_ipaddrv4($pconfig['alias-address'])) { + $input_errors[] = gettext("A valid alias IP address must be specified."); + } + if (!empty($pconfig['alias-subnet']) && !is_numeric($pconfig['alias-subnet'])) { + $input_errors[] = gettext("A valid alias subnet bit count must be specified."); + } + if (!empty($pconfig['dhcprejectfrom']) && !is_ipaddrv4($pconfig['dhcprejectfrom'])) { + $input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from."); + } + + if ($pconfig['gateway'] != "none" || $pconfig['gatewayv6'] != "none") { + $match = false; + if (!empty($config['gateways']['gateway_item'])) { + foreach($config['gateways']['gateway_item'] as $gateway) { + if (in_array($pconfig['gateway'], $gateway)) { + $match = true; + } + } + foreach($config['gateways']['gateway_item'] as $gateway) { + if (in_array($pconfig['gatewayv6'], $gateway)) { + $match = true; + } + } + } + if (!$match) { + $input_errors[] = gettext("A valid gateway must be specified."); + } + } + if (!empty($pconfig['provider']) && !is_domain($pconfig['provider'])){ + $input_errors[] = gettext("The service name contains invalid characters."); + } + if (!empty($pconfig['pppoe_idletimeout']) && !is_numericint($pconfig['pppoe_idletimeout'])) { + $input_errors[] = gettext("The idle timeout value must be an integer."); + } + + if (!empty($pconfig['pppoe-reset-type'])) { + if (!empty($pconfig['pppoe_resethour']) && (!is_numericint($pconfig['pppoe_resethour']) || $pconfig['pppoe_resethour'] < 0 || $pconfig['pppoe_resethour'] > 23)) { + $input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23)."); + } + if (!empty($pconfig['pppoe_resetminute']) && (!is_numericint($pconfig['pppoe_resetminute']) || $pconfig['pppoe_resetminute'] < 0 || $pconfig['pppoe_resetminute'] > 59)) { + $input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59)."); + } + if (!empty($pconfig['pppoe_resetdate']) && !is_numeric(str_replace("/", "", $pconfig['pppoe_resetdate']))) { + $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy)."); + } + } + if (!empty($pconfig['localip']) && !is_ipaddrv4($pconfig['localip'])) { + $input_errors[] = gettext("A valid PPTP local IP address must be specified."); + } + if (!empty($pconfig['pptp_subnet']) && !is_numeric($pconfig['pptp_subnet'])) { + $input_errors[] = gettext("A valid PPTP subnet bit count must be specified."); + } + if (!empty($pconfig['pptp_remote']) && !is_ipaddrv4($pconfig['pptp_remote']) && !is_hostname($pconfig['gateway'][$iface])) { + $input_errors[] = gettext("A valid PPTP remote IP address must be specified."); + } + if (!empty($pconfig['pptp_idletimeout']) && !is_numericint($pconfig['pptp_idletimeout'])) { + $input_errors[] = gettext("The idle timeout value must be an integer."); + } + if (!empty($pconfig['spoofmac']) && !is_macaddr($pconfig['spoofmac'])) { + $input_errors[] = gettext("A valid MAC address must be specified."); + } + if (!empty($pconfig['mtu'])) { + if ($pconfig['mtu'] < 576 || $pconfig['mtu'] > 9000) { + $input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000."); + } + + if (stristr($a_interfaces[$if]['if'], "_vlan")) { + $realhwif_array = get_parent_interface($a_interfaces[$if]['if']); + // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling + $parent_realhwif = $realhwif_array[0]; + $parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif); + if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) { + if ($pconfig['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) { + $input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface."); + } + } + } else { + foreach ($config['interfaces'] as $idx => $ifdata) { + if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) { + continue; + } + + $realhwif_array = get_parent_interface($ifdata['if']); + // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling + $parent_realhwif = $realhwif_array[0]; + + if ($parent_realhwif != $a_interfaces[$if]['if']) { + continue; + } + + if (isset($ifdata['mtu']) && $ifdata['mtu'] > $pconfig['mtu']) { + $input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a bigger value"), $ifdata['descr']); + } + } + } + } + if (!empty($pconfig['mss']) && $pconfig['mss'] < 576) { + $input_errors[] = gettext("The MSS must be greater than 576 bytes."); + } + /* + Wireless interface + */ + if (isset($a_interfaces[$if]['wireless'])) { + $reqdfields = array("mode"); + $reqdfieldsn = array(gettext("Mode")); + if ($pconfig['mode'] == 'hostap') { + $reqdfields[] = "ssid"; + $reqdfieldsn[] = gettext("SSID"); + } + do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); + + // check_wireless_mode (more wireless weirness) + // validations shouldn't perform actual actions, needs serious fixing at some point + if ($a_interfaces[$if]['wireless']['mode'] != $pconfig['mode']) { + if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) { + $clone_count = 1; + } else { + $clone_count = 0; + } + if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) { + foreach ($config['wireless']['clone'] as $clone) { + if ($clone['if'] == $wlanbaseif) { + $clone_count++; + } + } + } + if ($clone_count > 1) { + $wlanif = get_real_interface($if); + $old_wireless_mode = $a_interfaces[$if]['wireless']['mode']; + $a_interfaces[$if]['wireless']['mode'] = $pconfig['mode']; + if (!interface_wireless_clone("{$wlanif}_", $a_interfaces[$if])) { + $input_errors[] = sprintf(gettext("Unable to change mode to %s. You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$a_interfaces[$if]['wireless']['mode']]); + } else { + mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy"); + } + } + } + + /* loop through keys and enforce size */ + for ($i = 1; $i <= 4; $i++) { + if ($pconfig['key' . $i]) { + if (strlen($pconfig['key' . $i]) == 5) { + /* 64 bit */ + continue; + } elseif (strlen($pconfig['key' . $i]) == 10) { + /* hex key */ + if (stristr($pconfig['key' . $i], "0x") == false) { + $pconfig['key' . $i] = "0x" . $pconfig['key' . $i]; + } + continue; + } elseif (strlen($pconfig['key' . $i]) == 12) { + /* hex key */ + if (stristr($pconfig['key' . $i], "0x") == false) { + $pconfig['key' . $i] = "0x" . $pconfig['key' . $i]; + } + continue; + } elseif (strlen($pconfig['key' . $i]) == 13) { + /* 128 bit */ + continue; + } elseif (strlen($pconfig['key' . $i]) == 26) { + /* hex key */ + if (stristr($pconfig['key' . $i], "0x") == false) + $_POST['key' . $i] = "0x" . $pconfig['key' . $i]; + continue; + } elseif (strlen($pconfig['key' . $i]) == 28) { + continue; + } else { + $input_errors[] = gettext("Invalid WEP key size. Sizes should be 40 (64) bit keys or 104 (128) bit."); + } + } + } + + if (!empty($pconfig['passphrase'])) { + $passlen = strlen($pconfig['passphrase']); + if ($passlen < 8 || $passlen > 63) { + $input_errors[] = gettext("The length of the passphrase should be between 8 and 63 characters."); + } + } + } + // save form data + if (count($input_errors) == 0) { + $old_config = $a_interfaces[$if]; + $new_config = array(); + $new_ppp_config = array(); + + // copy physical interface data (wireless is a strange case, partly managed via interface_sync_wireless_clones) + $new_config["if"] = $old_config["if"]; + if (!empty($old_config['wireless'])) { + $new_config['wireless'] = $old_config['wireless']; + } + // + $new_config['descr'] = preg_replace('/[^a-z_0-9]/i', '', $pconfig['descr']); + $new_config['enable'] = !empty($pconfig['enable']); + $new_config['spoofmac'] = $pconfig['spoofmac']; + + $new_config['blockpriv'] = !empty($pconfig['blockpriv']); + $new_config['blockbogons'] = !empty($pconfig['blockbogons']); + if (!empty($pconfig['mtu'])) { + $new_config['mtu'] = $pconfig['mtu']; + } + if (!empty($pconfig['mss'])) { + $new_config['mss'] = $pconfig['mss']; + } + if (!empty($pconfig['mediaopt'])) { + $mediaopts = explode(' ', $pconfig['mediaopt']); + if (isset($mediaopts[0])) { + $new_config['media'] = $mediaopts[0]; + } + if (isset($mediaopts[0])) { + $new_config ['mediaopt'] = $mediaopts[1]; + } + } + + // switch ipv4 config by type + switch($pconfig['type']) { + case "staticv4": + $new_config['ipaddr'] = $pconfig['ipaddr']; + $new_config['subnet'] = $pconfig['subnet']; + if ($pconfig['gateway'] != "none") { + $new_config['gateway'] = $pconfig['gateway']; + } + break; + case "dhcp": + $new_config['ipaddr'] = "dhcp"; + $new_config['dhcphostname'] = $pconfig['dhcphostname']; + $new_config['alias-address'] = $pconfig['alias-address']; + $new_config['alias-subnet'] = $pconfig['alias-subnet']; + $new_config['dhcprejectfrom'] = $pconfig['dhcprejectfrom']; + $new_config['adv_dhcp_pt_timeout'] = $pconfig['adv_dhcp_pt_timeout']; + $new_config['adv_dhcp_pt_retry'] = $pconfig['adv_dhcp_pt_retry']; + $new_config['adv_dhcp_pt_select_timeout'] = $pconfig['adv_dhcp_pt_select_timeout']; + $new_config['adv_dhcp_pt_reboot'] = $pconfig['adv_dhcp_pt_reboot']; + $new_config['adv_dhcp_pt_backoff_cutoff'] = $pconfig['adv_dhcp_pt_backoff_cutoff']; + $new_config['adv_dhcp_pt_initial_interval'] = $pconfig['adv_dhcp_pt_initial_interval']; + $new_config['adv_dhcp_pt_values'] = $pconfig['adv_dhcp_pt_values']; + $new_config['adv_dhcp_send_options'] = $pconfig['adv_dhcp_send_options']; + $new_config['adv_dhcp_request_options'] = $pconfig['adv_dhcp_request_options']; + $new_config['adv_dhcp_required_options'] = $pconfig['adv_dhcp_required_options']; + $new_config['adv_dhcp_option_modifiers'] = $pconfig['adv_dhcp_option_modifiers']; + $new_config['adv_dhcp_config_advanced'] = $pconfig['adv_dhcp_config_advanced']; + $new_config['adv_dhcp_config_file_override'] = $pconfig['adv_dhcp_config_file_override']; + $new_config['adv_dhcp_config_file_override_path'] = $pconfig['adv_dhcp_config_file_override_path']; + break; + case "ppp": + $new_config['if'] = $pconfig['type'] . $pconfig['ptpid']; + $new_config['ipaddr'] = $pconfig['type']; + $new_ppp_config['ptpid'] = $pconfig['ptpid']; + $new_ppp_config['type'] = $pconfig['type']; + $new_ppp_config['if'] = $pconfig['type'].$pconfig['ptpid']; + $new_ppp_config['ports'] = $pconfig['ports']; + $new_ppp_config['username'] = $pconfig['username']; + $new_ppp_config['password'] = base64_encode($pconfig['password']); + $new_ppp_config['phone'] = $pconfig['phone']; + $new_ppp_config['apn'] = $pconfig['apn']; + break; + case "pppoe": + $new_config['if'] = $pconfig['type'].$pconfig['ptpid']; + $new_config['ipaddr'] = $pconfig['type']; + $new_ppp_config['ptpid'] = $pconfig['ptpid']; + $new_ppp_config['type'] = $pconfig['type']; + $new_ppp_config['if'] = $pconfig['type'].$pconfig['ptpid']; + if (!empty($pconfig['ppp_port'])) { + $new_ppp_config['ports'] = $pconfig['ppp_port']; + } else { + $new_ppp_config['ports'] = $old_config['if']; + } + $new_ppp_config['username'] = $pconfig['pppoe_username']; + $new_ppp_config['password'] = base64_encode($pconfig['pppoe_password']); + if (!empty($pconfig['provider'])) { + $new_ppp_config['provider'] = $pconfig['provider']; + } else { + $new_ppp_config['provider'] = true; + } + $new_ppp_config['ondemand'] = !empty($pconfig['pppoe_dialondemand']); + if (!empty($pconfig['pppoe_idletimeout'])) { + $new_ppp_config['idletimeout'] = $pconfig['pppoe_idletimeout']; + } + + if (!empty($pconfig['pppoe-reset-type'])) { + $new_ppp_config['pppoe-reset-type'] = $pconfig['pppoe-reset-type']; + } + break; + case "pptp": + case "l2tp": + $new_config['if'] = $pconfig['type'].$pconfig['ptpid']; + $new_config['ipaddr'] = $pconfig['type']; + $new_ppp_config['ptpid'] = $pconfig['ptpid']; + $new_ppp_config['type'] = $pconfig['type']; + $new_ppp_config['if'] = $pconfig['type'].$pconfig['ptpid']; + if (!empty($pconfig['ppp_port'])) { + $new_ppp_config['ports'] = $pconfig['ppp_port']; + } else { + $new_ppp_config['ports'] = $old_config['if']; + } + $new_ppp_config['username'] = $pconfig['pptp_username']; + $new_ppp_config['password'] = base64_encode($pconfig['pptp_password']); + $new_ppp_config['localip'] = $pconfig['localip']; + $new_ppp_config['subnet'] = $pconfig['pptp_subnet']; + $new_ppp_config['gateway'] = $pconfig['pptp_remote']; + $new_ppp_config['ondemand'] = !empty($pconfig['pptp_dialondemand']); + if (!empty($pconfig['pptp_idletimeout'])) { + $new_ppp_config['idletimeout'] = $pconfig['pptp_idletimeout']; + } + break; + } + + // switch ipv6 config by type + switch($pconfig['type6']) { + case "staticv6": + $new_config['ipaddrv6'] = $pconfig['ipaddrv6']; + $new_config['subnetv6'] = $pconfig['subnetv6']; + if ($pconfig['gatewayv6'] != "none") { + $new_config['gatewayv6'] = $pconfig['gatewayv6']; + } + break; + case "slaac": + $new_config['ipaddrv6'] = "slaac"; + break; + case "dhcp6": + $new_config['ipaddrv6'] = "dhcp6"; + $new_config['dhcp6-ia-pd-len'] = $pconfig['dhcp6-ia-pd-len']; + if (!empty($pconfig['dhcp6-ia-pd-send-hint'])) { + $new_config['dhcp6-ia-pd-send-hint'] = true; + } + if (!empty($new_config['dhcp6prefixonly'])) { + $new_config['dhcp6prefixonly'] = true; + } + if (!empty($pconfig['dhcp6usev4iface'])) { + $new_config['dhcp6usev4iface'] = true; + } + $new_config['adv_dhcp6_interface_statement_send_options'] = $pconfig['adv_dhcp6_interface_statement_send_options']; + $new_config['adv_dhcp6_interface_statement_request_options'] = $pconfig['adv_dhcp6_interface_statement_request_options']; + $new_config['adv_dhcp6_interface_statement_information_only_enable'] = $pconfig['adv_dhcp6_interface_statement_information_only_enable']; + $new_config['adv_dhcp6_interface_statement_script'] = $pconfig['adv_dhcp6_interface_statement_script']; + $new_config['adv_dhcp6_id_assoc_statement_address_enable'] = $pconfig['adv_dhcp6_id_assoc_statement_address_enable']; + $new_config['adv_dhcp6_id_assoc_statement_address'] = $pconfig['adv_dhcp6_id_assoc_statement_address']; + $new_config['adv_dhcp6_id_assoc_statement_address_id'] = $pconfig['adv_dhcp6_id_assoc_statement_address_id']; + $new_config['adv_dhcp6_id_assoc_statement_address_pltime'] = $pconfig['adv_dhcp6_id_assoc_statement_address_pltime']; + $new_config['adv_dhcp6_id_assoc_statement_address_vltime'] = $pconfig['adv_dhcp6_id_assoc_statement_address_vltime']; + $new_config['adv_dhcp6_id_assoc_statement_prefix_enable'] = $pconfig['adv_dhcp6_id_assoc_statement_prefix_enable']; + $new_config['adv_dhcp6_id_assoc_statement_prefix'] = $pconfig['adv_dhcp6_id_assoc_statement_prefix']; + $new_config['adv_dhcp6_id_assoc_statement_prefix_id'] = $pconfig['adv_dhcp6_id_assoc_statement_prefix_id']; + $new_config['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime']; + $new_config['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime']; + $new_config['adv_dhcp6_prefix_interface_statement_sla_id'] = $pconfig['adv_dhcp6_prefix_interface_statement_sla_id']; + $new_config['adv_dhcp6_prefix_interface_statement_sla_len'] = $pconfig['adv_dhcp6_prefix_interface_statement_sla_len']; + $new_config['adv_dhcp6_authentication_statement_authname'] = $pconfig['adv_dhcp6_authentication_statement_authname']; + $new_config['adv_dhcp6_authentication_statement_protocol'] = $pconfig['adv_dhcp6_authentication_statement_protocol']; + $new_config['adv_dhcp6_authentication_statement_algorithm'] = $pconfig['adv_dhcp6_authentication_statement_algorithm']; + $new_config['adv_dhcp6_authentication_statement_rdm'] = $pconfig['adv_dhcp6_authentication_statement_rdm']; + $new_config['adv_dhcp6_key_info_statement_keyname'] = $pconfig['adv_dhcp6_key_info_statement_keyname']; + $new_config['adv_dhcp6_key_info_statement_realm'] = $pconfig['adv_dhcp6_key_info_statement_realm']; + $new_config['adv_dhcp6_key_info_statement_keyid'] = $pconfig['adv_dhcp6_key_info_statement_keyid']; + $new_config['adv_dhcp6_key_info_statement_secret'] = $pconfig['adv_dhcp6_key_info_statement_secret']; + $new_config['adv_dhcp6_key_info_statement_expire'] = $pconfig['adv_dhcp6_key_info_statement_expire']; + $new_config['adv_dhcp6_config_advanced'] = $pconfig['adv_dhcp6_config_advanced']; + $new_config['adv_dhcp6_config_file_override'] = $pconfig['adv_dhcp6_config_file_override']; + $new_config['adv_dhcp6_config_file_override_path'] = $pconfig['adv_dhcp6_config_file_override_path']; + break; + case "6rd": + $new_config['ipaddrv6'] = "6rd"; + $new_config['prefix-6rd'] = $pconfig['prefix-6rd']; + $new_config['prefix-6rd-v4plen'] = $pconfig['prefix-6rd-v4plen']; + $new_config['gateway-6rd'] = $pconfig['gateway-6rd']; + break; + case "6to4": + $new_config['ipaddrv6'] = "6to4"; + break; + case "track6": + $new_config['ipaddrv6'] = "track6"; + $new_config['track6-interface'] = $pconfig['track6-interface']; + $new_config['track6-prefix-id'] = 0; + if (is_numeric("0x" . $pconfig['track6-prefix-id--hex'])) { + $new_config['track6-prefix-id'] = intval($pconfig['track6-prefix-id--hex'], 16); + } + break; + } + + // wireless + if (isset($new_config['wireless'])) { + $new_config['wireless']['wpa'] = array(); + $new_config['wireless']['wme'] = array(); + $new_config['wireless']['wep'] = array(); + $new_config['wireless']['hidessid'] = array(); + $new_config['wireless']['pureg'] = array(); + $new_config['wireless']['puren'] = array(); + $new_config['wireless']['standard'] = $pconfig['standard']; + $new_config['wireless']['mode'] = $pconfig['mode']; + $new_config['wireless']['protmode'] = $pconfig['protmode']; + $new_config['wireless']['ssid'] = $pconfig['ssid']; + $new_config['wireless']['hidessid']['enable'] = !empty($pconfig['hidessid_enable']); + $new_config['wireless']['channel'] = $pconfig['channel']; + $new_config['wireless']['authmode'] = $pconfig['authmode']; + $new_config['wireless']['txpower'] = $pconfig['txpower']; + $new_config['wireless']['distance'] = $pconfig['distance']; + $new_config['wireless']['regdomain'] = $pconfig['regdomain']; + $new_config['wireless']['regcountry'] = $pconfig['regcountry']; + $new_config['wireless']['reglocation'] = $pconfig['reglocation']; + if (!empty($pconfig['regcountry']) && !empty($pconfig['reglocation'])) { + foreach($wl_countries_attr as $wl_country) { + if ($pconfig['regcountry'] == $wl_country['ID']) { + $new_config['wireless']['regdomain'] = $wl_country['rd'][0]['REF']; + break; + } + } + } + if (isset($pconfig['diversity']) && is_numeric($pconfig['diversity'])) { + $new_config['wireless']['diversity'] = $pconfig['diversity']; + } elseif (isset($new_config['wireless']['diversity'])) { + unset($new_config['wireless']['diversity']); + } + if (isset($pconfig['txantenna']) && is_numeric($pconfig['txantenna'])) { + $new_config['wireless']['txantenna'] = $pconfig['txantenna']; + } elseif (isset($new_config['wireless']['txantenna'])) { + unset($new_config['wireless']['txantenna']); + } + if (isset($pconfig['rxantenna']) && is_numeric($pconfig['rxantenna'])) { + $new_config['wireless']['rxantenna'] = $_POST['rxantenna']; + } elseif (isset($new_config['wireless']['rxantenna'])) { + unset($new_config['wireless']['rxantenna']); + } + $new_config['wireless']['wpa']['macaddr_acl'] = $pconfig['macaddr_acl']; + $new_config['wireless']['wpa']['auth_algs'] = $pconfig['auth_algs']; + $new_config['wireless']['wpa']['wpa_mode'] = $pconfig['wpa_mode']; + $new_config['wireless']['wpa']['wpa_key_mgmt'] = $pconfig['wpa_key_mgmt']; + $new_config['wireless']['wpa']['wpa_pairwise'] = $pconfig['wpa_pairwise']; + $new_config['wireless']['wpa']['wpa_group_rekey'] = $pconfig['wpa_group_rekey']; + $new_config['wireless']['wpa']['wpa_gmk_rekey'] = $pconfig['wpa_gmk_rekey']; + $new_config['wireless']['wpa']['passphrase'] = $pconfig['passphrase']; + $new_config['wireless']['wpa']['ext_wpa_sw'] = $pconfig['ext_wpa_sw']; + $new_config['wireless']['wpa']['mac_acl_enable'] = !empty($pconfig['mac_acl_enable']); + $new_config['wireless']['wpa']['rsn_preauth'] = !empty($pconfig['rsn_preauth']); + $new_config['wireless']['wpa']['ieee8021x']['enable'] = !empty($pconfig['ieee8021x']); + $new_config['wireless']['wpa']['wpa_strict_rekey'] = !empty($pconfig['wpa_strict_rekey']); + $new_config['wireless']['wpa']['debug_mode'] = !empty($pconfig['debug_mode']); + $new_config['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = !empty($pconfig['wpa_enable']); + + $new_config['wireless']['auth_server_addr'] = $pconfig['auth_server_addr']; + $new_config['wireless']['auth_server_port'] = $pconfig['auth_server_port']; + $new_config['wireless']['auth_server_shared_secret'] = $pconfig['auth_server_shared_secret']; + $new_config['wireless']['auth_server_addr2'] = $pconfig['auth_server_addr2']; + $new_config['wireless']['auth_server_port2'] = $pconfig['auth_server_port2']; + $new_config['wireless']['auth_server_shared_secret2'] = $pconfig['auth_server_shared_secret2']; + + $new_config['wireless']['wep']['enable'] = !empty($pconfig['wep_enable']); + $new_config['wireless']['wme']['enable'] = !empty($pconfig['wme_enable']); + + $new_config['wireless']['pureg']['enable'] = !empty($pconfig['puremode']) && $pconfig['puremode'] == "11g"; + $new_config['wireless']['puren']['enable'] = !empty($pconfig['puremode']) && $pconfig['puremode'] == "11n"; + $new_config['wireless']['apbridge']['enable'] = !empty($pconfig['apbridge_enable']) ; + $new_config['wireless']['turbo']['enable'] = $pconfig['standard'] == "11g Turbo" || $pconfig['standard'] == "11a Turbo"; + + $new_config['wireless']['wep']['key'] = array(); + for ($i = 1; $i <= 4; $i++) { + if (!empty($pconfig['key' . $i])) { + $newkey = array(); + $newkey['value'] = $pconfig['key' . $i]; + if ($pconfig['txkey'] == $i) { + $newkey['txkey'] = true; + } + $new_config['wireless']['wep']['key'][] = $newkey; + } + } + + // todo: it's probably better to choose one place to store wireless data + // this construction implements a lot of weirness (more info interface_sync_wireless_clones) + $wlanbaseif = interface_get_wireless_base($a_interfaces[$if]['if']); + if (!empty($pconfig['persistcommonwireless'])) { + if (!isset($config['wireless']) || !is_array($config['wireless'])) { + $config['wireless'] = array(); + } + if (!isset($config['wireless']['interfaces']) || !is_array($config['wireless']['interfaces'])) { + $config['wireless']['interfaces'] = array(); + } + if (empty($config['wireless']['interfaces'][$wlanbaseif])) { + $config['wireless']['interfaces'][$wlanbaseif] = array(); + } + } else if (isset($config['wireless']['interfaces'][$wlanbaseif])) { + unset($config['wireless']['interfaces'][$wlanbaseif]); + } + + // quite obscure this... copies parts of the config + interface_sync_wireless_clones($new_config, true); + } + + if (count($new_ppp_config) > 0) { + // ppp details changed + $a_ppps[$pppid] = $new_ppp_config; + } elseif (!empty($a_ppps[$pppid])) { + // ppp removed + $new_config['if'] = $a_ppps[$pppid]['ports']; + unset($a_ppps[$pppid]); + } + // save interface details + $a_interfaces[$if] = $new_config; + + if (!empty($old_config['ipaddr']) && $old_config['ipaddr'] == 'dhcp' && $new_config['ipaddr'] != 'dhcp') { + // change from dhcp to something else, kill dhclient + kill_dhclient_process($old_config['if']); + } + + if (!empty($old_config['ipaddrv6']) && $old_config['ipaddrv6'] == 'dhcp6' && $new_config['ipaddrv6'] != 'dhcp6') { + // change from dhcp to something else, kill dhcp6c + $pid = find_dhcp6c_process($old_config['if']); + if ($pid) { + exec('/bin/kill ' . $pid); + } + } + // yak... room for improvement here.... + handle_pppoe_reset($pconfig); + + // save to config + write_config(); + + // log changes for apply action + // (it would be better to diff the physical situation with the new config for changes) + if (file_exists('/tmp/.interfaces.apply')) { + $toapplylist = unserialize(file_get_contents('/tmp/.interfaces.apply')); + } else { + $toapplylist = array(); + } + $old_config['realif'] = get_real_interface($if); + $toapplylist[$if]['ifcfg'] = $old_config; + $toapplylist[$if]['ppps'] = $old_ppps; + + file_put_contents('/tmp/.interfaces.apply', serialize($toapplylist)); + + mark_subsystem_dirty('interfaces'); + + /* regenerate cron settings/crontab file */ + configure_cron(); + + header("Location: interfaces.php?if={$if}"); + exit; + } + } } -function check_wireless_mode() { - global $_POST, $config, $g, $wlan_modes, $wancfg, $if, $wlanif, $wlanbaseif, $old_wireless_mode, $input_errors; +legacy_html_escape_form_data($pconfig); - if ($wancfg['wireless']['mode'] == $_POST['mode']) - return; - - if (does_interface_exist(interface_get_wireless_clone($wlanbaseif))) - $clone_count = 1; - else - $clone_count = 0; - if (isset($config['wireless']['clone']) && is_array($config['wireless']['clone'])) { - foreach ($config['wireless']['clone'] as $clone) { - if ($clone['if'] == $wlanbaseif) - $clone_count++; - } - } - if ($clone_count > 1) { - $old_wireless_mode = $wancfg['wireless']['mode']; - $wancfg['wireless']['mode'] = $_POST['mode']; - if (!interface_wireless_clone("{$wlanif}_", $wancfg)) { - $input_errors[] = sprintf(gettext("Unable to change mode to %s. You may already have the maximum number of wireless clones supported in this mode."), $wlan_modes[$wancfg['wireless']['mode']]); - } else { - mwexec("/sbin/ifconfig " . escapeshellarg($wlanif) . "_ destroy"); - } - $wancfg['wireless']['mode'] = $old_wireless_mode; - } -} // Find all possible media options for the interface $mediaopts_list = array(); -$intrealname = $config['interfaces'][$if]['if']; -exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts); +exec("/sbin/ifconfig -m {$pconfig['if']} | grep \"media \"", $mediaopts); foreach ($mediaopts as $mediaopt){ - preg_match("/media (.*)/", $mediaopt, $matches); - if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){ - // there is media + mediaopt like "media 1000baseT mediaopt full-duplex" - array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]); - }else{ - // there is only media like "media 1000baseT" - array_push($mediaopts_list, $matches[1]); - } + preg_match("/media (.*)/", $mediaopt, $matches); + if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){ + // there is media + mediaopt like "media 1000baseT mediaopt full-duplex" + array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]); + } else { + // there is only media like "media 1000baseT" + array_push($mediaopts_list, $matches[1]); + } } $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")); -$types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), "dhcp6" => gettext("DHCPv6"), "slaac" => gettext("SLAAC"), "6rd" => gettext("6rd Tunnel"), "6to4" => gettext("6to4 Tunnel"), "track6" => gettext("Track Interface")); ?> @@ -1634,2145 +1342,2049 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"), + - - -
-
-
- - 0) print_input_errors($input_errors); ?> -

- ".gettext("You must apply the changes in order for them to take effect.")."
".gettext("Don't forget to adjust the DHCP Server range if needed after applying."));?> - - - -

- -
- -
-
- -
- - - - - - - - - - - - - -
- onclick="show_allcfg(this);" /> - -
-
-
- - - - - - - - -
-   - -
- " /> - " onclick="window.location.href=''" /> - - - - - -
-
-
-
-
-
-
-
-
- - - +
+
+
+ 0) { + print_input_errors($input_errors) ; + } + if (is_subsystem_dirty('interfaces')) { + print_info_box_apply(sprintf(gettext("The %s configuration has been changed."),$pconfig['descr'])."
".gettext("You must apply the changes in order for them to take effect.")."
".gettext("Don't forget to adjust the DHCP Server range if needed after applying.")); + } + if (isset($savemsg)) { + print_info_box($savemsg); + } +?> +
+
+
+
+
+ + + + + + + + + +
+ + +
+ /> + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + 0):?> + + + + + +
+ + +
+ +
+ +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ + +
+ + + + + +
+ + + + +
+
+ + +
+ : + : + : + : + : + : +
+
+
+ + + + +
+ +
+ +
+ + +
+ + + +
+ + + +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ /> + +
+ /> + +
+ + +
+ /> + +
+ /> +
+ +
+
+ + +
+
+
+ + +
+
+
+ + +
+ /> + + +
+ /> + + +
+ + sla-id"); ?> + + sla-len"); ?> + +
+ authname"); ?> + + protocol"); ?> + + algorithm"); ?> + + rdm"); ?> + +
+ keyname"); ?> + + realm"); ?> + +
+ keyid"); ?> + + secret"); ?> + + expire"); ?> + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ +
+
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ /> +
+ +
+ + +
+ + + + + + + +
+ +   +
+
" id="pppoecustomwrap"> + +
+ +
+ "*" && $pconfig['pppoe_resetmonth'] <> "*") { + $pconfig['pppoe_resetdate'] = "{$pconfig['pppoe_resetmonth']}/{$pconfig['pppoe_resetmday']}/" . date("Y"); + } + ?> + + + +
+
" id="pppoepresetwrap"> + + /> + +
+ /> + +
+ /> + +
+ /> + +

+
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + / + +
+ +
+ /> +
+ +
+
+
+ + + + + . +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ /> + +
+ +
802.11g OFDM + + +
+ + +
+ + +
+ + + + + + + + + + + + +
+
+ +
   +
+ +
   +
+ +
+ +
+ + +
+
+ + + +

+
+ +
+ +

+
+ +

+ +
+ +
+ + +
+ + +
+ /> + +
+ /> + +
+ /> + +
+ /> + +
+ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    
   + + + /> +
   + + + /> +
   + + + /> +
   + + + /> +
+
+
+ +
+ /> + +

+ + + + + + + + + +
   
   + +
+
+
+ +
+ +
+ +

+
+ +
+ " /> +
+
+ " /> +
+
+ /> +
+
+ /> +
+
: +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
802.1X + /> +
+
  + + /> +
+ +    +
  + /> +
+    + +

+ Advanced Firewall/NAT settings.")?> +
+
+ + + + + + +
+   + +
+ " /> + " onclick="window.location.href=''" /> + + + + + +
+
+
+
+
+
+
+
+
+ + +