Project

General

Profile

Download (5.41 KB) Statistics
| Branch: | Tag: | Revision:
1 d0330501 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * status_wireless.php
4 782922c2 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 782922c2 Stephen Beaver
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 782922c2 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 782922c2 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 782922c2 Stephen Beaver
 */
21 5b237745 Scott Ullrich
22 6b07c15a Matthew Grooms
##|+PRIV
23
##|*IDENT=page-diagnostics-wirelessstatus
24 5230f468 jim-p
##|*NAME=Status: Wireless
25 d1104fa6 Chris Buechler
##|*DESCR=Allow access to the 'Status: Wireless' page.
26 6b07c15a Matthew Grooms
##|*MATCH=status_wireless.php*
27
##|-PRIV
28
29 d0330501 Scott Ullrich
require_once("guiconfig.inc");
30 5b237745 Scott Ullrich
31 6c07db48 Phil Davis
$pgtitle = array(gettext("Status"), gettext("Wireless"));
32 b32dd0a6 jim-p
$shortcut_section = "wireless";
33 454f52f9 sbeaver
34 4df96eff Scott Ullrich
include("head.inc");
35
36 1a8b6554 Steve Beaver
$if = $_REQUEST['if'];
37 64b2f3c8 Ermal Lu?i
38
$ciflist = get_configured_interface_with_descr();
39 42b0c921 Phil Davis
if (empty($if)) {
40 abe98adb Phil Davis
	/* Find the first interface that is wireless */
41 42b0c921 Phil Davis
	foreach ($ciflist as $interface => $ifdescr) {
42
		if (is_interface_wireless(get_real_interface($interface))) {
43 64b2f3c8 Ermal Lu?i
			$if = $interface;
44 be2b47d5 Erik Fonnesbeck
			break;
45
		}
46 d0330501 Scott Ullrich
	}
47
}
48 5b237745 Scott Ullrich
49 d0330501 Scott Ullrich
$tab_array = array();
50 454f52f9 sbeaver
51 abe98adb Phil Davis
foreach ($ciflist as $interface => $ifdescr) {
52 88e9bceb smos
	if (is_interface_wireless(get_real_interface($interface))) {
53 64b2f3c8 Ermal Lu?i
		$enabled = false;
54 abe98adb Phil Davis
		if ($if == $interface) {
55 d0330501 Scott Ullrich
			$enabled = true;
56 abe98adb Phil Davis
		}
57 454f52f9 sbeaver
58 24357d92 jim-p
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
59 d0330501 Scott Ullrich
	}
60
}
61 454f52f9 sbeaver
62 72d2682c Erik Fonnesbeck
$rwlif = get_real_interface($if);
63 454f52f9 sbeaver
64 abe98adb Phil Davis
if ($_POST['rescanwifi'] != "") {
65 4362a612 Chris Buechler
	mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
66 c3ff89b4 Renato Botelho
	$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
67 6f87ed42 Chris Buechler
}
68 454f52f9 sbeaver
69 abe98adb Phil Davis
if ($savemsg) {
70 454f52f9 sbeaver
	print_info_box($savemsg, 'success');
71 abe98adb Phil Davis
}
72 454f52f9 sbeaver
73 d0330501 Scott Ullrich
display_top_tabs($tab_array);
74
?>
75 454f52f9 sbeaver
76
<div class="panel panel-default">
77 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby Access Points or Ad-Hoc Peers")?></h2></div>
78 454f52f9 sbeaver
	<div class="panel-body">
79
		<div class="table-responsive">
80 10fe1eb5 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
81 454f52f9 sbeaver
				<thead>
82
					<tr>
83
						<th>SSID</th>
84
						<th>BSSID</th>
85
						<th>CHAN</th>
86
						<th>RATE</th>
87
						<th>RSSI</th>
88
						<th>INT</th>
89
						<th>CAPS</th>
90
					</tr>
91
				</thead>
92
				<tbody>
93 351cbef7 Scott Ullrich
<?php
94 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
95 e2d90eac Seth Mos
	/* Skip Header */
96
	array_shift($states);
97 d0330501 Scott Ullrich
98 6c07db48 Phil Davis
	$counter = 0;
99 42b0c921 Phil Davis
	foreach ($states as $state) {
100 e2d90eac Seth Mos
		/* Split by Mac address for the SSID Field */
101 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);
102
		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);
103 2bf0ada5 jim-p
		$ssid = htmlspecialchars($split[0]);
104 22275785 Seth Mos
		$bssid = $bssid[0];
105 e2d90eac Seth Mos
		/* Split the rest by using spaces for this line using the 2nd part */
106
		$split = preg_split("/[ ]+/i", $split[1]);
107
		$channel = $split[1];
108
		$rate = $split[2];
109
		$rssi = $split[3];
110
		$int = $split[4];
111
		$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
112 1f3a3ed2 jim-p
?>
113 454f52f9 sbeaver
					<tr>
114
						<td>
115
							<?=$ssid?>
116
						</td>
117
						<td>
118
							<?=$bssid?>
119
						</td>
120
						<td>
121
							<?=$channel?>
122
						</td>
123
						<td>
124
							<?=$rate?>
125
						</td>
126
						<td>
127
							<?=$rssi?>
128
						</td>
129
						<td>
130
							<?=$int?>
131
						</td>
132
						<td>
133
							<?=$caps?>
134
						</td>
135
					</tr>
136
<?php
137
	} // e-o-foreach
138
?>
139
				</tbody>
140
			</table>
141
		</div>
142
	</div>
143
</div>
144
145
<div class="panel panel-default">
146 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or Ad-Hoc Peers")?></h2></div>
147 454f52f9 sbeaver
	<div class="panel-body">
148
		<div class="table-responsive">
149 2f4e37b1 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
150 454f52f9 sbeaver
				<thead>
151
					<tr>
152 c3c2bd7a Colin Fleming
						<th>ADDR</th>
153
						<th>AID</th>
154
						<th>CHAN</th>
155
						<th>RATE</th>
156
						<th>RSSI</th>
157
						<th>IDLE</th>
158
						<th>TXSEQ</th>
159
						<th>RXSEQ</th>
160
						<th>CAPS</th>
161
						<th>ERP</th>
162 454f52f9 sbeaver
					</tr>
163
				</thead>
164
				<tbody>
165 c29ad853 Scott Ullrich
166 1f3a3ed2 jim-p
<?php
167 105bb6a6 Seth Mos
	$states = array();
168 64b2f3c8 Ermal Lu?i
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
169 e2d90eac Seth Mos
	array_shift($states);
170 f2f0c37e Scott Ullrich
171
	$counter=0;
172 454f52f9 sbeaver
173 abe98adb Phil Davis
	foreach ($states as $state) {
174 105bb6a6 Seth Mos
		$split = preg_split("/[ ]+/i", $state);
175 454f52f9 sbeaver
?>
176
					<tr>
177
<?php
178 105bb6a6 Seth Mos
		/* Split the rest by using spaces for this line using the 2nd part */
179 abe98adb Phil Davis
		for ($idx=0; $idx<10; $idx++) {
180 454f52f9 sbeaver
?>
181
						<td>
182
							<?=$split[$idx]?>
183
						</td>
184
<?php
185
		}
186
?>
187
					</tr>
188
<?php
189 f2f0c37e Scott Ullrich
	}
190 454f52f9 sbeaver
?>
191
				</tbody>
192
			</table>
193
		</div>
194
	</div>
195
</div>
196 351cbef7 Scott Ullrich
197 f2f0c37e Scott Ullrich
198 454f52f9 sbeaver
<form action="status_wireless.php" method="post">
199 c10cb196 Stephen Beaver
	<nav class="action-buttons">
200 782922c2 Stephen Beaver
		<input type="hidden" name="if" id="if" value="<?=htmlspecialchars($if)?>" />
201
		<button type="submit" class="btn btn-success" name="rescanwifi" id="rescanwifi" value="Rescan">
202 15b6dcac jim-p
			<i class="fa fa-refresh icon-embed-btn"></i>
203 782922c2 Stephen Beaver
			<?=gettext("Rescan")?>
204
		</button>
205 454f52f9 sbeaver
	</nav>
206
</form>
207 f78bbe16 Phil Davis
<div class="infoblock">
208 454f52f9 sbeaver
<?php
209 7f0d6ccf Phil Davis
print_info_box(sprintf(gettext('%1$sFlags:%2$s A = authorized, E = Extended Rate (802.11g), P = Power saving mode.%3$s' .
210
			   '%1$sCapabilities:%2$s E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), ' .
211
			   'S = Short preamble, s = Short slot time.'), '<b>', '</b>', '<br />'), 'info', false);
212 f78bbe16 Phil Davis
?>
213
</div>
214
<?php
215 c10cb196 Stephen Beaver
include("foot.inc");