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