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