From d0330501ca5b62534f010a78e931a1d674ad3d89 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 16 Oct 2005 23:27:48 +0000 Subject: MFC 6910 6911 Beginning of new wireless status tool. So far it shows ifconfig list sta and includes all wireless interfaces defined as top tabs. --- usr/local/www/status_wireless.php | 260 +++++++++++++++----------------------- 1 file changed, 99 insertions(+), 161 deletions(-) (limited to 'usr') diff --git a/usr/local/www/status_wireless.php b/usr/local/www/status_wireless.php index ac15b20..0f36512 100755 --- a/usr/local/www/status_wireless.php +++ b/usr/local/www/status_wireless.php @@ -1,22 +1,19 @@ #!/usr/local/bin/php -. + Copyright (C) 2004 Scott Ullrich All rights reserved. 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. + 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. + 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 @@ -30,173 +27,114 @@ POSSIBILITY OF SUCH DAMAGE. */ -require("guiconfig.inc"); +require_once("config.inc"); +require_once("guiconfig.inc"); -function get_wireless_info($ifdescr) { - +function gentitle_pkg($pgname) { global $config; - - $ifinfo = array(); - $ifinfo['if'] = $config['interfaces'][$ifdescr]['if']; - - /* get signal strength cache */ - exec("/usr/sbin/wicontrol -i " . $ifinfo['if'] . " -C", $sscache); - - $ifinfo['sscache'] = array(); - foreach ($sscache as $ss) { - if ($ss) { - $ssa = preg_split("/\s+/", $ss); - $sscent = array(); - $sscent['mac'] = chop($ssa[1], ","); - $sscent['ipaddr'] = chop($ssa[2], ","); - $sscent['sig'] = chop($ssa[4], ","); - $sscent['noise'] = chop($ssa[6], ","); - $sscent['qual'] = chop($ssa[8], ","); - $ifinfo['sscache'][] = $sscent; - } - } - - /* if in hostap mode: get associated stations */ - if ($config['interfaces'][$ifdescr]['wireless']['mode'] == "hostap") { - exec("/usr/sbin/wicontrol -i " . $ifinfo['if'] . " -l", $aslist); - - $ifinfo['aslist'] = array(); - array_shift($aslist); - foreach ($aslist as $as) { - if ($as) { - if (preg_match("/^ap/", $as)) { - if (is_array($aslent) && count($aslent)) - $ifinfo['aslist'][] = $aslent; - $aslent = array(); - } else if (preg_match("/BSSID:\s*\[ (.*) \]/", $as, $matches)) { - $aslent['bssid'] = $matches[1]; - } else if (preg_match("/\[dBm\]:\s*\[ .* \/ (.*) \/ (.*) \]/", $as, $matches)) { - $aslent['sig'] = $matches[1]; - $aslent['noise'] = $matches[2]; - } - } - } - if (is_array($aslent) && count($aslent)) - $ifinfo['aslist'][] = $aslent; - } - - return $ifinfo; + return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname; } -$pgtitle = "Status: Wireless"; +$pgtitle = "Diagnostics: Wireless Status"; include("head.inc"); +$if = $_POST['if']; +if($_GET['if'] <> "") + $if = $_GET['if']; +if($if == "") { + /* Find the first interface + that is wireless */ + foreach($config['interfaces'] as $interface) { + if($interface['wireless'] <> "") { + $if = $interface['if']; + break; + } + } +} ?> -
+ + +

+ + -This program is currently undergoing changes and is broke. Check back before release! +
+ + + +
+ "") { + if($if == $interface['if']) + $enabled = true; + else + $enabled = false; + $friendly = convert_real_interface_to_friendly_interface_name($interface['if']); + if($interface['descr'] <> "") + $friendly = $interface['descr']; + $tab_array[] = array("Status ($friendly)", $enabled, "status_wireless.php?if={$interface['if']}"); + break; + } +} +/* XXX: add other wireless interfaces here */ +display_top_tabs($tab_array); +?> +
+"; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +print "\n\n"; + +$states=split("\n",`/sbin/ifconfig {$if} list sta | grep -v "AID CHAN"`); + +$counter=0; +foreach($states as $state) { + $state_fixed = str_replace(" ", " ", $state); + $state_fixed = str_replace(" ", " ", $state_fixed); + $state_fixed = str_replace(" ", " ", $state_fixed); + $state_split = split(" ", $state_fixed); + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + print "\n"; +} ?> +
ADDRAIDCHANRATERSSIIDLETXSEQRXSEQCAPSERP
{$state_split[0]}{$state_split[1]}{$state_split[2]}{$state_split[3]}{$state_split[4]}{$state_split[5]}{$state_split[6]}{$state_split[7]}{$state_split[8]}{$state_split[9]}
- - -

- +
+
- if (is_array($config['interfaces']['wan']['wireless']) && - preg_match($g['wireless_regex'], $config['interfaces']['wan']['if'])) - $ifdescrs['wan'] = 'WAN'; - - if (is_array($config['interfaces']['lan']['wireless']) && - preg_match($g['wireless_regex'], $config['interfaces']['lan']['if'])) - $ifdescrs['lan'] = 'LAN'; - - for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) { - if (is_array($config['interfaces']['opt' . $j]['wireless']) && - isset($config['interfaces']['opt' . $j]['enable']) && - preg_match($g['wireless_regex'], $config['interfaces']['opt' . $j]['if'])) - $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; - } - - if (count($ifdescrs) > 0): ?> - - $ifname): - $ifinfo = get_wireless_info($ifdescr); - ?> - - - - - - - - - - - - - - - - - -
- interface (SSID "")
Signal strength - cache - - - - - - - - - - "0.0.0.0" - and $ss['ipaddr'] <> ""): ?> - - - - - - - - - -
MAC addressIP addressSignalNoiseQuality
- - - - - - - - - -
Associated stations - - - - - - - - - - - - - - -
BSSIDSignalNoise
- - - dBm - - dBm -
- -No supported wireless interfaces were found for status display (only cards that use the wi[n], ath[n], an[n], ral[n], ural[n] and wai[n] driver are supported). - + + + -- cgit v1.1