1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
status_wireless.php
|
6 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
7 |
|
|
|
8 |
d0440f75
|
Scott Ullrich
|
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
|
9 |
5b237745
|
Scott Ullrich
|
All rights reserved.
|
10 |
|
|
|
11 |
|
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
|
|
|
14 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
|
|
|
17 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
|
|
|
21 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
require("guiconfig.inc");
|
34 |
|
|
|
35 |
|
|
function get_wireless_info($ifdescr) {
|
36 |
|
|
|
37 |
63637de9
|
Bill Marquette
|
global $config;
|
38 |
5b237745
|
Scott Ullrich
|
|
39 |
|
|
$ifinfo = array();
|
40 |
|
|
$ifinfo['if'] = $config['interfaces'][$ifdescr]['if'];
|
41 |
|
|
|
42 |
|
|
/* get signal strength cache */
|
43 |
|
|
exec("/usr/sbin/wicontrol -i " . $ifinfo['if'] . " -C", $sscache);
|
44 |
|
|
|
45 |
|
|
$ifinfo['sscache'] = array();
|
46 |
|
|
foreach ($sscache as $ss) {
|
47 |
|
|
if ($ss) {
|
48 |
|
|
$ssa = preg_split("/\s+/", $ss);
|
49 |
|
|
$sscent = array();
|
50 |
|
|
$sscent['mac'] = chop($ssa[1], ",");
|
51 |
|
|
$sscent['ipaddr'] = chop($ssa[2], ",");
|
52 |
|
|
$sscent['sig'] = chop($ssa[4], ",");
|
53 |
|
|
$sscent['noise'] = chop($ssa[6], ",");
|
54 |
|
|
$sscent['qual'] = chop($ssa[8], ",");
|
55 |
|
|
$ifinfo['sscache'][] = $sscent;
|
56 |
|
|
}
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
/* if in hostap mode: get associated stations */
|
60 |
|
|
if ($config['interfaces'][$ifdescr]['wireless']['mode'] == "hostap") {
|
61 |
|
|
exec("/usr/sbin/wicontrol -i " . $ifinfo['if'] . " -l", $aslist);
|
62 |
|
|
|
63 |
|
|
$ifinfo['aslist'] = array();
|
64 |
|
|
array_shift($aslist);
|
65 |
|
|
foreach ($aslist as $as) {
|
66 |
|
|
if ($as) {
|
67 |
d0440f75
|
Scott Ullrich
|
if (preg_match("/^ap/", $as)) {
|
68 |
|
|
if (is_array($aslent) && count($aslent))
|
69 |
|
|
$ifinfo['aslist'][] = $aslent;
|
70 |
|
|
$aslent = array();
|
71 |
|
|
} else if (preg_match("/BSSID:\s*\[ (.*) \]/", $as, $matches)) {
|
72 |
|
|
$aslent['bssid'] = $matches[1];
|
73 |
|
|
} else if (preg_match("/\[dBm\]:\s*\[ .* \/ (.*) \/ (.*) \]/", $as, $matches)) {
|
74 |
|
|
$aslent['sig'] = $matches[1];
|
75 |
|
|
$aslent['noise'] = $matches[2];
|
76 |
|
|
}
|
77 |
5b237745
|
Scott Ullrich
|
}
|
78 |
|
|
}
|
79 |
d0440f75
|
Scott Ullrich
|
if (is_array($aslent) && count($aslent))
|
80 |
|
|
$ifinfo['aslist'][] = $aslent;
|
81 |
5b237745
|
Scott Ullrich
|
}
|
82 |
|
|
|
83 |
|
|
return $ifinfo;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
4df96eff
|
Scott Ullrich
|
$pgtitle = "Status: Wireless";
|
87 |
|
|
include("head.inc");
|
88 |
|
|
|
89 |
5b237745
|
Scott Ullrich
|
?>
|
90 |
|
|
|
91 |
d0440f75
|
Scott Ullrich
|
<form>
|
92 |
|
|
|
93 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
94 |
|
|
<?php include("fbegin.inc"); ?>
|
95 |
74f446e8
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
96 |
d0440f75
|
Scott Ullrich
|
<?php $i = 0; $ifdescrs = array();
|
97 |
|
|
|
98 |
|
|
if (is_array($config['interfaces']['wan']['wireless']) &&
|
99 |
|
|
(strstr($config['interfaces']['wan']['if'], "wi") || strstr($config['interfaces']['wan']['if'], "ath")))
|
100 |
|
|
$ifdescrs['wan'] = 'WAN';
|
101 |
|
|
|
102 |
|
|
if (is_array($config['interfaces']['lan']['wireless']) &&
|
103 |
|
|
(strstr($config['interfaces']['lan']['if'], "wi") || strstr($config['interfaces']['lan']['if'], "ath")))
|
104 |
|
|
$ifdescrs['lan'] = 'LAN';
|
105 |
|
|
|
106 |
|
|
for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
|
107 |
|
|
if (is_array($config['interfaces']['opt' . $j]['wireless']) &&
|
108 |
|
|
isset($config['interfaces']['opt' . $j]['enable']) &&
|
109 |
|
|
(strstr($config['interfaces']['opt' . $j]['if'], "wi") || strstr($config['interfaces']['opt' . $j]['if'], "ath")))
|
110 |
|
|
$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
if (count($ifdescrs) > 0): ?>
|
114 |
5b237745
|
Scott Ullrich
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
115 |
|
|
<?php
|
116 |
|
|
foreach ($ifdescrs as $ifdescr => $ifname):
|
117 |
|
|
$ifinfo = get_wireless_info($ifdescr);
|
118 |
|
|
?>
|
119 |
|
|
<?php if ($i): ?>
|
120 |
|
|
<tr>
|
121 |
|
|
<td colspan="8" class="list" height="12"></td>
|
122 |
|
|
</tr>
|
123 |
|
|
<?php endif; ?>
|
124 |
|
|
<tr>
|
125 |
|
|
<td colspan="2" class="listtopic">
|
126 |
|
|
<?=htmlspecialchars($ifname);?> interface (SSID "<?=htmlspecialchars($config['interfaces'][$ifdescr]['wireless']['ssid']);?>")</td>
|
127 |
|
|
</tr>
|
128 |
|
|
<tr>
|
129 |
d0440f75
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellt">Signal strength
|
130 |
5b237745
|
Scott Ullrich
|
cache</td>
|
131 |
|
|
<td width="78%" class="listrpad">
|
132 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
133 |
|
|
<tr>
|
134 |
|
|
<td width="30%" class="listhdrr">MAC address</td>
|
135 |
|
|
<td width="25%" class="listhdrr">IP address</td>
|
136 |
|
|
<td width="15%" class="listhdrr">Signal</td>
|
137 |
|
|
<td width="15%" class="listhdrr">Noise</td>
|
138 |
|
|
<td width="15%" class="listhdr">Quality</td>
|
139 |
|
|
</tr>
|
140 |
|
|
<?php foreach ($ifinfo['sscache'] as $ss): ?>
|
141 |
8a3c130b
|
Scott Ullrich
|
<?php if($ss['ipaddr'] <> "0.0.0.0"
|
142 |
|
|
and $ss['ipaddr'] <> ""): ?>
|
143 |
|
|
<tr>
|
144 |
5b237745
|
Scott Ullrich
|
<td class="listlr">
|
145 |
|
|
<?=htmlspecialchars($ss['mac']);?>
|
146 |
|
|
</td>
|
147 |
|
|
<td class="listr">
|
148 |
|
|
<?=htmlspecialchars($ss['ipaddr']);?>
|
149 |
|
|
</td>
|
150 |
|
|
<td class="listr">
|
151 |
|
|
<?=htmlspecialchars($ss['sig']);?>
|
152 |
|
|
</td>
|
153 |
|
|
<td class="listr">
|
154 |
|
|
<?=htmlspecialchars($ss['noise']);?>
|
155 |
|
|
</td>
|
156 |
|
|
<td class="listr">
|
157 |
|
|
<?=htmlspecialchars($ss['qual']);?>
|
158 |
|
|
</td>
|
159 |
|
|
</tr>
|
160 |
8a3c130b
|
Scott Ullrich
|
<?php endif; ?>
|
161 |
5b237745
|
Scott Ullrich
|
<?php endforeach; ?>
|
162 |
|
|
</table></td>
|
163 |
|
|
</tr><?php if ($ifinfo['aslist']): ?>
|
164 |
|
|
<tr>
|
165 |
d0440f75
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellt">Associated stations
|
166 |
5b237745
|
Scott Ullrich
|
</td>
|
167 |
|
|
<td width="78%" class="listrpad">
|
168 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
169 |
|
|
<tr>
|
170 |
d0440f75
|
Scott Ullrich
|
<td width="40%" class="listhdrr">BSSID</td>
|
171 |
|
|
<td width="30%" class="listhdrr">Signal</td>
|
172 |
|
|
<td width="30%" class="listhdrr">Noise</td>
|
173 |
5b237745
|
Scott Ullrich
|
</tr>
|
174 |
|
|
<?php foreach ($ifinfo['aslist'] as $as): ?>
|
175 |
|
|
<tr>
|
176 |
|
|
<td class="listlr">
|
177 |
d0440f75
|
Scott Ullrich
|
<?=htmlspecialchars($as['bssid']);?>
|
178 |
5b237745
|
Scott Ullrich
|
</td>
|
179 |
|
|
<td class="listr">
|
180 |
d0440f75
|
Scott Ullrich
|
<?=htmlspecialchars($as['sig']);?> dBm
|
181 |
5b237745
|
Scott Ullrich
|
</td>
|
182 |
|
|
<td class="listr">
|
183 |
d0440f75
|
Scott Ullrich
|
<?=htmlspecialchars($as['noise']);?> dBm
|
184 |
5b237745
|
Scott Ullrich
|
</td>
|
185 |
|
|
</tr>
|
186 |
|
|
<?php endforeach; ?>
|
187 |
|
|
</table></td>
|
188 |
|
|
</tr><?php endif; ?>
|
189 |
|
|
<?php $i++; endforeach; ?>
|
190 |
|
|
</table>
|
191 |
|
|
<?php else: ?>
|
192 |
d0440f75
|
Scott Ullrich
|
<strong>No supported wireless interfaces were found for status display (only cards that use the wi[n] or ath[n] driver are supported).</strong>
|
193 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
194 |
|
|
<?php include("fend.inc"); ?>
|