Project

General

Profile

Download (5.81 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=Diagnostics: Wireless Status page
35
##|*DESCR=Allow access to the 'Diagnostics: Wireless Status' page.
36
##|*MATCH=status_wireless.php*
37
##|-PRIV
38

    
39
require_once("guiconfig.inc");
40

    
41
function gentitle_pkg($pgname) {
42
	global $config;
43
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
44
}
45

    
46
$pgtitle = array("Diagnostics","Wireless Status");
47
include("head.inc");
48

    
49
$if = $_POST['if'];
50
if($_GET['if'] <> "")
51
	$if = $_GET['if'];
52
if($if == "") {
53
	/* Find the first interface
54
	   that is wireless */
55
	foreach($config['interfaces'] as $interface) {
56
		if($interface['wireless'] <> "") {
57
			$if = $interface['if'];
58
		}
59
	}
60
}
61
?>
62

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

    
70
<table width="100%" border="0" cellpadding="0" cellspacing="0">
71
<tr><td>
72
<?php
73
$tab_array = array();
74
$mode = "";
75
foreach($config['interfaces'] as $interface) {
76
	if($interface['wireless'] <> "") {
77
		if($if == $interface['if']) {
78
			$enabled = true;
79
			$mode = $interface['wireless']['mode'];
80
		} else
81
			$enabled = false;
82
		$friendly = convert_real_interface_to_friendly_interface_name($interface['if']);
83
		if($interface['descr'] <> "")
84
			$friendly = $interface['descr'];
85
		$tab_array[] = array("Status ($friendly)", $enabled, "status_wireless.php?if={$interface['if']}");
86
	}
87
}
88
/* XXX: add other wireless interfaces here */
89
display_top_tabs($tab_array);
90
?>
91
</td></tr>
92
<tr><td>
93
<div id="mainarea">
94
<table class="tabcont" colspan="3" cellpadding="3" width="100%">
95
<?php
96

    
97

    
98
	/* table header */
99
	print "\n<tr>";
100
	print "<tr bgcolor='#990000'>";
101
	print "<td><b><font color='#ffffff'>SSID</td>";
102
	print "<td><b><font color='#ffffff'>BSSID</td>";
103
	print "<td><b><font color='#ffffff'>CHAN</td>";
104
	print "<td><b><font color='#ffffff'>RATE</td>";
105
	print "<td><b><font color='#ffffff'>RSSI</td>";
106
	print "<td><b><font color='#ffffff'>INT</td>";
107
	print "<td><b><font color='#ffffff'>CAPS</td>";
108
	print "</tr>\n\n";
109

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

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

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

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

    
143
	/* table header */
144
	print "\n<tr>";
145
	print "<tr bgcolor='#990000'>";
146
	print "<td><b><font color='#ffffff'>ADDR</td>";
147
	print "<td><b><font color='#ffffff'>AID</td>";
148
	print "<td><b><font color='#ffffff'>CHAN</td>";
149
	print "<td><b><font color='#ffffff'>RATE</td>";
150
	print "<td><b><font color='#ffffff'>RSSI</td>";
151
	print "<td><b><font color='#ffffff'>IDLE</td>";
152
	print "<td><b><font color='#ffffff'>TXSEQ</td>";
153
	print "<td><b><font color='#ffffff'>RXSEQ</td>";
154
	print "<td><b><font color='#ffffff'>CAPS</td>";
155
	print "<td><b><font color='#ffffff'>ERP</td>";
156
	print "</tr>\n\n";
157

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

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

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

    
182
?>
183
</table>
184
</div>
185
</td></tr>
186
</table>
187

    
188
<?php include("fend.inc"); ?>
189
</body>
190
</html>
(164-164/214)