Project

General

Profile

Download (5.51 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
require_once("guiconfig.inc");
30

    
31
function gentitle_pkg($pgname) {
32
	global $config;
33
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
34
}
35

    
36
$pgtitle = "Diagnostics: Wireless Status";
37
include("head.inc");
38

    
39
$if = $_POST['if'];
40
if($_GET['if'] <> "")
41
	$if = $_GET['if'];
42
if($if == "") {
43
	/* Find the first interface
44
	   that is wireless */
45
	foreach($config['interfaces'] as $interface) {
46
		if($interface['wireless'] <> "") {
47
			$if = $interface['if'];
48
		}
49
	}
50
}
51
?>
52

    
53
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
54
<?php
55
include("fbegin.inc");
56
?>
57
<p class="pgtitle"><?=$pgtitle?></p>
58
<form action="status_wireless.php" method="post">
59
<?php if ($savemsg) print_info_box($savemsg); ?>
60

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

    
88
if ($mode == 'bss') {
89
	/* table header */
90
	print "\n<tr><!-- " . count($state_split) . " -->";
91
	print "<tr bgcolor='#990000'>";
92
	print "<td><b><font color='#ffffff'>SSID</td>";
93
	print "<td><b><font color='#ffffff'>BSSID</td>";
94
	print "<td><b><font color='#ffffff'>CHAN</td>";
95
	print "<td><b><font color='#ffffff'>RATE</td>";
96
	print "<td><b><font color='#ffffff'>RSSI</td>";
97
	print "<td><b><font color='#ffffff'>INT</td>";
98
	print "<td><b><font color='#ffffff'>CAPS</td>";
99
	print "</tr>\n\n";
100

    
101
	$states=split("\n",`/sbin/ifconfig {$if} list scan | grep -v "CHAN RATE"`);
102

    
103
	$counter=0;
104
	foreach($states as $state) {
105
		$state_fixed = str_replace("  ", " ", $state);
106
		$state_fixed = str_replace("  ", " ", $state_fixed);
107
		$state_fixed = str_replace("  ", " ", $state_fixed);
108
		$state_split = split(" ", $state_fixed);
109
		if($state_split[1] <> ""){
110
			print "<tr>";
111
			print "<td>{$state_split[0]}</td>";
112
			print "<td>{$state_split[1]}</td>";
113
			print "<td>{$state_split[2]}</td>";
114
			print "<td>{$state_split[3]}</td>";
115
			print "<td>{$state_split[4]}</td>";
116
			print "<td>{$state_split[5]}</td>";
117
			print "<td>{$state_split[6]}</td>";
118
			print "</tr>\n";
119
			print "<!-- $state_fixed -->\n";
120
		}
121
	}
122
} elseif ($mode == 'hostap') {
123
	/* table header */
124
	print "\n<tr><!-- " . count($state_split) . " -->";
125
	print "<tr bgcolor='#990000'>";
126
	print "<td><b><font color='#ffffff'>ADDR</td>";
127
	print "<td><b><font color='#ffffff'>AID</td>";
128
	print "<td><b><font color='#ffffff'>CHAN</td>";
129
	print "<td><b><font color='#ffffff'>RATE</td>";
130
	print "<td><b><font color='#ffffff'>RSSI</td>";
131
	print "<td><b><font color='#ffffff'>IDLE</td>";
132
	print "<td><b><font color='#ffffff'>TXSEQ</td>";
133
	print "<td><b><font color='#ffffff'>RXSEQ</td>";
134
	print "<td><b><font color='#ffffff'>CAPS</td>";
135
	print "<td><b><font color='#ffffff'>ERP</td>";
136
	print "</tr>\n\n";
137

    
138
	$states=split("\n",`/sbin/ifconfig {$if} list sta | grep -v "AID CHAN"`);
139

    
140
	$counter=0;
141
	foreach($states as $state) {
142
		$state_fixed = str_replace("  ", " ", $state);
143
		$state_fixed = str_replace("  ", " ", $state_fixed);
144
		$state_fixed = str_replace("  ", " ", $state_fixed);
145
		$state_split = split(" ", $state_fixed);
146
		print "<tr>";
147
		print "<td>{$state_split[0]}</td>";
148
		print "<td>{$state_split[1]}</td>";
149
		print "<td>{$state_split[2]}</td>";
150
		print "<td>{$state_split[3]}</td>";
151
		print "<td>{$state_split[4]}</td>";
152
		print "<td>{$state_split[5]}</td>";
153
		print "<td>{$state_split[6]}</td>";
154
		print "<td>{$state_split[7]}</td>";
155
		print "<td>{$state_split[8]}</td>";
156
		print "<td>{$state_split[9]}</td>";
157
		print "</tr>\n";
158
		print "<!-- $state_fixed -->\n";
159
	}
160
}
161

    
162
/* XXX: what stats to we get for adhoc mode? */ 
163

    
164
?>
165
</table>
166
</div>
167
</td></tr>
168
</table>
169

    
170
<?php include("fend.inc"); ?>
171
<meta http-equiv="refresh" content="120;url=<?php print $_SERVER['SCRIPT_NAME']; ?>?if=<?php echo $if; ?>">
172
</body>
173
</html>
(141-141/183)