Project

General

Profile

Download (7.15 KB) Statistics
| Branch: | Tag: | Revision:
1 d0330501 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3
	status_wireless.php
4
*/
5 782922c2 Stephen Beaver
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Redistribution and use in source and binary forms, with or without modification,
9
 *	are permitted provided that the following conditions are met:
10
 *
11
 *	1. Redistributions of source code must retain the above copyright notice,
12
 *		this list of conditions and the following disclaimer.
13
 *
14
 *	2. Redistributions in binary form must reproduce the above copyright
15
 *		notice, this list of conditions and the following disclaimer in
16
 *		the documentation and/or other materials provided with the
17
 *		distribution.
18
 *
19
 *	3. All advertising materials mentioning features or use of this software
20
 *		must display the following acknowledgment:
21
 *		"This product includes software developed by the pfSense Project
22
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
23
 *
24
 *	4. The names "pfSense" and "pfSense Project" must not be used to
25
 *		 endorse or promote products derived from this software without
26
 *		 prior written permission. For written permission, please contact
27
 *		 coreteam@pfsense.org.
28
 *
29
 *	5. Products derived from this software may not be called "pfSense"
30
 *		nor may "pfSense" appear in their names without prior written
31
 *		permission of the Electric Sheep Fencing, LLC.
32
 *
33
 *	6. Redistributions of any form whatsoever must retain the following
34
 *		acknowledgment:
35
 *
36
 *	"This product includes software developed by the pfSense Project
37
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
38
 *
39
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
40
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
43
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
51
 *
52
 *	====================================================================
53
 *
54
 */
55 5b237745 Scott Ullrich
56 6b07c15a Matthew Grooms
##|+PRIV
57
##|*IDENT=page-diagnostics-wirelessstatus
58 5230f468 jim-p
##|*NAME=Status: Wireless
59 d1104fa6 Chris Buechler
##|*DESCR=Allow access to the 'Status: Wireless' page.
60 6b07c15a Matthew Grooms
##|*MATCH=status_wireless.php*
61
##|-PRIV
62
63 d0330501 Scott Ullrich
require_once("guiconfig.inc");
64 5b237745 Scott Ullrich
65 6c07db48 Phil Davis
$pgtitle = array(gettext("Status"), gettext("Wireless"));
66 b32dd0a6 jim-p
$shortcut_section = "wireless";
67 454f52f9 sbeaver
68 4df96eff Scott Ullrich
include("head.inc");
69
70 d0330501 Scott Ullrich
$if = $_POST['if'];
71 454f52f9 sbeaver
72 abe98adb Phil Davis
if ($_GET['if'] != "") {
73 d0330501 Scott Ullrich
	$if = $_GET['if'];
74 abe98adb Phil Davis
}
75 64b2f3c8 Ermal Lu?i
76
$ciflist = get_configured_interface_with_descr();
77 42b0c921 Phil Davis
if (empty($if)) {
78 abe98adb Phil Davis
	/* Find the first interface that is wireless */
79 42b0c921 Phil Davis
	foreach ($ciflist as $interface => $ifdescr) {
80
		if (is_interface_wireless(get_real_interface($interface))) {
81 64b2f3c8 Ermal Lu?i
			$if = $interface;
82 be2b47d5 Erik Fonnesbeck
			break;
83
		}
84 d0330501 Scott Ullrich
	}
85
}
86 5b237745 Scott Ullrich
87 d0330501 Scott Ullrich
$tab_array = array();
88 454f52f9 sbeaver
89 abe98adb Phil Davis
foreach ($ciflist as $interface => $ifdescr) {
90 88e9bceb smos
	if (is_interface_wireless(get_real_interface($interface))) {
91 64b2f3c8 Ermal Lu?i
		$enabled = false;
92 abe98adb Phil Davis
		if ($if == $interface) {
93 d0330501 Scott Ullrich
			$enabled = true;
94 abe98adb Phil Davis
		}
95 454f52f9 sbeaver
96 24357d92 jim-p
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
97 d0330501 Scott Ullrich
	}
98
}
99 454f52f9 sbeaver
100 72d2682c Erik Fonnesbeck
$rwlif = get_real_interface($if);
101 454f52f9 sbeaver
102 abe98adb Phil Davis
if ($_POST['rescanwifi'] != "") {
103 4362a612 Chris Buechler
	mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
104 c3ff89b4 Renato Botelho
	$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
105 6f87ed42 Chris Buechler
}
106 454f52f9 sbeaver
107 abe98adb Phil Davis
if ($savemsg) {
108 454f52f9 sbeaver
	print_info_box($savemsg, 'success');
109 abe98adb Phil Davis
}
110 454f52f9 sbeaver
111 d0330501 Scott Ullrich
display_top_tabs($tab_array);
112
?>
113 454f52f9 sbeaver
114
<div class="panel panel-default">
115 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby Access Points or Ad-Hoc Peers")?></h2></div>
116 454f52f9 sbeaver
	<div class="panel-body">
117
		<div class="table-responsive">
118 10fe1eb5 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
119 454f52f9 sbeaver
				<thead>
120
					<tr>
121
						<th>SSID</th>
122
						<th>BSSID</th>
123
						<th>CHAN</th>
124
						<th>RATE</th>
125
						<th>RSSI</th>
126
						<th>INT</th>
127
						<th>CAPS</th>
128
					</tr>
129
				</thead>
130
				<tbody>
131 351cbef7 Scott Ullrich
<?php
132 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
133 e2d90eac Seth Mos
	/* Skip Header */
134
	array_shift($states);
135 d0330501 Scott Ullrich
136 6c07db48 Phil Davis
	$counter = 0;
137 42b0c921 Phil Davis
	foreach ($states as $state) {
138 e2d90eac Seth Mos
		/* Split by Mac address for the SSID Field */
139 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);
140
		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);
141 2bf0ada5 jim-p
		$ssid = htmlspecialchars($split[0]);
142 22275785 Seth Mos
		$bssid = $bssid[0];
143 e2d90eac Seth Mos
		/* Split the rest by using spaces for this line using the 2nd part */
144
		$split = preg_split("/[ ]+/i", $split[1]);
145
		$channel = $split[1];
146
		$rate = $split[2];
147
		$rssi = $split[3];
148
		$int = $split[4];
149
		$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
150 1f3a3ed2 jim-p
?>
151 454f52f9 sbeaver
					<tr>
152
						<td>
153
							<?=$ssid?>
154
						</td>
155
						<td>
156
							<?=$bssid?>
157
						</td>
158
						<td>
159
							<?=$channel?>
160
						</td>
161
						<td>
162
							<?=$rate?>
163
						</td>
164
						<td>
165
							<?=$rssi?>
166
						</td>
167
						<td>
168
							<?=$int?>
169
						</td>
170
						<td>
171
							<?=$caps?>
172
						</td>
173
					</tr>
174
<?php
175
	} // e-o-foreach
176
?>
177
				</tbody>
178
			</table>
179
		</div>
180
	</div>
181
</div>
182
183
<div class="panel panel-default">
184 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or Ad-Hoc Peers")?></h2></div>
185 454f52f9 sbeaver
	<div class="panel-body">
186
		<div class="table-responsive">
187 2f4e37b1 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
188 454f52f9 sbeaver
				<thead>
189
					<tr>
190 c3c2bd7a Colin Fleming
						<th>ADDR</th>
191
						<th>AID</th>
192
						<th>CHAN</th>
193
						<th>RATE</th>
194
						<th>RSSI</th>
195
						<th>IDLE</th>
196
						<th>TXSEQ</th>
197
						<th>RXSEQ</th>
198
						<th>CAPS</th>
199
						<th>ERP</th>
200 454f52f9 sbeaver
					</tr>
201
				</thead>
202
				<tbody>
203 c29ad853 Scott Ullrich
204 1f3a3ed2 jim-p
<?php
205 105bb6a6 Seth Mos
	$states = array();
206 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
207 e2d90eac Seth Mos
	array_shift($states);
208 f2f0c37e Scott Ullrich
209
	$counter=0;
210 454f52f9 sbeaver
211 abe98adb Phil Davis
	foreach ($states as $state) {
212 105bb6a6 Seth Mos
		$split = preg_split("/[ ]+/i", $state);
213 454f52f9 sbeaver
?>
214
					<tr>
215
<?php
216 105bb6a6 Seth Mos
		/* Split the rest by using spaces for this line using the 2nd part */
217 abe98adb Phil Davis
		for ($idx=0; $idx<10; $idx++) {
218 454f52f9 sbeaver
?>
219
						<td>
220
							<?=$split[$idx]?>
221
						</td>
222
<?php
223
		}
224
?>
225
					</tr>
226
<?php
227 f2f0c37e Scott Ullrich
	}
228 454f52f9 sbeaver
?>
229
				</tbody>
230
			</table>
231
		</div>
232
	</div>
233
</div>
234 351cbef7 Scott Ullrich
235 f2f0c37e Scott Ullrich
236 454f52f9 sbeaver
<form action="status_wireless.php" method="post">
237 c10cb196 Stephen Beaver
	<nav class="action-buttons">
238 782922c2 Stephen Beaver
		<input type="hidden" name="if" id="if" value="<?=htmlspecialchars($if)?>" />
239
		<button type="submit" class="btn btn-success" name="rescanwifi" id="rescanwifi" value="Rescan">
240 15b6dcac jim-p
			<i class="fa fa-refresh icon-embed-btn"></i>
241 782922c2 Stephen Beaver
			<?=gettext("Rescan")?>
242
		</button>
243 454f52f9 sbeaver
	</nav>
244
</form>
245 f78bbe16 Phil Davis
<div class="infoblock">
246 454f52f9 sbeaver
<?php
247 8545adde k-paulius
print_info_box(gettext('<b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power saving mode.<br />' .
248 454f52f9 sbeaver
			   '<b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), ' .
249 8545adde k-paulius
			   'S = Short preamble, s = Short slot time.'), 'info', false);
250 f78bbe16 Phil Davis
?>
251
</div>
252
<?php
253 c10cb196 Stephen Beaver
include("foot.inc");