Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / www / status-devices.asp
bloba9c8075026ebeea89c83515f0ab456b150f1bc04
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Tomato VLAN GUI
8 Copyright (C) 2011 Augusto Bott
9 http://code.google.com/p/tomato-sdhc-vlan/
11 For use with Tomato Firmware only.
12 No part of this file may be used without permission.
13 -->
14 <html>
15 <head>
16 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
17 <meta name='robots' content='noindex,nofollow'>
18 <title>[<% ident(); %>] Status: Device List</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'>
20 <% css(); %>
21 <script type='text/javascript' src='tomato.js'></script>
23 <!-- / / / -->
25 <style type='text/css'>
26 #dev-grid .co1 {
27 width: 9%;
29 #dev-grid .co2 {
30 width: 18%;
32 #dev-grid .co3 {
33 width: 14%;
35 #dev-grid .co4 {
36 width: 21%;
38 #dev-grid .co5 {
39 width: 8%;
40 text-align: right;
42 #dev-grid .co6 {
43 width: 8%;
44 text-align: center;
46 #dev-grid .co7 {
47 width: 9%;
48 text-align: right;
50 #dev-grid .co8 {
51 width: 13%;
52 text-align: right;
54 #dev-grid .header {
55 text-align: left;
57 </style>
59 <script type='text/javascript' src='debug.js'></script>
61 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
62 <script type='text/javascript'>
64 ipp = '<% lipp(); %>.';
65 //<% nvram('lan_ifname,wl_ifname,wl_mode,wl_radio'); %>
66 // <% devlist(); %>
68 list = [];
70 function find(mac, ip)
72 var e, i;
74 mac = mac.toUpperCase();
75 for (i = list.length - 1; i >= 0; --i) {
76 e = list[i];
77 if (((e.mac == mac) && ((e.ip == ip) || (e.ip == '') || (ip == null))) ||
78 ((e.mac == '00:00:00:00:00:00') && (e.ip == ip))) {
79 return e;
82 return null;
85 function get(mac, ip)
87 var e, i;
89 mac = mac.toUpperCase();
90 if ((e = find(mac, ip)) != null) {
91 if (ip) e.ip = ip;
92 return e;
95 e = {
96 mac: mac,
97 ip: ip || '',
98 ifname: '',
99 unit: 0,
100 name: '',
101 rssi: '',
102 txrx: '',
103 lease: ''
105 list.push(e);
107 return e;
111 var xob = null;
113 function _deleteLease(ip)
115 form.submitHidden('dhcpd.cgi', { remove: ip });
118 function deleteLease(a, ip)
120 if (xob) return;
121 if ((xob = new XmlHttp()) == null) {
122 _deleteLease(ip);
123 return;
126 a = E(a);
127 a.innerHTML = 'deleting...';
129 xob.onCompleted = function(text, xml) {
130 a.innerHTML = '...';
131 xob = null;
133 xob.onError = function() {
134 _deleteLease(ip);
137 xob.post('dhcpd.cgi', 'remove=' + ip);
140 function addStatic(n)
142 var e = list[n];
143 cookie.set('addstatic', [e.mac, e.ip, e.name.split(',')[0]].join(','), 1);
144 location.href = 'basic-static.asp';
147 function addWF(n)
149 var e = list[n];
150 cookie.set('addmac', [e.mac, e.name.split(',')[0]].join(','), 1);
151 location.href = 'basic-wfilter.asp';
154 function addqoslimit(n)
156 var e = list[n];
157 cookie.set('addqoslimit', [e.ip, e.name.split(',')[0]].join(','), 1);
158 location.href = 'qoslimit.asp';
161 var ref = new TomatoRefresh('update.cgi', 'exec=devlist', 0, 'status_devices_refresh');
163 ref.refresh = function(text)
165 eval(text);
166 dg.removeAllData();
167 dg.populate();
168 dg.resort();
169 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
170 if (wl_sunit(uidx)<0)
171 E("noise"+uidx).innerHTML = wlnoise[uidx];
176 var dg = new TomatoGrid();
178 dg.sortCompare = function(a, b) {
179 var col = this.sortColumn;
180 var ra = a.getRowData();
181 var rb = b.getRowData();
182 var r;
184 switch (col) {
185 case 2:
186 r = cmpIP(ra.ip, rb.ip);
187 break;
188 case 4:
189 r = cmpInt(ra.rssi, rb.rssi);
190 break;
191 case 5:
192 r = cmpInt(ra.qual, rb.qual);
193 break;
194 default:
195 r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
197 if (r == 0) {
198 r = cmpIP(ra.ip, rb.ip);
199 if (r == 0) r = cmpText(ra.ifname, rb.ifname);
201 return this.sortAscending ? r : -r;
204 dg.populate = function()
206 var i, j;
207 var a, b, c, e;
209 list = [];
211 for (i = 0; i < list.length; ++i) {
212 list[i].ip = '';
213 list[i].ifname = '';
214 list[i].unit = 0;
215 list[i].name = '';
216 list[i].rssi = '';
217 list[i].txrx = '';
218 list[i].lease = '';
221 for (i = dhcpd_lease.length - 1; i >= 0; --i) {
222 a = dhcpd_lease[i];
223 e = get(a[2], a[1]);
224 e.lease = '<small><a href="javascript:deleteLease(\'L' + i + '\',\'' + a[1] + '\')" title="Delete Lease" id="L' + i + '">' + a[3] + '</a></small>';
225 e.name = a[0];
226 /* NOVLAN-BEGIN */
227 e.ifname = nvram.lan_ifname;
228 /* NOVLAN-END */
229 /* VLAN-BEGIN */
230 e.ifname = '';
231 /* VLAN-END */
234 for (i = wldev.length - 1; i >= 0; --i) {
235 a = wldev[i];
236 if (a[0].indexOf('wds') == 0) {
237 e = get(a[1], '-');
239 else {
240 e = get(a[1], null);
242 e.ifname = a[0];
243 e.unit = a[6] * 1;
244 e.rssi = a[2];
246 if ((a[3] > 1000) || (a[4] > 1000))
247 e.txrx = ((a[3] > 1000) ? Math.round(a[3] / 1000) : '-') + ' / ' + ((a[4] > 1000) ? Math.round(a[4] / 1000) : '-'); //+ '<br><small>Mbps</small>';
250 for (i = arplist.length - 1; i >= 0; --i) {
251 a = arplist[i];
253 if ((e = get(a[1], a[0])) != null) {
254 if (e.ifname == '') e.ifname = a[2];
258 for (i = dhcpd_static.length - 1; i >= 0; --i) {
259 a = dhcpd_static[i].split('<');
260 if (a.length < 3) continue;
262 if (a[1].indexOf('.') == -1) a[1] = (ipp + a[1]);
264 c = a[0].split(',');
265 for (j = c.length - 1; j >= 0; --j) {
266 if ((e = find(c[j], a[1])) != null) break;
268 if (j < 0) continue;
270 if (e.ip == '') {
271 e.ip = a[1];
274 if (e.name == '') {
275 e.name = a[2];
277 else {
278 b = e.name.toLowerCase();
279 c = a[2].toLowerCase();
280 if ((b.indexOf(c) == -1) && (c.indexOf(b) == -1)) {
281 if (e.name != '') e.name += ', ';
282 e.name += a[2];
287 for (i = list.length - 1; i >= 0; --i) {
288 e = list[i];
290 b = e.mac;
291 if (e.mac.match(/^(..):(..):(..)/)) {
292 b += '<br><small>' +
293 '<a href="http://standards.ieee.org/cgi-bin/ouisearch?' + RegExp.$1 + '-' + RegExp.$2 + '-' + RegExp.$3 + '" target="_new" title="OUI Search">[oui]</a> ' +
294 '<a href="javascript:addStatic(' + i + ')" title="Static Lease...">[static]</a>' +
295 '<a href="javascript:addqoslimit(' + i + ')" title="QoS BW Limiter">[qoslimit]</a>';
297 if (e.rssi != '') {
298 b += ' <a href="javascript:addWF(' + i + ')" title="Wireless Filter...">[wfilter]</a>';
300 b += '</small>';
302 else {
303 b = '';
306 var ifidx = wl_uidx(e.unit);
307 if ((e.rssi !== '') && (ifidx >= 0) && (wlnoise[ifidx] < 0)) {
308 e.qual = MAX(e.rssi - wlnoise[ifidx], 0);
310 else {
311 e.qual = -1;
314 this.insert(-1, e, [
315 e.ifname, b, (e.ip == '-') ? '' : e.ip, e.name,
316 (e.rssi != 0) ? e.rssi + ' <small>dBm</small>' : '',
317 (e.qual < 0) ? '' : '<small>' + e.qual + '</small> <img src="bar' + MIN(MAX(Math.floor(e.qual / 10), 1), 6) + '.gif">',
318 e.txrx, e.lease], false);
322 dg.setup = function()
324 this.init('dev-grid', 'sort');
325 this.headerSet(['Interface', 'MAC Address', 'IP Address', 'Name', 'RSSI &nbsp; &nbsp; ', 'Quality', 'TX/RX Rate&nbsp;', 'Lease &nbsp; &nbsp; ']);
326 this.populate();
327 this.sort(2);
330 function earlyInit()
332 dg.setup();
335 function init()
337 dg.recolor();
338 ref.initPage(3000, 3);
340 </script>
341 </head>
342 <body onload='init()'>
343 <table id='container' cellspacing=0>
344 <tr><td colspan=2 id='header'>
345 <div class='title'>Tomato</div>
346 <div class='version'>Version <% version(); %></div>
347 </td></tr>
348 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
349 <td id='content'>
350 <div id='ident'><% ident(); %></div>
352 <!-- / / / -->
354 <div class='section-title'>Device List</div>
355 <div class='section'>
356 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
358 <script type='text/javascript'>
359 f = [];
360 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
361 var u = wl_unit(uidx);
362 if (nvram['wl'+u+'_radio'] == '1') {
363 if (wl_sunit(uidx)<0) {
364 var a = '';
365 if ((nvram['wl'+u+'_mode'] == 'ap') || (nvram['wl'+u+'_mode'] == 'wds'))
366 a = '&nbsp;&nbsp;&nbsp; <input type="button" value="Measure" onclick="javascript:window.location=\'wlmnoise.cgi?_http_id=' + nvram.http_id + '&_wl_unit=' + u +'\'">';
367 f.push( { title: '<b>Ground Noise (' + wl_ifaces[uidx][0] + ')&nbsp;:</b>',
368 prefix: '<span id="noise'+uidx+'">',
369 custom: wlnoise[uidx],
370 suffix: '</span>&nbsp;<small>dBm</small>' + a } );
374 createFieldTable('', f);
375 </script>
377 </div>
379 <!-- / / / -->
381 </td></tr>
382 <tr><td id='footer' colspan=2><script type='text/javascript'>genStdRefresh(1,1,'ref.toggle()');</script></td></tr>
383 </table>
384 <script type='text/javascript'>earlyInit();</script>
385 </body>
386 </html>