<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
  <link rel="stylesheet" href="stylemain.css" type="text/css">
  <link rel="stylesheet" href="colors.css" type="text/css">
  <meta http-equiv="Pragma" content="no-cache">
  <title> IPSec Settings</title>

   <script language="javascript" src="util.js"></script>
   <script language="javascript">
   
<!-- hide

var ipsTableIndex = '<%ejGet(ipsTableIndex)%>';
var ipsConnName = '<%ejGet(ipsConnName)%>';
var ipsIpver = '<%ejGet(ipsIpver)%>';
var ipsLocalGwIf = '<%ejGet(ipsLocalGwIf)%>';
var ipsTunMode = '<%ejGet(ipsTunMode)%>';
var ipsRemoteGWAddr = '<%ejGet(ipsRemoteGWAddr)%>';
var ipsLocalIPMode = '<%ejGet(ipsLocalIPMode)%>';
var ipsLocalIP = '<%ejGet(ipsLocalIP)%>';
var ipsLocalMask = '<%ejGet(ipsLocalMask)%>'; 
var ipsLocalRangeLo = '<%ejGet(ipsLocalRangeLo)%>';
var ipsLocalRangeHi = '<%ejGet(ipsLocalRangeHi)%>'; 
var ipsRemoteIPMode = '<%ejGet(ipsRemoteIPMode)%>';
var ipsRemoteIP = '<%ejGet(ipsRemoteIP)%>'; 
var ipsRemoteMask = '<%ejGet(ipsRemoteMask)%>';
var ipsRemoteRangeLo = '<%ejGet(ipsRemoteRangeLo)%>'; 
var ipsRemoteRangeHi = '<%ejGet(ipsRemoteRangeHi)%>';
var ipsKeyExM = '<%ejGet(ipsKeyExM)%>';
var ipsAuthM = '<%ejGet(ipsAuthM)%>';
var ipsPSK = '<%ejGet(ipsPSK)%>';
var ipsCertificateName = '<%ejGet(ipsCertificateName)%>';
var ipsPerfectFSEn = '<%ejGet(ipsPerfectFSEn)%>';
var ipsManualEncryptionAlgo = '<%ejGet(ipsManualEncryptionAlgo)%>';
var ipsManualEncryptionKey = '<%ejGet(ipsManualEncryptionKey)%>';
var ipsManualAuthAlgo = '<%ejGet(ipsManualAuthAlgo)%>';
var ipsManualAuthKey = '<%ejGet(ipsManualAuthKey)%>';
var ipsSPI = '<%ejGet(ipsSPI)%>';
var ipsPh1Mode = '<%ejGet(ipsPh1Mode)%>';
var ipsPh1EncryptionAlgo = '<%ejGet(ipsPh1EncryptionAlgo)%>';
var ipsPh1IntegrityAlgo = '<%ejGet(ipsPh1IntegrityAlgo)%>';
var ipsPh1DHGroup = '<%ejGet(ipsPh1DHGroup)%>';
var ipsPh1KeyTime = '<%ejGet(ipsPh1KeyTime)%>';
var ipsPh2EncryptionAlgo = '<%ejGet(ipsPh2EncryptionAlgo)%>';
var ipsPh2IntegrityAlgo = '<%ejGet(ipsPh2IntegrityAlgo)%>';
var ipsPh2DHGroup = '<%ejGet(ipsPh2DHGroup)%>';
var ipsPh2KeyTime = '<%ejGet(ipsPh2KeyTime)%>';
var enblIP6 = '<%ejGetOther(sysInfo, enblIPv6)%>';
var ipsConnNameList = <%ejGet(ipsConnNameList)%>;
var ipsSPIList = <%ejGet(ipsSPIList)%>;
var ipsCertList = '<%ejGet(ipsCertList)%>';
var showAdv = 0;

var lanIpAddress = '<%ejGet(ethIpAddress)%>';
var lanNetMask = '<%ejGet(ethSubnetMask)%>';

function showhide(element, sh)
{
    var status;
    if (sh == 1) {
        status = "block";
    }
    else {
        status = "none"
    }
        
	if (document.getElementById)
	{
		// standard
		document.getElementById(element).style.display = status;
	}
	else if (document.all)
	{
		// old IE
		document.all[element].style.display = status;
	}
	else if (document.layers)
	{
		// Netscape 4
		document.layers[element].display = status;
	}
}

function setSelect(item, value)
{
	for (i=0; i<item.options.length; i++) {
        if (item.options[i].value == value) {
        	item.selectedIndex = i;
        	break;
        }
    }
}

function submitText(item, name)
{
	return '&' + name + '=' + item.value;
}

function getSelect(item)
{
	var idx;
	if (item.options.length > 0) {
	    idx = item.selectedIndex;
	    return item.options[idx].value;
	}
	else {
		return '';
    }
}

function submitSelect(item, name)
{
	return '&' + name + '=' + getSelect(item);
}

function localIPModeChange() {
   with ( document.forms[0] ) {
      var mode = localIPMode[localIPMode.selectedIndex].value;
      switch ( mode ) {
      case "subnet":
        showhide("IP11", 1);
        showhide("IP12", 1);
        break; 
      case "single":
        showhide("IP11", 1);
        showhide("IP12", 0);
        break;
      default:
    }
  }
}

function remoteIPModeChange() {
   with ( document.forms[0] ) {
      var mode = remoteIPMode[remoteIPMode.selectedIndex].value;
      switch ( mode ) {
      case "subnet":
        showhide("IP21", 1);
        showhide("IP22", 1);
        break; 
      case "single":
        showhide("IP21", 1);
        showhide("IP22", 0);
        break;
      default:
    }
  }
}

function tunnelModeChange() {
   with ( document.forms[0] ) {
      var keymode = keyExM[keyExM.selectedIndex].value;
      var mode = tunnelMode[tunnelMode.selectedIndex].value;
      switch (keymode) {
      case "auto":
         showhideAdv(showAdv);
         break;
      case "manual":
         if (mode == "esp") {
            showhide("ManualKeyEnc", 1);
         }
         else {
            showhide("ManualKeyEnc", 0);
         }
         showhide("ManualKeyAuth", 1);
         break; 
      default:
      }
   }
}


function keyauthChange() {
   with ( document.forms[0] ) {
      var keymode = keyExM[keyExM.selectedIndex].value;
      var authmode = authM[authM.selectedIndex].value;
      var mode = tunnelMode[tunnelMode.selectedIndex].value;
      switch (keymode) {
      case "auto":
         showhide("AutoKeyEx", 1);
         showhide("ManualKeyEnc", 0);
         showhide("ManualKeyAuth", 0);
         switch (authmode) {
         case "pre_shared_key":
            showhide("PSK", 1);
            showhide("Certificate", 0);
            break;
         case "certificate":
            showhide("PSK", 0);
            showhide("Certificate", 1);
            break;        
         default:       
         }
         break; 
      case "manual":
         showhide("AutoKeyEx", 0);
         if (mode == "esp") {
            showhide("ManualKeyEnc", 1);
         }
         else {
            showhide("ManualKeyEnc", 0);
         }
         showhide("ManualKeyAuth", 1);
         showhide("PSK", 0);
         showhide("Certificate", 0);
         showAdv = 0;
         showhideAdv(showAdv);
         break;
      default:
      }
  }
}

function switchAdv() {
   with ( document.forms[0] ) {
      showAdv = !showAdv;
      showhideAdv(showAdv);
   }
}

function showhideAdv(show) {
   with ( document.forms[0] ) {
      var mode = tunnelMode[tunnelMode.selectedIndex].value;
      showhide("adv_ph1", show);
      showhide("adv_ph2header", show);
      showhide("adv_ph2enc", 0);
      showhide("adv_ph2auth", show);
      showhide("adv_ph2footer", show);
      if (show) {
         advSWButton.value = "Hide Advanced Settings";
         if (mode == "esp") {
            showhide("adv_ph2enc", show);
         }
      }
      else {
         advSWButton.value = "Show Advanced Settings";
      }
      showAdv = show;
   }
}

function formLoad()
{
	with ( document.forms[0] ) {
		connName.value = ipsConnName;
		setSelect(ipver, ipsIpver);
		setSelect(localGwV4, ipsLocalGwIf);
		setSelect(localGwV6, ipsLocalGwIf);
		if (ipsIpver == '4') {
			showhide('gwv4', 1);
			showhide('gwv6', 0);
		}
		else {
			showhide('gwv4', 0);
			showhide('gwv6', 1);
		}
		setSelect(tunnelMode, ipsTunMode);
		remoteGWAddr.value = ipsRemoteGWAddr;
		setSelect(localIPMode, ipsLocalIPMode);
		localIP.value = ipsLocalIP; 
		localMask.value = ipsLocalMask;
		setSelect(remoteIPMode, ipsRemoteIPMode);
		remoteIP.value = ipsRemoteIP;
		remoteMask.value = ipsRemoteMask;
		setSelect(keyExM, ipsKeyExM);
		setSelect(authM, ipsAuthM);
		psk.value = ipsPSK;
		setSelect(certificateName, ipsCertificateName);
		perfectFSEn.value = ipsPerfectFSEn;
		setSelect(manualEncryptionAlgo, ipsManualEncryptionAlgo);
		manualEncryptionKey.value = ipsManualEncryptionKey;
		setSelect(manualAuthAlgo, ipsManualAuthAlgo)
		manualAuthKey.value = ipsManualAuthKey;
		spi.value = ipsSPI;
		setSelect(ph1Mode, ipsPh1Mode);
		setSelect(ph1EncryptionAlgo, ipsPh1EncryptionAlgo);
		setSelect(ph1IntegrityAlgo, ipsPh1IntegrityAlgo);
		setSelect(ph1DHGroup, ipsPh1DHGroup);
		ph1KeyTime.value = ipsPh1KeyTime;
		setSelect(ph2EncryptionAlgo, ipsPh2EncryptionAlgo);
		setSelect(ph2IntegrityAlgo, ipsPh2IntegrityAlgo);
		setSelect(ph2DHGroup, ipsPh2DHGroup);
		ph2KeyTime.value = ipsPh2KeyTime;
	}
	
	localIPModeChange();
	remoteIPModeChange();
	keyauthChange();
	showhideAdv(showAdv);
    
}

function changeSelect(OnPageLoad) 
{
   with ( document.forms[0] ) {
      if (getSelect(ipver) == '6') {
         showhide('gwv4', 0);
         showhide('gwv6', 1);
         remoteGWAddr.value  = '0::0';
         localIP.value       = '0::0';
         localMask.value     = '64';
         remoteIP.value      = '0::0';
         remoteMask.value    = '64';
         setselect(localGwV6, 'None');
      }
      else {
         showhide('gwv4', 1);
         showhide('gwv6', 0);
         remoteGWAddr.value  = '0.0.0.0';
         localIP.value       = '0.0.0.0';
         localMask.value     = '255.255.255.0';
         remoteIP.value      = '0.0.0.0';
         remoteMask.value    = '255.255.255.0';
         setselect(localGwV4, 'None');
      }
   }
}

function isConnNameUnique(name)
{
	var i;
	for ( i = 0; i < ipsConnNameList.length; i++ ) {
		if ( name == ipsConnNameList[i] )
			return false;
	}
	return true;
}

function isSPIUnique(name)
{
	var i;
	for ( i = 0; i < ipsSPIList.length; i++ ) {
		if ( name == ipsSPIList[i] )
			return false;
	}
	return true;
}

function applyClick() {
	var loc = 'ipsec.cmd?action=add';
	var ret = 0;

	with ( document.forms[0] ) {
	
		if ( isValidNameWSpace(connName.value) == false ) {
			alert('Invalid connection name "' + connName.value + '".');
			return;
		}

		if ( isConnNameUnique(connName.value) == false ) {
			alert('Connection name "' + connName.value + '" is already in use.');
			return;
		}

		if ( ( getSelect(keyExM) == "manual" )  &&
			  ( isSPIUnique(spi.value) == false ) ) {
			alert('SPI "' + spi.value + '" is already in use.');
			return;
		}

		if (getSelect(ipver) == '6') {
			if (getSelect(localGwV6) == 'None' ) {
				alert('Local Gateway Interface is invalid.');
				return;
			}

			if ( isValidIpAddress6(remoteGWAddr.value) == false ) {
				alert('Remote GW IP Address "' + remoteGWAddr.value + '" is invalid.');
				return;
			}

			if ( isValidIpAddress6(localIP.value) == false ) {
				alert('Local IP Address "' + localIP.value + '" is invalid.');
				return;
			}

			if ((getSelect(localIPMode) == "subnet") && (isValidPrefixLength(localMask.value) == false)) {
				alert('Local Prefix Len "' + localMask.value + '" is invalid.');
				return;
			}

			if ( isValidIpAddress6(remoteIP.value) == false ) {
				alert('Local IP Address "' + remoteIP.value + '" is invalid.');
				return;
			}

			if ((getSelect(remoteIPMode) == "subnet") && (isValidPrefixLength(remoteMask.value) == false)) {
				alert('Local Prefix Len "' + remoteMask.value + '" is invalid.');
				return;
			}
		}
		else {
			if (getSelect(localGwV4) == 'None' ) {
				alert('Local Gateway Interface is invalid.');
				return;
			}

			if ( isValidIpAddress(remoteGWAddr.value) == false ) {
				alert('Remote GW IP Address "' + remoteGWAddr.value + '" is invalid.');
				return;
			}

			if ( isValidIpAddress(localIP.value) == false ) {
				alert('Local IP Address "' + localIP.value + '" is invalid.');
				return;
			}

			if ((getSelect(localIPMode) == "subnet") && (isValidSubnetMask(localMask.value) == false)) {
				alert('Local Subnet Mask or Prefix Len "' + localMask.value + '" is invalid.');
				return;
			}

			if ( isValidIpAddress(remoteIP.value) == false ) {
				alert('Local IP Address "' + remoteIP.value + '" is invalid.');
				return;
			}

			if ((getSelect(remoteIPMode) == "subnet") && (isValidSubnetMask(remoteMask.value) == false)) {
				alert('Local Subnet Mask "' + remoteMask.value + '" is invalid.');
				return;
			}

			/*
			 * 1. The remote address cannot be in the local subnet.
			 * 2. The local address cannot be in the remote subnet.
			*/
			if ((getSelect(localIPMode) == "subnet") && (getSelect(remoteIPMode) == "subnet"))
			{
				ret = isSubNetContainAnother(localIP.value, localMask.value, remoteIP.value, remoteMask.value);

				if (1 == ret)
				{
					alert('remote subnet is in local subnet.');
					return;
				}
				else if (-1 == ret)
				{
					alert('local subnet is in remote subnet.');
					return;
				}
				else if (2 == ret)
				{
					alert('local subnet is the same as remote subnet.');
					return;
				}
			}
			else if (getSelect(localIPMode) == "subnet")
			{
				ret = isSubNetContainAnother(localIP.value, localMask.value, remoteIP.value, "255.255.255.255");
				if (0 != ret)
				{
					alert('remote IP address is in local subnet.');
					return;
				}
			}
			else if (getSelect(remoteIPMode) == "subnet")
			{
				ret = isSubNetContainAnother(localIP.value, "255.255.255.255", remoteIP.value, remoteMask.value);
				if (0 != ret)
				{
					alert('local IP address is in remote subnet.');
					return;
				}
			}
			else
			{
				ret = isSubNetContainAnother(localIP.value, "255.255.255.255", remoteIP.value, "255.255.255.255");
				if (0 != ret)
				{
					alert('The local IP address is the same as the remote IP address.');
					return;
				}
			}

			/*
			 * 1. The remote address cannot be in the LAN subnet.
			 * 2. The LAN address cannot be in the remote subnet.
			*/
			if (getSelect(remoteIPMode) == "subnet")
			{
				ret = isSubNetContainAnother(lanIpAddress, lanNetMask, remoteIP.value, remoteMask.value);

				if (1 == ret)
				{
					alert('remote subnet is in LAN subnet.');
					return;
				}
				else if (-1 == ret)
				{
					alert('LAN subnet is in remote subnet.');
					return;
				}
				else if (2 == ret)
				{
					alert('remote subnet is the same as LAN subnet.');
					return;
				}
			}
			else
			{
				ret = isSubNetContainAnother(lanIpAddress, lanNetMask, remoteIP.value, "255.255.255.255");
				if (0 != ret)
				{
					alert('The remote IP address is in LAN subnet.');
					return;
				}
			}
		}
		
		if ( getSelect(keyExM) == "auto" ) {
			val = parseInt(ph1KeyTime.value);
			if (  isNaN(val) == true || val < 0 ) {
				alert('Phase 1 Key Life Time is invalid.');
				showhideAdv(1);
				return;
			}
			val = parseInt(ph2KeyTime.value);
			if (  isNaN(val) == true || val < 0 ) {
				alert('Phase 2 Key Life Time is invalid.');
				showhideAdv(1);
				return;
			}
			if ( getSelect(authM) == "certificate") {
				if ( certificateName.options.length == 0) {
					alert('No certificate avaiable for authentication. Use Certificate menu to add certificates or choose another autentication method.');
					return;
				}
			}
		}
		
		if ( getSelect(keyExM) == "manual" ) {
			if (tunnelMode[tunnelMode.selectedIndex].value == "esp") {
				if ( getSelect(manualEncryptionAlgo) == "des-cbc") {
					if ( isValidHexKey(manualEncryptionKey.value, 16) == false) {
						alert('Invalid Manual DES Key.');
						return;
					}
				}
				else if ( getSelect(manualEncryptionAlgo) == "3des-cbc") {
					if ( isValidHexKey(manualEncryptionKey.value, 48) == false) {
						alert('Invalid Manual 3DES Key.');
						return;
					}
				}
				else {
					if ( isValidHexKey(manualEncryptionKey.value, 64) == false) {
						if ( isValidHexKey(manualEncryptionKey.value, 48) == false) {
							if ( isValidHexKey(manualEncryptionKey.value, 32) == false) {
								alert('Invalid Manual AES Key.');
								return;
							}
						}
					}
				}
			}

			if ( getSelect(manualAuthAlgo) == "hmac-md5") {
				if ( isValidHexKey(manualAuthKey.value, 32) == false) {
					alert('Invalid Manual MD5 Key.');
					return;
				}
			}
			else {
				if ( isValidHexKey(manualAuthKey.value, 40) == false) {
					alert('Invalid Manual SHA1 Key.');
					return;
				}
			}
		}
	
		loc += '&ipsTableIndex=' + ipsTableIndex;   
		loc += '&ipsConnName=' + connName.value;
		loc += submitText(connName, 'ipsConnName');
		loc += submitSelect(ipver, 'ipsIpver');
		if (getSelect(ipver) == '4')
		{
			loc += submitSelect(localGwV4, 'ipsLocalGwIf');
		}
		else
		{
			loc += submitSelect(localGwV6, 'ipsLocalGwIf');
		}
		
		loc += submitSelect(tunnelMode, 'ipsTunMode');
		loc += submitText(remoteMask, 'ipsRemoteMask');
		loc += submitText(remoteGWAddr, 'ipsRemoteGWAddr');
		loc += submitSelect(localIPMode, 'ipsLocalIPMode');
		loc += submitText(localIP, 'ipsLocalIP');
		loc += submitText(localMask, 'ipsLocalMask');
		loc += submitSelect(remoteIPMode, 'ipsRemoteIPMode');
		loc += submitText(remoteIP, 'ipsRemoteIP');
		loc += submitText(remoteMask, 'ipsRemoteMask');
		loc += submitSelect(keyExM, 'ipsKeyExM');
		loc += submitSelect(authM, 'ipsAuthM');
		loc += submitText(psk, 'ipsPSK');
		loc += submitSelect(certificateName, 'ipsCertificateName');
		loc += submitSelect(perfectFSEn, 'ipsPerfectFSEn');
		loc += submitSelect(manualEncryptionAlgo, 'ipsManualEncryptionAlgo');
		loc += submitText(manualEncryptionKey, 'ipsManualEncryptionKey');
		loc += submitSelect(manualAuthAlgo, 'ipsManualAuthAlgo');
		loc += submitText(manualAuthKey, 'ipsManualAuthKey');
		loc += submitText(spi, 'ipsSPI');
		loc += submitSelect(ph1Mode, 'ipsPh1Mode');
		loc += submitSelect(ph1EncryptionAlgo, 'ipsPh1EncryptionAlgo');
		loc += submitSelect(ph1IntegrityAlgo, 'ipsPh1IntegrityAlgo');
		loc += submitSelect(ph1DHGroup, 'ipsPh1DHGroup');
		loc += submitText(ph1KeyTime, 'ipsPh1KeyTime');
		loc += submitSelect(ph2EncryptionAlgo, 'ipsPh2EncryptionAlgo');
		loc += submitSelect(ph2IntegrityAlgo, 'ipsPh2IntegrityAlgo');
		loc += submitSelect(ph2DHGroup, 'ipsPh2DHGroup');
		loc += submitText(ph2KeyTime, 'ipsPh2KeyTime');
	}
	loc += '&sessionKey=<%ejGetOther(sessionKey)%>';
	var code = 'location="' + loc + '"';
	eval(code);
}

// done hiding -->
</script>
  
</head>

<body onLoad="formLoad()">
<blockquote>
<form>
  <b>IPSec Settings</b> 
  <br><br>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr>
      <td width="40%"> IPSec Connection Name </td>
      <td> <input name="connName" size="20" maxlength="60" type="text"> </td>
    </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr><script language="javascript">
    <!-- hide 
    {
        document.writeln("<td width='290'>IP Version:</td>");
        document.writeln("<td><select name='ipver' size='1' onChange='changeSelect(0)'>");
        document.writeln("      <option value='4'>IPv4");
        if (enblIP6 == '1')
            document.writeln("      <option value='6'>IPv6");
        document.writeln("    </select></td>");
    }
    // done hiding -->
    </script></tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
     <tr> 
        <td width="40%">Tunnel Mode</td>
        <td><select name="tunnelMode" onChange="tunnelModeChange();">
            <option value="esp">ESP</option>
            <option value="ah">AH</option>
          </select>
        </td>
     </tr>
     <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table>
  <div id='gwv4'>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr><script language="javascript">
    <!-- hide
    {
      var i;
      var intfInfo = '<%ejGetOther(wanInterfaceInfo, route)%>';
      var intf     = intfInfo.split('|');

      document.writeln("<td width='40%'>Local Gateway Interface:</td>");
      document.writeln("<td><select name='localGwV4'>");
      for ( i = 0; i < intf.length; i++ ) {
        var names = intf[i].split('/');
        if (names.length > 1) {
          document.write("  <option value='" + names[1] + "'>");
          document.writeln(intf[i]);
        }
      } 
      document.write("  <option value='None'>");
      document.writeln("Select interface");
      document.writeln("    </select></td>");
    }
    // done hiding -->
    </script>
    </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table>
  </div>
  <div id='gwv6'>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr><script language="javascript">
    <!-- hide
    {
      var i;
      var intfInfo = '<%ejGetOther(wanInterfaceInfo, route6)%>';
      var intf     = intfInfo.split('|');

      document.writeln("<td width='40%'>Local Gateway Interface:</td>");
      document.writeln("<td><select name='localGwV6'>");
      for ( i = 0; i < intf.length; i++ ) {
        var names = intf[i].split('/');
        if (names.length > 1) {
          document.write("  <option value='" + names[1] + "'>");
          document.writeln(intf[i]);
        }
      } 
      document.write("  <option value='None'>");
      document.writeln("Select interface");
      document.writeln("    </select></td>");
    }
    // done hiding -->
    </script>
    </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table>
  </div>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
     <tr>
        <td width="40%">Remote IPSec Gateway Address </td>
        <td><input name="remoteGWAddr" size="20" maxlength="255" type="text"></td>
    </tr>
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    <tr>
      <td width="40%"> Tunnel access from local IP addresses </td>
      <td >
      <select name="localIPMode" onchange="localIPModeChange();">
        <option value="subnet">Subnet</option>
        <option value="single">Single Address</option>
      </select>
    </td>
    </tr>
  </table>
  <div id = "IP11"><table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr>
      <td width="40%">&nbsp;&nbsp; IP Address for VPN</td>
        <td> <input name="localIP" type="text"> </td>
      </td>
    </tr>
  </table></div>
  <div id = "IP12"><table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
        <td width="40%">&nbsp;&nbsp; Mask or Prefix Length</td>
        <td> <input name="localMask" type="text"> </td> 
      </tr>
  </table></div>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr><td></td><td>&nbsp;</td></tr>
      <tr>
        <td width="40%"> Tunnel access from remote IP addresses </td>
        <td >
        <select name="remoteIPMode" onchange="remoteIPModeChange();">
        <option value="subnet">Subnet</option>
        <option value="single">Single Address</option>
        </select>
        </td>
      </tr>
  </table>
  <div id = "IP21"><table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr>
      <td width="40%">&nbsp;&nbsp; IP Address for VPN</td>
        <td> <input name="remoteIP" type="text"> </td>
    </tr>
  </table></div>
  <div id = "IP22"><table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
        <td width="40%">&nbsp;&nbsp; Mask or Prefix Length</td>
        <td> <input name="remoteMask" type="text"> </td>
      </tr>
  </table></div>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
     <tr> 
        <td width="40%">Key Exchange Method </td>
        <td><select name="keyExM" onChange="keyauthChange();">
            <option value="auto">Auto(IKEv1)</option>
            <option value="manual">Manual</option>
          </select>
        </td>
     </tr> 
  </table>
  <div id="AutoKeyEx"><table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
    <script language="javascript">
    <!-- hide
    {
    if(ipsCertList == '')
    {
        document.write("<td width='40%'> Authentication Method </td>");
        document.write("<td>");
        document.write("  <select name='authM' onChange='keyauthChange();' disabled>");
        document.write("    <option value='pre_shared_key'>Pre-Shared Key</option>");
        document.write("  </select>");
        document.write("</td>");
    }
    else
    {
        document.write("<td width='40%'> Authentication Method </td>");
        document.write("<td>");
        document.write("  <select name='authM' onChange='keyauthChange();'>");
        document.write("    <option value='pre_shared_key'>Pre-Shared Key</option>");
        document.write("    <option value='certificate'>Certificate (X.509)</option>");
        document.write("  </select>");
        document.write("</td>");
    }
    }
    // done hiding -->
    </script>
      </tr>
  </table>
  <div id="PSK"><table border="0" cellpadding="0" cellspacing="2" width="100%">
       <tr>
        <td width="40%">Pre-Shared Key</td>
        <td> <input name="psk"></td>
      </tr>
  </table></div>
  <div id="Certificate"><table border="0" cellpadding="0" cellspacing="2" width="100%">
        <tr>
          <td width="40%"> Certificates </td>
          <td><select name="certificateName">
          <%ejGet(ipsCertList)%>
          </select></td>
        </tr>
  </table></div>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
        <td width="40%">Perfect Forward Secrecy</td>
        <td align="left" > 
          <select name="perfectFSEn">
            <option value="enable">Enable</option>
            <option value="disable">Disable</option>
          </select>
        </td>
     </tr> 
     <tr><td>&nbsp;</td></tr>
     <tr>
       <td width="40%">Advanced IKE Settings</td>
       <td><input name="advSWButton" type="button" value="Show Advanced Settings" onclick="switchAdv();" ></td>
     </tr>
     <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table></div> 
  <div id="ManualKeyEnc"> <table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
        <td width="40%">Encryption Algorithm</td>
        <td>
          <select name="manualEncryptionAlgo">
          <option value="des-cbc">DES</option>
          <option value="3des-cbc">3DES</option>
          <option value="aes-cbc">AES</option>
        </select>
        </td>
      </tr>
      <tr>
        <td width = "40%"> Encryption Key </td>
        <td> <input name="manualEncryptionKey", size = "40" maxlength = "80"></td>
      </tr>
      <tr>
        <td width = "40%"> &nbsp </td>
        <td> Hex value: DES - 16 digit, 3DES - 48, AES 32, 48, 64 digit</td>
      </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table></div>
  <div id="ManualKeyAuth"> <table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
       <td width="40%">Authentication Algorithm</td>
       <td>
         <select name="manualAuthAlgo">
           <option value="hmac-md5">MD5</option>
           <option value="hmac-sha1">SHA1</option>
         </select>
       </td>
      </tr>
      <tr>
        <td> Authentication Key </td>
        <td> <input name="manualAuthKey" size="50" maxlength = "60"></td>
      </tr>
      <tr>
        <td width = "40%"> &nbsp </td>
        <td> Hex value: MD5 - 32 digit, SHA1 - 40 digit </td>
      </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
      <tr>
        <td> SPI </td>
        <td> <input name="spi" size="8" maxlength = "8"></td>
      </tr>
      <tr>
        <td width = "40%"> &nbsp </td>
        <td> Hex value: 100-FFFFFFFF</td>
      </tr>
      <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
  </table></div>
  <div id = "adv_ph1"><table border="0" cellpadding="0" cellspacing="2" width="100%">
     <tr>
       <td> Phase 1</td>
     </tr>
     <tr>
       <td width="40%">Mode</td>
       <td>
         <select name="ph1Mode">
           <option value="main">Main</option>
           <option value="aggressive">Aggressive</option>
         </select>
       </td>
       </tr>
       <tr>
        <td width="40%">Encryption Algorithm</td>
        <td>
          <select name="ph1EncryptionAlgo">
           <%ejGetOther(ipsEncryptList, ph1)%>
        </select>
        </td>
      </tr>
      <tr>
       <td width="40%">Integrity Algorithm</td>
       <td>
         <select name="ph1IntegrityAlgo">
           <%ejGetOther(ipsHashList, ph1)%>
         </select>
       </td>
      </tr>
       <tr>
       <td width="40%">Select Diffie-Hellman Group for Key Exchange</td>
       <td>
         <select name="ph1DHGroup">
           <option value="modp768">768bit</option>
           <option value="modp1024">1024bit</option>
           <option value="modp1536">1536bit</option>
           <option value="modp2048">2048bit</option>
           <option value="modp3072">3072bit</option>
           <option value="modp4096">4096bit</option>
           <option value="modp6144">6144bit</option>
           <option value="modp8192">8192bit</option>
         </select>
       </td>
      </tr>
      <tr>
        <td width="40%">Key Life Time </td>
        <td> <input name="ph1KeyTime" > &nbsp Seconds </td>
      </tr>
     <tr><td>&nbsp;</td></tr>
  </table></div>
  <div id = "adv_ph2header"><table border="0" cellpadding="0" cellspacing="2" width="100%">
     <tr>
       <td> Phase 2</td>
     </tr>
  </table></div>
  <div id = "adv_ph2enc"><table border="0" cellpadding="0" cellspacing="2" width="100%">
     <tr id="ph2enc" >
        <td width="40%">Encryption Algorithm</td>
        <td>
          <select name="ph2EncryptionAlgo">
           <%ejGetOther(ipsEncryptList, ph2)%>
        </select>
        </td>
      </tr>
  </table></div>
  <div id = "adv_ph2auth"><table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
       <td width="40%">Integrity Algorithm</td>
       <td>
         <select name="ph2IntegrityAlgo">
           <%ejGetOther(ipsHashList, ph2)%>
         </select>
       </td>
      </tr>
  </table></div>
  <div id = "adv_ph2footer"><table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr>
       <td width="40%">Select Diffie-Hellman Group for Key Exchange</td>
       <td>
         <select name="ph2DHGroup">
           <option value="modp768">768bit</option>
           <option value="modp1024">1024bit</option>
           <option value="modp1536">1536bit</option>
           <option value="modp2048">2048bit</option>
           <option value="modp3072">3072bit</option>
           <option value="modp4096">4096bit</option>
           <option value="modp6144">6144bit</option>
           <option value="modp8192">8192bit</option>
         </select>
       </td>
      </tr>
      <tr>
        <td width="40%">Key Life Time </td>
        <td> <input name="ph2KeyTime" > &nbsp Seconds </td>
      </tr>
  </table></div>
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
      <tr><td></td><td>&nbsp;</td></tr>
      <tr>
        <td colspan="2" align="center"> 
          <input value="Apply/Save" type="button" onclick="applyClick();" > 
        </td>
      </tr>
  </table>
</form>
</blockquote>
</body>
</html>
