http://downloads.netgear.com/files/GPL/DM111PSP_v3.61d_GPL.tar.gz
[bcm963xx.git] / userapps / broadcom / cfm / html / lancfg2.html
1 <html>
2    <head>
3       <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
4       <link rel="stylesheet" href='stylemain.css' type='text/css'>
5          <link rel="stylesheet" href='colors.css' type='text/css'>
6             <script language="javascript" src="util.js"></script>
7             <script language="javascript">
8 <!-- hide
9 var state = '<%ejGet(lanRefresh)%>';
10 if ( state == '1' ) {
11    var code = 'location="lancfg2.cgi?lanRefresh=0"';
12    eval(code);
13 }
14
15 var dhcpStart = '<%ejGet(dhcpEthStart)%>';
16 var dhcpEnd = '<%ejGet(dhcpEthEnd)%>';
17 var dhcpLease = '<%ejGet(dhcpLeasedTime)%>';
18 var proto = '<%ejGetOther(sysInfo, noBrPrtcl)%>';
19 var ipExt = '<%ejGetOther(sysInfo, pppIpExtension)%>';
20 var dhcpEnbl = '<%ejGet(enblDhcpSrv)%>';
21 var natEnbl = '<%ejGetOther(sysInfo, enblNat)%>';
22 var enblUpnp = '<%ejGet(enblUpnp)%>';
23 var enblIgmpSnp = '<%ejGet(enblIgmpSnp)%>';
24 var enblIgmpMode = '<%ejGet(enblIgmpMode)%>';
25 var buildUpnp = '<%ejGetOther(sysInfo, buildUpnp)%>';
26
27 function hideUpnpInfo(hide) {
28    var status = 'visible';
29
30    if ( hide == 1 )
31       status = 'hidden';
32    if (document.getElementById)  // DOM3 = IE5, NS6
33       document.getElementById('upnpInfo').style.visibility = status;
34    else {
35       if (document.layers == false) // IE4
36          document.all.upnpInfo.style.visibility = status;
37    }
38 }
39
40 function hideIgmpSnpInfo(hide) {
41    var status = 'visible';
42
43    if ( hide == 1 )
44       status = 'hidden';
45    if (document.getElementById)  // DOM3 = IE5, NS6
46       document.getElementById('igmpSnpInfo').style.visibility = status;
47    else {
48       if (document.layers == false) // IE4
49          document.all.igmpSnpInfo.style.visibility = status;
50    }
51 }
52
53 function hideDhcpInfo(hide) {
54    var status = 'visible';
55
56    if ( hide == 1 )
57       status = 'hidden';
58    if (document.getElementById)  // DOM3 = IE5, NS6
59       document.getElementById('dhcpInfo').style.visibility = status;
60    else {
61       if (document.layers == false) // IE4
62          document.all.dhcpInfo.style.visibility = status;
63    }
64 }
65
66 function disableDhcpSrv() {
67    with ( document.forms[0] ) {
68       dhcpSrvType[1].checked = false;
69       dhcpEthStart.disabled = 1;
70       dhcpEthEnd.disabled = 1;
71       dhcpLeasedTime.value = '';
72       dhcpLeasedTime.disabled = 1;
73    }
74 }
75
76 function enableDhcpSrv(formLoad) {
77    with ( document.forms[0] ) {
78       dhcpSrvType[1].checked = true;
79       dhcpEthStart.disabled = 0;
80       dhcpEthEnd.disabled = 0;
81       if (formLoad == 0)
82          setDhcpAddresses(ethIpAddress.value);
83       else {
84          dhcpEthStart.value = dhcpStart;
85          dhcpEthEnd.value = dhcpEnd;
86       }
87       dhcpLeasedTime.value = dhcpLease;
88       dhcpLeasedTime.disabled = 0;
89    }
90 }
91
92 function hideRelayInfo(hide) {
93    var status = 'visible';
94
95    if ( hide == 1 )
96       status = 'hidden';
97    if (document.getElementById)  // DOM3 = IE5, NS6
98       document.getElementById('relayInfo').style.visibility = status;
99    else {
100       if (document.layers == false) // IE4
101          document.all.relayInfo.style.visibility = status;
102    }
103 }
104
105 function disableDhcpSrvRelay() {
106    with ( document.forms[0] ) {
107       dhcpSrvType[2].checked = false;
108       dhcpSrvAddr.disabled = 1;
109    }
110 }
111
112 function enableDhcpSrvRelay() {
113    with ( document.forms[0] ) {
114       dhcpSrvType[2].checked = true;
115       if (dhcpEthStart.value != "")
116          dhcpSrvAddr.value = dhcpEthStart.value;
117       else
118          dhcpSrvAddr.value = dhcpStart;
119       dhcpSrvAddr.disabled = 0;
120    }
121 }
122
123 function typeClick() {
124    with ( document.forms[0] ) {
125       // if any protocol has NAT enabled then
126       // don't show DHCP relay
127       if ( natEnbl == '1' ) {
128          if ( dhcpSrvType[0].checked == true )
129             disableDhcpSrv();
130          else
131             enableDhcpSrv(0);
132       } else {
133          if ( dhcpSrvType[0].checked == true ) {
134             disableDhcpSrv();
135             disableDhcpSrvRelay();
136          } else if ( dhcpSrvType[1].checked == true ) {
137             enableDhcpSrv(0);
138             disableDhcpSrvRelay();
139          } else {
140             enableDhcpSrvRelay();
141             disableDhcpSrv();
142          }
143       }
144    }
145 }
146
147 function igmpClick() {
148 }
149
150 function frmLoad() {
151    with ( document.forms[0] ) {
152       ethIpAddress.value = '<%ejGet(ethIpAddress)%>';
153       ethSubnetMask.value = '<%ejGet(ethSubnetMask)%>';
154
155       if ( natEnbl == '1' && buildUpnp == '1' ) {
156          if ( enblUpnp == '1' )
157             chkUpnp.checked = true;
158          else
159             chkUpnp.checked = false;
160          hideUpnpInfo(0);
161       } else
162          hideUpnpInfo(1);
163
164       if ( enblIgmpSnp == '1' )
165         chkIgmpSnp.checked = true;
166       else
167         chkIgmpSnp.checked = false;
168       if ( enblIgmpMode == '1' ) {
169         igmpMode[0].checked = false;
170         igmpMode[1].checked = true;
171       }
172       else {
173         igmpMode[0].checked = true;
174         igmpMode[1].checked = false;
175       }
176       hideIgmpSnpInfo(0);
177
178       // if protocol is Bridge or PPP IP extension
179       // then don't show DHCP info
180       if (proto == 'Bridge' || ipExt == '1')
181          hideDhcpInfo(1);
182       else {
183          hideDhcpInfo(0);
184          // if any protocol has NAT enabled then
185          // don't show DHCP relay
186          if ( natEnbl == '1' ) {
187             hideRelayInfo(1);
188             if ( dhcpEnbl == '1' )
189                enableDhcpSrv(1);
190             else {
191                dhcpSrvType[0].checked = true;
192                disableDhcpSrv();
193             }
194          } else {
195             hideRelayInfo(0);
196             if ( dhcpEnbl == '1' ) {
197                enableDhcpSrv(1);
198                disableDhcpSrvRelay();
199             } else if ( dhcpEnbl == '2' ) {
200                enableDhcpSrvRelay();
201                disableDhcpSrv();
202             } else {
203                dhcpSrvType[0].checked = true;
204                disableDhcpSrv();
205                disableDhcpSrvRelay();
206             }
207          }
208          lan2IpAddress.value = '<%ejGet(lan2IpAddress)%>';
209          lan2SubnetMask.value = '<%ejGet(lan2SubnetMask)%>';
210          if ('<%ejGet(enblLan2)%>' == '1') {
211             enblLan2.checked = true;
212             hideLan2Info(0);
213          } else {
214             enblLan2.checked = false;
215             hideLan2Info(1);
216          }
217       }
218    }
219 }
220
221 function hideLan2Info(hide) {
222    var status = 'visible';
223
224    if ( hide == 1 )
225       status = 'hidden';
226    if (document.getElementById)  // DOM3 = IE5, NS6
227       document.getElementById('lan2Info').style.visibility = status;
228    else {
229       if (document.layers == false) // IE4
230          document.all.lan2Info.style.visibility = status;
231    }
232 }
233
234 function lan2CbClick(cb) {
235    if ( cb.checked == true )
236       hideLan2Info(0);
237    else
238       hideLan2Info(1);
239 }
240
241 function isEndGTEStart(EndIp, StartIp)
242 {
243    addrEnd = EndIp.split('.');
244    addrStart = StartIp.split('.');
245    E = parseInt(addrEnd[3]) + 1;
246    S = parseInt(addrStart[3]) + 1;
247    if (E < S) 
248       return false;
249    return true;
250 }
251
252 function btnSave(reboot) {
253    var loc = 'lancfg2.cgi?';
254
255    if (reboot)
256       loc = 'lancfg2Reset.cgi?';
257
258    with ( document.forms[0] ) {
259       if ( isValidIpAddress(ethIpAddress.value) == false ) {
260          alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
261          return;
262       }
263       if ( isValidIpAddress(ethSubnetMask.value) == false ) {
264          alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
265          return;
266       }
267       loc += 'ethIpAddress=' + ethIpAddress.value;
268       loc += '&ethSubnetMask=' + ethSubnetMask.value;
269       if ( buildUpnp == '1' ) {
270          if ( chkUpnp.checked == true )
271             loc += '&enblUpnp=1';
272          else
273             loc += '&enblUpnp=0';
274       }
275      if ( chkIgmpSnp.checked == true )
276         loc += '&enblIgmpSnp=1';
277      else
278         loc += '&enblIgmpSnp=0';
279     if ( igmpMode[1].checked == true )
280         loc += '&enblIgmpMode=1';
281      else
282         loc += '&enblIgmpMode=0';
283       if ( dhcpSrvType[1].checked == true ) {
284          if (isValidIpAddress(dhcpEthStart.value) == false || 
285                !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthStart.value, ethSubnetMask.value))) {
286             alert('Start IP address "' + dhcpEthStart.value + '" is invalid IP address.');
287             return;
288          }
289          if ( isValidIpAddress(dhcpEthEnd.value) == false ||
290                !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthEnd.value, ethSubnetMask.value))) {
291             alert('End IP address "' + dhcpEthEnd.value + '" is invalid IP address.');
292             return;
293          }   
294          if (!(isEndGTEStart(dhcpEthEnd.value, dhcpEthStart.value))) {
295             alert("End ip has to be equal or greater than Start Ip address.");
296             return;
297          }
298          if ( isNaN(dhcpLeasedTime.value) == true || dhcpLeasedTime.value <= 0) {
299             alert('Leased time "' + dhcpLeasedTime.value + '" is invalid.');
300             return;
301          }
302          loc += '&dhcpEthStart=' + dhcpEthStart.value;
303          loc += '&dhcpEthEnd=' + dhcpEthEnd.value;
304          loc += '&dhcpLeasedTime=' + dhcpLeasedTime.value;
305          loc += '&enblDhcpSrv=1';
306       } else {
307          if ( natEnbl == '1' )
308             loc += '&enblDhcpSrv=0';
309          else {
310             if ( dhcpSrvType[2].checked == true ) {
311                if ( isValidIpAddress(dhcpSrvAddr.value) == false ) {
312                   alert('DHCP server IP address "' + dhcpSrvAddr.value + '" is invalid IP address.');
313                   return;
314                }
315                loc += '&dhcpEthStart=' + dhcpSrvAddr.value;
316                loc += '&enblDhcpSrv=2';
317             } else
318                loc += '&enblDhcpSrv=0';
319          }
320       }
321       if (enblLan2.checked == true) {
322          if ( isValidIpAddress(lan2IpAddress.value) == false ) {
323             alert('Address "' + lan2IpAddress.value + '" is invalid IP address.');
324             return;
325          }
326          if ( isValidIpAddress(lan2SubnetMask.value) == false ) {
327             alert('Subnet mask "' + lan2SubnetMask.value + '" has invalid IP address.');
328             return;
329          }
330          if (ethIpAddress.value == lan2IpAddress.value) {
331             alert('The IP address "' + ethIpAddress.value + '" for both LAN interfaces should not be the same.');
332             return;
333          }
334          if (isSameSubNet(ethIpAddress.value, ethSubnetMask.value, lan2IpAddress.value, lan2SubnetMask.value)) {
335             alert('The Subnet can not be the same for both LAN interfaces.');
336             return;
337          }
338          loc += '&enblLan2=1';
339          loc += '&lan2IpAddress=' + lan2IpAddress.value;
340          loc += '&lan2SubnetMask=' + lan2SubnetMask.value;
341       }
342       else
343          loc += '&enblLan2=0';
344    }
345    var code = 'location="' + loc + '"';
346    eval(code);
347 }
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 </head>
378    <body onLoad='frmLoad()'>
379       <blockquote>
380          <form>
381             <b>Local Area Network (LAN)&nbsp;Setup</b><br>
382             <br>
383             Configure the DSL Router IP Address and Subnet Mask for
384             LAN&nbsp;interface.&nbsp; Save button only saves the LAN configuration
385             data.&nbsp; Save/Reboot button saves the LAN configuration data and reboots the
386             router to make the new configuration effective.<br>
387             <br>
388             <table border="0" cellpadding="0" cellspacing="0">
389                <tr>
390                   <td width="150">IP Address:</td>
391                   <td><input type='text' name='ethIpAddress' onChange='setDhcpAddresses(this.value)'></td>
392                </tr>
393                <tr>
394                   <td>Subnet Mask:</td>
395                   <td><input type='text' name='ethSubnetMask'></td>
396                </tr>
397             </table>
398             <br>
399             <div id='upnpInfo'>
400             <table border="0" cellpadding="0" cellspacing="0">
401                <tr>
402                   <td><input type='checkbox' name='chkUpnp'>&nbsp;&nbsp;Enable UPnP</td>
403                </tr>
404             </table>
405             <br>
406             </div>
407             <div id='igmpSnpInfo'>
408             <table border="0" cellpadding="0" cellspacing="0">
409                <tr>
410                   <td><input type='checkbox' name='chkIgmpSnp' onClick='igmpClick(this)'>&nbsp;&nbsp;Enable IGMP Snooping</td>
411                   <tr>
412                      <td colspan="2"><input type='radio' name='igmpMode'>&nbsp;&nbsp;Standard Mode</td>
413                   </tr>
414                   <tr>
415                      <td colspan="2"><input type='radio' name='igmpMode'>&nbsp;&nbsp;Blocking Mode</td>
416                   </tr>
417                </tr>
418             </table>
419             <br>
420             </div>
421             <div id='dhcpInfo'>
422                <table border="0" cellpadding="0" cellspacing="0">
423                   <tr>
424                      <td colspan="2"><input type='radio' name='dhcpSrvType' onClick='typeClick()'>&nbsp;&nbsp;Disable DHCP Server</td>
425                   </tr>
426                   <tr>
427                      <td colspan="2"><input type='radio' name='dhcpSrvType' onClick='typeClick()'>&nbsp;&nbsp;Enable DHCP Server</td>
428                   </tr>
429                   <tr>
430                      <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start IP Address:</td>
431                      <td><input type='text' name='dhcpEthStart'></td>
432                   </tr>
433                   <tr>
434                      <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End IP Address:</td>
435                      <td><input type='text' name='dhcpEthEnd'></td>
436                   </tr>
437                   <tr>
438                      <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Leased Time (hour):</td>
439                      <td><input type='text' name='dhcpLeasedTime'></td>
440                   </tr>
441                </table>
442                <div id='relayInfo'>
443                   <table border="0" cellpadding="0" cellspacing="0">
444                      <tr>
445                         <td colspan="2"><input type='radio' name='dhcpSrvType' onClick='typeClick()'>&nbsp;&nbsp;Enable DHCP Server Relay</td>
446                      </tr>
447                      <tr>
448                         <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DHCP Server IP Address:&nbsp;&nbsp;</td>
449                         <td><input type='text' name='dhcpSrvAddr'></td>
450                      </tr>
451                   </table>
452                </div>
453                <br>
454                <table border="0" cellpadding="0" cellspacing="0">
455                   <tr>
456                      <td colspan="2">&nbsp</td>
457                   </tr>
458                   <tr>
459                      <td colspan="2"><input type='checkbox' name='enblLan2' onClick='lan2CbClick(this)'>Configure the second IP Address and Subnet Mask for LAN interface
460                   </tr>
461                </table>
462                <div id='lan2Info'>
463                   <table border="0" cellpadding="0" cellspacing="0">
464                      <tr>
465                         <td width="150">IP Address:</td>
466                         <td><input type='text' name='lan2IpAddress'></td>
467                      </tr>
468                      <tr>
469                         <td>Subnet Mask:</td>
470                         <td><input type='text' name='lan2SubnetMask'></td>
471                      </tr>
472                   </table>
473                </div>
474             </div>
475             <br>
476             <center>
477                <p align="center">
478                   <input type='button' onClick='btnSave(0)' value='Save'> <input type='button' onClick='btnSave(1)' value='Save/Reboot'>
479             </center>
480          </form>
481       </blockquote>
482    </body>
483 </html>