Project

General

Profile

Download (5.75 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
	}
56
}
57
?>
58

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

    
66
<table width="100%" border="0" cellpadding="0" cellspacing="0">
67
<tr><td>
68
<?php
69
$tab_array = array();
70
foreach($ciflist as $interface => $ifdescr) {
71
	if (is_interface_wireless(get_real_interface($interface))) {
72
		$enabled = false;
73
		if($if == $interface)
74
			$enabled = true;
75
		$tab_array[] = array(printf(gettext("Status (%s)"),$ifdescr), $enabled, "status_wireless.php?if={$interface}");
76
	}
77
}
78
display_top_tabs($tab_array);
79
?>
80
</td></tr>
81
<tr><td>
82
<div id="mainarea">
83
<table class="tabcont" colspan="3" cellpadding="3" width="100%">
84
<?php
85

    
86

    
87
	/* table header */
88
	printf(gettext("%s%s%sNearby access points or ad-hoc peers.%s%s%s%s"),'<tr>','<td colspan=7>','<b>','<br/>','</td>','</tr>','\n');
89
	print "\n<tr>";
90
	print "<tr bgcolor='#990000'>";
91
	print "<td><b><font color='#ffffff'>SSID</td>";
92
	print "<td><b><font color='#ffffff'>BSSID</td>";
93
	print "<td><b><font color='#ffffff'>CHAN</td>";
94
	print "<td><b><font color='#ffffff'>RATE</td>";
95
	print "<td><b><font color='#ffffff'>RSSI</td>";
96
	print "<td><b><font color='#ffffff'>INT</td>";
97
	print "<td><b><font color='#ffffff'>CAPS</td>";
98
	print "</tr>\n\n";
99

    
100
	$rwlif = get_real_interface($if);
101
	exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret);
102
	/* Skip Header */
103
	array_shift($states);
104

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

    
120
		print "<tr>";
121
		print "<td>{$ssid}</td>";
122
		print "<td>{$bssid}</td>";
123
		print "<td>{$channel}</td>";
124
		print "<td>{$rate}</td>";
125
		print "<td>{$rssi}</td>";
126
		print "<td>{$int}</td>";
127
		print "<td>{$caps}</td>";
128
		print "</tr>\n";
129
	}
130

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

    
133
	/* table header */
134
        print "\n<tr>";
135
	printf(gettext("%s%s%sAssociated or ad-hoc peers.%s%s%s%s"),'<tr>','<td colspan=7>','<b>','<br/>','</td>','</tr>','\n');
136
	print "<tr bgcolor='#990000'>";
137
	print "<td><b><font color='#ffffff'>ADDR</td>";
138
	print "<td><b><font color='#ffffff'>AID</td>";
139
	print "<td><b><font color='#ffffff'>CHAN</td>";
140
	print "<td><b><font color='#ffffff'>RATE</td>";
141
	print "<td><b><font color='#ffffff'>RSSI</td>";
142
	print "<td><b><font color='#ffffff'>IDLE</td>";
143
	print "<td><b><font color='#ffffff'>TXSEQ</td>";
144
	print "<td><b><font color='#ffffff'>RXSEQ</td>";
145
	print "<td><b><font color='#ffffff'>CAPS</td>";
146
	print "<td><b><font color='#ffffff'>ERP</td>";
147
	print "</tr>\n\n";
148

    
149
	$states = array();
150
	exec("/sbin/ifconfig {$rwlif} list sta 2>&1", $states, $ret);
151
	array_shift($states);
152

    
153
	$counter=0;
154
	foreach($states as $state) {
155
		$split = preg_split("/[ ]+/i", $state);
156
		/* Split the rest by using spaces for this line using the 2nd part */
157
		print "<tr>";
158
		print "<td>{$split[0]}</td>";
159
		print "<td>{$split[1]}</td>";
160
		print "<td>{$split[2]}</td>";
161
		print "<td>{$split[3]}</td>";
162
		print "<td>{$split[4]}</td>";
163
		print "<td>{$split[5]}</td>";
164
		print "<td>{$split[6]}</td>";
165
		print "<td>{$split[7]}</td>";
166
		print "<td>{$split[8]}</td>";
167
		print "<td>{$split[9]}</td>";
168
		print "</tr>\n";
169
	}
170

    
171
/* XXX: what stats to we get for adhoc mode? */ 
172

    
173
?>
174
</table>
175
</div>
176
</td></tr>
177
</table>
178

    
179
<?php include("fend.inc"); ?>
180
</body>
181
</html>
(171-171/222)