Project

General

Profile

Download (7.43 KB) Statistics
| Branch: | Tag: | Revision:
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 351cbef7 Scott Ullrich
This program is currently undergoing changes and is broke.  Check back before release!
94
95
<?php
96
97
exit;
98
99
?>
100
101 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
102
<?php include("fbegin.inc"); ?>
103 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
104 d0440f75 Scott Ullrich
<?php $i = 0; $ifdescrs = array();
105
106
	if (is_array($config['interfaces']['wan']['wireless']) &&
107 fa1d5f98 Scott Ullrich
			preg_match($g['wireless_regex'], $config['interfaces']['wan']['if']))
108 d0440f75 Scott Ullrich
			$ifdescrs['wan'] = 'WAN';
109
			
110
	if (is_array($config['interfaces']['lan']['wireless']) &&
111 fa1d5f98 Scott Ullrich
			preg_match($g['wireless_regex'], $config['interfaces']['lan']['if']))
112 d0440f75 Scott Ullrich
			$ifdescrs['lan'] = 'LAN';
113
	
114
	for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
115
		if (is_array($config['interfaces']['opt' . $j]['wireless']) &&
116
			isset($config['interfaces']['opt' . $j]['enable']) &&
117 fa1d5f98 Scott Ullrich
			preg_match($g['wireless_regex'], $config['interfaces']['opt' . $j]['if']))
118 d0440f75 Scott Ullrich
			$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
119
	}
120
		
121
	if (count($ifdescrs) > 0): ?>
122 5b237745 Scott Ullrich
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
123
              <?php
124
			      foreach ($ifdescrs as $ifdescr => $ifname): 
125
				  $ifinfo = get_wireless_info($ifdescr);
126
			  ?>
127
              <?php if ($i): ?>
128
              <tr> 
129
                <td colspan="8" class="list" height="12"></td>
130
              </tr>
131
              <?php endif; ?>
132
              <tr> 
133
                <td colspan="2" class="listtopic"> 
134
                  <?=htmlspecialchars($ifname);?> interface (SSID &quot;<?=htmlspecialchars($config['interfaces'][$ifdescr]['wireless']['ssid']);?>&quot;)</td>
135
              </tr>
136
              <tr> 
137 d0440f75 Scott Ullrich
                <td width="22%" valign="top" class="vncellt">Signal strength 
138 5b237745 Scott Ullrich
                  cache</td>
139
                <td width="78%" class="listrpad"> 
140
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
141
                    <tr> 
142
                      <td width="30%" class="listhdrr">MAC address</td>
143
                      <td width="25%" class="listhdrr">IP address</td>
144
                      <td width="15%" class="listhdrr">Signal</td>
145
                      <td width="15%" class="listhdrr">Noise</td>
146
                      <td width="15%" class="listhdr">Quality</td>
147
                    </tr>
148
                    <?php foreach ($ifinfo['sscache'] as $ss): ?>
149 8a3c130b Scott Ullrich
		    <?php if($ss['ipaddr'] <> "0.0.0.0"
150
			  and $ss['ipaddr'] <> ""): ?>
151
                    <tr>                                 
152 5b237745 Scott Ullrich
                      <td class="listlr"> 
153
                        <?=htmlspecialchars($ss['mac']);?>
154
                      </td>
155
                      <td class="listr"> 
156
                        <?=htmlspecialchars($ss['ipaddr']);?>
157
                      </td>
158
                      <td class="listr"> 
159
                        <?=htmlspecialchars($ss['sig']);?>
160
                      </td>
161
                      <td class="listr"> 
162
                        <?=htmlspecialchars($ss['noise']);?>
163
                      </td>
164
                      <td class="listr"> 
165
                        <?=htmlspecialchars($ss['qual']);?>
166
                      </td>
167
                    </tr>
168 8a3c130b Scott Ullrich
		    <?php endif; ?>
169 5b237745 Scott Ullrich
                    <?php endforeach; ?>
170
                  </table></td>
171
              </tr><?php if ($ifinfo['aslist']): ?>
172
              <tr> 
173 d0440f75 Scott Ullrich
                <td width="22%" valign="top" class="vncellt">Associated stations 
174 5b237745 Scott Ullrich
                </td>
175
                <td width="78%" class="listrpad"> 
176
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
177
                    <tr> 
178 d0440f75 Scott Ullrich
                      <td width="40%" class="listhdrr">BSSID</td>
179
                      <td width="30%" class="listhdrr">Signal</td>
180
                      <td width="30%" class="listhdrr">Noise</td>
181 5b237745 Scott Ullrich
                    </tr>
182
                    <?php foreach ($ifinfo['aslist'] as $as): ?>
183
                    <tr> 
184
                      <td class="listlr"> 
185 d0440f75 Scott Ullrich
                        <?=htmlspecialchars($as['bssid']);?>
186 5b237745 Scott Ullrich
                      </td>
187
                      <td class="listr"> 
188 d0440f75 Scott Ullrich
                        <?=htmlspecialchars($as['sig']);?> dBm
189 5b237745 Scott Ullrich
                      </td>
190
                      <td class="listr"> 
191 d0440f75 Scott Ullrich
                        <?=htmlspecialchars($as['noise']);?> dBm
192 5b237745 Scott Ullrich
                      </td>
193
                    </tr>
194
                    <?php endforeach; ?>
195
                  </table></td>
196
              </tr><?php endif; ?>
197
              <?php $i++; endforeach; ?>
198
            </table>
199
<?php else: ?>
200 fa1d5f98 Scott Ullrich
<strong>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).</strong>
201 5b237745 Scott Ullrich
<?php endif; ?>
202
<?php include("fend.inc"); ?>