Project

General

Profile

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