Project

General

Profile

Download (5.5 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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * 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
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * 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
 */
23

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

    
31
require_once("guiconfig.inc");
32

    
33
$pgtitle = array(gettext("Status"), gettext("Wireless"));
34
$shortcut_section = "wireless";
35

    
36
include("head.inc");
37

    
38
$if = $_REQUEST['if'];
39

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

    
51
$tab_array = array();
52

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

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

    
64
$rwlif = get_real_interface($if);
65

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

    
71
if ($savemsg) {
72
	print_info_box($savemsg, 'success');
73
}
74

    
75
display_top_tabs($tab_array);
76
?>
77

    
78
<div class="panel panel-default">
79
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby Access Points or Ad-Hoc Peers")?></h2></div>
80
	<div class="panel-body">
81
		<div class="table-responsive">
82
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
83
				<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
<?php
96
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
97
	/* Skip Header */
98
	array_shift($states);
99

    
100
	$counter = 0;
101
	foreach ($states as $state) {
102
		/* Split by Mac address for the SSID Field */
103
		$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
		$ssid = htmlspecialchars($split[0]);
106
		$bssid = $bssid[0];
107
		/* 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
?>
115
					<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
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or Ad-Hoc Peers")?></h2></div>
149
	<div class="panel-body">
150
		<div class="table-responsive">
151
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
152
				<thead>
153
					<tr>
154
						<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
					</tr>
165
				</thead>
166
				<tbody>
167

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

    
173
	$counter=0;
174

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

    
199

    
200
<form action="status_wireless.php" method="post">
201
	<nav class="action-buttons">
202
		<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
			<i class="fa fa-refresh icon-embed-btn"></i>
205
			<?=gettext("Rescan")?>
206
		</button>
207
	</nav>
208
</form>
209
<div class="infoblock">
210
<?php
211
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
?>
215
</div>
216
<?php
217
include("foot.inc");
(185-185/229)