Project

General

Profile

Download (6.71 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
include("head.inc");
45

    
46
$if = $_POST['if'];
47
if ($_GET['if'] <> "") {
48
	$if = $_GET['if'];
49
}
50

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

    
64
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
65
<?php
66
include("fbegin.inc");
67
?>
68
<form action="status_wireless.php" method="post">
69
<?php if ($savemsg) print_info_box($savemsg); ?>
70

    
71
<table width="100%" border="0" cellpadding="0" cellspacing="0">
72
	<tr><td>
73
<?php
74
	$tab_array = array();
75
	foreach ($ciflist as $interface => $ifdescr) {
76
		if (is_interface_wireless(get_real_interface($interface))) {
77
			$enabled = false;
78
			if ($if == $interface) {
79
				$enabled = true;
80
			}
81
			$tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}");
82
		}
83
	}
84
	$rwlif = get_real_interface($if);
85
	if ($_POST['rescanwifi'] <> "") {
86
		mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
87
		$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
88
	}
89
	if ($savemsg) print_info_box($savemsg);
90
	display_top_tabs($tab_array);
91
?>
92
	</td></tr>
93
	<tr>
94
		<td>
95
			<div id="mainarea" class="tabcont">
96
				<input type="hidden" name="if" id="if" value="<?php echo htmlspecialchars($if); ?>">
97
				<b><input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan"></b><br /><br />
98
				<b><?php echo gettext("Nearby access points or ad-hoc peers"); ?></b>
99
				<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%">
100
					<thead>
101
						<tr bgcolor='#990000'>
102
							<td><b><font color='#ffffff'>SSID</font></b></td>
103
							<td><b><font color='#ffffff'>BSSID</font></b></td>
104
							<td><b><font color='#ffffff'>CHAN</font></b></td>
105
							<td><b><font color='#ffffff'>RATE</font></b></td>
106
							<td><b><font color='#ffffff'>RSSI</font></b></td>
107
							<td><b><font color='#ffffff'>INT</font></b></td>
108
							<td><b><font color='#ffffff'>CAPS</font></b></td>
109
						</tr>
110
					</thead>
111
					<tbody>
112
<?php
113
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
114
	/* Skip Header */
115
	array_shift($states);
116

    
117
	$counter = 0;
118
	foreach ($states as $state) {
119
		/* Split by Mac address for the SSID Field */
120
		$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);
121
		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);
122
		$ssid = htmlspecialchars($split[0]);
123
		$bssid = $bssid[0];
124
		/* Split the rest by using spaces for this line using the 2nd part */
125
		$split = preg_split("/[ ]+/i", $split[1]);
126
		$channel = $split[1];
127
		$rate = $split[2];
128
		$rssi = $split[3];
129
		$int = $split[4];
130
		$caps = "$split[5] $split[6] $split[7] $split[8] $split[9] $split[10] $split[11] ";
131

    
132
		print "<tr>";
133
		print "<td>{$ssid}</td>";
134
		print "<td>{$bssid}</td>";
135
		print "<td>{$channel}</td>";
136
		print "<td>{$rate}</td>";
137
		print "<td>{$rssi}</td>";
138
		print "<td>{$int}</td>";
139
		print "<td>{$caps}</td>";
140
		print "</tr>\n";
141
	}
142
?>
143
					</tbody>
144
				</table>
145
				<b><?php echo gettext("Associated or ad-hoc peers"); ?></b><br />
146
				<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%">
147
					<thead>
148
						<tr bgcolor='#990000'>
149
							<td><b><font color='#ffffff'>ADDR</font></b></td>
150
							<td><b><font color='#ffffff'>AID</font></b></td>
151
							<td><b><font color='#ffffff'>CHAN</font></b></td>
152
							<td><b><font color='#ffffff'>RATE</font></b></td>
153
							<td><b><font color='#ffffff'>RSSI</font></b></td>
154
							<td><b><font color='#ffffff'>IDLE</font></b></td>
155
							<td><b><font color='#ffffff'>TXSEQ</font></b></td>
156
							<td><b><font color='#ffffff'>RXSEQ</font></b></td>
157
							<td><b><font color='#ffffff'>CAPS</font></b></td>
158
							<td><b><font color='#ffffff'>ERP</font></b></td>
159
						</tr>
160
					</thead>
161
					<tbody>
162

    
163
<?php
164
	$states = array();
165
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
166
	array_shift($states);
167

    
168
	$counter = 0;
169
	foreach ($states as $state) {
170
		$split = preg_split("/[ ]+/i", $state);
171
		/* Split the rest by using spaces for this line using the 2nd part */
172
		print "<tr>";
173
		print "<td>{$split[0]}</td>";
174
		print "<td>{$split[1]}</td>";
175
		print "<td>{$split[2]}</td>";
176
		print "<td>{$split[3]}</td>";
177
		print "<td>{$split[4]}</td>";
178
		print "<td>{$split[5]}</td>";
179
		print "<td>{$split[6]}</td>";
180
		print "<td>{$split[7]}</td>";
181
		print "<td>{$split[8]}</td>";
182
		print "<td>{$split[9]}</td>";
183
		print "</tr>\n";
184
	}
185

    
186
/* XXX: what stats to we get for adhoc mode? */
187

    
188
?>
189
					</tbody>
190
				</table>
191
			</div>
192
			<br />
193
			<b>Flags:</b> A = Authorized, E = Extended Rate (802.11g), P = Power save mode, H = High Throughput (HT), Q = QoS (WME)<br />
194
			<b>Capabilities:</b> WME = Wireless Multimedia Extensions (QoS), WPA = Wi-Fi Protected Access, RSN = 802.11i, HTCAP = 802.11n High Throughput, ATH = Atheros protocol extensions<br />
195
		</td>
196
	</tr>
197
</table>
198

    
199
<?php include("fend.inc"); ?>
200
</body>
201
</html>
(199-199/252)