Project

General

Profile

Download (6.45 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_wireless.php
4
	Copyright (C) 2004 Scott Ullrich
5
	All rights reserved.
6
	
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9
	
10
	1. Redistributions of source code must retain the above copyright notice,
11
	this list of conditions and the following disclaimer.
12
	
13
	2. Redistributions in binary form must reproduce the above copyright
14
	notice, this list of conditions and the following disclaimer in the
15
	documentation and/or other materials provided with the distribution.
16
	
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28
/*
29
	pfSense_MODULE:	interfaces
30
*/
31

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

    
39
require_once("guiconfig.inc");
40

    
41
$pgtitle = array(gettext("Status"),gettext("Wireless"));
42
include("head.inc");
43

    
44
$if = $_POST['if'];
45
if($_GET['if'] <> "")
46
	$if = $_GET['if'];
47

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

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

    
68
<table width="100%" border="0" cellpadding="0" cellspacing="0">
69
<tr><td>
70
<?php
71
$tab_array = array();
72
foreach($ciflist as $interface => $ifdescr) {
73
	if (is_interface_wireless(get_real_interface($interface))) {
74
		$enabled = false;
75
		if($if == $interface)
76
			$enabled = true;
77
		$tab_array[] = array(printf(gettext("Status (%s)"),$ifdescr), $enabled, "status_wireless.php?if={$interface}");
78
	}
79
}
80
$rwlif = get_real_interface($if);
81
if($_POST['rescanwifi'] <> "") {
82
	mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1");
83
	$savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results.");
84
}
85
if ($savemsg) print_info_box($savemsg);
86
display_top_tabs($tab_array);
87
?>
88
</td></tr>
89
<tr><td>
90
<div id="mainarea">
91
<table class="tabcont" colspan="3" cellpadding="3" width="100%">
92
<?php
93

    
94
	/* table header */
95
	print "<input type=\"hidden\" name=\"if\" id=\"if\" value=\"{$if}\">\n";
96
	print "<tr><td colspan=7><b><input type=\"submit\" name=\"rescanwifi\" id=\"rescanwifi\" value=\"Rescan\"><br/></td></tr>\n";
97
	print "<tr><td colspan=7><b>" . gettext("Nearby access points or ad-hoc peers") . ".<br/></td></tr>\n";
98
	print "\n<tr>";
99
	print "<tr bgcolor='#990000'>";
100
	print "<td><b><font color='#ffffff'>SSID</td>";
101
	print "<td><b><font color='#ffffff'>BSSID</td>";
102
	print "<td><b><font color='#ffffff'>CHAN</td>";
103
	print "<td><b><font color='#ffffff'>RATE</td>";
104
	print "<td><b><font color='#ffffff'>RSSI</td>";
105
	print "<td><b><font color='#ffffff'>INT</td>";
106
	print "<td><b><font color='#ffffff'>CAPS</td>";
107
	print "</tr>\n\n";
108

    
109
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
110
	/* Skip Header */
111
	array_shift($states);
112

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

    
128
		print "<tr>";
129
		print "<td>{$ssid}</td>";
130
		print "<td>{$bssid}</td>";
131
		print "<td>{$channel}</td>";
132
		print "<td>{$rate}</td>";
133
		print "<td>{$rssi}</td>";
134
		print "<td>{$int}</td>";
135
		print "<td>{$caps}</td>";
136
		print "</tr>\n";
137
	}
138

    
139
	print "</table><table class=\"tabcont\" colspan=\"3\" cellpadding=\"3\" width=\"100%\">";
140

    
141
	/* table header */
142
        print "\n<tr>";
143
	printf(gettext("%s%s%sAssociated or ad-hoc peers.%s%s%s%s"),'<tr>','<td colspan=7>','<b>','<br/>','</td>','</tr>','\n');
144
	print "<tr bgcolor='#990000'>";
145
	print "<td><b><font color='#ffffff'>ADDR</td>";
146
	print "<td><b><font color='#ffffff'>AID</td>";
147
	print "<td><b><font color='#ffffff'>CHAN</td>";
148
	print "<td><b><font color='#ffffff'>RATE</td>";
149
	print "<td><b><font color='#ffffff'>RSSI</td>";
150
	print "<td><b><font color='#ffffff'>IDLE</td>";
151
	print "<td><b><font color='#ffffff'>TXSEQ</td>";
152
	print "<td><b><font color='#ffffff'>RXSEQ</td>";
153
	print "<td><b><font color='#ffffff'>CAPS</td>";
154
	print "<td><b><font color='#ffffff'>ERP</td>";
155
	print "</tr>\n\n";
156

    
157
	$states = array();
158
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
159
	array_shift($states);
160

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

    
179
/* XXX: what stats to we get for adhoc mode? */ 
180

    
181
?>
182
</table>
183
</div><br>
184
                  <b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power save mode<br>
185
                  <b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES),
186
                  	S = Short preamble, s = Short slot time
187
</td></tr>
188
</table>
189

    
190
<?php include("fend.inc"); ?>
191
</body>
192
</html>
(171-171/222)