http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / userapps / broadcom / cfm / html / lancfg2.html
1 <html>
2    <head>
3       <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
4       <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
5       <link rel="stylesheet" href='stylemain.css' type='text/css'>
6          <link rel="stylesheet" href='colors.css' type='text/css'>
7             <script language="javascript" src="util.js"></script>
8             <script language="javascript">
9 <!-- hide
10 parent.helpframe.location.href="hlplansetup.html";
11 var randomNum = '<%ejGet(CheckNum)%>';
12 var lanIpAddr='<%ejGet(ethIpAddress)%>';
13 var lanSubMask='<%ejGet(ethSubnetMask)%>';
14 var lan2Status='<%ejGet(enblLan2)%>';
15 var lan2IpAddr='<%ejGet(lan2IpAddress)%>';
16 var lan2SubMask='<%ejGet(lan2SubnetMask)%>';
17 var old_lan2status;
18 var BridgeOnly = '<%ejGetOther(sysInfo, PrtclBridgeOnly)%>';
19 var hostname='<%ejGet(hostname)%>';
20 var domainname='<%ejGet(domainname)%>';
21 var lanmtu = '<%ejGet(lanmtu)%>';
22 var includemtu = '<%ejGetOther(sysInfo, includemtu)%>';
23 var dhcpStart = '<%ejGet(dhcpEthStart)%>';
24 var dhcpEnd = '<%ejGet(dhcpEthEnd)%>';
25 var dhcpLease = '<%ejGet(dhcpLeasedTime)%>';
26 var old_Leasetime=dhcpLease;
27 var nat = '<%ejGet(enblNat)%>';
28 var dhcpEnbl = '<%ejGet(enblDhcpSrv)%>';
29 var natEnbl = '<%ejGetOther(sysInfo, enblNat)%>';
30 var old_DhcpStatus;
31 var DD;
32 var HH;
33 var MM;
34
35 //for DHCP start
36 function viewList(){\r
37   window.open("viewdhcprelist.html","","width=470, height=300, scrollbars=yes");\r
38 }\r
39 \r
40 function showDhcpInfo(){\r
41         document.getElementById('DhcpInfo').innerHTML =\r
42                 '<table width="570" border="0" cellspacing="0" cellpadding="0" height="96">'+\r
43                 '<tr>'+\r
44                 '<td width="195" height="30"><input type="radio" name="dhcpser" id="dhcpenable" onClick="radiobut()">&nbsp;DHCP Server On</td>'+\r
45                 '<td width="75" height="30" name="startipstr" id="startipstr">Start IP: </td>'+\r
46                 '<td width="280" height="30" align="left">&nbsp;'+\r
47                 '<input type="text" name="startIp" id="startIp" size="20"></td>'+\r
48                 '</tr>'+\r
49                 '<tr>'+\r
50                 '<td width="195" height="30">&nbsp;</td>'+\r
51                 '<td width="75" height="30" name="endipstr" id="endipstr">End IP: </td>'+\r
52                 '<td width="280" height="30">&nbsp;<input type="text" name="endIp" id="endIp" size="20"></td>'+\r
53                 '</tr>'+\r
54                 '<tr>'+\r
55                 '<td width="195" height="30">&nbsp;</td>'+\r
56                 '<td width="75" height="30" name="leasetimestr" id="leasetimestr">Lease Time:&nbsp; </td>'+\r
57                 '<td width="280" height="30" name="dhmstr" id="dhmstr">&nbsp;<input type="text" name="time_dd" id="time_dd" size="3">&nbsp;'+\r
58                 'days&nbsp; <input type="text" name="time_hh" id="time_hh" size="2">&nbsp; hours&nbsp;'+\r
59                 '<input type="text" name="time_mm" id="time_mm" size="2">&nbsp; minutes</td>'+\r
60                 '</tr>'+\r
61                 '<tr>'+\r
62                 '<td width="195" height="33">&nbsp;</td>'+\r
63                 '<td width="85" height="33">&nbsp;</td>'+\r
64                 '<td width="280" height="33">&nbsp;'+\r
65                 '<input type="button" value="Reserved IP Address List" name="resbut" id="resbut" onClick="viewList()"></td>'+\r
66                 '</tr>'+\r
67                 '<tr>'+\r
68                 '<td width="550" height="42" colspan="3">'+\r
69                 '<table width="550" border="0" cellspacing="0" cellpadding="0" height="42">'+\r
70                 '<tr>'+\r
71                 '<td><input type="radio" name="dhcpser" id="dhcprelay" onClick="radiobut()"> Relay On</td>'+\r
72                 '<td name="relaystr" id="relaystr">&nbsp;Relay to Server IP:</td>'+\r
73                 '<td><input type="text" name="relayIp" id="relayIp" size="20"></td>'+\r
74                 '</tr>'+\r
75                 '</table>'+\r
76                 '</td></tr>'+\r
77                 '<tr>'+\r
78                 '<td width="550" height="30" colspan="3" align="left">'+\r
79                 '<input type="radio" name="dhcpser" id="dhcpdisable" onClick="radiobut()"> Server and Relay Off</td>'+\r
80                 '</tr>'+\r
81                 '</table>';\r
82 }\r
83 \r
84 function setvalue(){\r
85         if (document.getElementById("dhcpenable").checked==true){\r
86                 document.getElementById("dhcpenable").checked=true;\r
87                 document.getElementById("dhcprelay").checked=false;\r
88                 document.getElementById("dhcpdisable").checked=false;\r
89                 document.getElementById("startipstr").style.color="#000000";\r
90                 document.getElementById("endipstr").style.color="#000000";\r
91                 document.getElementById("leasetimestr").style.color="#000000";\r
92                 document.getElementById("dhmstr").style.color="#000000";\r
93                 document.getElementById("relaystr").style.color="#666666";\r
94                 document.getElementById("startIp").disabled=false;\r
95                 document.getElementById("endIp").disabled=false;\r
96                 document.getElementById("time_dd").disabled=false;\r
97                 document.getElementById("time_hh").disabled=false;\r
98                 document.getElementById("time_mm").disabled=false;\r
99                 document.getElementById("resbut").disabled=false;\r
100                 document.getElementById("relayIp").disabled=true;\r
101         } else if (document.getElementById("dhcprelay").checked==true){\r
102                 document.getElementById("dhcpenable").checked=false;\r
103                 document.getElementById("dhcprelay").checked=true\r
104                 document.getElementById("dhcpdisable").checked=false;\r
105                 document.getElementById("startipstr").style.color="#666666";\r
106                 document.getElementById("endipstr").style.color="#666666";\r
107                 document.getElementById("leasetimestr").style.color="#666666";\r
108                 document.getElementById("dhmstr").style.color="#666666";\r
109                 document.getElementById("relaystr").style.color="#000000";\r
110                 document.getElementById("startIp").disabled=true;\r
111                 document.getElementById("endIp").disabled=true;\r
112                 document.getElementById("time_dd").disabled=true;\r
113                 document.getElementById("time_hh").disabled=true;\r
114                 document.getElementById("time_mm").disabled=true;\r
115                 document.getElementById("resbut").disabled=true;\r
116                 document.getElementById("relayIp").disabled=false;\r
117         } else {\r
118                 document.getElementById("dhcpenable").checked=false;\r
119                 document.getElementById("dhcprelay").checked=false;\r
120                 document.getElementById("dhcpdisable").checked=true;\r
121                 document.getElementById("startipstr").style.color="#666666";\r
122                 document.getElementById("endipstr").style.color="#666666";\r
123                 document.getElementById("leasetimestr").style.color="#666666";\r
124                 document.getElementById("dhmstr").style.color="#666666";\r
125                 document.getElementById("relaystr").style.color="#666666";\r
126                 document.getElementById("startIp").disabled=true;\r
127                 document.getElementById("endIp").disabled=true;\r
128                 document.getElementById("time_dd").disabled=true;\r
129                 document.getElementById("time_hh").disabled=true;\r
130                 document.getElementById("time_mm").disabled=true;\r
131                 document.getElementById("resbut").disabled=true;\r
132                 document.getElementById("relayIp").disabled=true;\r
133 }\r
134         document.getElementById("startIp").value=dhcpStart;\r
135         document.getElementById("endIp").value=dhcpEnd;\r
136                 dhcpLease=old_Leasetime;\r
137                 DD = Math.floor(dhcpLease/86400);\r
138                 dhcpLease%=86400;\r
139                 HH = Math.floor(dhcpLease/3600);\r
140                 dhcpLease%=3600;\r
141                 MM = Math.floor(dhcpLease/60);\r
142         document.getElementById("time_dd").value=DD;\r
143         document.getElementById("time_hh").value=HH;\r
144         document.getElementById("time_mm").value=MM;\r
145         document.getElementById("relayIp").value=dhcpStart;\r
146                 old_DhcpStatus = dhcpEnbl;\r
147         }\r
148 \r
149 function radiobut(){\r
150         setvalue();\r
151 }
152 //DHCP end
153
154
155 function showlan2(){
156   with(document.forms[0]){
157       if(enblLan2.checked==true){
158           document.getElementById('displaylan2').innerHTML ='<table border="0" cellpadding="0" cellspacing="0">'+
159                      '<tr>'+
160                      '<td width="150">Secondary IP Address:</td>'+
161                      '<td><input type="text" name="lan2IpAddress"></td>'+
162                      '</tr>'+
163                      '<tr>'+
164                      '<td>Subnet Mask:</td>'+
165                      '<td><input type="text" name="lan2SubnetMask"></td>'+
166                      '</tr>'+
167                      '</table>'+
168                      '<br>';
169          if (lan2IpAddr == '0.0.0.0'){
170                 lan2IpAddr = '';
171                 lan2SubMask = '';
172          }
173          lan2IpAddress.value = lan2IpAddr;
174          lan2SubnetMask.value = lan2SubMask;
175       } else {
176         document.getElementById('displaylan2').innerHTML = '';
177       }
178   }
179 }
180
181 function showLanMTUInfo(){
182         with ( document.forms[0] ) {
183                 document.getElementById('LanMtuInfo').innerHTML =
184                         '<table border="0" cellspacing="0" cellpadding="0" height="30">'+
185                         '<tr>'+
186                         '<td width="150" height="30">MTU:</td>'+
187                         '<td height="30"><input type="text" name="lmtu" id="mtu" size="5"> (Default: 1500)</td>'+
188                         '</tr>'+
189                         '</table>';
190                         
191                         lmtu.value=lanmtu;
192         }
193 }
194
195 function frmLoad() {
196         with ( document.forms[0] ) {
197                 ethIpAddress.value = lanIpAddr;
198                 ethSubnetMask.value = lanSubMask;
199                 hname.value=hostname;
200                 dname.value=domainname;
201
202                 if ( BridgeOnly == '0' ){
203                         if (lan2Status == '1') {
204                                 enblLan2.checked = true;
205                                 showlan2();
206                                 old_lan2status=true;
207                         } else {
208                                 enblLan2.checked = false;
209                                 showlan2();
210                                 old_lan2status=false;
211                         }
212                 }
213                 if (includemtu == '1')
214                 showLanMTUInfo();
215
216                 //for DHCP start
217                 showDhcpInfo();\r
218                 if (dhcpEnbl == '1'){\r
219                         document.getElementById("dhcpenable").checked=true;\r
220                         document.getElementById("dhcprelay").checked=false;\r
221                         document.getElementById("dhcpdisable").checked=false;\r
222                 } else if (dhcpEnbl == '2'){\r
223                         document.getElementById("dhcpenable").checked=false;\r
224                         document.getElementById("dhcprelay").checked=true;\r
225                         document.getElementById("dhcpdisable").checked=false;\r
226                 } else {\r
227                         document.getElementById("dhcpenable").checked=false;\r
228                         document.getElementById("dhcprelay").checked=false;\r
229                         document.getElementById("dhcpdisable").checked=true;\r
230                 }\r
231                 setvalue();
232                 //DHCP end
233         }
234
235         if (<%ejGet(changeset)%> == 1){
236                 parent.footerfrm.location.href="footer.html";
237         }
238 }
239
240 function do_cgi(){
241         var loc = 'lancfg2.cgi?';
242         loc += 'checkNum=' + randomNum + '&';
243         with ( document.forms[0] ) {
244                 if ( isValidIpAddress(ethIpAddress.value) == false ) {
245                         alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
246                     return;
247                 }
248                 if ( isValidIpAddress(ethSubnetMask.value) == false ) {
249                         alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
250                         return;
251                 }
252                 loc += 'ethIpAddress=' + ethIpAddress.value;
253                 loc += '&ethSubnetMask=' + ethSubnetMask.value;
254                 if(hname.value.charAt(0).match("^[0-9]") != null){
255                 alert("Host name can not start with a number.");
256                 return;
257         }
258         loc += '&hostname=' + encodeUrl(hname.value);
259         if(urlError==1) return;
260         if(dname.value.charAt(0).match("^[0-9]") != null){
261                 alert("Domain name can not start with a number.");
262                 return;
263         }
264                 loc += '&domainname=' + encodeUrl(dname.value);
265                 if(urlError==1) return;
266
267
268                 if (enblLan2.checked == true) {
269                         if ( isValidIpAddress(lan2IpAddress.value) == false ) {
270                         alert('Address "' + lan2IpAddress.value + '" is invalid IP address.');
271                         return;
272                         }
273                     if ( isValidIpAddress(lan2SubnetMask.value) == false ) {
274                         alert('Subnet mask "' + lan2SubnetMask.value + '" has invalid IP address.');
275                         return;
276                     }
277                     if ( checkLan1andLan2(ethIpAddress.value, ethSubnetMask.value, lan2IpAddress.value, lan2SubnetMask.value)==false){
278                         alert("The primary LAN IP address and secondary LAN IP address MUST belong to different subnets.");
279                         return;
280                     }
281                     loc += '&enblLan2=1';
282                     loc += '&lan2IpAddress=' + lan2IpAddress.value;
283                     loc += '&lan2SubnetMask=' + lan2SubnetMask.value;
284                  } else {
285                     loc += '&enblLan2=0';
286                     loc += '&lan2IpAddress=' + '0.0.0.0';
287                 loc += '&lan2SubnetMask=' + '255.255.255.255';
288          }
289
290                 if (includemtu == '1'){
291                         if (lmtu.value <1000){
292                                 alert("Minimum MTU is 1000.");
293                                 return;
294                         }
295                         if (lmtu.value >1500){
296                                 alert("Maximum MTU is 1500.");
297                                 return;
298                         }
299                         loc += '&lanmtu=' + lmtu.value;
300                 }
301
302                 //for DHCP start        \r
303                 if (dhcpser[2].checked == true){\r
304                         loc += '&enblDhcpSrv=0';\r
305                 } else if (dhcpser[1].checked == true){\r
306                         if ( isValidIpAddress(relayIp.value) == false ) {\r
307                         alert('Relay IP address "' + relayIp.value + '" is invalid IP address.');\r
308                         return;\r
309                 }\r
310                         loc += '&enblDhcpSrv=2';\r
311                 loc += '&dhcpEthStart=' + relayIp.value;\r
312                 } else {\r
313                         if ( isValidIpAddress(startIp.value) == false ) {\r
314                         alert('Start IP address "' +startIp.value + '" is invalid IP address.');\r
315                         return;\r
316                 }\r
317                 if ( isValidIpAddress(endIp.value) == false ) {\r
318                         alert('Stop IP address "' + endIp.value + '" is invalid IP address.');\r
319                         return;\r
320                 }\r
321                 if ( isNaN(time_dd.value) == true || isNaN(time_hh.value) == true ||\r
322                            isNaN(time_mm.value) == true) {\r
323                         alert("Dhcp lease time is invalid.");\r
324                         return;\r
325                 }\r
326                 if (checkDhcpIpAddrRange(startIp.value, endIp.value) == false){\r
327                         alert('DHCP IP Address range is Error.');\r
328                         return;\r
329                 }\r
330                         loc += '&enblDhcpSrv=1';\r
331                         loc += '&dhcpEthStart=' + startIp.value;\r
332                         loc += '&dhcpEthEnd=' + endIp.value;\r
333                         var leasetime=(time_dd.value*86400)+(time_hh.value*3600)+(time_mm.value*60);\r
334                         loc += '&dhcpLeasedTime=' + leasetime;\r
335                 }
336                 //DHCP end
337
338                 var code = 'window.location.href="/'; // for Mac safari browser compatibility
339                 code += loc + '"';
340                 eval(code);
341         }
342 }
343
344 function do_cgi_noIP2(){
345         var loc = 'lancfg2.cgi?';
346         loc += 'checkNum=' + randomNum + '&';
347         with ( document.forms[0] ) {
348                 if ( isValidIpAddress(ethIpAddress.value) == false ) {
349                         alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
350                         return;
351                 }
352                 if ( isValidIpAddress(ethSubnetMask.value) == false ) {
353                         alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
354                         return;
355                 }
356                 loc += 'ethIpAddress=' + ethIpAddress.value;
357                 loc += '&ethSubnetMask=' + ethSubnetMask.value;
358                 loc += '&hostname=' + encodeUrl(hname.value);
359                 if(urlError==1) return;
360                 loc += '&domainname=' + encodeUrl(dname.value);
361                 if(urlError==1) return;
362                 if (includemtu == '1'){
363                         if (lmtu.value <1000){
364                                 alert("Minimum MTU is 1000.");
365                                 return;
366                         }
367                         if (lmtu.value >1500){
368                                 alert("Maximum MTU is 1500.");
369                                 return;
370                         }
371                         loc += '&lanmtu=' + lmtu.value;
372                 }
373                 
374                 //for DHCP start        \r
375                 if (dhcpser[2].checked == true){\r
376                         loc += '&enblDhcpSrv=0';\r
377                 } else if (dhcpser[1].checked == true){\r
378                         if ( isValidIpAddress(relayIp.value) == false ) {\r
379                         alert('Relay IP address "' + relayIp.value + '" is invalid IP address.');\r
380                         return;\r
381                 }\r
382                         loc += '&enblDhcpSrv=2';\r
383                 loc += '&dhcpEthStart=' + relayIp.value;\r
384                 } else {\r
385                         if ( isValidIpAddress(startIp.value) == false ) {\r
386                         alert('Start IP address "' +startIp.value + '" is invalid IP address.');\r
387                         return;\r
388                 }\r
389                 if ( isValidIpAddress(endIp.value) == false ) {\r
390                         alert('Stop IP address "' + endIp.value + '" is invalid IP address.');\r
391                         return;\r
392                 }\r
393                 if ( isNaN(time_dd.value) == true || isNaN(time_hh.value) == true ||\r
394                            isNaN(time_mm.value) == true) {\r
395                         alert("Dhcp lease time is invalid.");\r
396                         return;\r
397                 }\r
398                 if (checkDhcpIpAddrRange(startIp.value, endIp.value) == false){\r
399                         alert('DHCP IP Address range is Error.');\r
400                         return;\r
401                 }\r
402                         loc += '&enblDhcpSrv=1';\r
403                         loc += '&dhcpEthStart=' + startIp.value;\r
404                         loc += '&dhcpEthEnd=' + endIp.value;\r
405                         var leasetime=(time_dd.value*86400)+(time_hh.value*3600)+(time_mm.value*60);\r
406                         loc += '&dhcpLeasedTime=' + leasetime;\r
407                 }
408                 //DHCP end
409                 
410                 var code = 'window.location.href="/'; // for Mac safari browser compatibility
411                 code += loc + '"';
412                 eval(code);
413         }
414 }
415
416 function btnApply() {
417         with ( document.forms[0] ) {
418         if ( BridgeOnly == '0' ){
419                 do_cgi();               
420                 } else {                
421             do_cgi_noIP2();                     
422                 }
423         }
424 }
425 // done hiding -->
426 </script>
427 <base target="_self">
428 </head>
429
430 <body onLoad='frmLoad()'>
431
432 <form class="formpadding">
433 <table border="0" cellpadding="0" cellspacing="3" width="98%">
434 <tr>
435   <td><b><font class="netgear">LAN IP Setup</font></b></td>
436 </tr>
437 <tr><td>&nbsp;</td></tr>
438 <tr>\r
439   <td background="liteblue.gif" height="12">&nbsp;</td>\r
440 </tr>
441 </table>
442   <font color="#0099cc"><b>LAN IP Address Configuration</b></font><br><br>
443   Enter the ADSL router IP address and subnet mask for LAN interface.
444   <br><br>
445   <table border="0" cellpadding="0" cellspacing="0">
446      <tr>
447        <td width="150">Primary IP Address:</td>
448        <td><input type='text' name='ethIpAddress'></td>
449      </tr>
450      <tr>
451        <td>Subnet Mask:</td>
452        <td><input type='text' name='ethSubnetMask'></td>
453      </tr>
454      <tr>
455        <td width="150">Host Name:</td>
456        <td><input type='text' name='hname' maxlength="31"></td>
457      </tr>
458      <tr>
459        <td>Domain Name:</td>
460        <td><input type='text' name='dname' maxlength="63"></td>
461      </tr>
462   </table>
463   <br>
464 <script language="javascript">
465 <!-- hide
466 if ( BridgeOnly == '0' ){
467         document.writeln("<table border='0' cellpadding='0' cellspacing='0'>");
468         document.writeln("<tr>");
469                 document.writeln("<td valign='middle' align='left' width='24' height='20'><input type='checkbox' name='enblLan2' onClick='showlan2()'></td>");
470                 document.writeln("<td>Configure secondary IP address and subnet mask.</td>");
471         document.writeln("</tr>");
472         document.writeln("</table>");
473         document.writeln("<br>");
474 }
475 // done hiding -->
476 </script>
477   <table border="0" cellpadding="0" cellspacing="0">
478   <tr><td><div ID="displaylan2"></div></td></tr>
479   </table>
480   <div ID="LanMtuInfo"></div>
481   
482 <table border="0" cellpadding="0" cellspacing="3" width="98%">
483 <tr>\r
484   <td background="liteblue.gif" height="12">&nbsp;</td>\r
485 </tr>
486 </table>\r
487 <font color="#0099cc"><b>DHCP Server Configuration</b></font><br><br>
488 <table border='0' cellspacing="0" cellpadding="0">\r
489   <tr><td width="580">\r
490   Enabling DHCP Server on LAN interface can provide the proper IP address settings to your computer.\r
491   </td></tr></table>\r
492   \r
493   <p ID="DhcpInfo"></p>
494     
495 <table border="0" cellpadding="0" cellspacing="3" width="98%">
496 <tr>\r
497   <td background="liteblue.gif" height="12">&nbsp;</td>\r
498 </tr>
499 </table>  
500   <table border="0" width="520">
501   <tr>
502   <td align="left" width="50"><input type='button' onClick='btnApply()' value='Apply'></td>
503   <td align="left" width="60"><input type="button" onClick="btnCancel('lancfg2.html')" value="Cancel"></td>
504   <td class="grey_comment" width="410">New settings only take effect after your ADSL router is rebooted. If necessary, reconfigure your PC's IP address to match new settings.</td>
505   </tr>
506   </table>
507   </form>
508 </body>
509 </html>