Project

General

Profile

Download (6.43 KB) Statistics
| Branch: | Tag: | Revision:
1 d0330501 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3
	status_wireless.php
4 d0330501 Scott Ullrich
	Copyright (C) 2004 Scott Ullrich
5 29aef6c4 Jim Thompson
        Copyright (C) 2013-2014 Electric Sheep Fencing, LP
6 5b237745 Scott Ullrich
	All rights reserved.
7 1f3a3ed2 jim-p
8 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10 1f3a3ed2 jim-p
11 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
12 d0330501 Scott Ullrich
	this list of conditions and the following disclaimer.
13 1f3a3ed2 jim-p
14 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
15 d0330501 Scott Ullrich
	notice, this list of conditions and the following disclaimer in the
16
	documentation and/or other materials provided with the distribution.
17 1f3a3ed2 jim-p
18 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29 1d333258 Scott Ullrich
/*
30
	pfSense_MODULE:	interfaces
31
*/
32 5b237745 Scott Ullrich
33 6b07c15a Matthew Grooms
##|+PRIV
34
##|*IDENT=page-diagnostics-wirelessstatus
35 d1104fa6 Chris Buechler
##|*NAME=Status: Wireless page
36
##|*DESCR=Allow access to the 'Status: Wireless' page.
37 6b07c15a Matthew Grooms
##|*MATCH=status_wireless.php*
38
##|-PRIV
39
40 d0330501 Scott Ullrich
require_once("guiconfig.inc");
41 5b237745 Scott Ullrich
42 41740617 Rafael Lucas
$pgtitle = array(gettext("Status"),gettext("Wireless"));
43 b32dd0a6 jim-p
$shortcut_section = "wireless";
44 4df96eff Scott Ullrich
include("head.inc");
45
46 d0330501 Scott Ullrich
$if = $_POST['if'];
47
if($_GET['if'] <> "")
48
	$if = $_GET['if'];
49 64b2f3c8 Ermal Lu?i
50
$ciflist = get_configured_interface_with_descr();
51
if(empty($if)) {
52 d0330501 Scott Ullrich
	/* Find the first interface
53
	   that is wireless */
54 64b2f3c8 Ermal Lu?i
	foreach($ciflist as $interface => $ifdescr) {
55 be2b47d5 Erik Fonnesbeck
		if(is_interface_wireless(get_real_interface($interface))) {
56 64b2f3c8 Ermal Lu?i
			$if = $interface;
57 be2b47d5 Erik Fonnesbeck
			break;
58
		}
59 d0330501 Scott Ullrich
	}
60
}
61 5b237745 Scott Ullrich
?>
62
63 d0330501 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php
65
include("fbegin.inc");
66
?>
67 53961f06 Scott Ullrich
<form action="status_wireless.php" method="post">
68 d0330501 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
69 d0440f75 Scott Ullrich
70 d0330501 Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
71
<tr><td>
72
<?php
73
$tab_array = array();
74 64b2f3c8 Ermal Lu?i
foreach($ciflist as $interface => $ifdescr) {
75 88e9bceb smos
	if (is_interface_wireless(get_real_interface($interface))) {
76 64b2f3c8 Ermal Lu?i
		$enabled = false;
77 a2b724a6 Ermal Lu?i
		if($if == $interface)
78 d0330501 Scott Ullrich
			$enabled = true;
79 24357d92 jim-p
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
80 d0330501 Scott Ullrich
	}
81
}
82 72d2682c Erik Fonnesbeck
$rwlif = get_real_interface($if);
83 6f87ed42 Chris Buechler
if($_POST['rescanwifi'] <> "") {
84 4362a612 Chris Buechler
	mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
85 c3ff89b4 Renato Botelho
	$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
86 6f87ed42 Chris Buechler
}
87 ea52942c Chris Buechler
if ($savemsg) print_info_box($savemsg);
88 d0330501 Scott Ullrich
display_top_tabs($tab_array);
89
?>
90
</td></tr>
91 53961f06 Scott Ullrich
<tr><td>
92 1f3a3ed2 jim-p
<div id="mainarea" class="tabcont">
93 e41ec584 Renato Botelho
<input type="hidden" name="if" id="if" value="<?php echo htmlspecialchars($if); ?>">
94 8cd558b6 ayvis
<b><input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan"></b><br /><br />
95 1f3a3ed2 jim-p
<b><?php echo gettext("Nearby access points or ad-hoc peers"); ?></b>
96
<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%">
97
	<thead>
98
		<tr bgcolor='#990000'>
99
			<td><b><font color='#ffffff'>SSID</font></b></td>
100
			<td><b><font color='#ffffff'>BSSID</font></b></td>
101
			<td><b><font color='#ffffff'>CHAN</font></b></td>
102
			<td><b><font color='#ffffff'>RATE</font></b></td>
103
			<td><b><font color='#ffffff'>RSSI</font></b></td>
104
			<td><b><font color='#ffffff'>INT</font></b></td>
105
			<td><b><font color='#ffffff'>CAPS</font></b></td>
106
		</tr>
107
	</thead>
108
	<tbody>
109 351cbef7 Scott Ullrich
<?php
110 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
111 e2d90eac Seth Mos
	/* Skip Header */
112
	array_shift($states);
113 d0330501 Scott Ullrich
114 f2f0c37e Scott Ullrich
	$counter=0;
115
	foreach($states as $state) {
116 e2d90eac Seth Mos
		/* Split by Mac address for the SSID Field */
117 22275785 Seth Mos
		$split = preg_split("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state);
118
		preg_match("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state, $bssid);
119 2bf0ada5 jim-p
		$ssid = htmlspecialchars($split[0]);
120 22275785 Seth Mos
		$bssid = $bssid[0];
121 e2d90eac Seth Mos
		/* Split the rest by using spaces for this line using the 2nd part */
122
		$split = preg_split("/[ ]+/i", $split[1]);
123
		$channel = $split[1];
124
		$rate = $split[2];
125
		$rssi = $split[3];
126
		$int = $split[4];
127
		$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
128
129 bdeca4ed Scott Ullrich
		print "<tr>";
130 e2d90eac Seth Mos
		print "<td>{$ssid}</td>";
131
		print "<td>{$bssid}</td>";
132
		print "<td>{$channel}</td>";
133
		print "<td>{$rate}</td>";
134
		print "<td>{$rssi}</td>";
135
		print "<td>{$int}</td>";
136
		print "<td>{$caps}</td>";
137 6c40c007 Scott Ullrich
		print "</tr>\n";
138 f2f0c37e Scott Ullrich
	}
139 1f3a3ed2 jim-p
?>
140
	</tbody>
141
</table>
142 8cd558b6 ayvis
<b><?php echo gettext("Associated or ad-hoc peers"); ?></b><br />
143 1f3a3ed2 jim-p
<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%">
144
	<thead>
145
		<tr bgcolor='#990000'>
146
			<td><b><font color='#ffffff'>ADDR</font></b></td>
147
			<td><b><font color='#ffffff'>AID</font></b></td>
148
			<td><b><font color='#ffffff'>CHAN</font></b></td>
149
			<td><b><font color='#ffffff'>RATE</font></b></td>
150
			<td><b><font color='#ffffff'>RSSI</font></b></td>
151
			<td><b><font color='#ffffff'>IDLE</font></b></td>
152
			<td><b><font color='#ffffff'>TXSEQ</font></b></td>
153
			<td><b><font color='#ffffff'>RXSEQ</font></b></td>
154
			<td><b><font color='#ffffff'>CAPS</font></b></td>
155
			<td><b><font color='#ffffff'>ERP</font></b></td>
156
		</tr>
157
	</thead>
158
	<tbody>
159 c29ad853 Scott Ullrich
160 1f3a3ed2 jim-p
<?php
161 105bb6a6 Seth Mos
	$states = array();
162 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
163 e2d90eac Seth Mos
	array_shift($states);
164 f2f0c37e Scott Ullrich
165
	$counter=0;
166
	foreach($states as $state) {
167 105bb6a6 Seth Mos
		$split = preg_split("/[ ]+/i", $state);
168
		/* Split the rest by using spaces for this line using the 2nd part */
169 f2f0c37e Scott Ullrich
		print "<tr>";
170 105bb6a6 Seth Mos
		print "<td>{$split[0]}</td>";
171
		print "<td>{$split[1]}</td>";
172
		print "<td>{$split[2]}</td>";
173
		print "<td>{$split[3]}</td>";
174
		print "<td>{$split[4]}</td>";
175
		print "<td>{$split[5]}</td>";
176
		print "<td>{$split[6]}</td>";
177
		print "<td>{$split[7]}</td>";
178
		print "<td>{$split[8]}</td>";
179
		print "<td>{$split[9]}</td>";
180 f2f0c37e Scott Ullrich
		print "</tr>\n";
181
	}
182 351cbef7 Scott Ullrich
183 1f3a3ed2 jim-p
/* XXX: what stats to we get for adhoc mode? */
184 f2f0c37e Scott Ullrich
185 351cbef7 Scott Ullrich
?>
186 1f3a3ed2 jim-p
	</tbody>
187 d0330501 Scott Ullrich
</table>
188 8cd558b6 ayvis
</div><br />
189
	<b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power save mode<br />
190 1f3a3ed2 jim-p
	<b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES),
191
		S = Short preamble, s = Short slot time
192 d0330501 Scott Ullrich
</td></tr>
193
</table>
194 d0440f75 Scott Ullrich
195 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
196 d0330501 Scott Ullrich
</body>
197
</html>