Project

General

Profile

Download (7.09 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * status_wireless.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 *
12
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14
 *
15
 * 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
 *
20
 * 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
 *
25
 * 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
 *
30
 * 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
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *
37
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 * 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
 */
53

    
54
##|+PRIV
55
##|*IDENT=page-diagnostics-wirelessstatus
56
##|*NAME=Status: Wireless
57
##|*DESCR=Allow access to the 'Status: Wireless' page.
58
##|*MATCH=status_wireless.php*
59
##|-PRIV
60

    
61
require_once("guiconfig.inc");
62

    
63
$pgtitle = array(gettext("Status"), gettext("Wireless"));
64
$shortcut_section = "wireless";
65

    
66
include("head.inc");
67

    
68
$if = $_POST['if'];
69

    
70
if ($_GET['if'] != "") {
71
	$if = $_GET['if'];
72
}
73

    
74
$ciflist = get_configured_interface_with_descr();
75
if (empty($if)) {
76
	/* Find the first interface that is wireless */
77
	foreach ($ciflist as $interface => $ifdescr) {
78
		if (is_interface_wireless(get_real_interface($interface))) {
79
			$if = $interface;
80
			break;
81
		}
82
	}
83
}
84

    
85
$tab_array = array();
86

    
87
foreach ($ciflist as $interface => $ifdescr) {
88
	if (is_interface_wireless(get_real_interface($interface))) {
89
		$enabled = false;
90
		if ($if == $interface) {
91
			$enabled = true;
92
		}
93

    
94
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
95
	}
96
}
97

    
98
$rwlif = get_real_interface($if);
99

    
100
if ($_POST['rescanwifi'] != "") {
101
	mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
102
	$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
103
}
104

    
105
if ($savemsg) {
106
	print_info_box($savemsg, 'success');
107
}
108

    
109
display_top_tabs($tab_array);
110
?>
111

    
112
<div class="panel panel-default">
113
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby Access Points or Ad-Hoc Peers")?></h2></div>
114
	<div class="panel-body">
115
		<div class="table-responsive">
116
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
117
				<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
<?php
130
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
131
	/* Skip Header */
132
	array_shift($states);
133

    
134
	$counter = 0;
135
	foreach ($states as $state) {
136
		/* Split by Mac address for the SSID Field */
137
		$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
		$ssid = htmlspecialchars($split[0]);
140
		$bssid = $bssid[0];
141
		/* 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
?>
149
					<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
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or Ad-Hoc Peers")?></h2></div>
183
	<div class="panel-body">
184
		<div class="table-responsive">
185
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
186
				<thead>
187
					<tr>
188
						<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
					</tr>
199
				</thead>
200
				<tbody>
201

    
202
<?php
203
	$states = array();
204
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
205
	array_shift($states);
206

    
207
	$counter=0;
208

    
209
	foreach ($states as $state) {
210
		$split = preg_split("/[ ]+/i", $state);
211
?>
212
					<tr>
213
<?php
214
		/* Split the rest by using spaces for this line using the 2nd part */
215
		for ($idx=0; $idx<10; $idx++) {
216
?>
217
						<td>
218
							<?=$split[$idx]?>
219
						</td>
220
<?php
221
		}
222
?>
223
					</tr>
224
<?php
225
	}
226
?>
227
				</tbody>
228
			</table>
229
		</div>
230
	</div>
231
</div>
232

    
233

    
234
<form action="status_wireless.php" method="post">
235
	<nav class="action-buttons">
236
		<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
			<i class="fa fa-refresh icon-embed-btn"></i>
239
			<?=gettext("Rescan")?>
240
		</button>
241
	</nav>
242
</form>
243
<div class="infoblock">
244
<?php
245
print_info_box(gettext('<b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power saving mode.<br />' .
246
			   '<b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), ' .
247
			   'S = Short preamble, s = Short slot time.'), 'info', false);
248
?>
249
</div>
250
<?php
251
include("foot.inc");
(185-185/227)