Project

General

Profile

Download (5.42 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
 * 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
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * 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
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-diagnostics-wirelessstatus
24
##|*NAME=Status: Wireless
25
##|*DESCR=Allow access to the 'Status: Wireless' page.
26
##|*MATCH=status_wireless.php*
27
##|-PRIV
28

    
29
require_once("guiconfig.inc");
30

    
31
$pgtitle = array(gettext("Status"), gettext("Wireless"));
32
$shortcut_section = "wireless";
33

    
34
include("head.inc");
35

    
36
$if = $_POST['if'];
37

    
38
if ($_GET['if'] != "") {
39
	$if = $_GET['if'];
40
}
41

    
42
$ciflist = get_configured_interface_with_descr();
43
if (empty($if)) {
44
	/* Find the first interface that is wireless */
45
	foreach ($ciflist as $interface => $ifdescr) {
46
		if (is_interface_wireless(get_real_interface($interface))) {
47
			$if = $interface;
48
			break;
49
		}
50
	}
51
}
52

    
53
$tab_array = array();
54

    
55
foreach ($ciflist as $interface => $ifdescr) {
56
	if (is_interface_wireless(get_real_interface($interface))) {
57
		$enabled = false;
58
		if ($if == $interface) {
59
			$enabled = true;
60
		}
61

    
62
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
63
	}
64
}
65

    
66
$rwlif = get_real_interface($if);
67

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

    
73
if ($savemsg) {
74
	print_info_box($savemsg, 'success');
75
}
76

    
77
display_top_tabs($tab_array);
78
?>
79

    
80
<div class="panel panel-default">
81
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby Access Points or Ad-Hoc Peers")?></h2></div>
82
	<div class="panel-body">
83
		<div class="table-responsive">
84
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
85
				<thead>
86
					<tr>
87
						<th>SSID</th>
88
						<th>BSSID</th>
89
						<th>CHAN</th>
90
						<th>RATE</th>
91
						<th>RSSI</th>
92
						<th>INT</th>
93
						<th>CAPS</th>
94
					</tr>
95
				</thead>
96
				<tbody>
97
<?php
98
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
99
	/* Skip Header */
100
	array_shift($states);
101

    
102
	$counter = 0;
103
	foreach ($states as $state) {
104
		/* Split by Mac address for the SSID Field */
105
		$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);
106
		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);
107
		$ssid = htmlspecialchars($split[0]);
108
		$bssid = $bssid[0];
109
		/* Split the rest by using spaces for this line using the 2nd part */
110
		$split = preg_split("/[ ]+/i", $split[1]);
111
		$channel = $split[1];
112
		$rate = $split[2];
113
		$rssi = $split[3];
114
		$int = $split[4];
115
		$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
116
?>
117
					<tr>
118
						<td>
119
							<?=$ssid?>
120
						</td>
121
						<td>
122
							<?=$bssid?>
123
						</td>
124
						<td>
125
							<?=$channel?>
126
						</td>
127
						<td>
128
							<?=$rate?>
129
						</td>
130
						<td>
131
							<?=$rssi?>
132
						</td>
133
						<td>
134
							<?=$int?>
135
						</td>
136
						<td>
137
							<?=$caps?>
138
						</td>
139
					</tr>
140
<?php
141
	} // e-o-foreach
142
?>
143
				</tbody>
144
			</table>
145
		</div>
146
	</div>
147
</div>
148

    
149
<div class="panel panel-default">
150
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or Ad-Hoc Peers")?></h2></div>
151
	<div class="panel-body">
152
		<div class="table-responsive">
153
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
154
				<thead>
155
					<tr>
156
						<th>ADDR</th>
157
						<th>AID</th>
158
						<th>CHAN</th>
159
						<th>RATE</th>
160
						<th>RSSI</th>
161
						<th>IDLE</th>
162
						<th>TXSEQ</th>
163
						<th>RXSEQ</th>
164
						<th>CAPS</th>
165
						<th>ERP</th>
166
					</tr>
167
				</thead>
168
				<tbody>
169

    
170
<?php
171
	$states = array();
172
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
173
	array_shift($states);
174

    
175
	$counter=0;
176

    
177
	foreach ($states as $state) {
178
		$split = preg_split("/[ ]+/i", $state);
179
?>
180
					<tr>
181
<?php
182
		/* Split the rest by using spaces for this line using the 2nd part */
183
		for ($idx=0; $idx<10; $idx++) {
184
?>
185
						<td>
186
							<?=$split[$idx]?>
187
						</td>
188
<?php
189
		}
190
?>
191
					</tr>
192
<?php
193
	}
194
?>
195
				</tbody>
196
			</table>
197
		</div>
198
	</div>
199
</div>
200

    
201

    
202
<form action="status_wireless.php" method="post">
203
	<nav class="action-buttons">
204
		<input type="hidden" name="if" id="if" value="<?=htmlspecialchars($if)?>" />
205
		<button type="submit" class="btn btn-success" name="rescanwifi" id="rescanwifi" value="Rescan">
206
			<i class="fa fa-refresh icon-embed-btn"></i>
207
			<?=gettext("Rescan")?>
208
		</button>
209
	</nav>
210
</form>
211
<div class="infoblock">
212
<?php
213
print_info_box(gettext('<b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power saving mode.<br />' .
214
			   '<b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), ' .
215
			   'S = Short preamble, s = Short slot time.'), 'info', false);
216
?>
217
</div>
218
<?php
219
include("foot.inc");
(185-185/227)