Fix issues with 'disappearing' WL ifaces (when not assigned as part of any LAN bridges)
[tomato.git] / release / src / router / www / status-overview.asp
blob0235db8760de3a66e41e1ac6d583f14108310e9b
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: Overview</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'>
20 <% css(); %>
21 <script type='text/javascript' src='tomato.js'></script>
22 <script type='text/javascript' src='interfaces.js'></script>
24 <!-- / / / -->
26 <style type='text/css'>
27 .controls {
28 width: 90px;
29 margin-top: 5px;
30 margin-bottom: 10px;
32 </style>
34 <script type='text/javascript' src='debug.js'></script>
36 <script type='text/javascript'>
37 wmo = {'ap':'Access Point','sta':'Wireless Client','wet':'Wireless Ethernet Bridge','wds':'WDS'};
38 auth = {'disabled':'-','wep':'WEP','wpa_personal':'WPA Personal (PSK)','wpa_enterprise':'WPA Enterprise','wpa2_personal':'WPA2 Personal (PSK)','wpa2_enterprise':'WPA2 Enterprise','wpaX_personal':'WPA / WPA2 Personal','wpaX_enterprise':'WPA / WPA2 Enterprise','radius':'Radius'};
39 enc = {'tkip':'TKIP','aes':'AES','tkip+aes':'TKIP / AES'};
40 bgmo = {'disabled':'-','mixed':'Auto','b-only':'B Only','g-only':'G Only','bg-mixed':'B/G Mixed','lrs':'LRS','n-only':'N Only'};
42 lastjiffiestotal = 0;
43 lastjiffiesidle = 0;
44 lastjiffiesusage = 100;
45 </script>
47 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
48 <script type='text/javascript' src='status-data.jsx?_http_id=<% nv(http_id); %>'></script>
50 <script type='text/javascript'>
51 show_dhcpc = ((nvram.wan_proto == 'dhcp') || (((nvram.wan_proto == 'l2tp') || (nvram.wan_proto == 'pptp')) && (nvram.pptp_dhcp == '1')));
52 show_codi = ((nvram.wan_proto == 'pppoe') || (nvram.wan_proto == 'l2tp') || (nvram.wan_proto == 'pptp'));
54 show_radio = [];
55 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
56 /* REMOVE-BEGIN
57 // show_radio.push((nvram['wl'+wl_unit(uidx)+'_radio'] == '1'));
58 REMOVE-END */
59 if (wl_sunit(uidx)<0)
60 show_radio.push((nvram['wl'+wl_fface(uidx)+'_radio'] == '1'));
63 nphy = features('11n');
65 function dhcpc(what)
67 form.submitHidden('dhcpc.cgi', { exec: what, _redirect: 'status-overview.asp' });
70 function serv(service, sleep)
72 form.submitHidden('service.cgi', { _service: service, _redirect: 'status-overview.asp', _sleep: sleep });
75 function wan_connect()
77 serv('wan-restart', 5);
80 function wan_disconnect()
82 serv('wan-stop', 2);
85 function wlenable(uidx, n)
87 form.submitHidden('wlradio.cgi', { enable: '' + n, _nextpage: 'status-overview.asp', _nextwait: n ? 6 : 3, _wl_unit: wl_unit(uidx) });
90 var ref = new TomatoRefresh('status-data.jsx', '', 0, 'status_overview_refresh');
92 ref.refresh = function(text)
94 stats = {};
95 try {
96 eval(text);
98 catch (ex) {
99 stats = {};
101 show();
105 function c(id, htm)
107 E(id).cells[1].innerHTML = htm;
110 function show()
112 c('cpu', stats.cpuload);
113 c('cpupercent', stats.cpupercent);
114 c('uptime', stats.uptime);
115 c('time', stats.time);
116 c('wanip', stats.wanip);
117 c('wanprebuf',stats.wanprebuf); //Victek
118 c('wannetmask', stats.wannetmask);
119 c('wangateway', stats.wangateway);
120 c('dns', stats.dns);
121 c('memory', stats.memory);
122 c('swap', stats.swap);
123 elem.display('swap', stats.swap != '');
125 /* IPV6-BEGIN */
126 c('ip6_wan', stats.ip6_wan);
127 elem.display('ip6_wan', stats.ip6_wan != '');
128 c('ip6_lan', stats.ip6_lan);
129 elem.display('ip6_lan', stats.ip6_lan != '');
130 c('ip6_lan_ll', stats.ip6_lan_ll);
131 elem.display('ip6_lan_ll', stats.ip6_lan_ll != '');
132 /* IPV6-END */
134 c('wanstatus', stats.wanstatus);
135 c('wanuptime', stats.wanuptime);
136 if (show_dhcpc) c('wanlease', stats.wanlease);
137 if (show_codi) {
138 E('b_connect').disabled = stats.wanup;
139 E('b_disconnect').disabled = !stats.wanup;
142 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
143 if (wl_sunit(uidx)<0) {
144 c('radio'+uidx, wlstats[uidx].radio ? 'Enabled' : '<b>Disabled</b>');
145 c('rate'+uidx, wlstats[uidx].rate);
146 if (show_radio[uidx]) {
147 E('b_wl'+uidx+'_enable').disabled = wlstats[uidx].radio;
148 E('b_wl'+uidx+'_disable').disabled = !wlstats[uidx].radio;
150 c('channel'+uidx, stats.channel[uidx]);
151 if (nphy) {
152 c('nbw'+uidx, wlstats[uidx].nbw);
154 c('interference'+uidx, stats.interference[uidx]);
155 elem.display('interference'+uidx, stats.interference[uidx] != '');
157 if (wlstats[uidx].client) {
158 c('rssi'+uidx, wlstats[uidx].rssi || '');
159 c('noise'+uidx, wlstats[uidx].noise || '');
160 c('qual'+uidx, stats.qual[uidx] || '');
163 c('ifstatus'+uidx, wlstats[uidx].ifstatus || '');
167 function earlyInit()
169 elem.display('b_dhcpc', show_dhcpc);
170 elem.display('b_connect', 'b_disconnect', show_codi);
171 elem.display('wan-title', 'wan-section', nvram.wan_proto != 'disabled');
172 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
173 if (wl_sunit(uidx)<0)
174 elem.display('b_wl'+uidx+'_enable', 'b_wl'+uidx+'_disable', show_radio[uidx]);
176 show();
179 function init()
181 ref.initPage(3000, 3);
183 </script>
185 </head>
186 <body onload='init()'>
187 <form>
188 <table id='container' cellspacing=0>
189 <tr><td colspan=2 id='header'>
190 <div class='title'>Tomato</div>
191 <div class='version'>Version <% version(); %></div>
192 </td></tr>
193 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
194 <td id='content'>
195 <div id='ident'><% ident(); %></div>
197 <!-- / / / -->
199 <div class='section-title'>System</div>
200 <div class='section'>
201 <script type='text/javascript'>
202 createFieldTable('', [
203 { title: 'Name', text: nvram.router_name },
204 { title: 'Model', text: nvram.t_model_name },
205 { title: 'Chipset', text: stats.systemtype },
206 { title: 'CPU Freq', text: stats.cpumhz },
207 { title: 'Flash RAM Size', text: stats.flashsize },
208 null,
209 { title: 'Time', rid: 'time', text: stats.time },
210 { title: 'Uptime', rid: 'uptime', text: stats.uptime },
211 { title: 'CPU Load <small>(1 / 5 / 15 mins)</small>', rid: 'cpu', text: stats.cpuload },
212 { title: 'CPU Usage', rid: 'cpupercent', text: stats.cpupercent },
213 { title: 'Total / Free Memory', rid: 'memory', text: stats.memory },
214 { title: 'Total / Free Swap', rid: 'swap', text: stats.swap, hidden: (stats.swap == '') },
216 </script>
217 </div>
219 <div class='section-title' id='wan-title'>WAN</div>
220 <div class='section' id='wan-section'>
221 <script type='text/javascript'>
222 createFieldTable('', [
223 { title: 'MAC Address', text: nvram.wan_hwaddr },
224 { title: 'Connection Type', text: { 'dhcp':'DHCP', 'static':'Static IP', 'pppoe':'PPPoE', 'pptp':'PPTP', 'l2tp':'L2TP' }[nvram.wan_proto] || '-' },
225 { title: 'IP Address', rid: 'wanip', text: stats.wanip },
226 { title: 'Previous WAN IP', rid: 'wanprebuf',text:stats.wanprebuf }, //Victek
227 { title: 'Subnet Mask', rid: 'wannetmask', text: stats.wannetmask },
228 { title: 'Gateway', rid: 'wangateway', text: stats.wangateway },
229 /* IPV6-BEGIN */
230 { title: 'IPv6 Address', rid: 'ip6_wan', text: stats.ip6_wan, hidden: (stats.ip6_wan == '') },
231 /* IPV6-END */
232 { title: 'DNS', rid: 'dns', text: stats.dns },
233 { title: 'MTU', text: nvram.wan_run_mtu },
234 null,
235 { title: 'Status', rid: 'wanstatus', text: stats.wanstatus },
236 { title: 'Connection Uptime', rid: 'wanuptime', text: stats.wanuptime },
237 { title: 'Remaining Lease Time', rid: 'wanlease', text: stats.wanlease, ignore: !show_dhcpc }
239 </script>
240 <span id='b_dhcpc' style='display:none'>
241 <input type='button' class='controls' onclick='dhcpc("renew")' value='Renew'>
242 <input type='button' class='controls' onclick='dhcpc("release")' value='Release'> &nbsp;
243 </span>
244 <input type='button' class='controls' onclick='wan_connect()' value='Connect' id='b_connect' style='display:none'>
245 <input type='button' class='controls' onclick='wan_disconnect()' value='Disconnect' id='b_disconnect' style='display:none'>
246 </div>
249 <div class='section-title'>LAN</div>
250 <div class='section'>
251 <script type='text/javascript'>
253 /* VLAN-BEGIN */
254 var s='';
255 var t='';
256 for (var i = 0 ; i <= MAX_BRIDGE_ID ; i++) {
257 var j = (i == 0) ? '' : i.toString();
258 if (nvram['lan' + j + '_ifname'].length > 0) {
259 if (nvram['lan' + j + '_proto'] == 'dhcp') {
260 if ((!fixIP(nvram.dhcpd_startip)) || (!fixIP(nvram.dhcpd_endip))) {
261 var x = nvram['lan' + j + '_ipaddr'].split('.').splice(0, 3).join('.') + '.';
262 nvram['dhcpd' + j + '_startip'] = x + nvram['dhcp' + j + '_start'];
263 nvram['dhcpd' + j + '_endip'] = x + ((nvram['dhcp' + j + '_start'] * 1) + (nvram['dhcp' + j + '_num'] * 1) - 1);
265 s += ((s.length>0)&&(s.charAt(s.length-1) != ' ')) ? ', ' : '';
266 s += '<a href="status-devices.asp">' + nvram['dhcpd' + j + '_startip'] + ' - ' + nvram['dhcpd' + j + '_endip'] + '</a> on LAN' + j + ' (br' + i + ')';
267 } else {
268 s += ((s.length>0)&&(s.charAt(s.length-1) != ' ')) ? ', ' : '';
269 s += 'Disabled on LAN' + j + ' (br' + i + ')';
271 t += ((t.length>0)&&(t.charAt(t.length-1) != ' ')) ? ', ' : '';
272 t += nvram['lan' + j + '_ipaddr'] + '/' + numberOfBitsOnNetMask(nvram['lan' + j + '_netmask']) + ' on LAN' + j + ' (br' + i + ')';
276 createFieldTable('', [
277 { title: 'Router MAC Address', text: nvram.et0macaddr },
278 { title: 'Router IP Addresses', text: t },
279 { title: 'Gateway', text: nvram.lan_gateway, ignore: nvram.wan_proto != 'disabled' },
280 /* IPV6-BEGIN */
281 { title: 'Router IPv6 Address', rid: 'ip6_lan', text: stats.ip6_lan, hidden: (stats.ip6_lan == '') },
282 { title: 'IPv6 Link-local Address', rid: 'ip6_lan_ll', text: stats.ip6_lan_ll, hidden: (stats.ip6_lan_ll == '') },
283 /* IPV6-END */
284 { title: 'DNS', rid: 'dns', text: stats.dns, ignore: nvram.wan_proto != 'disabled' },
285 { title: 'DHCP', text: s }
287 /* VLAN-END */
289 /* NOVLAN-BEGIN */
290 if (nvram.lan_proto == 'dhcp') {
291 if ((!fixIP(nvram.dhcpd_startip)) || (!fixIP(nvram.dhcpd_endip))) {
292 var x = nvram.lan_ipaddr.split('.').splice(0, 3).join('.') + '.';
293 nvram.dhcpd_startip = x + nvram.dhcp_start;
294 nvram.dhcpd_endip = x + ((nvram.dhcp_start * 1) + (nvram.dhcp_num * 1) - 1);
296 s = '<a href="status-devices.asp">' + nvram.dhcpd_startip + ' - ' + nvram.dhcpd_endip + '</a>';
298 else {
299 s = 'Disabled';
301 createFieldTable('', [
302 { title: 'Router MAC Address', text: nvram.et0macaddr },
303 { title: 'Router IP Address', text: nvram.lan_ipaddr },
304 { title: 'Subnet Mask', text: nvram.lan_netmask },
305 { title: 'Gateway', text: nvram.lan_gateway, ignore: nvram.wan_proto != 'disabled' },
306 /* IPV6-BEGIN */
307 { title: 'Router IPv6 Address', rid: 'ip6_lan', text: stats.ip6_lan, hidden: (stats.ip6_lan == '') },
308 { title: 'IPv6 Link-local Address', rid: 'ip6_lan_ll', text: stats.ip6_lan_ll, hidden: (stats.ip6_lan_ll == '') },
309 /* IPV6-END */
310 { title: 'DNS', rid: 'dns', text: stats.dns, ignore: nvram.wan_proto != 'disabled' },
311 { title: 'DHCP', text: s }
313 /* NOVLAN-END */
315 </script>
316 </div>
318 <script type='text/javascript'>
319 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
320 u = wl_unit(uidx);
321 W('<div class=\'section-title\' id=\'wl'+uidx+'-title\'>Wireless');
322 if (wl_ifaces.length > 1)
323 W(' (' + wl_display_ifname(uidx) + ')');
324 W('</div>');
325 W('<div class=\'section\' id=\'wl'+uidx+'-section\'>');
326 sec = auth[nvram['wl'+u+'_security_mode']] + '';
327 if (sec.indexOf('WPA') != -1) sec += ' + ' + enc[nvram['wl'+u+'_crypto']];
329 wmode = wmo[nvram['wl'+u+'_mode']] + '';
330 if ((nvram['wl'+u+'_mode'] == 'ap') && (nvram['wl'+u+'_wds_enable'] * 1)) wmode += ' + WDS';
332 createFieldTable('', [
333 { title: 'MAC Address', text: nvram['wl'+u+'_hwaddr'] },
334 { title: 'Wireless Mode', text: wmode },
335 { title: 'Wireless Network Mode', text: bgmo[nvram['wl'+u+'_net_mode']] },
336 { title: 'Interface Status', rid: 'ifstatus'+uidx, text: wlstats[uidx].ifstatus },
337 { title: 'Radio', rid: 'radio'+uidx, text: (wlstats[uidx].radio == 0) ? '<b>Disabled</b>' : 'Enabled' },
338 /* REMOVE-BEGIN */
339 // { title: 'SSID', text: (nvram['wl'+u+'_ssid'] + ' <small><i>' + ((nvram['wl'+u+'_mode'] != 'ap') ? '' : ((nvram['wl'+u+'_closed'] == 0) ? '(Broadcast Enabled)' : '(Broadcast Disabled)')) + '</i></small>') },
340 /* REMOVE-END */
341 { title: 'SSID', text: nvram['wl'+u+'_ssid'] },
342 { title: 'Broadcast', text: (nvram['wl'+u+'_closed'] == 0) ? 'Enabled' : '<b>Disabled</b>', ignore: (nvram['wl'+u+'_mode'] != 'ap') },
343 { title: 'Security', text: sec },
344 { title: 'Channel', rid: 'channel'+uidx, text: stats.channel[uidx], ignore: (wl_sunit(uidx)>=0) },
345 { title: 'Channel Width', rid: 'nbw'+uidx, text: wlstats[uidx].nbw, ignore: ((!nphy) || (wl_sunit(uidx)>=0)) },
346 { title: 'Interference Level', rid: 'interference'+uidx, text: stats.interference[uidx], hidden: ((stats.interference[uidx] == '') || (wl_sunit(uidx)>=0)) },
347 { title: 'Rate', rid: 'rate'+uidx, text: wlstats[uidx].rate, ignore: (wl_sunit(uidx)>=0) },
348 { title: 'RSSI', rid: 'rssi'+uidx, text: wlstats[uidx].rssi || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) },
349 { title: 'Noise', rid: 'noise'+uidx, text: wlstats[uidx].noise || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) },
350 { title: 'Signal Quality', rid: 'qual'+uidx, text: stats.qual[uidx] || '', ignore: ((!wlstats[uidx].client) || (wl_sunit(uidx)>=0)) }
353 W('<input type=\'button\' class=\'controls\' onclick=\'wlenable('+uidx+', 1)\' id=\'b_wl'+uidx+'_enable\' value=\'Enable\' style=\'display:none\'>');
354 W('<input type=\'button\' class=\'controls\' onclick=\'wlenable('+uidx+', 0)\' id=\'b_wl'+uidx+'_disable\' value=\'Disable\' style=\'display:none\'>');
355 W('</div>');
357 </script>
360 <!-- / / / -->
362 </td></tr>
363 <tr><td id='footer' colspan=2>
364 <script type='text/javascript'>genStdRefresh(1,1,'ref.toggle()');</script>
365 </td></tr>
366 </table>
367 </form>
368 <script type='text/javascript'>earlyInit()</script>
369 </body>
370 </html>