Project

General

Profile

Download (5.87 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_wireless.php
4
	Copyright (C) 2004 Scott Ullrich
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	notice, this list of conditions and the following disclaimer in the
16
	documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
/*
30
	pfSense_MODULE: interfaces
31
*/
32

    
33
##|+PRIV
34
##|*IDENT=page-diagnostics-wirelessstatus
35
##|*NAME=Status: Wireless page
36
##|*DESCR=Allow access to the 'Status: Wireless' page.
37
##|*MATCH=status_wireless.php*
38
##|-PRIV
39

    
40
require_once("guiconfig.inc");
41

    
42
$pgtitle = array(gettext("Status"), gettext("Wireless"));
43
$shortcut_section = "wireless";
44

    
45
include("head.inc");
46

    
47
$if = $_POST['if'];
48

    
49
if($_GET['if'] != "")
50
	$if = $_GET['if'];
51

    
52
$ciflist = get_configured_interface_with_descr();
53
if (empty($if)) {
54
	/* Find the first interface
55
	   that is wireless */
56
	foreach ($ciflist as $interface => $ifdescr) {
57
		if (is_interface_wireless(get_real_interface($interface))) {
58
			$if = $interface;
59
			break;
60
		}
61
	}
62
}
63

    
64
$tab_array = array();
65

    
66
foreach($ciflist as $interface => $ifdescr) {
67
	if (is_interface_wireless(get_real_interface($interface))) {
68
		$enabled = false;
69
		if($if == $interface)
70
			$enabled = true;
71

    
72
		$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
73
	}
74
}
75

    
76
$rwlif = get_real_interface($if);
77

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

    
83
if ($savemsg)
84
	print_info_box($savemsg, 'success');
85

    
86
display_top_tabs($tab_array);
87
?>
88

    
89
<div class="panel panel-default">
90
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Nearby access points or ad-hoc peers")?></h2></div>
91
	<div class="panel-body">
92
		<div class="table-responsive">
93
			<table class="table table-striped table-hover table-condensed">
94
				<thead>
95
					<tr>
96
						<th>SSID</th>
97
						<th>BSSID</th>
98
						<th>CHAN</th>
99
						<th>RATE</th>
100
						<th>RSSI</th>
101
						<th>INT</th>
102
						<th>CAPS</th>
103
					</tr>
104
				</thead>
105
				<tbody>
106
<?php
107
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
108
	/* Skip Header */
109
	array_shift($states);
110

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

    
158
<div class="panel panel-default">
159
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Associated or ad-hoc peers")?></h2></div>
160
	<div class="panel-body">
161
		<div class="table-responsive">
162
			<table class="table table-striped table-hover table-condensed">
163
				<thead>
164
					<tr>
165
						<th>ADDR</font></th>
166
						<th>AID</font></th>
167
						<th>CHAN</font></th>
168
						<th>RATE</font></th>
169
						<th>RSSI</font></th>
170
						<th>IDLE</font></th>
171
						<th>TXSEQ</font></th>
172
						<th>RXSEQ</font></th>
173
						<th>CAPS</font></th>
174
						<th>ERP</font></th>
175
					</tr>
176
				</thead>
177
				<tbody>
178

    
179
<?php
180
	$states = array();
181
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
182
	array_shift($states);
183

    
184
	$counter=0;
185

    
186
	foreach($states as $state) {
187
		$split = preg_split("/[ ]+/i", $state);
188
?>
189
					<tr>
190
<?php
191
		/* Split the rest by using spaces for this line using the 2nd part */
192
		for($idx=0; $idx<10; $idx++) {
193
?>
194
						<td>
195
							<?=$split[$idx]?>
196
						</td>
197
<?php
198
		}
199
?>
200
					</tr>
201
<?php
202
	}
203
?>
204
				</tbody>
205
			</table>
206
		</div>
207
	</div>
208
</div>
209

    
210

    
211
<form action="status_wireless.php" method="post">
212
	<nav class="action-buttons">
213
		<input type="hidden" name="if" id="if" value="<?=htmlspecialchars($if)?>">
214
		<input type="submit" class="btn btn-success" name="rescanwifi" id="rescanwifi" value="Rescan">
215
	</nav>
216
</form>
217

    
218
<?php
219
print_info_box('<b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power saving mode<br />' .
220
			   '<b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), ' .
221
			   'S = Short preamble, s = Short slot time');
222

    
223
include("foot.inc");
(185-185/237)