Project

General

Profile

Download (39.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec_phase1.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5

    
6
	Copyright (C) 2008 Shrew Soft Inc
7
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8
	Copyright (C) 2014 Ermal Luçi
9
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-vpn-ipsec-editphase1
36
##|*NAME=VPN: IPsec: Edit Phase 1 page
37
##|*DESCR=Allow access to the 'VPN: IPsec: Edit Phase 1' page.
38
##|*MATCH=vpn_ipsec_phase1.php*
39
##|-PRIV
40

    
41
require("functions.inc");
42
require("guiconfig.inc");
43
require_once("ipsec.inc");
44
require_once("vpn.inc");
45
require_once("filter.inc");
46

    
47
if (!is_array($config['ipsec']['phase1'])) {
48
	$config['ipsec']['phase1'] = array();
49
}
50

    
51
if (!is_array($config['ipsec']['phase2'])) {
52
	$config['ipsec']['phase2'] = array();
53
}
54

    
55
$a_phase1 = &$config['ipsec']['phase1'];
56
$a_phase2 = &$config['ipsec']['phase2'];
57

    
58
if (is_numericint($_GET['p1index'])) {
59
	$p1index = $_GET['p1index'];
60
}
61
if (isset($_POST['p1index']) && is_numericint($_POST['p1index'])) {
62
	$p1index = $_POST['p1index'];
63
}
64

    
65
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
66
	$p1index = $_GET['dup'];
67
}
68

    
69
if (isset($p1index) && $a_phase1[$p1index]) {
70
	// don't copy the ikeid on dup
71
	if (!isset($_GET['dup']) || !is_numericint($_GET['dup'])) {
72
		$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
73
	}
74

    
75
	$old_ph1ent = $a_phase1[$p1index];
76

    
77
	$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
78

    
79
	if ($a_phase1[$p1index]['interface']) {
80
		$pconfig['interface'] = $a_phase1[$p1index]['interface'];
81
	} else {
82
		$pconfig['interface'] = "wan";
83
	}
84

    
85
	list($pconfig['remotenet'], $pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
86

    
87
	if (isset($a_phase1[$p1index]['mobile'])) {
88
		$pconfig['mobile'] = 'true';
89
	} else {
90
		$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
91
	}
92

    
93
	if (empty($a_phase1[$p1index]['iketype'])) {
94
		$pconfig['iketype'] = "ikev1";
95
	} else {
96
		$pconfig['iketype'] = $a_phase1[$p1index]['iketype'];
97
	}
98
	$pconfig['mode'] = $a_phase1[$p1index]['mode'];
99
	$pconfig['protocol'] = $a_phase1[$p1index]['protocol'];
100
	$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
101
	$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
102
	$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
103
	$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
104
	$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
105
	$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
106
	$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
107
	$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
108
	$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
109

    
110
	if (($pconfig['authentication_method'] == "pre_shared_key") ||
111
	    ($pconfig['authentication_method'] == "xauth_psk_server")) {
112
		$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
113
	} else {
114
		$pconfig['certref'] = $a_phase1[$p1index]['certref'];
115
		$pconfig['caref'] = $a_phase1[$p1index]['caref'];
116
	}
117

    
118
	$pconfig['descr'] = $a_phase1[$p1index]['descr'];
119
	$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
120
	$pconfig['mobike'] = $a_phase1[$p1index]['mobike'];
121

    
122
	if (isset($a_phase1[$p1index]['reauth_enable'])) {
123
		$pconfig['reauth_enable'] = true;
124
	}
125
	if (isset($a_phase1[$p1index]['rekey_enable'])) {
126
		$pconfig['rekey_enable'] = true;
127
	}
128
	if (isset($a_phase1[$p1index]['responderonly'])) {
129
		$pconfig['responderonly'] = true;
130
	}
131

    
132
	if ($a_phase1[$p1index]['dpd_delay'] &&	$a_phase1[$p1index]['dpd_maxfail']) {
133
		$pconfig['dpd_enable'] = true;
134
		$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
135
		$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
136
	}
137
} else {
138
	/* defaults */
139
	$pconfig['interface'] = "wan";
140
	if ($config['interfaces']['lan']) {
141
		$pconfig['localnet'] = "lan";
142
	}
143
	$pconfig['mode'] = "main";
144
	$pconfig['protocol'] = "inet";
145
	$pconfig['myid_type'] = "myaddress";
146
	$pconfig['peerid_type'] = "peeraddress";
147
	$pconfig['authentication_method'] = "pre_shared_key";
148
	$pconfig['ealgo'] = array(name => "aes");
149
	$pconfig['halgo'] = "sha1";
150
	$pconfig['dhgroup'] = "2";
151
	$pconfig['lifetime'] = "28800";
152
	$pconfig['nat_traversal'] = 'on';
153
	$pconfig['mobike'] = 'off';
154
	$pconfig['dpd_enable'] = true;
155
	$pconfig['iketype'] = "ikev1";
156

    
157
	/* mobile client */
158
	if ($_GET['mobile']) {
159
		$pconfig['mobile'] = true;
160
		$pconfig['mode'] = "aggressive";
161
	}
162
}
163

    
164
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
165
	unset($p1index);
166
}
167

    
168
if ($_POST) {
169
	unset($input_errors);
170
	$pconfig = $_POST;
171

    
172
	/* input validation */
173

    
174
	$method = $pconfig['authentication_method'];
175
	// Unset ca and cert if not required to avoid storing in config
176
	if ($method == "pre_shared_key" || $method == "xauth_psk_server") {
177
		unset($pconfig['caref']);
178
		unset($pconfig['certref']);
179
	}
180

    
181
	// Only require PSK here for normal PSK tunnels (not mobile) or xauth.
182
	// For RSA methods, require the CA/Cert.
183
	switch ($method) {
184
		case 'eap-mschapv2':
185
			if ($pconfig['iketype'] != 'ikev2') {
186
				$input_errors[] = gettext("EAP-MSChapv2 can only be used with IKEv2 type VPNs.");
187
			}
188
			break;
189
		case "eap-tls":
190
			if ($pconfig['iketype'] != 'ikev2') {
191
				$input_errors[] = gettext("EAP-TLS can only be used with IKEv2 type VPNs.");
192
			}
193
			break;
194
		case "eap-radius":
195
			if ($pconfig['iketype'] != 'ikev2') {
196
				$input_errors[] = gettext("EAP-RADIUS can only be used with IKEv2 type VPNs.");
197
			}
198
			break;
199
		case "pre_shared_key":
200
			// If this is a mobile PSK tunnel the user PSKs go on
201
			//    the PSK tab, not here, so skip the check.
202
			if ($pconfig['mobile']) {
203
				break;
204
			}
205
		case "xauth_psk_server":
206
			$reqdfields = explode(" ", "pskey");
207
			$reqdfieldsn = array(gettext("Pre-Shared Key"));
208
			$validate_pskey = true;
209
			break;
210
		case "hybrid_rsa_server":
211
		case "xauth_rsa_server":
212
		case "rsasig":
213
			$reqdfields = explode(" ", "caref certref");
214
			$reqdfieldsn = array(gettext("Certificate Authority"), gettext("Certificate"));
215
			break;
216
	}
217
	if (!$pconfig['mobile']) {
218
		$reqdfields[] = "remotegw";
219
		$reqdfieldsn[] = gettext("Remote gateway");
220
	}
221

    
222
	do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
223

    
224
	if (isset($validate_pskey) && isset($pconfig['pskey']) && !preg_match('/^[[:ascii:]]*$/', $pconfig['pskey'])) {
225
		unset($validate_pskey);
226
		$input_errors[] = gettext("Pre-Shared Key contains invalid characters.");
227
	}
228

    
229
	if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime']))) {
230
		$input_errors[] = gettext("The P1 lifetime must be an integer.");
231
	}
232

    
233
	if ($pconfig['remotegw']) {
234
		if (!is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw'])) {
235
			$input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
236
		} elseif (is_ipaddrv4($pconfig['remotegw']) && ($pconfig['protocol'] != "inet")) {
237
			$input_errors[] = gettext("A valid remote gateway IPv4 address must be specified or you need to change protocol to IPv6");
238
		} elseif (is_ipaddrv6($pconfig['remotegw']) && ($pconfig['protocol'] != "inet6")) {
239
			$input_errors[] = gettext("A valid remote gateway IPv6 address must be specified or you need to change protocol to IPv4");
240
		}
241
	}
242

    
243
	if ($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled'])) {
244
		$t = 0;
245
		foreach ($a_phase1 as $ph1tmp) {
246
			if ($p1index <> $t) {
247
				$tremotegw = $pconfig['remotegw'];
248
				if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
249
					$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
250
				}
251
			}
252
			$t++;
253
		}
254
	}
255

    
256
	if (is_array($a_phase2) && (count($a_phase2))) {
257
		foreach ($a_phase2 as $phase2) {
258
			if ($phase2['ikeid'] == $pconfig['ikeid']) {
259
				if (($pconfig['protocol'] == "inet") && ($phase2['mode'] == "tunnel6")) {
260
					$input_errors[] = gettext("There is a Phase 2 using IPv6, you cannot use IPv4.");
261
					break;
262
				}
263
				if (($pconfig['protocol'] == "inet6") && ($phase2['mode'] == "tunnel")) {
264
					$input_errors[] = gettext("There is a Phase 2 using IPv4, you cannot use IPv6.");
265
					break;
266
				}
267
			}
268
		}
269
	}
270

    
271
	/* My identity */
272

    
273
	if ($pconfig['myid_type'] == "myaddress") {
274
		$pconfig['myid_data'] = "";
275
	}
276

    
277
	if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "") {
278
		$input_errors[] = gettext("Please enter an address for 'My Identifier'");
279
	}
280

    
281
	if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "") {
282
		$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
283
	}
284

    
285
	if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "") {
286
		$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
287
	}
288

    
289
	if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "") {
290
		$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
291
	}
292

    
293
	if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "") {
294
		$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
295
	}
296

    
297
	if (($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data'])) {
298
		$input_errors[] = gettext("A valid IP address for 'My identifier' must be specified.");
299
	}
300

    
301
	if (($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data'])) {
302
		$input_errors[] = gettext("A valid domain name for 'My identifier' must be specified.");
303
	}
304

    
305
	if ($pconfig['myid_type'] == "fqdn") {
306
		if (is_domain($pconfig['myid_data']) == false) {
307
			$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
308
		}
309
	}
310

    
311
	if ($pconfig['myid_type'] == "user_fqdn") {
312
		$user_fqdn = explode("@", $pconfig['myid_data']);
313
		if (is_domain($user_fqdn[1]) == false) {
314
			$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
315
		}
316
	}
317

    
318
	if ($pconfig['myid_type'] == "dyn_dns") {
319
		if (is_domain($pconfig['myid_data']) == false) {
320
			$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
321
		}
322
	}
323

    
324
	/* Peer identity */
325

    
326
	if ($pconfig['myid_type'] == "peeraddress") {
327
		$pconfig['peerid_data'] = "";
328
	}
329

    
330
	// Only enforce peer ID if we are not dealing with a pure-psk mobile config.
331
	if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($pconfig['mobile']))) {
332
		if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "") {
333
			$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
334
		}
335

    
336
		if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "") {
337
			$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
338
		}
339

    
340
		if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "") {
341
			$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
342
		}
343

    
344
		if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "") {
345
			$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
346
		}
347

    
348
		if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data']))) {
349
			$input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified.");
350
		}
351

    
352
		if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data']))) {
353
			$input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified.");
354
		}
355

    
356
		if ($pconfig['peerid_type'] == "fqdn") {
357
			if (is_domain($pconfig['peerid_data']) == false) {
358
				$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
359
			}
360
		}
361

    
362
		if ($pconfig['peerid_type'] == "user_fqdn") {
363
			$user_fqdn = explode("@", $pconfig['peerid_data']);
364
			if (is_domain($user_fqdn[1]) == false) {
365
				$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
366
			}
367
		}
368
	}
369

    
370
	if ($pconfig['dpd_enable']) {
371
		if (!is_numeric($pconfig['dpd_delay'])) {
372
			$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
373
		}
374

    
375
		if (!is_numeric($pconfig['dpd_maxfail'])) {
376
			$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
377
		}
378
	}
379

    
380
	if (!empty($pconfig['iketype']) && $pconfig['iketype'] != "ikev1" && $pconfig['iketype'] != "ikev2" && $pconfig['iketype'] != "auto") {
381
		$input_errors[] = gettext("Valid arguments for IKE type is v1 or v2 or auto");
382
	}
383

    
384
	if (!empty($_POST['ealgo']) && isset($config['system']['crypto_hardware'])) {
385
		if ($config['system']['crypto_hardware'] == "glxsb") {
386
			if ($_POST['ealgo'] == "aes" && $_POST['ealgo_keylen'] != "128") {
387
				$input_errors[] = gettext("Only 128 bit AES can be used where the glxsb crypto accelerator is enabled.");
388
			}
389
		}
390
	}
391

    
392
	/* build our encryption algorithms array */
393
	$pconfig['ealgo'] = array();
394
	$pconfig['ealgo']['name'] = $_POST['ealgo'];
395
	if ($pconfig['ealgo_keylen']) {
396
		$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
397
	}
398

    
399
	if (!$input_errors) {
400
		$ph1ent['ikeid'] = $pconfig['ikeid'];
401
		$ph1ent['iketype'] = $pconfig['iketype'];
402
		if ($pconfig['iketype'] != 'ikev1') {
403
			unset($ph1ent['mode']);
404
		} else {
405
			$ph1ent['mode'] = $pconfig['mode'];
406
		}
407
		$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
408
		$ph1ent['interface'] = $pconfig['interface'];
409
		/* if the remote gateway changed and the interface is not WAN then remove route */
410
		/* the vpn_ipsec_configure() handles adding the route */
411
		if ($pconfig['interface'] <> "wan") {
412
			if ($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
413
				mwexec("/sbin/route delete -host {$old_ph1ent['remote-gateway']}");
414
			}
415
		}
416

    
417
		if ($pconfig['mobile']) {
418
			$ph1ent['mobile'] = true;
419
		} else {
420
			$ph1ent['remote-gateway'] = $pconfig['remotegw'];
421
		}
422

    
423
		$ph1ent['protocol'] = $pconfig['protocol'];
424

    
425
		$ph1ent['myid_type'] = $pconfig['myid_type'];
426
		$ph1ent['myid_data'] = $pconfig['myid_data'];
427
		$ph1ent['peerid_type'] = $pconfig['peerid_type'];
428
		$ph1ent['peerid_data'] = $pconfig['peerid_data'];
429

    
430
		$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
431
		$ph1ent['hash-algorithm'] = $pconfig['halgo'];
432
		$ph1ent['dhgroup'] = $pconfig['dhgroup'];
433
		$ph1ent['lifetime'] = $pconfig['lifetime'];
434
		$ph1ent['pre-shared-key'] = $pconfig['pskey'];
435
		$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
436
		$ph1ent['certref'] = $pconfig['certref'];
437
		$ph1ent['caref'] = $pconfig['caref'];
438
		$ph1ent['authentication_method'] = $pconfig['authentication_method'];
439
		$ph1ent['descr'] = $pconfig['descr'];
440
		$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
441
		$ph1ent['mobike'] = $pconfig['mobike'];
442

    
443
		if (isset($pconfig['reauth_enable'])) {
444
			$ph1ent['reauth_enable'] = true;
445
		} else {
446
			unset($ph1ent['reauth_enable']);
447
		}
448
		if (isset($pconfig['rekey_enable'])) {
449
			$ph1ent['rekey_enable'] = true;
450
		} else {
451
			unset($ph1ent['rekey_enable']);
452
		}
453

    
454
		if (isset($pconfig['responderonly'])) {
455
			$ph1ent['responderonly'] = true;
456
		} else {
457
			unset($ph1ent['responderonly']);
458
		}
459

    
460
		if (isset($pconfig['dpd_enable'])) {
461
			$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
462
			$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
463
		}
464

    
465
		/* generate unique phase1 ikeid */
466
		if ($ph1ent['ikeid'] == 0) {
467
			$ph1ent['ikeid'] = ipsec_ikeid_next();
468
		}
469

    
470
		if (isset($p1index) && $a_phase1[$p1index]) {
471
			$a_phase1[$p1index] = $ph1ent;
472
		} else {
473
			$a_phase1[] = $ph1ent;
474
		}
475

    
476
		write_config();
477
		mark_subsystem_dirty('ipsec');
478

    
479
		header("Location: vpn_ipsec.php");
480
		exit;
481
	}
482
}
483

    
484
if ($pconfig['mobile']) {
485
	$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Edit Phase 1"), gettext("Mobile Client"));
486
} else {
487
	$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Edit Phase 1"));
488
}
489
$shortcut_section = "ipsec";
490

    
491

    
492
include("head.inc");
493

    
494
?>
495

    
496
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
497
<?php include("fbegin.inc"); ?>
498
<script type="text/javascript">
499
//<![CDATA[
500

    
501
function myidsel_change() {
502
	index = document.iform.myid_type.selectedIndex;
503
	value = document.iform.myid_type.options[index].value;
504
	if (value == 'myaddress') {
505
		document.getElementById('myid_data').style.visibility = 'hidden';
506
	} else {
507
		document.getElementById('myid_data').style.visibility = 'visible';
508
	}
509
}
510

    
511
function iketype_change() {
512
	index = document.iform.iketype.selectedIndex;
513
	value = document.iform.iketype.options[index].value;
514
	if (value == 'ikev2') {
515
		document.getElementById('negmode').style.display= 'none';
516
		document.getElementById('mobike').style.display= '';
517
		document.getElementById('natt').style.display= 'none';
518
		document.getElementById('disablereauth').style.display= '';
519
	} else {
520
		document.getElementById('negmode').style.display = '';
521
		document.getElementById('mobike').style.display = 'none';
522
		document.getElementById('natt').style.display= '';
523
		document.getElementById('disablereauth').style.display= 'none';
524
	}
525
}
526

    
527
function peeridsel_change() {
528
	index = document.iform.peerid_type.selectedIndex;
529
	value = document.iform.peerid_type.options[index].value;
530
	if (value == 'peeraddress') {
531
		document.getElementById('peerid_data').style.visibility = 'hidden';
532
	} else {
533
		document.getElementById('peerid_data').style.visibility = 'visible';
534
	}
535
}
536

    
537
function methodsel_change() {
538
	index = document.iform.authentication_method.selectedIndex;
539
	value = document.iform.authentication_method.options[index].value;
540

    
541
	switch (value) {
542
		case 'eap-mschapv2':
543
		case 'eap-tls':
544
		case 'eap-radius':
545
			document.getElementById('opt_psk').style.display = 'none';
546
			document.getElementById('opt_peerid').style.display = '';
547
			document.getElementById('opt_cert').style.display = '';
548
			document.getElementById('opt_ca').style.display = '';
549
			document.getElementById('opt_cert').disabled = false;
550
			document.getElementById('opt_ca').disabled = false;
551
			break;
552
		case 'hybrid_rsa_server':
553
			document.getElementById('opt_psk').style.display = 'none';
554
			document.getElementById('opt_peerid').style.display = '';
555
			document.getElementById('opt_cert').style.display = '';
556
			document.getElementById('opt_ca').style.display = '';
557
			document.getElementById('opt_cert').disabled = false;
558
			document.getElementById('opt_ca').disabled = false;
559
			break;
560
		case 'xauth_rsa_server':
561
		case 'rsasig':
562
			document.getElementById('opt_psk').style.display = 'none';
563
			document.getElementById('opt_peerid').style.display = '';
564
			document.getElementById('opt_cert').style.display = '';
565
			document.getElementById('opt_ca').style.display = '';
566
			document.getElementById('opt_cert').disabled = false;
567
			document.getElementById('opt_ca').disabled = false;
568
			break;
569
<?php if ($pconfig['mobile']) { ?>
570
		case 'pre_shared_key':
571
			document.getElementById('opt_psk').style.display = 'none';
572
			document.getElementById('opt_peerid').style.display = 'none';
573
			document.getElementById('opt_cert').style.display = 'none';
574
			document.getElementById('opt_ca').style.display = 'none';
575
			document.getElementById('opt_cert').disabled = true;
576
			document.getElementById('opt_ca').disabled = true;
577
			break;
578
<?php } ?>
579
		default: /* psk modes*/
580
			document.getElementById('opt_psk').style.display = '';
581
			document.getElementById('opt_peerid').style.display = '';
582
			document.getElementById('opt_cert').style.display = 'none';
583
			document.getElementById('opt_ca').style.display = 'none';
584
			document.getElementById('opt_cert').disabled = true;
585
			document.getElementById('opt_ca').disabled = true;
586
			break;
587
	}
588
}
589

    
590
/* PHP generated java script for variable length keys */
591
function ealgosel_change(bits) {
592
	switch (document.iform.ealgo.selectedIndex) {
593
<?php
594
$i = 0;
595
foreach ($p1_ealgos as $algo => $algodata) {
596
	if (is_array($algodata['keysel'])) {
597
		echo "		case {$i}:\n";
598
		echo "			document.iform.ealgo_keylen.style.visibility = 'visible';\n";
599
		echo "			document.iform.ealgo_keylen.options.length = 0;\n";
600
		// echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
601

    
602
		$key_hi = $algodata['keysel']['hi'];
603
		$key_lo = $algodata['keysel']['lo'];
604
		$key_step = $algodata['keysel']['step'];
605

    
606
		for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step) {
607
			echo "			document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
608
		}
609
		echo "			break;\n";
610
	} else {
611
		echo "		case {$i}:\n";
612
		echo "			document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
613
		echo "			document.iform.ealgo_keylen.options.length = 0;\n";
614
		echo "			break;\n";
615
	}
616
	$i++;
617
}
618
?>
619
	}
620

    
621
	if (bits) {
622
		document.iform.ealgo_keylen.value = bits;
623
	}
624
}
625

    
626
function dpdchkbox_change() {
627
	if (document.iform.dpd_enable.checked) {
628
		document.getElementById('opt_dpd').style.display = '';
629
	} else {
630
		document.getElementById('opt_dpd').style.display = 'none';
631
	}
632

    
633
	if (!document.iform.dpd_delay.value) {
634
		document.iform.dpd_delay.value = "10";
635
	}
636

    
637
	if (!document.iform.dpd_maxfail.value) {
638
		document.iform.dpd_maxfail.value = "5";
639
	}
640
}
641

    
642
//]]>
643
</script>
644

    
645
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
646

    
647
<?php
648
	if ($input_errors) {
649
		print_input_errors($input_errors);
650
	}
651
?>
652

    
653
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec phase-1">
654
	<tr class="tabnavtbl">
655
		<td id="tabnav">
656
			<?php
657
				$tab_array = array();
658
				$tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
659
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
660
				$tab_array[2] = array(gettext("Pre-Shared Keys"), false, "vpn_ipsec_keys.php");
661
				$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
662
				display_top_tabs($tab_array);
663
			?>
664
		</td>
665
	</tr>
666
	<tr>
667
		<td id="mainarea">
668
			<div class="tabcont">
669
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
670
					<tr>
671
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
672
					</tr>
673
					<tr>
674
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
675
						<td width="78%" class="vtable">
676
							<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
677
							<strong><?=gettext("Disable this phase1 entry"); ?></strong><br />
678
							<span class="vexpl">
679
								<?=gettext("Set this option to disable this phase1 without removing it from the list"); ?>.
680
							</span>
681
						</td>
682
					</tr>
683
					<tr>
684
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Key Exchange version"); ?></td>
685
						<td width="78%" class="vtable">
686
							<select name="iketype" class="formselect" onchange='iketype_change()'>
687
							<?php
688
								$keyexchange = array("ikev1" => "V1", "ikev2" => "V2", "auto" => "Auto");
689
								foreach ($keyexchange as $kidx => $name):
690
							?>
691
								<option value="<?=$kidx;?>" <?php if ($kidx == $pconfig['iketype']) echo "selected=\"selected\""; ?>>
692
									<?=htmlspecialchars($name);?>
693
								</option>
694
							<?php endforeach; ?>
695
							</select>
696
							<br />
697
							<span class="vexpl"><?=gettext("Select the Internet Key Exchange protocol version to be used, IKEv1 or IKEv2"); ?>.</span>
698
						</td>
699
					</tr>
700
					<tr>
701
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Internet Protocol"); ?></td>
702
						<td width="78%" class="vtable">
703
							<select name="protocol" class="formselect">
704
							<?php
705
								$protocols = array("inet" => "IPv4", "inet6" => "IPv6");
706
								foreach ($protocols as $protocol => $name):
707
							?>
708
								<option value="<?=$protocol;?>" <?php if ($protocol == $pconfig['protocol']) echo "selected=\"selected\""; ?>>
709
									<?=htmlspecialchars($name);?>
710
								</option>
711
							<?php endforeach; ?>
712
							</select>
713
							<br />
714
							<span class="vexpl"><?=gettext("Select the Internet Protocol family from this dropdown"); ?>.</span>
715
						</td>
716
					</tr>
717
					<tr>
718
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
719
						<td width="78%" class="vtable">
720
							<select name="interface" class="formselect">
721
							<?php
722
								$interfaces = get_configured_interface_with_descr();
723

    
724
								$carplist = get_configured_carp_interface_list();
725
								foreach ($carplist as $cif => $carpip) {
726
									$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
727
								}
728

    
729
								$aliaslist = get_configured_ip_aliases_list();
730
								foreach ($aliaslist as $aliasip => $aliasif) {
731
									$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
732
								}
733

    
734
								$grouplist = return_gateway_groups_array();
735
								foreach ($grouplist as $name => $group) {
736
									if ($group[0]['vip'] <> "") {
737
										$vipif = $group[0]['vip'];
738
									} else {
739
										$vipif = $group[0]['int'];
740
									}
741
									$interfaces[$name] = "GW Group {$name}";
742
								}
743

    
744

    
745
								foreach ($interfaces as $iface => $ifacename):
746
							?>
747
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
748
									<?=htmlspecialchars($ifacename);?>
749
								</option>
750
							<?php endforeach; ?>
751
							</select>
752
							<br />
753
							<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span>
754
						</td>
755
					</tr>
756

    
757
					<?php if (!$pconfig['mobile']): ?>
758

    
759
					<tr>
760
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
761
						<td width="78%" class="vtable">
762
							<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="28" value="<?=htmlspecialchars($pconfig['remotegw']);?>" />
763
							<br />
764
							<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
765
						</td>
766
					</tr>
767

    
768
					<?php endif; ?>
769

    
770
					<tr>
771
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
772
						<td width="78%" class="vtable">
773
							<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
774
							<br />
775
							<span class="vexpl">
776
								<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
777
							</span>
778
						</td>
779
					</tr>
780
					<tr>
781
						<td colspan="2" class="list" height="12"></td>
782
					</tr>
783
					<tr>
784
						<td colspan="2" valign="top" class="listtopic">
785
							<?=gettext("Phase 1 proposal (Authentication)"); ?>
786
						</td>
787
					</tr>
788
					<tr>
789
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td>
790
						<td width="78%" class="vtable">
791
							<select name="authentication_method" class="formselect" onchange="methodsel_change()">
792
							<?php
793
								foreach ($p1_authentication_methods as $method_type => $method_params):
794
									if (!$pconfig['mobile'] && $method_params['mobile']) {
795
										continue;
796
									}
797
							?>
798
								<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected=\"selected\""; ?>>
799
									<?=htmlspecialchars($method_params['name']);?>
800
								</option>
801
							<?php endforeach; ?>
802
							</select>
803
							<br />
804
							<span class="vexpl">
805
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
806
							</span>
807
						</td>
808
					</tr>
809
					<tr id='negmode' >
810
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td>
811
						<td width="78%" class="vtable">
812
							<select name="mode" class="formselect">
813
							<?php
814
								$modes = array("main" => "Main", "aggressive" => "Aggressive");
815
								foreach ($modes as $mode => $mdescr):
816
							?>
817
								<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected=\"selected\""; ?>>
818
									<?=htmlspecialchars($mdescr);?>
819
								</option>
820
							<?php endforeach; ?>
821
							</select> <br /> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span>
822
						</td>
823
					</tr>
824
					<tr>
825
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td>
826
						<td width="78%" class="vtable">
827
							<select name="myid_type" class="formselect" onchange="myidsel_change()">
828
							<?php foreach ($my_identifier_list as $id_type => $id_params): ?>
829
								<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected=\"selected\""; ?>>
830
									<?=htmlspecialchars($id_params['desc']);?>
831
								</option>
832
							<?php endforeach; ?>
833
							</select>
834
							<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=htmlspecialchars($pconfig['myid_data']);?>" />
835
						</td>
836
					</tr>
837
					<tr id="opt_peerid">
838
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td>
839
						<td width="78%" class="vtable">
840
							<select name="peerid_type" class="formselect" onchange="peeridsel_change()">
841
							<?php
842
								foreach ($peer_identifier_list as $id_type => $id_params):
843
									if ($pconfig['mobile'] && !$id_params['mobile']) {
844
										continue;
845
									}
846
							?>
847
							<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected=\"selected\""; ?>>
848
								<?=htmlspecialchars($id_params['desc']);?>
849
							</option>
850
							<?php endforeach; ?>
851
							</select>
852
							<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=htmlspecialchars($pconfig['peerid_data']);?>" />
853
						<?php if ($pconfig['mobile']) { ?>
854
							<br /><br /><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.
855
						<?php } ?>
856
						</td>
857
					</tr>
858
					<tr id="opt_psk">
859
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
860
						<td width="78%" class="vtable">
861
							<?=$mandfldhtml;?>
862
							<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>" />
863
							<span class="vexpl">
864
							<br />
865
								<?=gettext("Input your Pre-Shared Key string"); ?>.
866
							</span>
867
						</td>
868
					</tr>
869
					<tr id="opt_cert">
870
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td>
871
						<td width="78%" class="vtable">
872
							<select name="certref" class="formselect">
873
							<?php
874
								foreach ($config['cert'] as $cert):
875
									$selected = "";
876
									if ($pconfig['certref'] == $cert['refid']) {
877
										$selected = "selected=\"selected\"";
878
									}
879
							?>
880
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=htmlspecialchars($cert['descr']);?></option>
881
							<?php endforeach; ?>
882
							</select>
883
							<br />
884
							<span class="vexpl">
885
								<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
886
							</span>
887
						</td>
888
					</tr>
889
					<tr id="opt_ca">
890
						<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td>
891
						<td width="78%" class="vtable">
892
							<select name="caref" class="formselect">
893
							<?php
894
								foreach ($config['ca'] as $ca):
895
									$selected = "";
896
									if ($pconfig['caref'] == $ca['refid']) {
897
										$selected = "selected=\"selected\"";
898
									}
899
							?>
900
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=htmlspecialchars($ca['descr']);?></option>
901
							<?php endforeach; ?>
902
							</select>
903
							<br />
904
							<span class="vexpl">
905
								<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
906
							</span>
907
						</td>
908
					</tr>
909
					<tr>
910
						<td colspan="2" valign="top" class="listtopic">
911
							<?=gettext("Phase 1 proposal (Algorithms)"); ?>
912
						</td>
913
					</tr>
914
					<tr>
915
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
916
						<td width="78%" class="vtable">
917
							<select name="ealgo" class="formselect" onchange="ealgosel_change()">
918
							<?php
919
								foreach ($p1_ealgos as $algo => $algodata):
920
									$selected = "";
921
									if ($algo == $pconfig['ealgo']['name']) {
922
										$selected = " selected=\"selected\"";
923
									}
924
							?>
925
								<option value="<?=$algo;?>"<?=$selected?>>
926
									<?=htmlspecialchars($algodata['name']);?>
927
								</option>
928
							<?php endforeach; ?>
929
							</select>
930
							<select name="ealgo_keylen" width="30" class="formselect">
931
							</select>
932
						</td>
933
					</tr>
934
					<tr>
935
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td>
936
						<td width="78%" class="vtable">
937
							<select name="halgo" class="formselect">
938
							<?php foreach ($p1_halgos as $algo => $algoname): ?>
939
								<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected=\"selected\""; ?>>
940
									<?=htmlspecialchars($algoname);?>
941
								</option>
942
							<?php endforeach; ?>
943
							</select>
944
							<br />
945
							<span class="vexpl">
946
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
947
							</span>
948
						</td>
949
					</tr>
950
					<tr>
951
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td>
952
						<td width="78%" class="vtable">
953
							<select name="dhgroup" class="formselect">
954
							<?php foreach ($p1_dhgroups as $keygroup => $keygroupname): ?>
955
								<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected=\"selected\""; ?>>
956
									<?=htmlspecialchars($keygroupname);?>
957
								</option>
958
							<?php endforeach; ?>
959
							</select>
960
							<br />
961
							<span class="vexpl">
962
								<?=gettext("Must match the setting chosen on the remote side"); ?>.
963
							</span>
964
						</td>
965
					</tr>
966
					<tr>
967
						<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td>
968
						<td width="78%" class="vtable">
969
							<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=htmlspecialchars($pconfig['lifetime']);?>" />
970
							<?=gettext("seconds"); ?>
971
						</td>
972
					</tr>
973
					<tr>
974
						<td colspan="2" class="list" height="12"></td>
975
					</tr>
976
					<tr>
977
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced Options"); ?></td>
978
					</tr>
979
					<tr>
980
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Rekey");?></td>
981
						<td width="78%" class="vtable">
982
							<input name="rekey_enable" type="checkbox" id="rekey_enable" value="yes" <?php if (isset($pconfig['rekey_enable'])) echo "checked=\"checked\""; ?> />
983
							<?=gettext("Whether a connection should be renegotiated when it is about to expire."); ?><br />
984
						</td>
985
					</tr>
986
					<tr id='disablereauth'>
987
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Reauth");?></td>
988
						<td width="78%" class="vtable">
989
							<input name="reauth_enable" type="checkbox" id="reauth_enable" value="yes" <?php if (isset($pconfig['reauth_enable'])) echo "checked=\"checked\""; ?> />
990
							<?=gettext("Whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done."); ?><br />
991
						</td>
992
					</tr>
993
					<tr>
994
						<td width="22%" valign="top" class="vncell"><?=gettext("Responder Only");?></td>
995
						<td width="78%" class="vtable">
996
							<input name="responderonly" type="checkbox" id="responderonly" value="yes" <?php if (isset($pconfig['responderonly'])) echo "checked=\"checked\""; ?> />
997
							<?=gettext("Enable this option to never initiate this connection from this side, only respond to incoming requests."); ?><br />
998
						</td>
999
					</tr>
1000
					<tr id='natt'>
1001
						<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td>
1002
						<td width="78%" class="vtable">
1003
							<select name="nat_traversal" class="formselect">
1004
								<option value="on" <?php if ($pconfig['nat_traversal'] != 'on') echo "selected=\"selected\""; ?>><?=gettext("Auto"); ?></option>
1005
								<option value="force" <?php if ($pconfig['nat_traversal'] == 'force') echo "selected=\"selected\""; ?>><?=gettext("Force"); ?></option>
1006
							</select>
1007
							<br />
1008
							<span class="vexpl">
1009
								<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
1010
								"which can help with clients that are behind restrictive firewalls"); ?>.
1011
							</span>
1012
						</td>
1013
					</tr>
1014
					<tr id='mobike'>
1015
						<td width="22%" valign="top" class="vncell"><?=gettext("MOBIKE"); ?></td>
1016
						<td width="78%" class="vtable">
1017
							<select name="mobike" class="formselect">
1018
								<option value="on" <?php if ($pconfig['mobike'] == 'on') echo "selected=\"selected\""; ?>><?=gettext("Enable"); ?></option>
1019
								<option value="off" <?php if ($pconfig['mobike'] != 'on') echo "selected=\"selected\""; ?>><?=gettext("Disable"); ?></option>
1020
							</select>
1021
							<br />
1022
							<span class="vexpl">
1023
								<?=gettext("Set this option to control the use of MOBIKE"); ?>.
1024
							</span>
1025
						</td>
1026
					</tr>
1027
					<tr>
1028
						<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td>
1029
						<td width="78%" class="vtable">
1030
							<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked=\"checked\""; ?> onclick="dpdchkbox_change()" />
1031
							<?=gettext("Enable DPD"); ?><br />
1032
							<div id="opt_dpd">
1033
								<br />
1034
								<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=htmlspecialchars($pconfig['dpd_delay']);?>" />
1035
								<?=gettext("seconds"); ?><br />
1036
								<span class="vexpl">
1037
									<?=gettext("Delay between requesting peer acknowledgement"); ?>.
1038
								</span><br />
1039
								<br />
1040
								<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=htmlspecialchars($pconfig['dpd_maxfail']);?>" />
1041
								<?=gettext("retries"); ?><br />
1042
								<span class="vexpl">
1043
									<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
1044
								</span>
1045
								<br />
1046
							</div>
1047
						</td>
1048
					</tr>
1049
					<tr>
1050
						<td width="22%" valign="top">&nbsp;</td>
1051
						<td width="78%">
1052
							<?php if (isset($p1index) && $a_phase1[$p1index]): ?>
1053
							<input name="p1index" type="hidden" value="<?=htmlspecialchars($p1index);?>" />
1054
							<?php endif; ?>
1055
							<?php if ($pconfig['mobile']): ?>
1056
							<input name="mobile" type="hidden" value="true" />
1057
							<?php endif; ?>
1058
							<input name="ikeid" type="hidden" value="<?=htmlspecialchars($pconfig['ikeid']);?>" />
1059
							<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
1060
						</td>
1061
					</tr>
1062
				</table>
1063
			</div>
1064
		</td>
1065
	</tr>
1066
</table>
1067
</form>
1068

    
1069
<script type="text/javascript">
1070
//<![CDATA[
1071
<?php
1072
	/* determine if we should init the key length */
1073
	$keyset = '';
1074
	if (isset($pconfig['ealgo']['keylen'])) {
1075
		if (is_numeric($pconfig['ealgo']['keylen'])) {
1076
			$keyset = $pconfig['ealgo']['keylen'];
1077
		}
1078
	}
1079
?>
1080
myidsel_change();
1081
peeridsel_change();
1082
iketype_change();
1083
methodsel_change();
1084
ealgosel_change(<?=$keyset;?>);
1085
dpdchkbox_change();
1086
//]]>
1087
</script>
1088
<?php include("fend.inc"); ?>
1089
</body>
1090
</html>
(237-237/252)