Project

General

Profile

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