Limit LAN subnet to 22 bits (255.255.252.0).
[tomato.git] / release / src / router / www / basic-network.asp
blob2e7d0254910597f3e677a9214a5d2d8afbde83ef
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 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Basic: Networks</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <% css(); %>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <style type='text/css'>
22 #lan-grid .co1,
23 #lan-grid .co2,
24 #lan-grid .co3,
25 #lan-grid .co4,
26 #lan-grid .co5,
27 #lan-grid .co6,
28 #lan-grid .co7 {
29 text-align: center;
32 #lan-grid .centered {
33 text-align: center;
35 </style>
37 <script type='text/javascript' src='debug.js'></script>
39 <script type='text/javascript' src='md5.js'></script>
40 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
41 <script type='text/javascript' src='interfaces.js'></script>
42 <script type='text/javascript'>
43 // <% nvram("dhcp_lease,dhcp_num,dhcp_start,dhcpd_startip,dhcpd_endip,l2tp_server_ip,lan_gateway,lan_ipaddr,lan_netmask,lan_proto,mtu_enable,ppp_demand,ppp_mlppp,ppp_idletime,ppp_passwd,ppp_redialperiod,ppp_service,ppp_username,ppp_custom,pptp_server_ip,pptp_dhcp,wl_security_mode,wan_dns,wan_gateway,wan_ipaddr,wan_mtu,wan_netmask,wan_proto,wan_wins,wl_wds_enable,wl_channel,wl_closed,wl_crypto,wl_key,wl_key1,wl_key2,wl_key3,wl_key4,wl_lazywds,wl_mode,wl_net_mode,wl_passphrase,wl_radio,wl_radius_ipaddr,wl_radius_port,wl_ssid,wl_wds,wl_wep_bit,wl_wpa_gtk_rekey,wl_wpa_psk,wl_radius_key,wl_auth,wl_hwaddr,wan_islan,t_features,wl_nbw_cap,wl_nctrlsb,wl_nband,wl_phytype,lan_ifname,lan_stp,lan1_ifname,lan1_ipaddr,lan1_netmask,lan1_proto,lan1_stp,dhcp1_start,dhcp1_num,dhcp1_lease,dhcpd1_startip,dhcpd1_endip,lan2_ifname,lan2_ipaddr,lan2_netmask,lan2_proto,lan2_stp,dhcp2_start,dhcp2_num,dhcp2_lease,dhcpd2_startip,dhcpd2_endip,lan3_ifname,lan3_ipaddr,lan3_netmask,lan3_proto,lan3_stp,dhcp3_start,dhcp3_num,dhcp3_lease,dhcpd3_startip,dhcpd3_endip,modem_pin,modem_dev,modem_init,modem_apn"); %>
45 var lg = new TomatoGrid();
46 lg.setup = function() {
47 this.init('lan-grid', '', 4, [
48 { type: 'select', options: [[0, '0'],[1, '1'],[2, '2'],[3, '3']], prefix: '<div class="centered">', suffix: '</div>' },
49 { type: 'checkbox', prefix: '<div class="centered">', suffix: '</div>' },
50 { type: 'text', maxlen: 15, size: 17 },
51 { type: 'text', maxlen: 15, size: 17 },
52 { type: 'checkbox', prefix: '<div class="centered">', suffix: '</div>' },
53 { multi: [ { type: 'text', maxlen: 15, size: 17}, { type: 'text', maxlen: 15, size: 17 } ] },
54 { type: 'text', maxlen: 6, size: 8 }] );
55 this.headerSet(['Bridge', 'STP', 'IP Address', 'Netmask', 'DHCP', 'IP&nbsp;Range&nbsp;<i>(first/last)</i>', 'Lease&nbsp;Time&nbsp;<i>(mins)</i>']);
57 var numBridges = 0;
58 for (var i = 0 ; i <= MAX_BRIDGE_ID ; i++) {
59 var j = (i == 0) ? '' : i.toString();
60 if (nvram['lan' + j + '_ifname'].length > 0) {
61 if ((!fixIP(nvram['dhcpd' + j + '_startip'])) || (!fixIP(nvram['dhcpd' + j + '_endip']))) {
62 if ((fixIP(nvram['lan' + j + '_ipaddr'])) && (fixIP(nvram['lan' + j + '_netmask'])) && (nvram['dhcp' + j + '_start'] != '')) {
63 var n = getNetworkAddress(nvram['lan' + j + '_ipaddr'], nvram['lan' + j + '_netmask']);
64 nvram['dhcpd' + j + '_startip'] = getAddress(('0.0.0.' + nvram['dhcp' + j + '_start'] * 1), n);
65 nvram['dhcpd' + j + '_endip'] = getAddress(('0.0.0.' + ((nvram['dhcp' + j + '_start'] * 1) + (nvram['dhcp' + j + '_num'] *1) - 1)), n);
68 lg.insertData(-1, [
69 i.toString(),
70 nvram['lan' + j + '_stp'],
71 nvram['lan' + j + '_ipaddr'],
72 nvram['lan' + j + '_netmask'],
73 (nvram['lan' + j + '_proto'] == 'dhcp') ? '1' : '0',
74 nvram['dhcpd' + j + '_startip'],
75 nvram['dhcpd' + j + '_endip'],
76 (nvram['dhcp' + j + '_start'] != '') ? nvram['dhcp' + j + '_lease'] : ''
77 ] ) ;
78 numBridges++;
81 lg.canDelete = false;
82 lg.sort(0);
83 elem.removeClass(lg.header.cells[lg.sortColumn], 'sortasc', 'sortdes');
84 lg.showNewEditor();
85 lg.resetNewEditor();
88 lg.dataToView = function(data) {
89 return ['br' + data[0],
90 (data[1].toString() == '1') ? '<small><i>Enabled</i></small>' : '<small><i>Disabled</i></small>',
91 data[2],
92 data[3],
93 (data[4].toString() == '1') ? '<small><i>Enabled</i></small>' : '<small><i>Disabled</i></small>',
94 (data[5].toString() + ((numberOfBitsOnNetMask(data[3])>=24) ? (' - ' + data[6].split('.').splice(3, 1).toString()) : ('<br>' + data[6].toString()) )),
95 (((data[7] != null) && (data[7] != '')) ? data[7] : '') ];
98 lg.dataToFieldValues = function (data) {
99 return [data[0],
100 (data[1] != 0) ? 'checked' : '',
101 data[2].toString(),
102 data[3].toString(),
103 (data[4].toString() == '1') ? 'checked' : '',
104 data[5].toString(),
105 data[6].toString(),
106 data[7].toString() ];
109 lg.fieldValuesToData = function(row) {
110 var f = fields.getAll(row);
111 return [f[0].value,
112 f[1].checked ? 1 : 0,
113 f[2].value,
114 f[3].value,
115 f[4].checked ? 1 : 0,
116 f[5].value,
117 f[6].value,
118 f[7].value ];
121 lg.resetNewEditor = function() {
122 var f = fields.getAll(this.newEditor);
123 f[0].selectedIndex=0;
124 var t = MAX_BRIDGE_ID;
125 while((this.countBridge(f[0].selectedIndex) > 0) && (t > 0)) {
126 f[0].selectedIndex = (f[0].selectedIndex%(MAX_BRIDGE_ID))+1;
127 t--;
129 for(var j=0; j<= MAX_BRIDGE_ID ; j++) {
130 f[0].options[j].disabled = (this.countBridge(j) > 0);
132 f[1].checked = 0;
133 f[2].value = '';
134 f[3].value = '';
135 f[5].value = '';
136 f[6].value = '';
137 f[7].value = '';
138 f[4].checked = 0;
139 f[4].disabled = 1;
140 f[5].disabled = 1;
141 f[6].disabled = 1;
142 f[7].disabled = 1;
143 ferror.clearAll(fields.getAll(this.newEditor));
146 lg.onCancel = function() {
147 this.removeEditor();
148 this.showSource();
149 this.disableNewEditor(false);
151 this.resetNewEditor();
154 lg.onAdd = function() {
155 var data;
157 this.moving = null;
158 this.rpHide();
160 if (!this.verifyFields(this.newEditor, false)) return;
162 data = this.fieldValuesToData(this.newEditor);
163 this.insertData(-1, data);
165 this.disableNewEditor(false);
166 this.resetNewEditor();
168 this.resort();
171 lg.onOK = function() {
172 var i, data, view;
174 if (!this.verifyFields(this.editor, false)) return;
176 data = this.fieldValuesToData(this.editor);
177 view = this.dataToView(data);
179 this.source.setRowData(data);
180 for (i = 0; i < this.source.cells.length; ++i) {
181 this.source.cells[i].innerHTML = view[i];
184 this.removeEditor();
185 this.showSource();
186 this.disableNewEditor(false);
188 this.resort();
189 this.resetNewEditor();
192 lg.onDelete = function() {
193 this.removeEditor();
194 elem.remove(this.source);
195 this.source = null;
196 this.disableNewEditor(false);
198 this.resetNewEditor();
201 lg.countElem = function(f, v) {
202 var data = this.getAllData();
203 var total = 0;
204 for (var i = 0; i < data.length; ++i) {
205 total += (data[i][f] == v) ? 1 : 0;
207 return total;
210 lg.countBridge = function (v) {
211 return this.countElem(0,v);
214 lg.countOverlappingNetworks = function (ip) {
215 var data = this.getAllData();
216 var total = 0;
217 for (var i = 0; i < data.length; ++i) {
218 var net = getNetworkAddress(data[i][2], data[i][3]);
219 var brd = getBroadcastAddress(net, data[i][3]);
220 total += ((aton(ip) <= aton(brd)) && (aton(ip) >= aton(net))) ? 1 : 0;
222 return total;
225 lg.verifyFields = function(row, quiet) {
226 var ok=1;
227 var f;
229 f = fields.getAll(row);
231 for(var j=0; j<= MAX_BRIDGE_ID ; j++) {
232 f[0].options[j].disabled = (this.countBridge(j) > 0);
235 if(this.countBridge(f[0].selectedIndex) > 0) {
236 ferror.set(f[0], 'Cannot add another entry for bridge br' + f[0].selectedIndex, quiet);
237 ok = 0;
238 } else {
239 ferror.clear(f[0]);
241 // valid IP address?
242 if(!v_ip(f[2], quiet || !ok))
243 ok = 0;
244 // if we have a properly defined IP address - 0.0.0.0 is NOT a valid IP address for our intents/purposes!
245 if ((f[2].value != '') && (f[2].value != '0.0.0.0')) {
246 // allow DHCP to be enabled
247 f[4].disabled = 0;
248 // validate netmask
249 if(!v_netmask(f[3], quiet || !ok)) {
250 return 0;
251 } else {
252 // must be 22 bits or smaller network
253 if (numberOfBitsOnNetMask(f[3].value) < 22) {
254 ferror.set(f[3], 'Netmask must have at least 22 bits set (255.255.252.0)', quiet);
255 return 0;
256 } else {
257 ferror.clear(f[3]);
260 if(f[2].value == getNetworkAddress(f[2].value, f[3].value)) {
261 var s = 'Invalid IP address or subnet mask (the address of the network cannot be used)';
262 ferror.set(f[2], s, quiet);
263 ferror.set(f[3], s, quiet);
264 return 0;
265 } else
266 if(f[2].value == getBroadcastAddress(getNetworkAddress(f[2].value, f[3].value), f[3].value)) {
267 var s = 'Invalid IP address or subnet mask (the broadcast address cannot be used)';
268 ferror.set(f[2], s, quiet);
269 ferror.set(f[3], s, quiet);
270 return 0;
271 } else
272 if (this.countOverlappingNetworks(f[2].value) > 0) {
273 var s = 'Invalid IP address or subnet mask (conflicts/overlaps with another LAN bridge)';
274 ferror.set(f[2], s, quiet);
275 ferror.set(f[3], s, quiet);
276 return 0;
277 } else {
278 ferror.clear(f[2]);
279 ferror.clear(f[3]);
281 } else {
282 f[4].checked = 0;
283 f[4].disabled = 1;
285 // dhcp enabled?
286 if( (f[4].checked) && (v_ip(f[2], 1)) && (v_netmask(f[3],1)) ) {
287 f[5].disabled = 0;
288 f[6].disabled = 0;
289 f[7].disabled = 0;
290 // first/last IP still unset?
291 if (f[5].value == '') {
292 var l;
293 var m = aton(f[2].value) & aton(f[3].value);
294 var o = (m) ^ (~ aton(f[3].value))
295 var n = o - m;
296 do {
297 if (--n < 0) {
298 f[5].value = '';
299 return;
301 m++;
302 } while (((l = fixIP(ntoa(m), 1)) == null) || (l == f[2].value) );
303 f[5].value = l;
305 if (f[6].value == '') {
306 var l;
307 var m = aton(f[2].value) & aton(f[3].value);
308 var o = (m) ^ (~ aton(f[3].value));
309 var n = o - m;
310 do {
311 if (--n < 0) {
312 f[6].value = '';
313 return;
315 o--;
316 } while (((l = fixIP(ntoa(o), 1)) == null) || (l == f[2].value) );
317 f[6].value = l;
319 // first IP valid?
320 if ((getNetworkAddress(f[5].value, f[3].value) != getNetworkAddress(f[2].value, f[3].value)) ||
321 (f[5].value == getBroadcastAddress(getNetworkAddress(f[2].value, f[3].value), f[3].value)) ||
322 (f[5].value == getNetworkAddress(f[2].value, f[3].value)) ||
323 (f[2].value == f[5].value)) {
324 ferror.set(f[5], 'Invalid first IP address or subnet mask', quiet || !ok);
325 return 0;
326 } else {
327 ferror.clear(f[5]);
329 // last IP valid?
330 if ((getNetworkAddress(f[6].value, f[3].value) != getNetworkAddress(f[2].value, f[3].value)) ||
331 (f[6].value == getBroadcastAddress(getNetworkAddress(f[2].value, f[3].value), f[3].value)) ||
332 (f[6].value == getNetworkAddress(f[2].value, f[3].value)) ||
333 (f[2].value == f[6].value)) {
334 ferror.set(f[6], 'Invalid last IP address or subnet mask', quiet || !ok);
335 return 0;
336 } else {
337 ferror.clear(f[6]);
339 // validate range, swap first/last IP if needed
340 if (aton(f[6].value) < aton(f[5].value)) {
341 var t = f[5].value;
342 f[5].value = f[6].value;
343 f[6].value = t;
345 // lease time
346 if (parseInt(f[7].value*1) == 0)
347 f[7].value = 1440; // from nvram/defaults.c
348 if(!v_mins(f[7], quiet || !ok, 1, 10080))
349 ok = 0;
350 } else {
351 f[5].disabled = 1;
352 f[6].disabled = 1;
353 f[7].disabled = 1;
354 ferror.clear(f[5]);
355 ferror.clear(f[6]);
356 ferror.clear(f[7]);
358 return ok;
361 W('<style type=\'text/css\'>');
362 for (var u = 0; u < wl_ifaces.length; ++u) {
363 W('#spin'+wl_unit(u)+', ');
365 W('#spin {');
366 W(' visibility: hidden;');
367 W(' vertical-align: middle;');
368 W('}');
369 W('</style>');
371 var xob = null;
372 var refresher = [];
373 var nphy = features('11n');
375 var ghz = [];
376 var bands = [];
377 var nm_loaded = [], ch_loaded = [], max_channel = [];
379 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
380 var b;
381 b = [];
382 for (var i = 0; i < wl_bands[uidx].length; ++i) {
383 b.push([wl_bands[uidx][i] + '', (wl_bands[uidx][i] == '1') ? '5 GHz' : '2.4 GHz']);
385 bands.push(b);
387 b = [];
388 ghz.push(b);
390 nm_loaded.push(0);
391 ch_loaded.push(0);
392 max_channel.push(0);
393 refresher.push(null);
396 function selectedBand(uidx)
398 if (bands[uidx].length > 1) {
399 var e = E('_f_wl'+u+'_nband');
400 return (e.value + '' == '' ? eval('nvram.wl'+u+'_nband') : e.value);
401 } else if (bands[uidx].length > 0) {
402 return bands[uidx][0][0] || '0';
403 } else {
404 return '0';
408 function refreshNetModes(uidx)
410 var e, i, buf, val;
412 if (uidx >= wl_ifaces.length) return;
413 var u = wl_unit(uidx);
415 var m = [['mixed','Auto']];
416 if (selectedBand(uidx) == '1') {
417 m.push(['a-only','A Only']);
418 if (nphy) {
419 m.push(['n-only','N Only']);
422 else {
423 m.push(['b-only','B Only']);
424 m.push(['g-only','G Only']);
425 if (nphy) {
426 m.push(['bg-mixed','B/G Mixed']);
427 m.push(['n-only','N Only']);
431 e = E('_wl'+u+'_net_mode');
432 buf = '';
433 val = (!nm_loaded[uidx] || (e.value + '' == '')) ? eval('nvram.wl'+u+'_net_mode') : e.value;
434 if (val == 'disabled') val = 'mixed';
435 for (i = 0; i < m.length; ++i)
436 buf += '<option value="' + m[i][0] + '"' + ((m[i][0] == val) ? ' selected' : '') + '>' + m[i][1] + '</option>';
438 e = E('__wl'+u+'_net_mode');
439 buf = '<select name="wl'+u+'_net_mode" onchange="verifyFields(this, 1)" id = "_wl'+u+'_net_mode">' + buf + '</select>';
440 elem.setInnerHTML(e, buf);
441 nm_loaded[uidx] = 1;
444 function refreshChannels(uidx)
446 if (refresher[uidx] != null) return;
447 if (u >= wl_ifaces.length) return;
448 var u = wl_unit(uidx);
450 refresher[uidx] = new XmlHttp();
451 refresher[uidx].onCompleted = function(text, xml) {
452 try {
453 var e, i, buf, val;
455 var wl_channels = [];
456 eval(text);
458 ghz[uidx] = [];
459 max_channel[uidx] = 0;
460 for (i = 0; i < wl_channels.length; ++i) {
461 ghz[uidx].push([wl_channels[i][0] + '',
462 (wl_channels[i][0]) ? ((wl_channels[i][1]) ? wl_channels[i][0] + ' - ' + (wl_channels[i][1] / 1000.0).toFixed(3) + ' GHz' : wl_channels[i][0] + '') : 'Auto']);
463 max_channel[uidx] = wl_channels[i][0] * 1;
466 e = E('_wl'+u+'_channel');
467 buf = '';
468 val = (!ch_loaded[uidx] || (e.value + '' == '')) ? eval('nvram.wl'+u+'_channel') : e.value;
469 for (i = 0; i < ghz[uidx].length; ++i)
470 buf += '<option value="' + ghz[uidx][i][0] + '"' + ((ghz[uidx][i][0] == val) ? ' selected' : '') + '>' + ghz[uidx][i][1] + '</option>';
472 e = E('__wl'+u+'_channel');
473 buf = '<select name="wl'+u+'_channel" onchange="verifyFields(this, 1)" id = "_wl'+u+'_channel">' + buf + '</select>';
474 elem.setInnerHTML(e, buf);
475 ch_loaded[uidx] = 1;
477 refresher[uidx] = null;
478 verifyFields(null, 1);
480 catch (x) {
482 refresher[uidx] = null;
485 var bw, sb, e;
487 e = E('_f_wl'+u+'_nctrlsb');
488 sb = (e.value + '' == '' ? eval('nvram.wl'+u+'_nctrlsb') : e.value);
489 e = E('_wl'+u+'_nbw_cap');
490 bw = (e.value + '' == '' ? eval('nvram.wl'+u+'_nbw_cap') : e.value) == '0' ? '20' : '40';
492 refresher[uidx].onError = function(ex) { alert(ex); refresher[uidx] = null; reloadPage(); }
493 refresher[uidx].post('update.cgi', 'exec=wlchannels&arg0=' + u + '&arg1=' + (nphy ? '1' : '0') +
494 '&arg2=' + bw + '&arg3=' + selectedBand(uidx) + '&arg4=' + sb);
497 function spin(x, unit)
499 for (var u = 0; u < wl_ifaces.length; ++u) {
500 E('_f_wl'+wl_unit(u)+'_scan').disabled = x;
502 var e = E('_f_wl'+unit+'_scan');
503 if (x) e.value = 'Scan ' + (wscan.tries + 1);
504 else e.value = 'Scan';
505 E('spin'+unit).style.visibility = x ? 'visible' : 'hidden';
508 function scan()
510 if (xob) return;
512 var unit = wscan.unit;
513 var uidx = wl_uidx(unit);
515 xob = new XmlHttp();
516 xob.onCompleted = function(text, xml) {
517 try {
518 var i;
520 wlscandata = [];
521 eval(text);
523 for (i = 0; i < wlscandata.length; ++i) {
524 var data = wlscandata[i];
525 var ch = data[2];
526 var mac = data[0];
528 if (!wscan.inuse[ch]) {
529 wscan.inuse[ch] = {
530 count: 0,
531 rssi: -999,
532 ssid: ''
536 if (!wscan.seen[mac]) {
537 wscan.seen[mac] = 1;
538 ++wscan.inuse[ch].count;
541 if (data[4] > wscan.inuse[ch].rssi) {
542 wscan.inuse[ch].rssi = data[4];
543 wscan.inuse[ch].ssid = data[1];
546 var e = E('_wl'+unit+'_channel');
547 for (i = 1; i < ghz[uidx].length; ++i) {
548 var s = ghz[uidx][i][1];
549 var u = wscan.inuse[ghz[uidx][i][0]];
550 if (u) s += ' (' + u.count + ' AP' + (u.count == 1 ? '' : 's') + ' / strongest: "' + escapeHTML(ellipsis(u.ssid, 15)) + '" ' + u.rssi + ' dBm)';
551 e.options[i].innerHTML = s;
553 e.style.width = '400px';
555 xob = null;
557 if (wscan.tries < 4) {
558 ++wscan.tries;
559 setTimeout(scan, 1000);
560 return;
563 catch (x) {
565 spin(0, unit);
567 xob.onError = function(x) {
568 alert('error: ' + x);
569 spin(0, unit);
570 xob = null;
573 spin(1, unit);
574 xob.post('update.cgi', 'exec=wlscan&arg0='+unit);
577 function scanButton(u)
579 if (xob) return;
581 wscan = {
582 unit: u,
583 seen: [],
584 inuse: [],
585 tries: 0
588 scan();
591 function joinAddr(a) {
592 var r, i, s;
594 r = [];
595 for (i = 0; i < a.length; ++i) {
596 s = a[i];
597 if ((s != '00:00:00:00:00:00') && (s != '0.0.0.0')) r.push(s);
599 return r.join(' ');
602 function random_x(max)
604 var c = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
605 var s = '';
606 while (max-- > 0) s += c.substr(Math.floor(c.length * Math.random()), 1);
607 return s;
610 function random_psk(id)
612 var e = E(id);
613 e.value = random_x(63);
614 verifyFields(null, 1);
617 function random_wep(u)
619 E('_wl'+u+'_passphrase').value = random_x(16);
620 generate_wep(u);
623 function v_wep(e, quiet)
625 var s = e.value;
627 if (((s.length == 5) || (s.length == 13)) && (s.length == (e.maxLength >> 1))) {
628 // no checking
630 else {
631 s = s.toUpperCase().replace(/[^0-9A-F]/g, '');
632 if (s.length != e.maxLength) {
633 ferror.set(e, 'Invalid WEP key. Expecting ' + e.maxLength + ' hex or ' + (e.maxLength >> 1) + ' ASCII characters.', quiet);
634 return 0;
638 e.value = s;
639 ferror.clear(e);
640 return 1;
643 // compatible w/ Linksys' and Netgear's (key 1) method for 128-bits
644 function generate_wep(u)
646 function _wepgen(pass, i)
648 while (pass.length < 64) pass += pass;
649 return hex_md5(pass.substr(0, 64)).substr(i, (E('_wl'+u+'_wep_bit').value == 128) ? 26 : 10);
652 var e = E('_wl'+u+'_passphrase');
653 var pass = e.value;
654 if (!v_length(e, false, 3)) return;
655 E('_wl'+u+'_key1').value = _wepgen(pass, 0);
656 pass += '#$%';
657 E('_wl'+u+'_key2').value = _wepgen(pass, 2);
658 pass += '!@#';
659 E('_wl'+u+'_key3').value = _wepgen(pass, 4);
660 pass += '%&^';
661 E('_wl'+u+'_key4').value = _wepgen(pass, 6);
662 verifyFields(null, 1);
665 function verifyFields(focused, quiet)
667 var i;
668 var ok = 1;
669 var a, b, c, d, e;
670 var u, uidx;
671 var wmode, sm2;
673 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
674 u = wl_unit(uidx);
675 if (focused == E('_f_wl'+u+'_nband')) {
676 refreshNetModes(uidx);
677 refreshChannels(uidx);
679 else if (focused == E('_f_wl'+u+'_nctrlsb') || focused == E('_wl'+u+'_nbw_cap')) {
680 refreshChannels(uidx);
684 // --- visibility ---
686 var vis = {
687 _wan_proto: 1,
688 _ppp_username: 1,
689 _ppp_passwd: 1,
690 _ppp_service: 1,
691 _ppp_custom: 1,
692 _l2tp_server_ip: 1,
693 _wan_ipaddr: 1,
694 _wan_netmask: 1,
695 _wan_gateway: 1,
696 _pptp_server_ip: 1,
697 _f_pptp_dhcp: 1,
698 _ppp_demand: 1,
699 _ppp_idletime: 1,
700 _ppp_redialperiod: 1,
701 _mtu_enable: 1,
702 _f_wan_mtu: 1,
703 _f_wan_islan: 0,
704 _f_ppp_mlppp: 1,
706 /* REMOVE-BEGIN
707 // _dhcp_lease: 1,
708 // _f_dhcpd_enable: 1,
709 // _dhcpd_startip: 1,
710 // _dhcpd_endip: 1,
711 // _lan_ipaddr: 1,
712 // _lan_netmask: 1,
713 REMOVE-END */
714 _f_dns_1: 1,
715 _f_dns_2: 1,
716 _f_dns_3: 1,
717 _lan_gateway: 1,
718 _wan_wins: 1,
719 _modem_pin: 1,
720 _modem_dev: 1,
721 _modem_init: 1,
722 _modem_apn: 1,
725 var wl_vis = [];
726 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
727 a = {
728 _f_wl_radio: 1,
729 _f_wl_mode: 1,
730 _f_wl_nband: (bands[uidx].length > 1) ? 1 : 0,
731 _wl_net_mode: 1,
732 _wl_ssid: 1,
733 _f_wl_bcast: 1,
734 _wl_channel: 1,
735 _wl_nbw_cap: nphy ? 1 : 0,
736 _f_wl_nctrlsb: nphy ? 1 : 0,
737 _f_wl_scan: 1,
739 _wl_security_mode: 1,
740 _wl_crypto: 1,
741 _wl_wpa_psk: 1,
742 _f_wl_psk_random1: 1,
743 _f_wl_psk_random2: 1,
744 _wl_wpa_gtk_rekey: 1,
745 _wl_radius_key: 1,
746 _wl_radius_ipaddr: 1,
747 _wl_radius_port: 1,
748 _wl_wep_bit: 1,
749 _wl_passphrase: 1,
750 _f_wl_wep_gen: 1,
751 _f_wl_wep_random: 1,
752 _wl_key1: 1,
753 _wl_key2: 1,
754 _wl_key3: 1,
755 _wl_key4: 1,
757 _f_wl_lazywds: 1,
758 _f_wl_wds_0: 1
760 wl_vis.push(a);
763 var wan = E('_wan_proto').value;
765 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
766 wmode = E('_f_wl'+wl_unit(uidx)+'_mode').value;
768 if (wmode == 'wet') {
769 wan = 'disabled';
770 vis._wan_proto = 0;
771 /* REMOVE-BEGIN
772 // vis._f_dhcpd_enable = 0;
773 // vis._dhcp_lease = 0;
774 REMOVE-END */
777 if ((wan == 'disabled') || (wmode == 'sta') || (wmode == 'wet')) {
778 vis._f_wan_islan = 1;
782 switch (wan) {
783 case 'disabled':
784 vis._ppp_username = 0;
785 vis._ppp_service = 0;
786 vis._ppp_custom = 0;
787 vis._l2tp_server_ip = 0;
788 vis._wan_ipaddr = 0;
789 vis._wan_netmask = 0;
790 vis._wan_gateway = 0;
791 vis._pptp_server_ip = 0;
792 vis._f_pptp_dhcp = 0;
793 vis._ppp_demand = 0;
794 vis._mtu_enable = 0;
795 vis._f_wan_mtu = 0;
796 vis._f_ppp_mlppp = 0;
797 vis._modem_pin = 0;
798 vis._modem_dev = 0;
799 vis._modem_init = 0;
800 vis._modem_apn = 0;
801 break;
802 case 'dhcp':
803 vis._l2tp_server_ip = 0;
804 vis._ppp_demand = 0;
805 vis._ppp_service = 0;
806 vis._ppp_username = 0;
807 vis._ppp_custom = 0;
808 vis._pptp_server_ip = 0;
809 vis._f_pptp_dhcp = 0;
810 vis._wan_gateway = 0;
811 vis._wan_ipaddr = 0;
812 vis._wan_netmask = 0;
813 vis._f_ppp_mlppp = 0;
815 vis._lan_gateway = 0;
816 vis._modem_pin = 0;
817 vis._modem_dev = 0;
818 vis._modem_init = 0;
819 vis._modem_apn = 0;
820 break;
821 case 'pppoe':
822 vis._l2tp_server_ip = 0;
823 vis._pptp_server_ip = 0;
824 vis._f_pptp_dhcp = 0;
825 vis._wan_gateway = 0;
826 vis._wan_ipaddr = 0;
827 vis._wan_netmask = 0;
829 vis._lan_gateway = 0;
830 vis._modem_pin = 0;
831 vis._modem_dev = 0;
832 vis._modem_init = 0;
833 vis._modem_apn = 0;
834 break;
835 case 'ppp3g':
836 vis._ppp_service = 0;
837 vis._ppp_custom = 0;
838 vis._l2tp_server_ip = 0;
839 vis._pptp_server_ip = 0;
840 vis._f_pptp_dhcp = 0;
841 vis._wan_gateway = 0;
842 vis._wan_ipaddr = 0;
843 vis._wan_netmask = 0;
844 vis._f_ppp_mlppp = 0;
846 vis._lan_gateway = 0;
847 break;
848 case 'static':
849 vis._l2tp_server_ip = 0;
850 vis._ppp_demand = 0;
851 vis._ppp_service = 0;
852 vis._ppp_username = 0;
853 vis._ppp_custom = 0;
854 vis._pptp_server_ip = 0;
855 vis._f_pptp_dhcp = 0;
856 vis._f_ppp_mlppp = 0;
858 vis._lan_gateway = 0;
859 vis._modem_pin = 0;
860 vis._modem_dev = 0;
861 vis._modem_init = 0;
862 vis._modem_apn = 0;
863 break;
864 case 'pptp':
865 vis._l2tp_server_ip = 0;
866 vis._ppp_service = 0;
867 vis._wan_gateway = (!E('_f_pptp_dhcp').checked);
868 vis._wan_ipaddr = (!E('_f_pptp_dhcp').checked);
870 vis._lan_gateway = 0;
871 vis._modem_pin = 0;
872 vis._modem_dev = 0;
873 vis._modem_init = 0;
874 vis._modem_apn = 0;
875 break;
876 case 'l2tp':
877 vis._pptp_server_ip = 0;
878 vis._ppp_service = 0;
879 vis._wan_gateway = (!E('_f_pptp_dhcp').checked);
880 vis._wan_ipaddr = (!E('_f_pptp_dhcp').checked);
882 vis._lan_gateway = 0;
883 vis._modem_pin = 0;
884 vis._modem_dev = 0;
885 vis._modem_init = 0;
886 vis._modem_apn = 0;
887 break;
890 vis._ppp_idletime = (E('_ppp_demand').value == 1) && vis._ppp_demand
891 vis._ppp_redialperiod = !vis._ppp_idletime && vis._ppp_demand;
893 if (vis._mtu_enable) {
894 if (E('_mtu_enable').value == 0) {
895 vis._f_wan_mtu = 2;
896 a = E('_f_wan_mtu');
897 switch (E('_wan_proto').value) {
898 case 'pppoe':
899 a.value = 1492;
900 break;
901 case 'pptp':
902 case 'l2tp':
903 a.value = 1460;
904 break;
905 default:
906 a.value = 1500;
907 break;
912 /* REMOVE-BEGIN
913 // if (!E('_f_dhcpd_enable').checked) vis._dhcp_lease = 0;
914 REMOVE-END */
915 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
916 u = wl_unit(uidx);
917 wmode = E('_f_wl'+u+'_mode').value;
919 if (!E('_f_wl'+u+'_radio').checked) {
920 for (a in wl_vis[uidx]) {
921 wl_vis[uidx][a] = 2;
923 wl_vis[uidx]._f_wl_radio = 1;
924 wl_vis[uidx]._wl_nbw_cap = nphy ? 2 : 0;
925 wl_vis[uidx]._f_wl_nband = (bands[uidx].length > 1) ? 2 : 0;
928 switch (wmode) {
929 case 'apwds':
930 case 'wds':
931 break;
932 case 'wet':
933 case 'sta':
934 wl_vis[uidx]._f_wl_bcast = 0;
935 wl_vis[uidx]._wl_channel = 0;
936 wl_vis[uidx]._wl_nbw_cap = 0;
937 default:
938 wl_vis[uidx]._f_wl_lazywds = 0;
939 wl_vis[uidx]._f_wl_wds_0 = 0;
940 break;
943 sm2 = E('_wl'+u+'_security_mode').value;
944 switch (sm2) {
945 case 'disabled':
946 wl_vis[uidx]._wl_crypto = 0;
947 wl_vis[uidx]._wl_wep_bit = 0;
948 wl_vis[uidx]._wl_wpa_psk = 0;
949 wl_vis[uidx]._wl_radius_key = 0;
950 wl_vis[uidx]._wl_radius_ipaddr = 0;
951 wl_vis[uidx]._wl_wpa_gtk_rekey = 0;
952 break;
953 case 'wep':
954 wl_vis[uidx]._wl_crypto = 0;
955 wl_vis[uidx]._wl_wpa_psk = 0;
956 wl_vis[uidx]._wl_radius_key = 0;
957 wl_vis[uidx]._wl_radius_ipaddr = 0;
958 wl_vis[uidx]._wl_wpa_gtk_rekey = 0;
959 break;
960 case 'radius':
961 wl_vis[uidx]._wl_crypto = 0;
962 wl_vis[uidx]._wl_wpa_psk = 0;
963 break;
964 default: // wpa*
965 wl_vis[uidx]._wl_wep_bit = 0;
966 if (sm2.indexOf('personal') != -1) {
967 wl_vis[uidx]._wl_radius_key = 0;
968 wl_vis[uidx]._wl_radius_ipaddr = 0;
970 else {
971 wl_vis[uidx]._wl_wpa_psk = 0;
973 break;
976 if ((E('_f_wl'+u+'_lazywds').value == 1) && (wl_vis[uidx]._f_wl_wds_0 == 1)) {
977 wl_vis[uidx]._f_wl_wds_0 = 2;
980 if (wl_vis[uidx]._wl_nbw_cap != 0) {
981 switch (E('_wl'+u+'_net_mode').value) {
982 case 'b-only':
983 case 'g-only':
984 case 'a-only':
985 case 'bg-mixed':
986 wl_vis[uidx]._wl_nbw_cap = 2;
987 if (E('_wl'+u+'_nbw_cap').value != '0') {
988 E('_wl'+u+'_nbw_cap').value = 0;
989 refreshChannels(uidx);
991 break;
993 // avoid Enterprise-TKIP with 40MHz
994 if ((sm2 == 'wpa_enterprise') && (E('_wl'+u+'_crypto').value == 'tkip')) {
995 wl_vis[uidx]._wl_nbw_cap = 2;
996 if (E('_wl'+u+'_nbw_cap').value != '0') {
997 E('_wl'+u+'_nbw_cap').value = 0;
998 refreshChannels(uidx);
1003 wl_vis[uidx]._f_wl_nctrlsb = (E('_wl'+u+'_nbw_cap').value == 0) ? 0 : wl_vis[uidx]._wl_nbw_cap;
1005 /* REMOVE-BEGIN
1006 This is ugly...
1007 Special case - 2.4GHz band, currently running in B/G-only mode,
1008 with N/Auto and 40MHz selected in the GUI.
1009 Channel list is not filtered in this case by the wl driver,
1010 and includes all channels available with 20MHz channel width.
1011 REMOVE-END */
1012 b = selectedBand(uidx);
1013 if (wl_vis[uidx]._wl_channel == 1 && wl_vis[uidx]._f_wl_nctrlsb != 0 &&
1014 ((b == '2') || (wl_vis[uidx]._f_wl_nband == 0 && b == '0'))) {
1015 switch (eval('nvram.wl'+u+'_net_mode')) {
1016 case 'b-only':
1017 case 'g-only':
1018 case 'bg-mixed':
1019 i = E('_wl'+u+'_channel').value * 1;
1020 if (i > 0 && i < 5) {
1021 E('_f_wl'+u+'_nctrlsb').value = 'lower';
1022 wl_vis[uidx]._f_wl_nctrlsb = 2;
1024 else if (i > max_channel[uidx] - 4) {
1025 E('_f_wl'+u+'_nctrlsb').value = 'upper';
1026 wl_vis[uidx]._f_wl_nctrlsb = 2;
1028 break;
1032 wl_vis[uidx]._f_wl_scan = wl_vis[uidx]._wl_channel;
1033 wl_vis[uidx]._f_wl_psk_random1 = wl_vis[uidx]._wl_wpa_psk;
1034 wl_vis[uidx]._f_wl_psk_random2 = wl_vis[uidx]._wl_radius_key;
1035 wl_vis[uidx]._wl_radius_port = wl_vis[uidx]._wl_radius_ipaddr;
1036 wl_vis[uidx]._wl_key1 = wl_vis[uidx]._wl_key2 = wl_vis[uidx]._wl_key3 = wl_vis[uidx]._wl_key4 = wl_vis[uidx]._f_wl_wep_gen = wl_vis[uidx]._f_wl_wep_random = wl_vis[uidx]._wl_passphrase = wl_vis[uidx]._wl_wep_bit;
1038 for (i = 1; i < 10; ++i) {
1039 wl_vis[uidx]['_f_wl_wds_' + i] = wl_vis[uidx]._f_wl_wds_0;
1041 } // for each wl_iface
1043 vis._ppp_passwd = vis._ppp_username;
1044 /* REMOVE-BEGIN
1045 // vis._dhcpd_startip = vis._dhcpd_endip = vis._wan_wins = vis._dhcp_lease;
1046 REMOVE-END */
1048 for (a in vis) {
1049 b = E(a);
1050 c = vis[a];
1051 /* REMOVE-BEGIN
1052 // if (b != null)
1053 REMOVE-END */
1054 b.disabled = (c != 1);
1055 PR(b).style.display = c ? '' : 'none';
1058 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1059 for (a in wl_vis[uidx]) {
1060 i = 3;
1061 if (a.substr(0, 6) == '_f_wl_') i = 5;
1062 b = E(a.substr(0, i) + wl_unit(uidx) + a.substr(i, a.length));
1063 c = wl_vis[uidx][a];
1064 b.disabled = (c != 1);
1065 PR(b).style.display = c ? '' : 'none';
1069 // --- verify ---
1071 ferror.clear('_wan_proto');
1073 var wlclnt = 0;
1074 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1075 u = wl_unit(uidx);
1076 wmode = E('_f_wl'+u+'_mode').value;
1077 sm2 = E('_wl'+u+'_security_mode').value;
1079 /* REMOVE-BEGIN
1080 if ((wl_vis[uidx]._f_wl_mode == 1) && (wmode != 'ap') && (sm2.substr(0, 4) == 'wpa2')) {
1081 ferror.set('_wl'+u+'_security_mode', 'WPA2 is supported only in AP mode.', quiet || !ok);
1082 ok = 0;
1084 else ferror.clear('_wl'+u+'_security_mode');
1085 REMOVE-END */
1087 // --- N standard does not support WPA+TKIP ---
1088 a = E('_wl'+u+'_crypto');
1089 switch (E('_wl'+u+'_net_mode').value) {
1090 case 'mixed':
1091 case 'n-only':
1092 if (nphy && (a.value == 'tkip') && (sm2.indexOf('wpa') != -1)) {
1093 ferror.set(a, 'TKIP encryption is not supported with WPA / WPA2 in N mode.', quiet || !ok);
1094 ok = 0;
1096 else ferror.clear(a);
1097 break;
1100 a = E('_wl'+u+'_net_mode');
1101 ferror.clear(a);
1102 b = E('_f_wl'+u+'_mode');
1103 ferror.clear(b);
1104 if ((wmode == 'sta') || (wmode == 'wet')) {
1105 ++wlclnt;
1106 if (wlclnt > 1) {
1107 ferror.set(b, 'Only one wireless interface can be configured in client mode.', quiet || !ok);
1108 ok = 0;
1110 else if (a.value == 'n-only') {
1111 ferror.set(a, 'N-only is not supported in wireless client modes, use Auto.', quiet || !ok);
1112 ok = 0;
1116 a = E('_wl'+u+'_wpa_psk');
1117 ferror.clear(a);
1118 if (wl_vis[uidx]._wl_wpa_psk == 1) {
1119 if ((a.value.length < 8) || ((a.value.length == 64) && (a.value.search(/[^0-9A-Fa-f]/) != -1))) {
1120 ferror.set('_wl'+u+'_wpa_psk', 'Invalid pre-shared key. Please enter at least 8 characters or 64 hexadecimal digits.', quiet || !ok);
1121 ok = 0;
1125 // wl channel
1126 if (((wmode == 'wds') || (wmode == 'apwds')) && (wl_vis[uidx]._wl_channel == 1) && (E('_wl'+u+'_channel').value == '0')) {
1127 ferror.set('_wl'+u+'_channel', 'Fixed wireless channel required in WDS mode.', quiet || !ok);
1128 ok = 0;
1130 else ferror.clear('_wl'+u+'_channel');
1132 if (E('_f_wl'+u+'_mode').value == 'sta') {
1133 if ((wan == 'disabled') && (E('_f_wl'+u+'_radio').checked)) {
1134 ferror.set('_wan_proto', 'Wireless Client mode requires a valid WAN setting (usually DHCP).', quiet || !ok);
1135 ok = 0;
1140 // domain name or IP address
1141 a = ['_l2tp_server_ip', '_pptp_server_ip'];
1142 for (i = a.length - 1; i >= 0; --i)
1143 if ((vis[a[i]]) && ((!v_length(a[i], 1, 1)) || ((!v_ip(a[i], 1)) && (!v_domain(a[i], 1))))) {
1144 if (!quiet && ok) ferror.show(a[i]);
1145 ok = 0;
1148 // IP address
1149 /* REMOVE-BEGIN
1150 // a = ['_wan_gateway','_wan_ipaddr','_lan_ipaddr', '_dhcpd_startip', '_dhcpd_endip'];
1151 REMOVE-END */
1152 a = ['_wan_gateway','_wan_ipaddr'];
1153 for (i = a.length - 1; i >= 0; --i)
1154 if ((vis[a[i]]) && (!v_ip(a[i], quiet || !ok))) ok = 0;
1156 // IP address, blank -> 0.0.0.0
1157 a = ['_f_dns_1', '_f_dns_2', '_f_dns_3','_wan_wins','_lan_gateway'];
1158 for (i = a.length - 1; i >= 0; --i)
1159 if ((vis[a[i]]) && (!v_dns(a[i], quiet || !ok))) ok = 0;
1161 // netmask
1162 /* REMOVE-BEGIN
1163 // a = ['_wan_netmask','_lan_netmask'];
1164 REMOVE-END */
1165 a = ['_wan_netmask'];
1166 for (i = a.length - 1; i >= 0; --i)
1167 if ((vis[a[i]]) && (!v_netmask(a[i], quiet || !ok))) ok = 0;
1169 // range
1170 /* REMOVE-BEGIN
1171 // a = [['_ppp_idletime', 3, 1440],['_ppp_redialperiod', 1, 86400],['_f_wan_mtu', 576, 1500],
1172 // ['_dhcp_lease', 1, 10080]];
1173 REMOVE-END */
1174 a = [['_ppp_idletime', 3, 1440],['_ppp_redialperiod', 1, 86400],['_f_wan_mtu', 576, 1500]];
1175 for (i = a.length - 1; i >= 0; --i) {
1176 v = a[i];
1177 if ((vis[v[0]]) && (!v_range(v[0], quiet || !ok, v[1], v[2]))) ok = 0;
1180 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1181 u = wl_unit(uidx);
1183 // IP address
1184 a = ['_radius_ipaddr'];
1185 for (i = a.length - 1; i >= 0; --i) {
1186 if ((wl_vis[uidx]['_wl'+a[i]]) && (!v_ip('_wl'+u+a[i], quiet || !ok))) ok = 0;
1189 // range
1190 a = [['_wpa_gtk_rekey', 60, 7200], ['_radius_port', 1, 65535]];
1191 for (i = a.length - 1; i >= 0; --i) {
1192 v = a[i];
1193 if ((wl_vis[uidx]['_wl'+v[0]]) && (!v_range('_wl'+u+v[0], quiet || !ok, v[1], v[2]))) ok = 0;
1196 // length
1197 a = [['_ssid', 1], ['_radius_key', 1]];
1198 for (i = a.length - 1; i >= 0; --i) {
1199 v = a[i];
1200 if ((wl_vis[uidx]['_wl'+v[0]]) && (!v_length('_wl'+u+v[0], quiet || !ok, v[1], E('_wl'+u+v[0]).maxlength))) ok = 0;
1203 if (wl_vis[uidx]._wl_key1) {
1204 a = (E('_wl'+u+'_wep_bit').value == 128) ? 26 : 10;
1205 for (i = 1; i <= 4; ++i) {
1206 b = E('_wl'+u+'_key' + i);
1207 b.maxLength = a;
1208 if ((b.value.length > 0) || (E('_f_wl'+u+'_wepidx_' + i).checked)) {
1209 if (!v_wep(b, quiet || !ok)) ok = 0;
1211 else ferror.clear(b);
1215 ferror.clear('_f_wl'+u+'_wds_0');
1216 if (wl_vis[uidx]._f_wl_wds_0 == 1) {
1217 b = 0;
1218 for (i = 0; i < 10; ++i) {
1219 a = E('_f_wl'+u+'_wds_' + i);
1220 if (!v_macz(a, quiet || !ok)) ok = 0;
1221 else if (!isMAC0(a.value)) b = 1;
1223 if (!b) {
1224 ferror.set('_f_wl'+u+'_wds_0', 'WDS MAC address required.', quiet || !ok);
1225 ok = 0;
1229 /* REMOVE-BEGIN
1230 a = E('_dhcpd_startip');
1231 b = E('_dhcpd_endip');
1232 ferror.clear(a);
1233 ferror.clear(b);
1235 if ((vis._dhcp_lease) && (!a._error_msg) && (!b._error_msg)) {
1236 c = aton(E('_lan_netmask').value);
1237 d = aton(E('_lan_ipaddr').value) & c;
1238 e = 'Invalid IP address or subnet mask';
1239 if ((aton(a.value) & c) != d) {
1240 ferror.set(a, e, quiet || !ok);
1241 ok = 0;
1243 if ((aton(b.value) & c) != d) {
1244 ferror.set(b, e, quiet || !ok);
1245 ok = 0;
1249 if ((vis._dhcp_lease) && (!a._error_msg) && (!b._error_msg)) {
1250 if (aton(a.value) > aton(b.value)) {
1251 c = a.value;
1252 a.value = b.value;
1253 b.value = c;
1256 elem.setInnerHTML('dhcp_count', '(' + ((aton(b.value) - aton(a.value)) + 1) + ')');
1258 REMOVE-END */
1260 return ok;
1263 function earlyInit()
1265 verifyFields(null, 1);
1268 function save()
1270 if (lg.isEditing()) return;
1271 lg.resetNewEditor();
1273 var a, b, c;
1274 var i;
1275 var u, uidx, wmode, sm2, wradio;
1277 if (!verifyFields(null, false)) return;
1279 var fom = E('_fom');
1281 fom.wan_mtu.value = fom.f_wan_mtu.value;
1282 fom.wan_mtu.disabled = fom.f_wan_mtu.disabled;
1284 for (uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1285 u = wl_unit(uidx);
1286 wmode = E('_f_wl'+u+'_mode').value;
1287 sm2 = E('_wl'+u+'_security_mode').value;
1288 wradio = E('_f_wl'+u+'_radio').checked;
1290 E('_wl'+u+'_nband').value = selectedBand(uidx);
1292 if (wmode == 'apwds') E('_wl'+u+'_mode').value = 'ap';
1293 else E('_wl'+u+'_mode').value = wmode;
1295 if (wmode == 'wet') {
1296 fom.wan_proto.value = 'disabled';
1297 fom.wan_proto.disabled = 0;
1298 /* REMOVE-BEGIN
1299 // fom.lan_proto.value = 'static';
1300 REMOVE-END */
1303 a = [];
1304 for (i = 0; i < 10; ++i) a.push(E('_f_wl'+u+'_wds_' + i).value);
1305 E('_wl'+u+'_wds').value = joinAddr(a);
1307 if (wmode.indexOf('wds') != -1) {
1308 E('_wl'+u+'_wds_enable').value = 1;
1309 E('_wl'+u+'_lazywds').value = E('_f_wl'+u+'_lazywds').value;
1310 if (E('_wl'+u+'_lazywds').value == 1) E('_wl'+u+'_wds').value = '';
1312 else {
1313 E('_wl'+u+'_wds_enable').value = 0;
1314 E('_wl'+u+'_wds').value = '';
1315 E('_wl'+u+'_lazywds').value = 0;
1318 E('_wl'+u+'_radio').value = wradio ? 1 : 0;
1319 E('_wl'+u+'_auth').value = eval('nvram.wl'+u+'_auth');
1321 e = E('_wl'+u+'_akm');
1322 switch (sm2) {
1323 case 'disabled':
1324 case 'radius':
1325 case 'wep':
1326 e.value = '';
1327 break;
1328 default:
1329 c = [];
1331 if (sm2.indexOf('personal') != -1) {
1332 if (sm2.indexOf('wpa2_') == -1) c.push('psk');
1333 if (sm2.indexOf('wpa_') == -1) c.push('psk2');
1335 else {
1336 if (sm2.indexOf('wpa2_') == -1) c.push('wpa');
1337 if (sm2.indexOf('wpa_') == -1) c.push('wpa2');
1339 c = c.join(' ');
1340 e.value = c;
1341 break;
1343 E('_wl'+u+'_auth_mode').value = (sm2 == 'radius') ? 'radius' : 'none';
1344 E('_wl'+u+'_wep').value = ((sm2 == 'radius') || (sm2 == 'wep')) ? 'enabled': 'disabled';
1346 if (sm2.indexOf('wpa') != -1) E('_wl'+u+'_auth').value = 0;
1348 E('_wl'+u+'_nreqd').value = 0;
1349 E('_wl'+u+'_gmode').value = 1;
1350 E('_wl'+u+'_nmode').value = 0;
1351 E('_wl'+u+'_nmcsidx').value = -2; // Legacy Rate
1352 E('_wl'+u+'_nbw').value = 0;
1353 switch (E('_wl'+u+'_net_mode').value) {
1354 case 'b-only':
1355 E('_wl'+u+'_gmode').value = 0;
1356 break;
1357 case 'g-only':
1358 E('_wl'+u+'_gmode').value = 4;
1359 break;
1360 case 'bg-mixed':
1361 break;
1362 case 'a-only':
1363 E('_wl'+u+'_nmcsidx').value = -1; // Auto
1364 break;
1365 case 'n-only':
1366 if (selectedBand(uidx) == '1') { // 5 GHz
1367 E('_wl'+u+'_nmode').value = -1;
1368 E('_wl'+u+'_nmcsidx').value = -1;
1369 } else {
1370 E('_wl'+u+'_nmode').value = 1;
1371 E('_wl'+u+'_nmcsidx').value = 32;
1373 E('_wl'+u+'_nreqd').value = 1;
1374 break;
1375 default: // Auto
1376 E('_wl'+u+'_nmode').value = -1;
1377 E('_wl'+u+'_nmcsidx').value = -1;
1378 break;
1381 E('_wl'+u+'_nctrlsb').value = eval('nvram.wl'+u+'_nctrlsb');
1382 if (E('_wl'+u+'_nmode').value != 0) {
1383 E('_wl'+u+'_nctrlsb').value = E('_f_wl'+u+'_nctrlsb').value;
1384 E('_wl'+u+'_nbw').value = (E('_wl'+u+'_nbw_cap').value == 0) ? 20 : 40;
1387 E('_wl'+u+'_closed').value = E('_f_wl'+u+'_bcast').checked ? 0 : 1;
1389 a = fields.radio.selected(eval('fom.f_wl'+u+'_wepidx'));
1390 if (a) E('_wl'+u+'_key').value = a.value;
1393 fom.wan_islan.value = fom.f_wan_islan.checked ? 1 : 0;
1394 fom.pptp_dhcp.value = fom.f_pptp_dhcp.checked ? 1 : 0;
1396 fom.wan_dns.value = joinAddr([fom.f_dns_1.value, fom.f_dns_2.value, fom.f_dns_3.value]);
1398 fom.ppp_mlppp.value = fom.f_ppp_mlppp.checked ? 1 : 0;
1400 // initialize/wipe out relevant fields
1401 for (var i = 0 ; i <= MAX_BRIDGE_ID ; i++) {
1402 var j = (i == 0) ? '' : i.toString();
1403 fom['lan' + j + '_ifname'].value = '';
1404 fom['lan' + j + '_ipaddr'].value = '';
1405 fom['lan' + j + '_netmask'].value = '';
1406 fom['lan' + j + '_proto'].value = '';
1407 fom['lan' + j + '_stp'].value = '';
1408 fom['dhcp' + j + '_start'].value = '';
1409 fom['dhcp' + j + '_num'].value = '';
1410 fom['dhcp' + j + '_lease'].value = '';
1411 fom['dhcpd' + j + '_startip'].value = '';
1412 fom['dhcpd' + j + '_endip'].value = '';
1415 var d = lg.getAllData();
1416 for (var i = 0; i < d.length; ++i) {
1418 if (lg.countOverlappingNetworks(d[i][2]) > 1) {
1419 var s = 'Cannot proceed: two or more LAN bridges have conflicting IP addresses or overlapping subnets';
1420 alert(s);
1421 var e = E('footer-msg');
1422 e.innerHTML = s;
1423 e.style.visibility = 'visible';
1424 setTimeout(
1425 function() {
1426 e.innerHTML = '';
1427 e.style.visibility = 'hidden';
1428 }, 5000);
1429 return;
1432 var j = (parseInt(d[i][0]) == 0) ? '' : d[i][0].toString();
1433 fom['lan' + j + '_ifname'].value = 'br' + d[i][0];
1434 fom['lan' + j + '_stp'].value = d[i][1];
1435 fom['lan' + j + '_ipaddr'].value = d[i][2];
1436 fom['lan' + j + '_netmask'].value = d[i][3];
1437 fom['lan' + j + '_proto'].value = (d[i][4] != '0') ? 'dhcp' : 'static';
1438 fom['dhcp' + j + '_start'].value = (d[i][4] != '0') ? (d[i][5]).split('.').splice(3, 1) : '';
1439 fom['dhcp' + j + '_num'].value = (d[i][4] != '0') ? d[i][6].split('.').splice(3, 1) - (d[i][5]).split('.').splice(3, 1) + 1 : ''; // presuming /24 subnet (legacy)
1440 fom['dhcp' + j + '_lease'].value = (d[i][4] != '0') ? d[i][7] : '';
1441 fom['dhcpd' + j + '_startip'].value = (d[i][4] != '0') ? d[i][5] : '';
1442 fom['dhcpd' + j + '_endip'].value = (d[i][4] != '0') ? d[i][6] : '';
1444 /* REMOVE-BEGIN */
1445 alert('lan' + j + '_ifname=' + fom['lan' + j + '_ifname'].value + '\n' +
1446 'lan' + j + '_stp=' + fom['lan' + j + '_stp'].value + '\n' +
1447 'lan' + j + '_ipaddr=' + fom['lan' + j + '_ipaddr'].value + '\n' +
1448 'lan' + j + '_netmask=' + fom['lan' + j + '_netmask'].value + '\n' +
1449 'lan' + j + '_proto=' + fom['lan' + j + '_proto'].value + '\n' +
1450 'dhcp' + j + '_start=' + fom['dhcp' + j + '_start'].value + '\n' +
1451 'dhcp' + j + '_num=' + fom['dhcp' + j + '_num'].value + '\n' +
1452 'dhcp' + j + '_lease=' + fom['dhcp' + j + '_lease'].value + '\n' +
1453 'dhcpd' + j + '_startip=' + fom['dhcpd' + j + '_startip'].value + '\n' +
1454 'dhcpd' + j + '_endip=' + fom['dhcpd' + j + '_endip'].value);
1455 /* REMOVE-END */
1458 var e = E('footer-msg');
1459 var t = fixIP(fom['lan_ipaddr'].value);
1460 if ((fom['lan_ifname'].value != 'br0') || (fom['lan_ipaddr'].value == '0.0.0.0') || (!t)) {
1461 e.innerHTML = 'Bridge br0 must be always defined and have a valid IP address set.';
1462 e.style.visibility = 'visible';
1463 setTimeout(
1464 function() {
1465 e.innerHTML = '';
1466 e.style.visibility = 'hidden';
1467 }, 5000);
1468 return;
1471 /* REMOVE-BEGIN
1472 // if ((nvram.lan_ipaddr != fom.lan_ipaddr.value) || (nvram.lan1_ipaddr != fom.lan1_ipaddr.value) ||
1473 // (nvram.lan2_ipaddr != fom.lan2_ipaddr.value) || (nvram.lan3_ipaddr != fom.lan3_ipaddr.value)){
1474 REMOVE-END */
1475 if (nvram.lan_ipaddr != fom.lan_ipaddr.value) {
1476 fom._moveip.value = 1;
1477 form.submit(fom);
1479 else {
1480 form.submit(fom, 1);
1484 function init()
1486 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1487 refreshNetModes(uidx);
1488 refreshChannels(uidx);
1491 </script>
1493 </head>
1494 <body onload='init()'>
1495 <form id='_fom' method='post' action='tomato.cgi'>
1496 <table id='container' cellspacing=0>
1497 <tr><td colspan=2 id='header'>
1498 <div class='title'>Tomato</div>
1499 <div class='version'>Version <% version(); %></div>
1500 </td></tr>
1501 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
1502 <td id='content'>
1503 <div id='ident'><% ident(); %></div>
1505 <!-- / / / -->
1507 <input type='hidden' name='_nextpage' value='basic-networks.asp'>
1508 <input type='hidden' name='_nextwait' value='10'>
1509 <input type='hidden' name='_service' value='*'>
1510 <input type='hidden' name='_moveip' value='0'>
1512 <input type='hidden' name='wan_mtu'>
1513 <input type='hidden' name='wan_islan'>
1514 <input type='hidden' name='pptp_dhcp'>
1515 <input type='hidden' name='wan_dns'>
1516 <input type='hidden' name='ppp_mlppp'>
1518 <script type='text/javascript'>
1520 for (var i = 0 ; i <= MAX_BRIDGE_ID ; i++) {
1521 var j = (i == 0) ? '' : i.toString();
1522 W('<input type=\'hidden\' id=\'lan' + j + '_ifname\' name=\'lan' + j + '_ifname\'>');
1523 W('<input type=\'hidden\' id=\'lan' + j + '_ipaddr\' name=\'lan' + j + '_ipaddr\'>');
1524 W('<input type=\'hidden\' id=\'lan' + j + '_netmask\' name=\'lan' + j + '_netmask\'>');
1525 W('<input type=\'hidden\' id=\'lan' + j + '_proto\' name=\'lan' + j + '_proto\'>');
1526 W('<input type=\'hidden\' id=\'lan' + j + '_stp\' name=\'lan' + j + '_stp\'>');
1527 W('<input type=\'hidden\' id=\'dhcp' + j + '_start\' name=\'dhcp' + j + '_start\'>');
1528 W('<input type=\'hidden\' id=\'dhcp' + j + '_num\' name=\'dhcp' + j + '_num\'>');
1529 W('<input type=\'hidden\' id=\'dhcp' + j + '_lease\' name=\'dhcp' + j + '_lease\'>');
1530 W('<input type=\'hidden\' id=\'dhcpd' + j + '_startip\' name=\'dhcpd' + j + '_startip\'>');
1531 W('<input type=\'hidden\' id=\'dhcpd' + j + '_endip\' name=\'dhcpd' + j + '_endip\'>');
1533 </script>
1535 <div class='section-title'>WAN / Internet</div>
1536 <div class='section'>
1537 <script type='text/javascript'>
1538 createFieldTable('', [
1539 { title: 'Type', name: 'wan_proto', type: 'select', options: [['dhcp','DHCP'],['pppoe','PPPoE'],['static','Static'],['pptp','PPTP'],['l2tp','L2TP'],
1540 /* LINUX26-BEGIN */
1541 /* USB-BEGIN */
1542 ['ppp3g','3G Modem'],
1543 /* USB-END */
1544 /* LINUX26-END */
1545 ['disabled','Disabled']], value: nvram.wan_proto },
1546 { title: 'Modem device', name: 'modem_dev', type: 'select', options: [['ttyUSB0', '/dev/ttyUSB0'],['ttyUSB2', '/dev/ttyUSB2']], value: nvram.modem_dev },
1547 { title: 'PIN Code', name: 'modem_pin', type: 'text', maxlen: 6, size: 8, value: nvram.modem_pin },
1548 { title: 'Modem init string', name: 'modem_init', type: 'text', maxlen: 25, size: 32, value: nvram.modem_init },
1549 { title: 'APN', name: 'modem_apn', type: 'text', maxlen: 25, size: 32, value: nvram.modem_apn },
1550 { title: 'Username', name: 'ppp_username', type: 'text', maxlen: 60, size: 64, value: nvram.ppp_username },
1551 { title: 'Password', name: 'ppp_passwd', type: 'password', maxlen: 60, size: 64, peekaboo: 1, value: nvram.ppp_passwd },
1552 { title: 'Service Name', name: 'ppp_service', type: 'text', maxlen: 50, size: 64, value: nvram.ppp_service },
1553 { title: 'L2TP Server', name: 'l2tp_server_ip', type: 'text', maxlen: 128, size: 64, value: nvram.l2tp_server_ip },
1554 { title: 'Use DHCP', name: 'f_pptp_dhcp', type: 'checkbox', value: (nvram.pptp_dhcp == 1) },
1555 { title: 'IP Address', name: 'wan_ipaddr', type: 'text', maxlen: 15, size: 17, value: nvram.wan_ipaddr },
1556 { title: 'Subnet Mask', name: 'wan_netmask', type: 'text', maxlen: 15, size: 17, value: nvram.wan_netmask },
1557 { title: 'Gateway', name: 'wan_gateway', type: 'text', maxlen: 15, size: 17, value: nvram.wan_gateway },
1558 { title: 'PPTP Gateway', name: 'pptp_server_ip', type: 'text', maxlen: 128, size: 64, value: nvram.pptp_server_ip },
1559 { title: 'Options', name: 'ppp_custom', type: 'text', maxlen: 256, size: 64, value: nvram.ppp_custom },
1560 { title: 'Connect Mode', name: 'ppp_demand', type: 'select', options: [['1', 'Connect On Demand'],['0', 'Keep Alive']],
1561 value: nvram.ppp_demand },
1562 { title: 'Max Idle Time', indent: 2, name: 'ppp_idletime', type: 'text', maxlen: 5, size: 7, suffix: ' <i>(minutes)</i>',
1563 value: nvram.ppp_idletime },
1564 { title: 'Check Interval', indent: 2, name: 'ppp_redialperiod', type: 'text', maxlen: 5, size: 7, suffix: ' <i>(seconds)</i>',
1565 value: nvram.ppp_redialperiod },
1566 { title: 'MTU', multi: [
1567 { name: 'mtu_enable', type: 'select', options: [['0', 'Default'],['1','Manual']], value: nvram.mtu_enable },
1568 { name: 'f_wan_mtu', type: 'text', maxlen: 4, size: 6, value: nvram.wan_mtu } ] },
1569 { title: 'Single Line MLPPP', name: 'f_ppp_mlppp', type: 'checkbox', value: (nvram.ppp_mlppp == 1) },
1570 { title: 'Bridge WAN port to primary LAN (br0)', name: 'f_wan_islan', type: 'checkbox', value: (nvram.wan_islan == 1) }
1572 </script>
1573 </div>
1575 <div class='section-title'>LAN</div>
1576 <div class='section'>
1577 <table class='tomato-grid' cellspacing=1 id='lan-grid'></table>
1578 <script type='text/javascript'>lg.setup();</script>
1579 <script type='text/javascript'>
1580 dns = nvram.wan_dns.split(/\s+/);
1581 /* REMOVE-BEGIN
1582 //ipp = nvram.lan_ipaddr.split('.').splice(0, 3).join('.');
1583 REMOVE-END */
1584 createFieldTable('', [
1585 /* REMOVE-BEGIN
1586 // { title: 'Router IP Address', name: 'lan_ipaddr', type: 'text', maxlen: 15, size: 17, value: nvram.lan_ipaddr },
1587 // { title: 'Subnet Mask', name: 'lan_netmask', type: 'text', maxlen: 15, size: 17, value: nvram.lan_netmask },
1588 REMOVE-END */
1589 { title: 'Default Gateway', name: 'lan_gateway', type: 'text', maxlen: 15, size: 17, value: nvram.lan_gateway },
1590 { title: 'Static DNS', suffix: '&nbsp; <i>(IP:port)</i>', name: 'f_dns_1', type: 'text', maxlen: 21, size: 25, value: dns[0] || '0.0.0.0' },
1591 { title: '', name: 'f_dns_2', type: 'text', maxlen: 21, size: 25, value: dns[1] || '0.0.0.0' },
1592 { title: '', name: 'f_dns_3', type: 'text', maxlen: 21, size: 25, value: dns[2] || '0.0.0.0' },
1593 /* REMOVE-BEGIN
1594 // { title: 'DHCP Server', name: 'f_dhcpd_enable', type: 'checkbox', value: (nvram.lan_proto == 'dhcp') },
1595 // { title: 'IP Address Range', indent: 2, multi: [
1596 // { name: 'dhcpd_startip', type: 'text', maxlen: 15, size: 17, value: nvram.dhcpd_startip, suffix: ' - ' },
1597 // { name: 'dhcpd_endip', type: 'text', maxlen: 15, size: 17, value: nvram.dhcpd_endip, suffix: ' <i id="dhcp_count"></i>' }
1598 // ] },
1600 // { title: 'Lease Time', indent: 2, name: 'dhcp_lease', type: 'text', maxlen: 6, size: 8, suffix: ' <i>(minutes)</i>',
1601 // value: (nvram.dhcp_lease > 0) ? nvram.dhcp_lease : 1440 },
1602 // { title: 'WINS <i>(for DHCP)</i>', indent: 2, name: 'wan_wins', type: 'text', maxlen: 15, size: 17, value: nvram.wan_wins }
1603 REMOVE-END */
1604 { title: 'WINS <i>(for DHCP)</i>', name: 'wan_wins', type: 'text', maxlen: 15, size: 17, value: nvram.wan_wins }
1606 </script>
1607 </div>
1609 <script type='text/javascript'>
1611 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
1613 var u = wl_unit(uidx);
1615 W('<input type=\'hidden\' id=\'_wl'+u+'_mode\' name=\'wl'+u+'_mode\'>');
1616 W('<input type=\'hidden\' id=\'_wl'+u+'_nband\' name=\'wl'+u+'_nband\'>');
1617 W('<input type=\'hidden\' id=\'_wl'+u+'_wds_enable\' name=\'wl'+u+'_wds_enable\'>');
1618 W('<input type=\'hidden\' id=\'_wl'+u+'_wds\' name=\'wl'+u+'_wds\'>');
1619 W('<input type=\'hidden\' id=\'_wl'+u+'_radio\' name=\'wl'+u+'_radio\'>');
1620 W('<input type=\'hidden\' id=\'_wl'+u+'_closed\' name=\'wl'+u+'_closed\'>');
1621 W('<input type=\'hidden\' id=\'_wl'+u+'_key\' name=\'wl'+u+'_key\'>');
1622 W('<input type=\'hidden\' id=\'_wl'+u+'_gmode\' name=\'wl'+u+'_gmode\'>');
1623 W('<input type=\'hidden\' id=\'_wl'+u+'_akm\' name=\'wl'+u+'_akm\'>');
1624 W('<input type=\'hidden\' id=\'_wl'+u+'_auth\' name=\'wl'+u+'_auth\'>');
1625 W('<input type=\'hidden\' id=\'_wl'+u+'_auth_mode\' name=\'wl'+u+'_auth_mode\'>');
1626 W('<input type=\'hidden\' id=\'_wl'+u+'_wep\' name=\'wl'+u+'_wep\'>');
1627 W('<input type=\'hidden\' id=\'_wl'+u+'_lazywds\' name=\'wl'+u+'_lazywds\'>');
1628 W('<input type=\'hidden\' id=\'_wl'+u+'_nmode\' name=\'wl'+u+'_nmode\'>');
1629 W('<input type=\'hidden\' id=\'_wl'+u+'_nmcsidx\' name=\'wl'+u+'_nmcsidx\'>');
1630 W('<input type=\'hidden\' id=\'_wl'+u+'_nreqd\' name=\'wl'+u+'_nreqd\'>');
1631 W('<input type=\'hidden\' id=\'_wl'+u+'_nctrlsb\' name=\'wl'+u+'_nctrlsb\'>');
1632 W('<input type=\'hidden\' id=\'_wl'+u+'_nbw\' name=\'wl'+u+'_nbw\'>');
1634 W('<div class=\'section-title\'>Wireless');
1635 if (wl_ifaces.length > 1)
1636 W(' (' + wl_display_ifname(uidx) + ')');
1637 W('</div>');
1639 W('<div class=\'section\'>');
1641 f = [
1642 { title: 'Enable Wireless', name: 'f_wl'+u+'_radio', type: 'checkbox',
1643 value: (eval('nvram.wl'+u+'_radio') == '1') && (eval('nvram.wl'+u+'_net_mode') != 'disabled') },
1644 { title: 'MAC Address', text: '<a href="advanced-mac.asp">' + eval('nvram.wl'+u+'_hwaddr') + '</a>' },
1645 { title: 'Wireless Mode', name: 'f_wl'+u+'_mode', type: 'select',
1646 options: [['ap', 'Access Point'],['apwds', 'Access Point + WDS'],['sta', 'Wireless Client'],['wet', 'Wireless Ethernet Bridge'],['wds', 'WDS']],
1647 value: ((eval('nvram.wl'+u+'_mode') == 'ap') && (eval('nvram.wl'+u+'_wds_enable') == '1')) ? 'apwds' : eval('nvram.wl'+u+'_mode') },
1648 { title: 'Radio Band', name: 'f_wl'+u+'_nband', type: 'select', options: bands[uidx],
1649 value: eval('nvram.wl'+u+'_nband') || '0' == '0' ? bands[uidx][0][0] : eval('nvram.wl'+u+'_nband') },
1650 { title: 'Wireless Network Mode', name: 'wl'+u+'_net_mode', type: 'select',
1651 value: (eval('nvram.wl'+u+'_net_mode') == 'disabled') ? 'mixed' : eval('nvram.wl'+u+'_net_mode'),
1652 options: [], prefix: '<span id="__wl'+u+'_net_mode">', suffix: '</span>' },
1653 { title: 'SSID', name: 'wl'+u+'_ssid', type: 'text', maxlen: 32, size: 34, value: eval('nvram.wl'+u+'_ssid') },
1654 { title: 'Broadcast', indent: 2, name: 'f_wl'+u+'_bcast', type: 'checkbox', value: (eval('nvram.wl'+u+'_closed') == '0') },
1655 { title: 'Channel', name: 'wl'+u+'_channel', type: 'select', options: ghz[uidx], prefix: '<span id="__wl'+u+'_channel">', suffix: '</span> <input type="button" id="_f_wl'+u+'_scan" value="Scan" onclick="scanButton('+u+')"> <img src="spin.gif" id="spin'+u+'">',
1656 value: eval('nvram.wl'+u+'_channel') },
1657 { title: 'Channel Width', name: 'wl'+u+'_nbw_cap', type: 'select', options: [['0','20 MHz'],['1','40 MHz']],
1658 value: eval('nvram.wl'+u+'_nbw_cap') },
1659 { title: 'Control Sideband', name: 'f_wl'+u+'_nctrlsb', type: 'select', options: [['lower','Lower'],['upper','Upper']],
1660 value: eval('nvram.wl'+u+'_nctrlsb') == 'none' ? 'lower' : eval('nvram.wl'+u+'_nctrlsb') },
1661 null,
1662 { title: 'Security', name: 'wl'+u+'_security_mode', type: 'select',
1663 options: [['disabled','Disabled'],['wep','WEP'],['wpa_personal','WPA Personal'],['wpa_enterprise','WPA Enterprise'],['wpa2_personal','WPA2 Personal'],['wpa2_enterprise','WPA2 Enterprise'],['wpaX_personal','WPA / WPA2 Personal'],['wpaX_enterprise','WPA / WPA2 Enterprise'],['radius','Radius']],
1664 value: eval('nvram.wl'+u+'_security_mode') },
1665 { title: 'Encryption', indent: 2, name: 'wl'+u+'_crypto', type: 'select',
1666 options: [['tkip','TKIP'],['aes','AES'],['tkip+aes','TKIP / AES']], value: eval('nvram.wl'+u+'_crypto') },
1667 { title: 'Shared Key', indent: 2, name: 'wl'+u+'_wpa_psk', type: 'password', maxlen: 64, size: 66, peekaboo: 1,
1668 suffix: ' <input type="button" id="_f_wl'+u+'_psk_random1" value="Random" onclick="random_psk(\'_wl'+u+'_wpa_psk\')">',
1669 value: eval('nvram.wl'+u+'_wpa_psk') },
1670 { title: 'Shared Key', indent: 2, name: 'wl'+u+'_radius_key', type: 'password', maxlen: 80, size: 32, peekaboo: 1,
1671 suffix: ' <input type="button" id="_f_wl'+u+'_psk_random2" value="Random" onclick="random_psk(\'_wl'+u+'_radius_key\')">',
1672 value: eval('nvram.wl'+u+'_radius_key') },
1673 { title: 'Group Key Renewal', indent: 2, name: 'wl'+u+'_wpa_gtk_rekey', type: 'text', maxlen: 4, size: 6, suffix: ' <i>(seconds)</i>',
1674 value: eval('nvram.wl'+u+'_wpa_gtk_rekey') },
1675 { title: 'Radius Server', indent: 2, multi: [
1676 { name: 'wl'+u+'_radius_ipaddr', type: 'text', maxlen: 15, size: 17, value: eval('nvram.wl'+u+'_radius_ipaddr') },
1677 { name: 'wl'+u+'_radius_port', type: 'text', maxlen: 5, size: 7, prefix: ' : ', value: eval('nvram.wl'+u+'_radius_port') } ] },
1678 { title: 'Encryption', indent: 2, name: 'wl'+u+'_wep_bit', type: 'select', options: [['128','128-bits'],['64','64-bits']],
1679 value: eval('nvram.wl'+u+'_wep_bit') },
1680 { title: 'Passphrase', indent: 2, name: 'wl'+u+'_passphrase', type: 'text', maxlen: 16, size: 20,
1681 suffix: ' <input type="button" id="_f_wl'+u+'_wep_gen" value="Generate" onclick="generate_wep('+u+')"> <input type="button" id="_f_wl'+u+'_wep_random" value="Random" onclick="random_wep('+u+')">',
1682 value: eval('nvram.wl'+u+'_passphrase') }
1685 for (i = 1; i <= 4; ++i) {
1686 f.push(
1687 { title: ('Key ' + i), indent: 2, name: ('wl'+u+'_key' + i), type: 'text', maxlen: 26, size: 34,
1688 suffix: '<input type="radio" onchange="verifyFields(this,1)" onclick="verifyFields(this,1)" name="f_wl'+u+'_wepidx" id="_f_wl'+u+'_wepidx_' + i + '" value="' + i + '"' + ((eval('nvram.wl'+u+'_key') == i) ? ' checked>' : '>'),
1689 value: nvram['wl'+u+'_key' + i] });
1692 f.push(null,
1693 { title: 'WDS', name: 'f_wl'+u+'_lazywds', type: 'select',
1694 options: [['0','Link With...'],['1','Automatic']], value: nvram['wl'+u+'_lazywds'] } );
1695 wds = eval('nvram.wl'+u+'_wds').split(/\s+/);
1696 for (i = 0; i < 10; i += 2) {
1697 f.push({ title: (i ? '' : 'MAC Address'), indent: 2, multi: [
1698 { name: 'f_wl'+u+'_wds_' + i, type: 'text', maxlen: 17, size: 20, value: wds[i] || '00:00:00:00:00:00' },
1699 { name: 'f_wl'+u+'_wds_' + (i + 1), type: 'text', maxlen: 17, size: 20, value: wds[i + 1] || '00:00:00:00:00:00' } ] } );
1702 createFieldTable('', f);
1703 W('</div>');
1706 // for each wlif
1707 </script>
1709 <!-- / / / -->
1711 </td></tr>
1712 <tr><td id='footer' colspan=2>
1713 <span id='footer-msg'></span>
1714 <input type='button' value='Save' id='save-button' onclick='save()'>
1715 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
1716 </td></tr>
1717 </table>
1718 </form>
1719 <script type='text/javascript'>earlyInit()</script>
1720 <div style='height:100px'></div>
1721 </body>
1722 </html>