0aef377ea92b51e2057149ba80b60ba847b82fcf
[bcm963xx.git] / userapps / broadcom / cfm / html / lancfg2.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <!--
3         (c) 2005 U.S. Robotics Corporation
4 -->
5 <html>
6 <head>
7         <title>DHCP Server &laquo; LAN</title>
8
9         <link href="usr_layout.css" type="text/css" rel="stylesheet" /><script src="usr_layout.js" type="text/javascript"></script>
10         <link href="usr_menus_dropdown.css" rel="stylesheet" type="text/css"><script src="usr_menus_dropdown.js" type="text/javascript"></script><script src="usr_menus_build.js" type="text/javascript"></script>
11         <link href="usr_device.css" type="text/css" rel="stylesheet" /><script src="usr_device.js" type="text/javascript"></script><link href="usr_91xx.css" type="text/css" rel="stylesheet" /><script src="usr_91xx.js" type="text/javascript"></script><script src="usr_resources.js" type="text/javascript"></script>
12
13         <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
14
15         <script type="text/javascript" src="util.js"></script>
16         <script type="text/javascript">
17 <!-- hide
18
19
20 var state = '<%ejGetJS(lanRefresh)%>';
21 if ( state == '1' ) {
22    var code = 'location="lancfg2.cgi?lanRefresh=0"';
23    eval(code);
24 }
25
26 var dhcpStart = '<%ejGetJS(dhcpEthStart)%>';
27 var dhcpEnd = '<%ejGetJS(dhcpEthEnd)%>';
28 var dhcpLease = '<%ejGetJS(dhcpLeasedTime)%>';
29 var proto = '<%ejGetOther(sysInfo, noBrPrtcl)%>';
30 var ipExt = '<%ejGetOther(sysInfo, pppIpExtension)%>';
31 var dhcpEnbl = '<%ejGetJS(enblDhcpSrv)%>';
32 var natEnbl = '<%ejGetOther(sysInfo, enblNat)%>';
33 var enblUpnp = '<%ejGetJS(enblUpnp)%>';
34 var enblIgmpSnp = '<%ejGetJS(enblIgmpSnp)%>';
35 var enblIgmpMode = '<%ejGetJS(enblIgmpMode)%>';
36 var buildUpnp = '<%ejGetOther(sysInfo, buildUpnp)%>';
37 var enblStp = '<%ejGetJS(enblStp)%>';
38
39 function hideStpInfo(hide) {
40    var status = 'visible';
41
42    if ( hide == 1 )
43       status = 'hidden';
44    if (document.getElementById)  // DOM3 = IE5, NS6
45       document.getElementById('idStp').style.visibility = status;
46    else {
47       if (document.layers == false) // IE4
48          document.all.idStp.style.visibility = status;
49    }
50 }
51
52 function hideUpnpInfo(hide) {
53    var status = 'visible';
54
55    if ( hide == 1 )
56       status = 'hidden';
57    if (document.getElementById)  // DOM3 = IE5, NS6
58       document.getElementById('upnpInfo').style.visibility = status;
59    else {
60       if (document.layers == false) // IE4
61          document.all.upnpInfo.style.visibility = status;
62    }
63 }
64
65 function hideIgmpSnpInfo(hide) {
66    var status = 'visible';
67
68    if ( hide == 1 )
69       status = 'hidden';
70    if (document.getElementById)  // DOM3 = IE5, NS6
71       document.getElementById('igmpSnpInfo').style.visibility = status;
72    else {
73       if (document.layers == false) // IE4
74          document.all.igmpSnpInfo.style.visibility = status;
75    }
76 }
77
78 function hideDhcpInfo(hide) {
79    var status = 'visible';
80
81    if ( hide == 1 )
82       status = 'hidden';
83    if (document.getElementById)  // DOM3 = IE5, NS6
84       document.getElementById('dhcpInfo').style.visibility = status;
85    else {
86       if (document.layers == false) // IE4
87          document.all.dhcpInfo.style.visibility = status;
88    }
89 }
90
91 function disableDhcpSrv() {
92    with ( document.forms[0] ) {
93       dhcpSrvType[1].checked = false;
94       dhcpEthStart.disabled = 1;
95       dhcpEthEnd.disabled = 1;
96       dhcpLeasedTime.value = '';
97       dhcpLeasedTime.disabled = 1;
98    }
99 }
100
101 function enableDhcpSrv(formLoad) {
102    with ( document.forms[0] ) {
103       dhcpSrvType[1].checked = true;
104       dhcpEthStart.disabled = 0;
105       dhcpEthEnd.disabled = 0;
106       if (formLoad == 0)
107          setDhcpAddresses(ethIpAddress.value);
108       else {
109          dhcpEthStart.value = dhcpStart;
110          dhcpEthEnd.value = dhcpEnd;
111       }
112       dhcpLeasedTime.value = dhcpLease;
113       dhcpLeasedTime.disabled = 0;
114    }
115 }
116
117 function hideRelayInfo(hide) {
118    var status = 'visible';
119
120    if ( hide == 1 )
121       status = 'hidden';
122    if (document.getElementById)  // DOM3 = IE5, NS6
123       document.getElementById('relayInfo').style.visibility = status;
124    else {
125       if (document.layers == false) // IE4
126          document.all.relayInfo.style.visibility = status;
127    }
128 }
129
130 function disableDhcpSrvRelay() {
131    with ( document.forms[0] ) {
132       dhcpSrvType[2].checked = false;
133       dhcpSrvAddr.disabled = 1;
134    }
135 }
136
137 function enableDhcpSrvRelay() {
138    with ( document.forms[0] ) {
139       dhcpSrvType[2].checked = true;
140       if (dhcpEthStart.value != "")
141          dhcpSrvAddr.value = dhcpEthStart.value;
142       else
143          dhcpSrvAddr.value = dhcpStart;
144       dhcpSrvAddr.disabled = 0;
145    }
146 }
147
148 function typeClick() {
149    with ( document.forms[0] ) {
150       // if any protocol has NAT enabled then
151       // don't show DHCP relay
152       if ( natEnbl == '1' ) {
153          if ( dhcpSrvType[0].checked == true )
154             disableDhcpSrv();
155          else
156             enableDhcpSrv(0);
157       } else {
158          if ( dhcpSrvType[0].checked == true ) {
159             disableDhcpSrv();
160             disableDhcpSrvRelay();
161          } else if ( dhcpSrvType[1].checked == true ) {
162             enableDhcpSrv(0);
163             disableDhcpSrvRelay();
164          } else {
165             enableDhcpSrvRelay();
166             disableDhcpSrv();
167          }
168       }
169    }
170 }
171
172 function igmpClick() {
173 }
174
175 function frmLoad() {
176    with ( document.forms[0] ) {
177       ethIpAddress.value = '<%ejGetJS(ethIpAddress)%>';
178       ethSubnetMask.value = '<%ejGetJS(ethSubnetMask)%>';
179
180       if ( natEnbl == '1' && buildUpnp == '1' ) {
181          if ( enblUpnp == '1' )
182             chkUpnp.checked = true;
183          else
184             chkUpnp.checked = false;
185          hideUpnpInfo(0);
186       } else
187          hideUpnpInfo(1);
188
189       if ( enblIgmpSnp == '1' )
190         chkIgmpSnp.checked = true;
191       else
192         chkIgmpSnp.checked = false;
193       if ( enblIgmpMode == '1' ) {
194         igmpMode[0].checked = false;
195         igmpMode[1].checked = true;
196       }
197       else {
198         igmpMode[0].checked = true;
199         igmpMode[1].checked = false;
200       }
201       hideIgmpSnpInfo(0);
202
203       // if protocol is Bridge or PPP IP extension
204       // then don't show DHCP info
205       if (proto == 'Bridge' || ipExt == '1')
206          hideDhcpInfo(1);
207       else {
208          hideDhcpInfo(0);
209          // if any protocol has NAT enabled then
210          // don't show DHCP relay
211          if ( natEnbl == '1' ) {
212             hideRelayInfo(1);
213             if ( dhcpEnbl == '1' )
214                enableDhcpSrv(1);
215             else {
216                dhcpSrvType[0].checked = true;
217                disableDhcpSrv();
218             }
219          } else {
220             hideRelayInfo(0);
221             if ( dhcpEnbl == '1' ) {
222                enableDhcpSrv(1);
223                disableDhcpSrvRelay();
224             } else if ( dhcpEnbl == '2' ) {
225                enableDhcpSrvRelay();
226                disableDhcpSrv();
227             } else {
228                dhcpSrvType[0].checked = true;
229                disableDhcpSrv();
230                disableDhcpSrvRelay();
231             }
232          }
233          lan2IpAddress.value = '<%ejGetJS(lan2IpAddress)%>';
234          lan2SubnetMask.value = '<%ejGetJS(lan2SubnetMask)%>';
235          if ('<%ejGetJS(enblLan2)%>' == '1') {
236             enblLan2.checked = true;
237             hideLan2Info(0);
238          } else {
239             enblLan2.checked = false;
240             hideLan2Info(1);
241          }
242       }
243       if (enblStp == '1')
244          chkStp.checked = true;
245       else 
246          chkStp.checked = false; 
247    }
248 }
249
250 function hideLan2Info(hide) {
251    var status = 'visible';
252
253    if ( hide == 1 )
254       status = 'hidden';
255    if (document.getElementById)  // DOM3 = IE5, NS6
256       document.getElementById('lan2Info').style.visibility = status;
257    else {
258       if (document.layers == false) // IE4
259          document.all.lan2Info.style.visibility = status;
260    }
261 }
262
263 function lan2CbClick(cb) {
264    if ( cb.checked == true )
265       hideLan2Info(0);
266    else
267       hideLan2Info(1);
268 }
269
270 function isEndGTEStart(EndIp, StartIp)
271 {
272    addrEnd = EndIp.split('.');
273    addrStart = StartIp.split('.');
274    E = parseInt(addrEnd[3]) + 1;
275    S = parseInt(addrStart[3]) + 1;
276    if (E < S) 
277       return false;
278    return true;
279 }
280
281 function btnApply(reboot) {
282    var loc = 'lancfg2.cgi?';
283
284    if (reboot)
285       loc = 'lancfg2Reset.cgi?';
286
287    with ( document.forms[0] ) {
288       if ( isValidIpAddress(ethIpAddress.value) == false ) {
289          alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
290          return;
291       }
292       if ( isValidIpAddress(ethSubnetMask.value) == false ) {
293          alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
294          return;
295       }
296       loc += 'ethIpAddress=' + ethIpAddress.value;
297       loc += '&ethSubnetMask=' + ethSubnetMask.value;
298       if ( buildUpnp == '1' ) {
299          if ( chkUpnp.checked == true )
300             loc += '&enblUpnp=1';
301          else
302             loc += '&enblUpnp=0';
303       }
304       if ( chkStp.checked == true )
305          loc += '&enblStp=1';
306       else
307          loc += '&enblStp=0';
308       
309      if ( chkIgmpSnp.checked == true )
310         loc += '&enblIgmpSnp=1';
311      else
312         loc += '&enblIgmpSnp=0';
313     if ( igmpMode[1].checked == true )
314         loc += '&enblIgmpMode=1';
315      else
316         loc += '&enblIgmpMode=0';
317       if ( dhcpSrvType[1].checked == true ) {
318          if (isValidIpAddress(dhcpEthStart.value) == false || 
319                !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthStart.value, ethSubnetMask.value))) {
320             alert('Start IP address "' + dhcpEthStart.value + '" is invalid IP address.');
321             return;
322          }
323          if ( isValidIpAddress(dhcpEthEnd.value) == false ||
324                !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthEnd.value, ethSubnetMask.value))) {
325             alert('End IP address "' + dhcpEthEnd.value + '" is invalid IP address.');
326             return;
327          }   
328          if (!(isEndGTEStart(dhcpEthEnd.value, dhcpEthStart.value))) {
329             alert("End ip has to be equal or greater than Start Ip address.");
330             return;
331          }
332          if ( isNaN(dhcpLeasedTime.value) == true || dhcpLeasedTime.value <= 0) {
333             alert('Leased time "' + dhcpLeasedTime.value + '" is invalid.');
334             return;
335          }
336          loc += '&dhcpEthStart=' + dhcpEthStart.value;
337          loc += '&dhcpEthEnd=' + dhcpEthEnd.value;
338          loc += '&dhcpLeasedTime=' + dhcpLeasedTime.value;
339          loc += '&enblDhcpSrv=1';
340       } else {
341          if ( natEnbl == '1' )
342             loc += '&enblDhcpSrv=0';
343          else {
344             if ( dhcpSrvType[2].checked == true ) {
345                if ( isValidIpAddress(dhcpSrvAddr.value) == false ) {
346                   alert('DHCP server IP address "' + dhcpSrvAddr.value + '" is invalid IP address.');
347                   return;
348                }
349                loc += '&dhcpEthStart=' + dhcpSrvAddr.value;
350                loc += '&enblDhcpSrv=2';
351             } else
352                loc += '&enblDhcpSrv=0';
353          }
354       }
355       if (enblLan2.checked == true) {
356          if ( isValidIpAddress(lan2IpAddress.value) == false ) {
357             alert('Address "' + lan2IpAddress.value + '" is invalid IP address.');
358             return;
359          }
360          if ( isValidIpAddress(lan2SubnetMask.value) == false ) {
361             alert('Subnet mask "' + lan2SubnetMask.value + '" has invalid IP address.');
362             return;
363          }
364          if (ethIpAddress.value == lan2IpAddress.value) {
365             alert('The IP address "' + ethIpAddress.value + '" for both LAN interfaces should not be the same.');
366             return;
367          }
368          if (isSameSubNet(ethIpAddress.value, ethSubnetMask.value, lan2IpAddress.value, lan2SubnetMask.value)) {
369             alert('The Subnet can not be the same for both LAN interfaces.');
370             return;
371          }
372          loc += '&enblLan2=1';
373          loc += '&lan2IpAddress=' + lan2IpAddress.value;
374          loc += '&lan2SubnetMask=' + lan2SubnetMask.value;
375       }
376       else
377          loc += '&enblLan2=0';
378    }
379    var code = 'location="' + loc + '"';
380    eval(code);
381 }
382
383 function btnReset() {
384      var loc = 'rebootinfo.cgi';
385
386      var code = 'location = "' + loc + '"';
387      eval(code);
388 }
389
390 function setDhcpAddresses(lanIp) {
391    with ( document.forms[0] ) {
392       if ( isValidIpAddress(lanIp) == false ) {
393          alert('Address "' + lanIp + '" is invalid IP address.');
394          return;
395       }
396       addrParts = lanIp.split('.');
397       if ( addrParts.length != 4 )
398          return false;
399       t1 = parseInt(addrParts[3]) + 1;
400       if (dhcpEthStart.value != '' && t1 >= 255) {
401          alert("Last portion of IP Address has to be less than 254 for Enabled DHCP Server");
402          return false;
403       }
404       dhcpEthStart.value = dhcpEthEnd.value = "";
405       for (i = 0; i < 3; i++) {
406          dhcpEthStart.value = dhcpEthStart.value + addrParts[i] + ".";
407          dhcpEthEnd.value = dhcpEthEnd.value + addrParts[i] + ".";
408       }
409       dhcpEthStart.value = dhcpEthStart.value + t1;
410       dhcpEthEnd.value = dhcpEthEnd.value + 254;
411    }
412 }
413
414 function manualModDhcp() {
415    with ( document.forms[0] ) {
416       dhcpStart = dhcpEthStart.value;
417       dhcpEnd = dhcpEthEnd.value;
418    }
419 }   
420
421 // done hiding -->
422 </script>
423               <base target="_self">
424      </head>
425
426 <body onload="initMenu(); frmLoad();">
427
428 <script type="text/javascript">
429         writeHeader("LAN");
430 </script>
431
432 <form>
433 <h3>DHCP Server</h3>
434
435 <p>Configure the router&rsquo;s IP address and subnet mask for LAN interface.</p>
436
437 <table border="0" cellpadding="1" cellspacing="0">
438   <tr>
439      <td><label for="ethIpAddress">IP address:</label></td>
440      <td><input type='text' name='ethIpAddress' id='ethIpAddress' onChange='setDhcpAddresses(this.value)'></td>
441   </tr>
442   <tr>
443      <td><label for="ethSubnetMask">Subnet mask:</label></td>
444      <td><input type='text' name='ethSubnetMask' id='ethSubnetMask'></td>
445   </tr>
446 </table>
447
448 <div id='dhcpInfo'>
449         <p>
450                 <input type='radio' name='dhcpSrvType' id='optDHCPoff' onClick='typeClick()'> <label for="optDHCPoff">Disable DHCP server</label><br>
451                 <input type='radio' name='dhcpSrvType' id='optDHCPon' onClick='typeClick()'> <label for="optDHCPon">Enable DHCP server</label>
452         </p>
453         <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
454                 <tr>
455                    <td><label for="dhcpEthStart">Start IP address:</label></td>
456                    <td><input type='text' name='dhcpEthStart' id='dhcpEthStart' onChange='manualModDhcp()'></td>
457                 </tr>
458                 <tr>
459                    <td><label for="dhcpEthEnd">End IP address:</label></td>
460                    <td><input type='text' name='dhcpEthEnd' id='dhcpEthEnd' onChange='manualModDhcp()'></td>
461                 </tr>
462                 <tr>
463                    <td><label for="dhcpLeasedTime">Lease time:</label></td>
464                     <td><input type='text' name='dhcpLeasedTime' id='dhcpLeasedTime'> hours</td>
465                   </tr>
466         </table>
467
468         <div id='relayInfo'>
469                 <p><input type='radio' name='dhcpSrvType' id='optDHCPrelay' onClick='typeClick()'> <label for="optDHCPrelay">Enable DHCP server relay</label></p>
470                 <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
471                    <tr>
472                       <td><label for="dhcpSrvAddr">DHCP server IP address:</label></td>
473                       <td><input type='text' name='dhcpSrvAddr' id='dhcpSrvAddr'></td>
474                    </tr>
475                 </table>
476         </div>
477
478         <p><input type='checkbox' name='enblLan2' id='enblLan2' onClick='lan2CbClick(this)'> <label for="enblLan2">Configure the second IP address and subnet mask for LAN interface</label></p>
479         <div id='lan2Info'>
480           <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
481              <tr>
482                <td><label for="lan2IpAddress">IP address:</label></td>
483                <td><input type='text' name='lan2IpAddress' id='lan2IpAddress'></td>
484              </tr>
485              <tr>
486                 <td><label for="lan2SubnetMask">Subnet mask:</label></td>
487                 <td><input type='text' name='lan2SubnetMask' id='lan2SubnetMask'></td>
488              </tr>
489           </table>
490         </div>
491 </div>
492
493 <div id='igmpSnpInfo'>
494 <h3>IGMP Snooping</h3>
495 <p><input type='checkbox' name='chkIgmpSnp' id='chkIgmpSnp'> <label for="chkIgmpSnp">IGMP snooping</label></p>
496 <P><input type='radio' name='igmpMode' id='igmpModeS'> <label for="igmpModeS">Standard mode</label><br/>
497    <input type='radio' name='igmpMode' id='igmpModeB'> <label for="igmpModeB">Blocking mode</label>
498 </p>
499 </div>
500
501 <div id='upnpInfo'>
502 <h3>Universal Plug-n-Play</h3>
503 <p><input type='checkbox' name='chkUpnp' id='chkUpnp'> <label for="chkUpnp">Universal Plug-n-Play (UPnP)</label></p>
504 </div>
505
506 <div id='idStp'>
507 <h3>802.1d</h3>
508 <p><input type='checkbox' name='chkStp' id='chkStp'> <label for="chkStp">802.1d spanning tree protocol</label></p>
509 </div>
510
511 <p><input type='button' onClick='btnApply(0)' value='Apply'> <input type='button' onClick='btnReset()' value='Restart'></p>
512 </form>
513
514 <script type="text/javascript">
515         writeFooter();
516 </script>
517
518 </body>
519 </html>