From fa71a9b6544832d1babaaf8758a705e8cf9a9bc9 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Thu, 11 Feb 2010 02:49:00 -0700 Subject: [PATCH 01/29] Use different interface names and BSSID's for wireless clones. --- etc/inc/interfaces.inc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 5fc6ddd0f2..68c4d2d018 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1353,19 +1353,26 @@ function interface_wireless_clone($realif, $wlcfg) { $mode = ""; break; } + if(!stristr($wlcfg['if'], "_wlan")) { + $baseif = $wlcfg['if']; + $bssid = ""; + } else { + $baseif = substr($wlcfg['if'], 0, stripos($wlcfg['if'], "_wlan")); + $bssid = "bssid"; + } if(does_interface_exist($realif)) { exec("/sbin/ifconfig {$realif}", $output, $ret); $ifconfig_str = implode($output); if(($wlcfg['wireless']['mode'] == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) { - log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to hostap mode"); + log_error("Interface {$realif} changed to hostap mode"); $needs_clone = true; } if(($wlcfg['wireless']['mode'] == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) { - log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to adhoc mode"); + log_error("Interface {$realif} changed to adhoc mode"); $needs_clone = true; } if(($wlcfg['wireless']['mode'] == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) { - log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to infrastructure mode"); + log_error("Interface {$realif} changed to infrastructure mode"); $needs_clone = true; } } else { @@ -1380,15 +1387,15 @@ function interface_wireless_clone($realif, $wlcfg) { log_error("Cloning new wireless interface {$realif}"); // Create the new wlan interface. FreeBSD returns the new interface name. // example: wlan2 - exec("/sbin/ifconfig wlan create wlandev {$wlcfg['if']} {$mode} 2>&1", $out, $ret); + exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} {$bssid} 2>&1", $out, $ret); if($ret <> 0) { - log_error("Failed to clone interface {$wlcfg['if']} with error code {$ret}, output {$out[0]}"); + log_error("Failed to clone interface {$baseif} with error code {$ret}, output {$out[0]}"); } $newif = trim($out[0]); // Rename the interface to {$parentnic}_wlan{$number}#: EX: ath0_wlan0 mwexec("/sbin/ifconfig {$newif} name {$realif} 2>&1", false); // FIXME: not sure what ngctl is for. Doesn't work. - // mwexec("/usr/sbin/ngctl name {$newif}: {$wlcfg['if']}_wlan{$interface_num}", false); + // mwexec("/usr/sbin/ngctl name {$newif}: {$realif}", false); } } @@ -2381,11 +2388,11 @@ function get_real_interface($interface = "wan") { // interface name format: $parentnic_wlanparentnic# // example: ath0_wlan0 if(is_interface_wireless($cfg['if'])) { - if ($interface == "wan") - $interface_num = 0; - else - $interface_num = substr($interface, 3); - $wanif = $cfg['if'] . "_wlan" . $interface_num; + if(!stristr($cfg['if'], "_wlan")) { + $wanif = $cfg['if'] . "_wlan0"; + } else { + $wanif = $cfg['if']; + } break; } From 5636c533fe9e5e4502ab75f2d51bca94830db18a Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Thu, 11 Feb 2010 03:06:13 -0700 Subject: [PATCH 02/29] Allow secondary wireless clones in interface list. --- etc/inc/util.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 559a3bc1ea..2ad1dddf93 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -539,7 +539,7 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") $ifname = rtrim(trim($alink[0]), '*'); /* trim out all numbers before checking for vfaces */ if (!in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces) && - !stristr($ifname, "_vlan") && !stristr($ifname, "_wlan")) { + !stristr($ifname, "_vlan") && !stristr($ifname, "_wlan0")) { $toput = array( "mac" => trim($alink[1]), "up" => in_array($ifname, $upints) From 298d6b080d1319d9eb0189c843c0977577a94c94 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Thu, 11 Feb 2010 03:32:21 -0700 Subject: [PATCH 03/29] For now, don't count any wireless clones as mismatches unless the base interface doesn't exist. --- etc/inc/util.inc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 2ad1dddf93..14c54dbbc0 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -961,10 +961,16 @@ function is_interface_mismatch() { if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan/i", $ifcfg['if'])) { $i++; } - else if (does_interface_exist($ifcfg['if']) == false) { - $do_assign = true; - } else - $i++; + else { + $baseif = $ifcfg['if']; + if(stristr($baseif, "_wlan")) { + $baseif = substr($baseif, 0, stripos($baseif, "_wlan")); + } + if (does_interface_exist($ifcfg['if']) == false) { + $do_assign = true; + } else + $i++; + } } if ($g['minimum_nic_count'] > $i) { From 6d54e8650338872eb0ebafe720a9ef3181337d5c Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sat, 13 Feb 2010 18:32:25 -0700 Subject: [PATCH 04/29] Missing a part of the last change. Also use bssid for the first wireless clone. --- etc/inc/interfaces.inc | 4 +--- etc/inc/util.inc | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 68c4d2d018..77d25a6a3b 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1355,10 +1355,8 @@ function interface_wireless_clone($realif, $wlcfg) { } if(!stristr($wlcfg['if'], "_wlan")) { $baseif = $wlcfg['if']; - $bssid = ""; } else { $baseif = substr($wlcfg['if'], 0, stripos($wlcfg['if'], "_wlan")); - $bssid = "bssid"; } if(does_interface_exist($realif)) { exec("/sbin/ifconfig {$realif}", $output, $ret); @@ -1387,7 +1385,7 @@ function interface_wireless_clone($realif, $wlcfg) { log_error("Cloning new wireless interface {$realif}"); // Create the new wlan interface. FreeBSD returns the new interface name. // example: wlan2 - exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} {$bssid} 2>&1", $out, $ret); + exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} bssid 2>&1", $out, $ret); if($ret <> 0) { log_error("Failed to clone interface {$baseif} with error code {$ret}, output {$out[0]}"); } diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 14c54dbbc0..cbacb3c1da 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -966,7 +966,7 @@ function is_interface_mismatch() { if(stristr($baseif, "_wlan")) { $baseif = substr($baseif, 0, stripos($baseif, "_wlan")); } - if (does_interface_exist($ifcfg['if']) == false) { + if (does_interface_exist($baseif) == false) { $do_assign = true; } else $i++; From fa13098bf03f83abb3279f3d8885108c8d3b64a7 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 03:57:54 -0700 Subject: [PATCH 05/29] Workaround for a hostapd bug that it uses the base interface's MAC instead of the clone's BSSID, preventing proper authorization on auxillary clones. --- etc/inc/interfaces.inc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 77d25a6a3b..00654c07ef 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1622,7 +1622,23 @@ EOD; fwrite($fd_set, "{$wpa_supplicant} -B -i {$if} -c {$g['varetc_path']}/wpa_supplicant_{$if}.conf\n"); } if ($wlcfg['mode'] == "hostap") { + $baseif = substr($if, 0, stripos($if, "_wlan")); + $baseif_mac = get_interface_mac($baseif); + $if_bssid = get_interface_bssid($if); + if(!is_macaddr($if_bssid)) { + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up"); + $if_bssid = get_interface_bssid($if); + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " down"); + } + if(!is_macaddr($if_bssid)) { + $if_bssid = baseif_mac; + } + /* XXX: Workaround because hostapd won't properly detect BSSID of + * clone interfaces and uses base interface's MAC instead + * wpa_supplicant may also need this, but that needs to be tested */ + fwrite($fd_set, "/sbin/ifconfig {$baseif} ether {$if_bssid}\n"); fwrite($fd_set, "{$hostapd} -B {$g['varetc_path']}/hostapd_{$if}.conf\n"); + fwrite($fd_set, "/sbin/ifconfig {$baseif} ether {$baseif_mac}\n"); } } @@ -2886,6 +2902,16 @@ function get_interface_mac($interface) { } } +function get_interface_bssid($interface) { + $mac = array(); + exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print $2}'", $mac); + if(is_macaddr($mac[0])) { + return trim($mac[0]); + } else { + return ""; + } +} + /****f* pfsense-utils/generate_random_mac_address * NAME * generate_random_mac - generates a random mac address From f27958f0b26d7610fb52742b52aee07b00cceee2 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 04:42:44 -0700 Subject: [PATCH 06/29] Fix code for getting the BSSID. --- etc/inc/interfaces.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 00654c07ef..92a89d049b 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1631,7 +1631,7 @@ EOD; mwexec("/sbin/ifconfig " . escapeshellarg($if) . " down"); } if(!is_macaddr($if_bssid)) { - $if_bssid = baseif_mac; + $if_bssid = $baseif_mac; } /* XXX: Workaround because hostapd won't properly detect BSSID of * clone interfaces and uses base interface's MAC instead @@ -2904,7 +2904,7 @@ function get_interface_mac($interface) { function get_interface_bssid($interface) { $mac = array(); - exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print $2}'", $mac); + exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print $NF}'", $mac); if(is_macaddr($mac[0])) { return trim($mac[0]); } else { From 636fd99ec4e0d51d8e0118b917ef328187ce5d6d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 05:12:04 -0700 Subject: [PATCH 07/29] Forgot to escape the $ --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 92a89d049b..6aab4a5b66 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -2904,7 +2904,7 @@ function get_interface_mac($interface) { function get_interface_bssid($interface) { $mac = array(); - exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print $NF}'", $mac); + exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print \$NF}'", $mac); if(is_macaddr($mac[0])) { return trim($mac[0]); } else { From eaa822f5cb870834c9c70a3d59a05c583f9cf102 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 05:37:59 -0700 Subject: [PATCH 08/29] Get the BSSID when the interface is up. --- etc/inc/interfaces.inc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 6aab4a5b66..c3347262aa 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1624,12 +1624,9 @@ EOD; if ($wlcfg['mode'] == "hostap") { $baseif = substr($if, 0, stripos($if, "_wlan")); $baseif_mac = get_interface_mac($baseif); + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up"); $if_bssid = get_interface_bssid($if); - if(!is_macaddr($if_bssid)) { - mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up"); - $if_bssid = get_interface_bssid($if); - mwexec("/sbin/ifconfig " . escapeshellarg($if) . " down"); - } + mwexec("/sbin/ifconfig " . escapeshellarg($if) . " down"); if(!is_macaddr($if_bssid)) { $if_bssid = $baseif_mac; } From 6e76b8ee135b3d46d155d139b87f539257f0e4ba Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 06:07:54 -0700 Subject: [PATCH 09/29] Configure and bring up the interface before getting the BSSID instead of bringing it up separately. --- etc/inc/interfaces.inc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index c3347262aa..40ce3931a7 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1617,6 +1617,10 @@ EOD; $standard_no_turbo = str_replace(" Turbo", "", $standard); + /* configure wireless */ + $wlcmd_args = implode(" ", $wlcmd); + mwexec("/sbin/ifconfig {$if} $wlcmd_args", false); + if (isset($wlcfg['wpa']['enable'])) { if ($wlcfg['mode'] == "bss") { fwrite($fd_set, "{$wpa_supplicant} -B -i {$if} -c {$g['varetc_path']}/wpa_supplicant_{$if}.conf\n"); @@ -1624,9 +1628,7 @@ EOD; if ($wlcfg['mode'] == "hostap") { $baseif = substr($if, 0, stripos($if, "_wlan")); $baseif_mac = get_interface_mac($baseif); - mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up"); $if_bssid = get_interface_bssid($if); - mwexec("/sbin/ifconfig " . escapeshellarg($if) . " down"); if(!is_macaddr($if_bssid)) { $if_bssid = $baseif_mac; } @@ -1642,10 +1644,6 @@ EOD; fclose($fd_set); conf_mount_ro(); - /* configure wireless */ - $wlcmd_args = implode(" ", $wlcmd); - mwexec("/sbin/ifconfig {$if} $wlcmd_args", false); - sleep(1); /* execute hostapd and wpa_supplicant if required in shell */ From 79f34b1f7864670cb6c1516668442b4ca4d52386 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 06:31:25 -0700 Subject: [PATCH 10/29] Use clone interface's MAC instead of BSSID if the BSSID could not be determined. --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 40ce3931a7..9b6ef829aa 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1630,7 +1630,7 @@ EOD; $baseif_mac = get_interface_mac($baseif); $if_bssid = get_interface_bssid($if); if(!is_macaddr($if_bssid)) { - $if_bssid = $baseif_mac; + $if_bssid = get_interface_mac($if); } /* XXX: Workaround because hostapd won't properly detect BSSID of * clone interfaces and uses base interface's MAC instead From 9485e547e71eb08b3bc703632520ed74b07ec70a Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Sun, 14 Feb 2010 06:38:45 -0700 Subject: [PATCH 11/29] Add slight delay before trying to get BSSID. --- etc/inc/interfaces.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 9b6ef829aa..ef3e16b73d 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1628,6 +1628,7 @@ EOD; if ($wlcfg['mode'] == "hostap") { $baseif = substr($if, 0, stripos($if, "_wlan")); $baseif_mac = get_interface_mac($baseif); + sleep(1); $if_bssid = get_interface_bssid($if); if(!is_macaddr($if_bssid)) { $if_bssid = get_interface_mac($if); From 9f428275e9b9ed3a978d6c8224b76b1f8ce37d62 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 15 Feb 2010 01:44:25 -0700 Subject: [PATCH 12/29] Add page for configuration of wireless clone interfaces. --- etc/inc/interfaces.inc | 38 +++- etc/inc/xmlparse.inc | 8 +- etc/inc/xmlreader.inc | 8 +- usr/local/www/interfaces_wireless.php | 146 +++++++++++++++ usr/local/www/interfaces_wireless_edit.php | 203 +++++++++++++++++++++ 5 files changed, 391 insertions(+), 12 deletions(-) create mode 100644 usr/local/www/interfaces_wireless.php create mode 100644 usr/local/www/interfaces_wireless_edit.php diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index ef3e16b73d..276944d777 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -279,6 +279,27 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) { return $vlanif; } +function interfaces_create_wireless_clones() { + global $config; + + if($g['booting']) + echo "Creating other wireless clone interfaces..."; + if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) { + foreach ($config['wireless']['clone'] as $clone) { + if(empty($clone['cloneif'])) + continue; + if(does_interface_exist($clone['cloneif'])) + continue; + /* XXX: Maybe we should report any errors?! */ + if(interface_wireless_clone($clone['cloneif'], $clone)) + if($g['booting']) + echo " " . $clone['cloneif']; + } + } + if($g['booting']) + echo " done.\n"; +} + function interfaces_bridge_configure() { global $config; @@ -695,6 +716,9 @@ function interfaces_configure() { } } + /* create the unconfigured wireless clones */ + interfaces_create_wireless_clones(); + /* set up GRE virtual interfaces */ interfaces_gre_configure(); @@ -1342,7 +1366,11 @@ function interface_wireless_clone($realif, $wlcfg) { * If it has not been cloned then go ahead and clone it. */ $needs_clone = false; - switch($wlcfg['wireless']['mode']) { + if(is_array($wlcfg['wireless'])) + $wlcfg_mode = $wlcfg['wireless']['mode']; + else + $wlcfg_mode = $wlcfg['mode']; + switch($wlcfg_mode) { case "hostap": $mode = "wlanmode hostap"; break; @@ -1361,15 +1389,15 @@ function interface_wireless_clone($realif, $wlcfg) { if(does_interface_exist($realif)) { exec("/sbin/ifconfig {$realif}", $output, $ret); $ifconfig_str = implode($output); - if(($wlcfg['wireless']['mode'] == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) { + if(($wlcfg_mode == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) { log_error("Interface {$realif} changed to hostap mode"); $needs_clone = true; } - if(($wlcfg['wireless']['mode'] == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) { + if(($wlcfg_mode == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) { log_error("Interface {$realif} changed to adhoc mode"); $needs_clone = true; } - if(($wlcfg['wireless']['mode'] == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) { + if(($wlcfg_mode == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) { log_error("Interface {$realif} changed to infrastructure mode"); $needs_clone = true; } @@ -1388,6 +1416,7 @@ function interface_wireless_clone($realif, $wlcfg) { exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} bssid 2>&1", $out, $ret); if($ret <> 0) { log_error("Failed to clone interface {$baseif} with error code {$ret}, output {$out[0]}"); + return false; } $newif = trim($out[0]); // Rename the interface to {$parentnic}_wlan{$number}#: EX: ath0_wlan0 @@ -1395,6 +1424,7 @@ function interface_wireless_clone($realif, $wlcfg) { // FIXME: not sure what ngctl is for. Doesn't work. // mwexec("/usr/sbin/ngctl name {$newif}: {$realif}", false); } + return true; } function interface_wireless_configure($if, &$wl, &$wlcfg) { diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index cb55117b2a..23ae588cac 100644 --- a/etc/inc/xmlparse.inc +++ b/etc/inc/xmlparse.inc @@ -36,10 +36,10 @@ function listtags() { * I know it's a pain, but it's a pain to find stuff too if it's not */ $ret = explode(" ", - "alias aliasurl allowedip authserver bridged ca cacert cert config container ". - "columnitem depends_on_package disk dnsserver dnsupdate domainoverrides ". - "dyndns earlyshellcmd element encryption-algorithm-option field ". - "fieldname hash-algorithm-option gateway_item gateway_group gif gre ". + "alias aliasurl allowedip authserver bridged ca cacert cert clone config ". + "container columnitem depends_on_package disk dnsserver dnsupdate ". + "domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ". + "field fieldname hash-algorithm-option gateway_item gateway_group gif gre ". "group hosts member ifgroupentry igmpentry interface_array item key lagg " . "lbaction lbpool l7rules lbprotocol ". "member menu tab mobilekey monitor_type mount ntpserver onetoone ". diff --git a/etc/inc/xmlreader.inc b/etc/inc/xmlreader.inc index 7627c4b130..dd6eb9a60b 100644 --- a/etc/inc/xmlreader.inc +++ b/etc/inc/xmlreader.inc @@ -40,10 +40,10 @@ function listtags() { * I know it's a pain, but it's a pain to find stuff too if it's not */ $ret = explode(" ", - "alias aliasurl allowedip authserver bridged ca cacert cert config container ". - "columnitem depends_on_package disk dnsserver dnsupdate domainoverrides ". - "dyndns earlyshellcmd element encryption-algorithm-option field ". - "fieldname hash-algorithm-option gateway_item gateway_group gif gre ". + "alias aliasurl allowedip authserver bridged ca cacert cert clone config ". + "container columnitem depends_on_package disk dnsserver dnsupdate ". + "domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ". + "field fieldname hash-algorithm-option gateway_item gateway_group gif gre ". "group hosts member ifgroupentry igmpentry interface_array item key lagg " . "lbaction lbpool l7rules lbprotocol ". "member menu tab mobilekey monitor_type mount ntpserver onetoone ". diff --git a/usr/local/www/interfaces_wireless.php b/usr/local/www/interfaces_wireless.php new file mode 100644 index 0000000000..562a005d45 --- /dev/null +++ b/usr/local/www/interfaces_wireless.php @@ -0,0 +1,146 @@ + + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
InterfaceModeDescription
+ + + + +   + +  
 

+ Note:
+
+ Here you can configure clones of wireless interfaces. +

 
+
+
+ + + diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php new file mode 100644 index 0000000000..58fa0c4e34 --- /dev/null +++ b/usr/local/www/interfaces_wireless_edit.php @@ -0,0 +1,203 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
Wireless clone configuration
Parent interface +
Mode +
Description + +
You may enter a description here + for your reference (not parsed).
  + + + + + +
+
+ + + From 79637b03ffd5fff43c5a15435c752f811b40cd29 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 15 Feb 2010 02:01:40 -0700 Subject: [PATCH 13/29] Add wireless tab to Interfaces: (assign) now that the configuration page is functional. --- usr/local/www/interfaces_assign.php | 15 ++++++++------- usr/local/www/interfaces_bridge.php | 15 ++++++++------- usr/local/www/interfaces_gif.php | 15 ++++++++------- usr/local/www/interfaces_gre.php | 15 ++++++++------- usr/local/www/interfaces_groups.php | 15 ++++++++------- usr/local/www/interfaces_lagg.php | 15 ++++++++------- usr/local/www/interfaces_ppp.php | 15 ++++++++------- usr/local/www/interfaces_qinq.php | 15 ++++++++------- usr/local/www/interfaces_vlan.php | 15 ++++++++------- 9 files changed, 72 insertions(+), 63 deletions(-) diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index 66cb0d0990..a2ca45a9f1 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -354,13 +354,14 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) $tab_array = array(); $tab_array[0] = array("Interface assignments", true, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_bridge.php b/usr/local/www/interfaces_bridge.php index 28060059de..d58771ec7b 100644 --- a/usr/local/www/interfaces_bridge.php +++ b/usr/local/www/interfaces_bridge.php @@ -88,13 +88,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", true, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", true, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_gif.php b/usr/local/www/interfaces_gif.php index 7fe6abd7e8..7704e92260 100644 --- a/usr/local/www/interfaces_gif.php +++ b/usr/local/www/interfaces_gif.php @@ -87,13 +87,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", true, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", true, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_gre.php b/usr/local/www/interfaces_gre.php index 9aca049e42..333ce35354 100644 --- a/usr/local/www/interfaces_gre.php +++ b/usr/local/www/interfaces_gre.php @@ -87,13 +87,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", true, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", true, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_groups.php b/usr/local/www/interfaces_groups.php index 9557ace5f5..65564ddcd9 100755 --- a/usr/local/www/interfaces_groups.php +++ b/usr/local/www/interfaces_groups.php @@ -73,13 +73,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", true, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_lagg.php b/usr/local/www/interfaces_lagg.php index a8ffd26121..e5ac41ad79 100644 --- a/usr/local/www/interfaces_lagg.php +++ b/usr/local/www/interfaces_lagg.php @@ -93,13 +93,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", true, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", true, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_ppp.php b/usr/local/www/interfaces_ppp.php index e40f87d03e..8e200d12f1 100644 --- a/usr/local/www/interfaces_ppp.php +++ b/usr/local/www/interfaces_ppp.php @@ -87,13 +87,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", true, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", true, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_qinq.php b/usr/local/www/interfaces_qinq.php index 84be902aee..fc88eab1bc 100755 --- a/usr/local/www/interfaces_qinq.php +++ b/usr/local/www/interfaces_qinq.php @@ -95,13 +95,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", false, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", true, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", false, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", true, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> diff --git a/usr/local/www/interfaces_vlan.php b/usr/local/www/interfaces_vlan.php index 5c71fab95d..b2322e921c 100755 --- a/usr/local/www/interfaces_vlan.php +++ b/usr/local/www/interfaces_vlan.php @@ -89,13 +89,14 @@ include("head.inc"); $tab_array = array(); $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); - $tab_array[2] = array("VLANs", true, "interfaces_vlan.php"); - $tab_array[3] = array("QinQs", false, "interfaces_qinq.php"); - $tab_array[4] = array("PPP", false, "interfaces_ppp.php"); - $tab_array[5] = array("GRE", false, "interfaces_gre.php"); - $tab_array[6] = array("GIF", false, "interfaces_gif.php"); - $tab_array[7] = array("Bridges", false, "interfaces_bridge.php"); - $tab_array[8] = array("LAGG", false, "interfaces_lagg.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", true, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); display_top_tabs($tab_array); ?> From 2a48a8853383bceafd25eb745900d15f184a9e12 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Fri, 19 Feb 2010 05:07:26 -0700 Subject: [PATCH 14/29] Revert "Workaround for a hostapd bug that it uses the base interface's MAC instead of the clone's BSSID, preventing proper authorization on auxillary clones." This reverts commit fa13098bf03f83abb3279f3d8885108c8d3b64a7 and subsequent related commits. --- etc/inc/interfaces.inc | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index c5a324e59c..c2b4bd1942 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1663,34 +1663,22 @@ EOD; $standard_no_turbo = str_replace(" Turbo", "", $standard); - /* configure wireless */ - $wlcmd_args = implode(" ", $wlcmd); - mwexec("/sbin/ifconfig {$if} $wlcmd_args", false); - if (isset($wlcfg['wpa']['enable'])) { if ($wlcfg['mode'] == "bss") { fwrite($fd_set, "{$wpa_supplicant} -B -i {$if} -c {$g['varetc_path']}/wpa_supplicant_{$if}.conf\n"); } if ($wlcfg['mode'] == "hostap") { - $baseif = substr($if, 0, stripos($if, "_wlan")); - $baseif_mac = get_interface_mac($baseif); - sleep(1); - $if_bssid = get_interface_bssid($if); - if(!is_macaddr($if_bssid)) { - $if_bssid = get_interface_mac($if); - } - /* XXX: Workaround because hostapd won't properly detect BSSID of - * clone interfaces and uses base interface's MAC instead - * wpa_supplicant may also need this, but that needs to be tested */ - fwrite($fd_set, "/sbin/ifconfig {$baseif} ether {$if_bssid}\n"); fwrite($fd_set, "{$hostapd} -B {$g['varetc_path']}/hostapd_{$if}.conf\n"); - fwrite($fd_set, "/sbin/ifconfig {$baseif} ether {$baseif_mac}\n"); } } fclose($fd_set); conf_mount_ro(); + /* configure wireless */ + $wlcmd_args = implode(" ", $wlcmd); + mwexec("/sbin/ifconfig {$if} $wlcmd_args", false); + sleep(1); /* execute hostapd and wpa_supplicant if required in shell */ @@ -2937,16 +2925,6 @@ function get_interface_mac($interface) { return $macinfo["macaddr"]; } -function get_interface_bssid($interface) { - $mac = array(); - exec("/sbin/ifconfig {$interface} | /usr/bin/awk '/bssid/ {print \$NF}'", $mac); - if(is_macaddr($mac[0])) { - return trim($mac[0]); - } else { - return ""; - } -} - /****f* pfsense-utils/generate_random_mac_address * NAME * generate_random_mac - generates a random mac address From 5e2ca757a9a1c8d636e7a179711f50de0519b4b3 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Fri, 19 Feb 2010 08:24:57 -0700 Subject: [PATCH 15/29] Don't allow changing the parent interface until this code supports deleting the old clone. --- usr/local/www/interfaces_wireless_edit.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php index 58fa0c4e34..2c3208a734 100644 --- a/usr/local/www/interfaces_wireless_edit.php +++ b/usr/local/www/interfaces_wireless_edit.php @@ -116,7 +116,8 @@ if ($_POST) { $input_errors[] = "This wireless clone cannot be modified because it is still being used as an interface."; else if ($clone['mode'] != $a_clones[$id]['mode']) $input_errors[] = "Use the configuration page for the assigned interface to change the mode."; - } + } else if ($clone['if'] != $a_clones[$id]['if']) + $input_errors[] = "Changing the parent interface is not currently supported. Create a new clone on the new parent and delete the old clone on the previous parent."; } if (!$input_errors) { if (!interface_wireless_clone($clone['cloneif'], $clone)) { From ce075a0fd4aa7eb0788f20233bf60706e4c77edf Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 22 Feb 2010 11:59:47 -0700 Subject: [PATCH 16/29] Don't skip disabled interfaces when checking which are assigned. --- usr/local/www/interfaces_wireless.php | 2 +- usr/local/www/interfaces_wireless_edit.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/www/interfaces_wireless.php b/usr/local/www/interfaces_wireless.php index 562a005d45..28312c31f2 100644 --- a/usr/local/www/interfaces_wireless.php +++ b/usr/local/www/interfaces_wireless.php @@ -48,7 +48,7 @@ $a_clones = &$config['wireless']['clone'] ; function clone_inuse($cloneif) { global $config; - $iflist = get_configured_interface_list(false, true); + $iflist = get_configured_interface_list(); foreach ($iflist as $if) { if ($config['interfaces'][$if]['if'] == $cloneif) return true; diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php index 2c3208a734..c0522c2d97 100644 --- a/usr/local/www/interfaces_wireless_edit.php +++ b/usr/local/www/interfaces_wireless_edit.php @@ -48,7 +48,7 @@ $a_clones = &$config['wireless']['clone']; function clone_inuse($cloneif) { global $config; - $iflist = get_configured_interface_list(false, true); + $iflist = get_configured_interface_list(); foreach ($iflist as $if) { if ($config['interfaces'][$if]['if'] == $cloneif) return true; From 8f0289e7ec338869f28467b748e27f580792b201 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 22 Feb 2010 13:08:09 -0700 Subject: [PATCH 17/29] Sync configuration of shared settings between wireless clones. --- etc/inc/interfaces.inc | 37 +++++++++++++++++++++++++++++ usr/local/www/interfaces.php | 4 ++++ usr/local/www/interfaces_assign.php | 4 +++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index c2b4bd1942..a387b1e6a6 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1427,6 +1427,40 @@ function interface_wireless_clone($realif, $wlcfg) { return true; } +function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) { + global $config, $g; + + $shared_settings = array('standard', 'turbo', 'protmode', 'channel', 'txpower'); + + if(!stristr($ifcfg['if'], "_wlan")) { + $baseif1 = $ifcfg['if']; + } else { + $baseif1 = substr($ifcfg['if'], 0, stripos($ifcfg['if'], "_wlan")); + } + + $iflist = get_configured_interface_list(); + foreach ($iflist as $if) { + if(!stristr($config['interfaces'][$if]['if'], "_wlan")) { + $baseif2 = $config['interfaces'][$if]['if']; + } else { + $baseif2 = substr($config['interfaces'][$if]['if'], 0, stripos($config['interfaces'][$if]['if'], "_wlan")); + } + if ($baseif1 != $baseif2) { + if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) { + foreach ($shared_settings as $setting) { + if ($sync_changes) { + $config['interfaces'][$if]['wireless'][$setting] = $ifcfg['wireless'][$setting]; + } else { + $ifcfg['wireless'][$setting] = $config['interfaces'][$if]['wireless'][$setting]; + } + } + if (!$sync_changes) + break; + } + } + } +} + function interface_wireless_configure($if, &$wl, &$wlcfg) { global $config, $g; @@ -1443,6 +1477,9 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) { // Clone wireless nic if needed. interface_wireless_clone($if, $wl); + // Reject inadvertent changes to shared settings in case the interface hasn't been configured. + interface_sync_wireless_clones($wl, false); + $fd_set = fopen("{$g['tmp_path']}/{$if}_setup.sh","w"); fwrite($fd_set, "#!/bin/sh\n"); fwrite($fd_set, "# {$g['product_name']} wireless configuration script.\n\n"); diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index a2a07ed3dd..16112a22a5 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -295,6 +295,9 @@ if ($_POST['apply']) { if ($_POST && $_POST['enable'] == "no") { unset($wancfg['enable']); interface_bring_down($if); + if (isset($wancfg['wireless'])) { + interface_sync_wireless_clones($wancfg, false); + } write_config("Interface {$_POST['descr']}({$if}) is now disabled."); mark_subsystem_dirty('interfaces'); header("Location: interfaces.php?if={$if}"); @@ -773,6 +776,7 @@ function handle_wireless_post() { $wancfg['wireless']['wep']['key'][] = $newkey; } } + interface_sync_wireless_clones($wancfg, true); } $pgtitle = array("Interfaces", $pconfig['descr']); diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index a2ca45a9f1..8e5cb05971 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -310,8 +310,10 @@ if ($_GET['act'] == "add") { } if (!$portused) { $config['interfaces'][$newifname]['if'] = $portname; - if (preg_match($g['wireless_regex'], $portname)) + if (preg_match($g['wireless_regex'], $portname)) { $config['interfaces'][$newifname]['wireless'] = array(); + interface_sync_wireless_clones($config['interfaces'][$newifname], false); + } break; } } From 7de319a159430fa2954789cd2572511bb8d90a08 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 22 Feb 2010 13:36:03 -0700 Subject: [PATCH 18/29] Make sure ['wireless'] does not get accessed as an array when it is not an array. --- etc/inc/interfaces.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index a387b1e6a6..718a6a11b7 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1432,6 +1432,9 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) { $shared_settings = array('standard', 'turbo', 'protmode', 'channel', 'txpower'); + if(!is_array($ifcfg['wireless'])) + return; + if(!stristr($ifcfg['if'], "_wlan")) { $baseif1 = $ifcfg['if']; } else { @@ -1445,7 +1448,7 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) { } else { $baseif2 = substr($config['interfaces'][$if]['if'], 0, stripos($config['interfaces'][$if]['if'], "_wlan")); } - if ($baseif1 != $baseif2) { + if ($baseif1 != $baseif2 && is_array($config['interfaces'][$if]['wireless'])) { if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) { foreach ($shared_settings as $setting) { if ($sync_changes) { From 658d28bfbb6e4c278c1f3d7374cf19e0831d60e0 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 22 Feb 2010 13:51:28 -0700 Subject: [PATCH 19/29] Part of the interface name comparison was wrong and part was missing. --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 718a6a11b7..4dc1aebcde 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1448,7 +1448,7 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) { } else { $baseif2 = substr($config['interfaces'][$if]['if'], 0, stripos($config['interfaces'][$if]['if'], "_wlan")); } - if ($baseif1 != $baseif2 && is_array($config['interfaces'][$if]['wireless'])) { + if ($baseif1 == $baseif2 && $ifcfg['if'] != $config['interfaces'][$if]['if']) { if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) { foreach ($shared_settings as $setting) { if ($sync_changes) { From b70138167bdeba1709342ccd785165232b0cdb3d Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 22 Feb 2010 23:54:41 -0700 Subject: [PATCH 20/29] Move shared wireless configuration settings to their own heading. --- usr/local/www/interfaces.php | 114 ++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 16112a22a5..e66055e0f4 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -215,6 +215,11 @@ if (isset($wancfg['wireless'])) { /* Get wireless modes */ $wlanif = get_real_interface($if); interface_wireless_clone($wlanif, $wancfg); + if(!stristr($wancfg['if'], "_wlan")) { + $wlanbaseif = $wancfg['if']; + } else { + $wlanbaseif = substr($wancfg['if'], 0, stripos($wancfg['if'], "_wlan")); + } $wl_modes = get_wireless_modes($if); $pconfig['standard'] = $wancfg['wireless']['standard']; $pconfig['mode'] = $wancfg['wireless']['mode']; @@ -1236,7 +1241,10 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" - Wireless configuration + Common wireless configuration + + + These settings apply to all wireless networks on . Standard @@ -1253,16 +1261,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" - - Mode - - - - 802.11g OFDM Protection Mode @@ -1275,6 +1273,61 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe" For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
+ + + Transmit power + +
+ Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value. Not all adaptors support changing the transmit power setting. + + + + Channel + + +
+ Note: Not all channels may be supported by your card + + + + + + + Wireless configuration + + + Mode + + + SSID @@ -1315,45 +1368,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
(this might create problems for some clients). - - Transmit power - -
- Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value. Not all adaptors support changing the transmit power setting. - - - - Channel - - -
- Note: Not all channels may be supported by your card - - Distance setting From 61f231c06fa98375ddfb6058dfc27dd01d06a7dc Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 00:13:50 -0700 Subject: [PATCH 21/29] Add more detail to the description on the Interfaces: Wireless page. --- usr/local/www/interfaces_wireless.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/interfaces_wireless.php b/usr/local/www/interfaces_wireless.php index 28312c31f2..06c698d49e 100644 --- a/usr/local/www/interfaces_wireless.php +++ b/usr/local/www/interfaces_wireless.php @@ -132,7 +132,7 @@ include("head.inc");

Note:
- Here you can configure clones of wireless interfaces. + Here you can configure clones of wireless interfaces, which can be assigned as separate independent interfaces. Only available on wireless chipsets that support this.   From 4a5e1d557942294f24d4d299a70c5937803bac30 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 00:22:46 -0700 Subject: [PATCH 22/29] Add note about limits on the number of wireless clones. --- usr/local/www/interfaces_wireless.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/interfaces_wireless.php b/usr/local/www/interfaces_wireless.php index 06c698d49e..1940a7df75 100644 --- a/usr/local/www/interfaces_wireless.php +++ b/usr/local/www/interfaces_wireless.php @@ -132,7 +132,7 @@ include("head.inc");

Note:
- Here you can configure clones of wireless interfaces, which can be assigned as separate independent interfaces. Only available on wireless chipsets that support this. + Here you can configure clones of wireless interfaces, which can be assigned as separate independent interfaces. Only available on wireless chipsets that support this, with limitations on the number that can be created in each mode.   From 34808d4ef99704030ce6d4bf5963a47fab46fc9e Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 02:12:50 -0700 Subject: [PATCH 23/29] Move most of the code for dealing with wireless clone interface names to separate functions. --- etc/inc/interfaces.inc | 41 ++++++++++++++++++------------------ etc/inc/util.inc | 14 ++++-------- usr/local/www/interfaces.php | 6 +----- 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 4dc1aebcde..7b59e8ea7c 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1381,11 +1381,7 @@ function interface_wireless_clone($realif, $wlcfg) { $mode = ""; break; } - if(!stristr($wlcfg['if'], "_wlan")) { - $baseif = $wlcfg['if']; - } else { - $baseif = substr($wlcfg['if'], 0, stripos($wlcfg['if'], "_wlan")); - } + $baseif = interface_get_wireless_base($wlcfg['if']); if(does_interface_exist($realif)) { exec("/sbin/ifconfig {$realif}", $output, $ret); $ifconfig_str = implode($output); @@ -1435,20 +1431,11 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) { if(!is_array($ifcfg['wireless'])) return; - if(!stristr($ifcfg['if'], "_wlan")) { - $baseif1 = $ifcfg['if']; - } else { - $baseif1 = substr($ifcfg['if'], 0, stripos($ifcfg['if'], "_wlan")); - } + $baseif = interface_get_wireless_base($ifcfg['if']); $iflist = get_configured_interface_list(); foreach ($iflist as $if) { - if(!stristr($config['interfaces'][$if]['if'], "_wlan")) { - $baseif2 = $config['interfaces'][$if]['if']; - } else { - $baseif2 = substr($config['interfaces'][$if]['if'], 0, stripos($config['interfaces'][$if]['if'], "_wlan")); - } - if ($baseif1 == $baseif2 && $ifcfg['if'] != $config['interfaces'][$if]['if']) { + if ($baseif == interface_get_wireless_base($config['interfaces'][$if]['if']) && $ifcfg['if'] != $config['interfaces'][$if]['if']) { if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) { foreach ($shared_settings as $setting) { if ($sync_changes) { @@ -2413,6 +2400,22 @@ function interface_translate_type_to_real($interface) { return $interface; } +function interface_get_wireless_base($wlif) + if(!stristr($wlif, "_wlan")) { + return $wlif; + } else { + return substr($wlif, 0, stripos($wlif, "_wlan")); + } +} + +function interface_get_wireless_clone($wlif) + if(!stristr($wlif, "_wlan")) { + return $wlif . "_wlan0"; + } else { + return $wlif; + } +} + function get_real_interface($interface = "wan") { global $config; @@ -2472,11 +2475,7 @@ function get_real_interface($interface = "wan") { // interface name format: $parentnic_wlanparentnic# // example: ath0_wlan0 if(is_interface_wireless($cfg['if'])) { - if(!stristr($cfg['if'], "_wlan")) { - $wanif = $cfg['if'] . "_wlan0"; - } else { - $wanif = $cfg['if']; - } + $wanif = interface_get_wireless_clone($cfg['if']); break; } diff --git a/etc/inc/util.inc b/etc/inc/util.inc index cbacb3c1da..a623e9d258 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -961,16 +961,10 @@ function is_interface_mismatch() { if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan/i", $ifcfg['if'])) { $i++; } - else { - $baseif = $ifcfg['if']; - if(stristr($baseif, "_wlan")) { - $baseif = substr($baseif, 0, stripos($baseif, "_wlan")); - } - if (does_interface_exist($baseif) == false) { - $do_assign = true; - } else - $i++; - } + else if (does_interface_exist(interface_get_wireless_base($ifcfg['if'])) == false) { + $do_assign = true; + } else + $i++; } if ($g['minimum_nic_count'] > $i) { diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index e66055e0f4..578bcde84a 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -215,11 +215,7 @@ if (isset($wancfg['wireless'])) { /* Get wireless modes */ $wlanif = get_real_interface($if); interface_wireless_clone($wlanif, $wancfg); - if(!stristr($wancfg['if'], "_wlan")) { - $wlanbaseif = $wancfg['if']; - } else { - $wlanbaseif = substr($wancfg['if'], 0, stripos($wancfg['if'], "_wlan")); - } + $wlanbaseif = interface_get_wireless_base($wancfg['if']); $wl_modes = get_wireless_modes($if); $pconfig['standard'] = $wancfg['wireless']['standard']; $pconfig['mode'] = $wancfg['wireless']['mode']; From 1d072761e1e1ebc906bee3fea95f073426518c2f Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 04:22:59 -0700 Subject: [PATCH 24/29] Add missing opening brace in the two new functions. --- etc/inc/interfaces.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 7b59e8ea7c..3a38ddb317 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -2400,7 +2400,7 @@ function interface_translate_type_to_real($interface) { return $interface; } -function interface_get_wireless_base($wlif) +function interface_get_wireless_base($wlif) { if(!stristr($wlif, "_wlan")) { return $wlif; } else { @@ -2408,7 +2408,7 @@ function interface_get_wireless_base($wlif) } } -function interface_get_wireless_clone($wlif) +function interface_get_wireless_clone($wlif) { if(!stristr($wlif, "_wlan")) { return $wlif . "_wlan0"; } else { From 82fccf3a96c88b751095d868c156b59dc396deaa Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 04:49:21 -0700 Subject: [PATCH 25/29] Allow changing the parent interface of an unassigned wireless clone. --- usr/local/www/interfaces_wireless_edit.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php index c0522c2d97..2f3a196a55 100644 --- a/usr/local/www/interfaces_wireless_edit.php +++ b/usr/local/www/interfaces_wireless_edit.php @@ -113,17 +113,18 @@ if ($_POST) { if (isset($id) && $a_clones[$id]) { if (clone_inuse($a_clones[$id]['if'])) { if ($clone['if'] != $a_clones[$id]['if']) - $input_errors[] = "This wireless clone cannot be modified because it is still being used as an interface."; + $input_errors[] = "This wireless clone cannot be modified because it is still assigned as an interface."; else if ($clone['mode'] != $a_clones[$id]['mode']) $input_errors[] = "Use the configuration page for the assigned interface to change the mode."; - } else if ($clone['if'] != $a_clones[$id]['if']) - $input_errors[] = "Changing the parent interface is not currently supported. Create a new clone on the new parent and delete the old clone on the previous parent."; + } } if (!$input_errors) { if (!interface_wireless_clone($clone['cloneif'], $clone)) { $input_errors[] = "Error creating interface with mode {$clone['mode']}. The {$clone['if']} interface may not support creating more clones with the selected mode."; } else { if (isset($id) && $a_clones[$id]) { + if ($clone['if'] != $a_clones[$id]['if']) + mwexec("/sbin/ifconfig " . $a_clones[$id]['cloneif'] . " destroy"); $input_errors[] = "Created with id {$id}"; $a_clones[$id] = $clone; } else { From 7c53bc7b0809d5ed47199327404dcd62484f4fbd Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 23 Feb 2010 06:00:00 -0700 Subject: [PATCH 26/29] Change method of displaying wireless clone interfaces on the assignment page. --- etc/inc/util.inc | 7 ++++--- usr/local/www/interfaces_assign.php | 13 +++++++++++++ usr/local/www/interfaces_wireless_edit.php | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index a623e9d258..d31e1a9c42 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -499,6 +499,7 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") 'lo', 'ng', '_vlan', + '_wlan', 'pflog', 'plip', 'pfsync', @@ -539,7 +540,7 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") $ifname = rtrim(trim($alink[0]), '*'); /* trim out all numbers before checking for vfaces */ if (!in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces) && - !stristr($ifname, "_vlan") && !stristr($ifname, "_wlan0")) { + !stristr($ifname, "_vlan") && !stristr($ifname, "_wlan")) { $toput = array( "mac" => trim($alink[1]), "up" => in_array($ifname, $upints) @@ -958,10 +959,10 @@ function is_interface_mismatch() { $do_assign = false; $i = 0; foreach ($config['interfaces'] as $ifname => $ifcfg) { - if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan/i", $ifcfg['if'])) { + if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) { $i++; } - else if (does_interface_exist(interface_get_wireless_base($ifcfg['if'])) == false) { + else if (does_interface_exist($ifcfg['if']) == false) { $do_assign = true; } else $i++; diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index 8e5cb05971..53875fedd0 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -58,6 +58,14 @@ require("rrd.inc"); /* get list without VLAN interfaces */ $portlist = get_interface_list(); +/* add wireless clone interfaces */ +if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) { + foreach ($config['wireless']['clone'] as $clone) { + $portlist[$clone['cloneif']] = $clone; + $portlist[$clone['cloneif']]['iswlclone'] = true; + } +} + /* add VLAN interfaces */ if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { foreach ($config['vlans']['vlan'] as $vlan) { @@ -393,6 +401,11 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) if ($portinfo['descr']) $descr .= " (" . $portinfo['descr'] . ")"; echo htmlspecialchars($descr); + } elseif ($portinfo['iswlclone']) { + $descr = $portinfo['cloneif']; + if ($portinfo['descr']) + $descr .= " (" . $portinfo['descr'] . ")"; + echo htmlspecialchars($descr); } elseif ($portinfo['isppp']) { $descr = "PPP {$portinfo['port']}"; if ($portinfo['descr']) diff --git a/usr/local/www/interfaces_wireless_edit.php b/usr/local/www/interfaces_wireless_edit.php index 2f3a196a55..d40d52acb5 100644 --- a/usr/local/www/interfaces_wireless_edit.php +++ b/usr/local/www/interfaces_wireless_edit.php @@ -161,7 +161,7 @@ include("head.inc");