#!/usr/local/bin/php
<?php
/*
status_wireless.php
part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2004 Manuel Kasper <mk at neon1 dot net>.
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.
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.
*/
/*
BSD 'ancontrol' options (for CISCO Aironet cards)
ancontrol -i iface -A (show specified APs)
ancontrol -i iface -N (show specified SSIDss)
ancontrol -i iface -S (show NIC status)
ancontrol -i iface -I (show NIC capabilities)
ancontrol -i iface -T (show stats counters)
ancontrol -i iface -C (show current config)
ancontrol -i iface -R (show RSSI map)
ancontrol -i iface -t 0-4 (set TX speed)
ancontrol -i iface -s 0-3 (set power save mode)
ancontrol -i iface [-v 1-4] -a AP (specify AP)
ancontrol -i iface -b val (set beacon period)
ancontrol -i iface [-v 0|1] -d val (set diversity)
ancontrol -i iface -j val (set netjoin timeout)
ancontrol -i iface -e 0-4 (enable transmit key)
ancontrol -i iface [-v 0-8] -k key (set key)
ancontrol -i iface -K 0-2 (no auth/open/shared secret)
ancontrol -i iface -W 0-2 (no WEP/full WEP/mixed cell)
ancontrol -i iface -l val (set station name)
ancontrol -i iface -m val (set MAC address)
ancontrol -i iface [-v 1-3] -n SSID (specify SSID)
ancontrol -i iface -o 0|1 (set operating mode)
ancontrol -i iface -c val (set ad-hoc channel)
ancontrol -i iface -f val (set frag threshold)
ancontrol -i iface -r val (set RTS threshold)
ancontrol -i iface -M 0-15 (set monitor mode)
ancontrol -i iface -L user (enter LEAP authentication mode)
** ancontrol -i iface -Q print signal quality cache
ancontrol -i iface -Z zero out signal cache
ancontrol -h (display this message)
BSD 'wicontrol' options (for PRISM 2.x cards)
wicontrol -i iface
wicontrol -i iface -o
wicontrol -i iface -l
wicontrol -i iface -t tx rate
wicontrol -i iface -n network name
wicontrol -i iface -s station name
wicontrol -i iface -c 0|1
wicontrol -i iface -q SSID
wicontrol -i iface -p port type
wicontrol -i iface -a access point density
wicontrol -i iface -m mac address
wicontrol -i iface -d max data length
wicontrol -i iface -e 0|1
wicontrol -i iface -k encryption key [-v 1|2|3|4]
wicontrol -i iface -r RTS threshold
wicontrol -i iface -f frequency
wicontrol -i iface -F 0|1
wicontrol -i iface -P 0|1
wicontrol -i iface -S max sleep duration
wicontrol -i iface -T 1|2|3|4
wicontrol -i iface -Z zero out signal cache
** wicontrol -i iface -C print signal cache
*/
require("guiconfig.inc");
function get_wireless_info($ifdescr) {
global $config, $g;
$ifinfo = array();
$ifinfo['if'] = $config['interfaces'][$ifdescr]['if'];
/*****************************/
/* get signal strength cache */
/*****************************/
/* PRISM 2.x */
if (!strstr($ifinfo['if'], "an"))
{
exec("/usr/sbin/wicontrol -i " . $ifinfo['if'] . " -C", $sscache);
}
/* CISCO */
elseif(strstr($ifinfo['if'], "an"))
{
exec("/usr/sbin/ancontrol -i " . $ifinfo['if'] . " -Q", $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 (not CISCO AIRNONET) */
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) {
$asa = preg_split("/\s+/", $as);
$aslent = array();
$aslent['mac'] = $asa[0];
$aslent['rates'] = substr($asa[4], strpos($asa[4], "<")+1,
strpos($asa[4], ">")-strpos($asa[4], "<")-1);
$aslent['sig'] = substr($asa[5], strpos($asa[5], "=")+1);
$ifinfo['aslist'][] = $aslent;
}
}
}
return $ifinfo;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>m0n0wall webGUI - Status: Wireless</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="gui.css" rel="stylesheet" type="text/css">
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<p class="pgtitle">Status: Wireless</p>
<?php $i = 0; $ifdescrs = array();
/* changed: or strstr($config['interfaces']['wan']['if'], "an") for CISCO Cards */
if (is_array($config['interfaces']['wan']['wireless']) &&
( strstr($config['interfaces']['wan']['if'], "wi") ||
strstr($config['interfaces']['wan']['if'], "an") )
)
$ifdescrs['wan'] = 'WAN';
/* changed: or strstr($config['interfaces']['lan']['if'], "an") for CISCO Cards */
if (is_array($config['interfaces']['lan']['wireless']) &&
( strstr($config['interfaces']['lan']['if'], "wi") ||
strstr($config['interfaces']['lan']['if'], "an") )
)
$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']) &&
strstr($config['interfaces']['opt' . $j]['if'], "wi"))
$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
}
if (count($ifdescrs) > 0): ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
foreach ($ifdescrs as $ifdescr => $ifname):
$ifinfo = get_wireless_info($ifdescr);
?>
<?php if ($i): ?>
<tr>
<td colspan="8" class="list" height="12"></td>
</tr>
<?php endif; ?>
<tr>
<td colspan="2" class="listtopic">
<?=htmlspecialchars($ifname);?> interface</td>
</tr>
<tr>
<td width="22%" valign="top" class="listhdrr">Signal strength
cache</td>
<td width="78%" class="listrpad">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" class="listhdrr">MAC address</td>
<td width="25%" class="listhdrr">IP address</td>
<td width="15%" class="listhdrr">Signal</td>
<td width="15%" class="listhdrr">Noise</td>
<td width="15%" class="listhdr">Quality</td>
</tr>
<?php foreach ($ifinfo['sscache'] as $ss): ?>
<tr>
<td class="listlr">
<?=htmlspecialchars($ss['mac']);?>
</td>
<td class="listr">
<?=htmlspecialchars($ss['ipaddr']);?>
</td>
<td class="listr">
<?=htmlspecialchars($ss['sig']);?>
</td>
<td class="listr">
<?=htmlspecialchars($ss['noise']);?>
</td>
<td class="listr">
<?=htmlspecialchars($ss['qual']);?>
</td>
</tr>
<?php endforeach; ?>
</table></td>
</tr><?php if ($ifinfo['aslist']): ?>
<tr>
<td width="22%" valign="top" class="listhdrr">Associated stations
</td>
<td width="78%" class="listrpad">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="40%" class="listhdrr">MAC address</td>
<td width="40%" class="listhdrr">TX rates</td>
<td width="20%" class="listhdrr">Signal</td>
</tr>
<?php foreach ($ifinfo['aslist'] as $as): ?>
<tr>
<td class="listlr">
<?=htmlspecialchars($as['mac']);?>
</td>
<td class="listr">
<?=htmlspecialchars($as['rates']);?>
</td>
<td class="listr">
<?=htmlspecialchars($as['sig']);?>
</td>
</tr>
<?php endforeach; ?>
</table></td>
</tr><?php endif; ?>
<?php $i++; endforeach; ?>
</table>
<?php else: ?>
<p><strong>No supported wireless interfaces were found for status display.</strong></p>
<?php endif; ?>
<?php include("fend.inc"); ?>
</body>
</html> |