use macvendors.com for OUI lookup
[tomato.git] / release / src-rt-6.x.4708 / router / www / status-devices.asp
blobd51936b63f59791b88d33a063a7ca2870bfe0f79
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: 8%;
29 #dev-grid .co2 {
30 width: 20%;
32 #dev-grid .co3 {
33 width: 13%;
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 addbwlimit(n)
156 var e = list[n];
157 cookie.set('addbwlimit', [e.ip, e.name.split(',')[0]].join(','), 1);
158 location.href = 'bwlimit.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 e.ifname = '';
229 for (i = wldev.length - 1; i >= 0; --i) {
230 a = wldev[i];
231 if (a[0].indexOf('wds') == 0) {
232 e = get(a[1], '-');
234 else {
235 e = get(a[1], null);
237 e.ifname = a[0];
238 e.unit = a[6] * 1;
239 e.rssi = a[2];
241 if ((a[3] > 1000) || (a[4] > 1000))
242 e.txrx = ((a[3] > 1000) ? Math.round(a[3] / 1000) : '-') + ' / ' + ((a[4] > 1000) ? Math.round(a[4] / 1000) : '-'); //+ '<br><small>Mbps</small>';
245 for (i = arplist.length - 1; i >= 0; --i) {
246 a = arplist[i];
248 if ((e = get(a[1], a[0])) != null) {
249 if (e.ifname == '') e.ifname = a[2];
253 for (i = dhcpd_static.length - 1; i >= 0; --i) {
254 a = dhcpd_static[i].split('<');
255 if (a.length < 3) continue;
257 if (a[1].indexOf('.') == -1) a[1] = (ipp + a[1]);
259 c = a[0].split(',');
260 for (j = c.length - 1; j >= 0; --j) {
261 if ((e = find(c[j], a[1])) != null) break;
263 if (j < 0) continue;
265 if (e.ip == '') {
266 e.ip = a[1];
269 if (e.name == '') {
270 e.name = a[2];
272 else {
273 b = e.name.toLowerCase();
274 c = a[2].toLowerCase();
275 if ((b.indexOf(c) == -1) && (c.indexOf(b) == -1)) {
276 if (e.name != '') e.name += ', ';
277 e.name += a[2];
282 for (i = list.length - 1; i >= 0; --i) {
283 e = list[i];
285 b = e.mac;
286 if (e.mac.match(/^(..):(..):(..)/)) {
287 b += '<br><small>' +
288 '<a href="http://api.macvendors.com/' + RegExp.$1 + '-' + RegExp.$2 + '-' + RegExp.$3 + '" target="_new" title="OUI Search">[oui]</a> ' +
289 '<a href="javascript:addStatic(' + i + ')" title="Static Lease...">[static]</a> ' +
290 '<a href="javascript:addbwlimit(' + i + ')" title="BW Limiter">[bwlimit]</a>';
292 if (e.rssi != '') {
293 b += ' <a href="javascript:addWF(' + i + ')" title="Wireless Filter...">[wfilter]</a>';
295 b += '</small>';
297 else {
298 b = '';
301 var ifidx = wl_uidx(e.unit);
302 if ((e.rssi !== '') && (ifidx >= 0) && (wlnoise[ifidx] < 0)) {
303 e.qual = MAX(e.rssi - wlnoise[ifidx], 0);
305 else {
306 e.qual = -1;
309 this.insert(-1, e, [
310 e.ifname, b, (e.ip == '-') ? '' : e.ip, e.name,
311 (e.rssi != 0) ? e.rssi + ' <small>dBm</small>' : '',
312 (e.qual < 0) ? '' : '<small>' + e.qual + '</small> <img src="bar' + MIN(MAX(Math.floor(e.qual / 10), 1), 6) + '.gif">',
313 e.txrx, e.lease], false);
317 dg.setup = function()
319 this.init('dev-grid', 'sort');
320 this.headerSet(['Interface', 'MAC Address', 'IP Address', 'Name', 'RSSI &nbsp; &nbsp; ', 'Quality', 'TX/RX Rate&nbsp;', 'Lease &nbsp; &nbsp; ']);
321 this.populate();
322 this.sort(2);
325 function earlyInit()
327 dg.setup();
330 function init()
332 dg.recolor();
333 ref.initPage(3000, 3);
335 </script>
336 </head>
337 <body onload='init()'>
338 <table id='container' cellspacing=0>
339 <tr><td colspan=2 id='header'>
340 <div class='title'>Tomato</div>
341 <div class='version'>Version <% version(); %></div>
342 </td></tr>
343 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
344 <td id='content'>
345 <div id='ident'><% ident(); %></div>
347 <!-- / / / -->
349 <div class='section-title'>Device List</div>
350 <div class='section'>
351 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
353 <script type='text/javascript'>
354 f = [];
355 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
356 var u = wl_unit(uidx);
357 if (nvram['wl'+u+'_radio'] == '1') {
358 if (wl_sunit(uidx)<0) {
359 var a = '';
360 if ((nvram['wl'+u+'_mode'] == 'ap') || (nvram['wl'+u+'_mode'] == 'wds'))
361 a = '&nbsp;&nbsp;&nbsp; <input type="button" value="Measure" onclick="javascript:window.location=\'wlmnoise.cgi?_http_id=' + nvram.http_id + '&_wl_unit=' + u +'\'">';
362 f.push( { title: '<b>Noise Floor (' + wl_ifaces[uidx][0] + ')&nbsp;:</b>',
363 prefix: '<span id="noise'+uidx+'">',
364 custom: wlnoise[uidx],
365 suffix: '</span>&nbsp;<small>dBm</small>' + a } );
369 createFieldTable('', f);
370 </script>
372 </div>
374 <!-- / / / -->
376 </td></tr>
377 <tr><td id='footer' colspan=2><script type='text/javascript'>genStdRefresh(1,0,'ref.toggle()');</script></td></tr>
378 </table>
379 <script type='text/javascript'>earlyInit();</script>
380 </body>
381 </html>