Projet

Général

Profil

Télécharger (27,9 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_gateways_edit.php @ 2d1e985d

1
<?php
2
/* $Id$ */
3
/*
4
	system_gateways_edit.php
5
	part of pfSense (https://www.pfsense.org)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	All rights reserved.
9

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

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

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

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

    
35
##|+PRIV
36
##|*IDENT=page-system-gateways-editgateway
37
##|*NAME=System: Gateways: Edit Gateway page
38
##|*DESCR=Allow access to the 'System: Gateways: Edit Gateway' page.
39
##|*MATCH=system_gateways_edit.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require("pkg-utils.inc");
44

    
45
$a_gateways = return_gateways_array(true);
46
$a_gateways_arr = array();
47
foreach($a_gateways as $gw) {
48
	$a_gateways_arr[] = $gw;
49
}
50
$a_gateways = $a_gateways_arr;
51

    
52
if (!is_array($config['gateways']['gateway_item']))
53
	$config['gateways']['gateway_item'] = array();
54

    
55
$a_gateway_item = &$config['gateways']['gateway_item'];
56
$apinger_default = return_apinger_defaults();
57

    
58
if (is_numericint($_GET['id']))
59
	$id = $_GET['id'];
60
if (isset($_POST['id']) && is_numericint($_POST['id']))
61
	$id = $_POST['id'];
62

    
63
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
64
	$id = $_GET['dup'];
65

    
66
if (isset($id) && $a_gateways[$id]) {
67
	$pconfig = array();
68
	$pconfig['name'] = $a_gateways[$id]['name'];
69
	$pconfig['weight'] = $a_gateways[$id]['weight'];
70
	$pconfig['interval'] = $a_gateways[$id]['interval'];
71
	$pconfig['interface'] = $a_gateways[$id]['interface'];
72
	$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
73
	$pconfig['ipprotocol'] = $a_gateways[$id]['ipprotocol'];
74
	if (isset($a_gateways[$id]['dynamic']))
75
		$pconfig['dynamic'] = true;
76
	$pconfig['gateway'] = $a_gateways[$id]['gateway'];
77
	$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
78
	$pconfig['latencylow'] = $a_gateways[$id]['latencylow'];
79
	$pconfig['latencyhigh'] = $a_gateways[$id]['latencyhigh'];
80
	$pconfig['losslow'] = $a_gateways[$id]['losslow'];
81
	$pconfig['losshigh'] = $a_gateways[$id]['losshigh'];
82
	$pconfig['down'] = $a_gateways[$id]['down'];
83
	$pconfig['monitor'] = $a_gateways[$id]['monitor'];
84
	$pconfig['monitor_disable'] = isset($a_gateways[$id]['monitor_disable']);
85
	$pconfig['descr'] = $a_gateways[$id]['descr'];
86
	$pconfig['attribute'] = $a_gateways[$id]['attribute'];
87
}
88

    
89
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
90
	unset($id);
91
	unset($pconfig['attribute']);
92
}
93

    
94
if (isset($id) && $a_gateways[$id])
95
	$realid = $a_gateways[$id]['attribute'];
96

    
97
if ($_POST) {
98

    
99
	unset($input_errors);
100

    
101
	/* input validation */
102
	$reqdfields = explode(" ", "name interface");
103
	$reqdfieldsn = array(gettext("Name"), gettext("Interface"));
104

    
105
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
106

    
107
	if (! isset($_POST['name'])) {
108
		$input_errors[] = "A valid gateway name must be specified.";
109
	}
110
	if (! is_validaliasname($_POST['name'])) {
111
		$input_errors[] = gettext("The gateway name must not contain invalid characters.");
112
	}
113
	/* skip system gateways which have been automatically added */
114
	if (($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($_POST['attribute'] !== "system")) && ($_POST['gateway'] != "dynamic")) {
115
		$input_errors[] = gettext("A valid gateway IP address must be specified.");
116
	}
117

    
118
	if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && !$_REQUEST['isAjax']) {
119
		if(is_ipaddrv4($_POST['gateway'])) {
120
			$parent_ip = get_interface_ip($_POST['interface']);
121
			$parent_sn = get_interface_subnet($_POST['interface']);
122
			if(empty($parent_ip) || empty($parent_sn)) {
123
				$input_errors[] = gettext("Cannot add IPv4 Gateway Address because no IPv4 address could be found on the interface.");
124
			} else {
125
				$subnets = array(gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn);
126
				$vips = link_interface_to_vips($_POST['interface']);
127
				if (is_array($vips))
128
					foreach($vips as $vip) {
129
						if (!is_ipaddrv4($vip['subnet']))
130
							continue;
131
						$subnets[] = gen_subnet($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
132
					}
133

    
134
				$found = false;
135
				foreach($subnets as $subnet)
136
					if(ip_in_subnet($_POST['gateway'], $subnet)) {
137
						$found = true;
138
						break;
139
					}
140

    
141
				if ($found === false)
142
					$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
143
			}
144
		}
145
		else if(is_ipaddrv6($_POST['gateway'])) {
146
			/* do not do a subnet match on a link local address, it's valid */
147
			if(!is_linklocal($_POST['gateway'])) {
148
				$parent_ip = get_interface_ipv6($_POST['interface']);
149
				$parent_sn = get_interface_subnetv6($_POST['interface']);
150
				if(empty($parent_ip) || empty($parent_sn)) {
151
					$input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
152
				} else {
153
					$subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
154
					$vips = link_interface_to_vips($_POST['interface']);
155
					if (is_array($vips))
156
						foreach($vips as $vip) {
157
							if (!is_ipaddrv6($vip['subnet']))
158
								continue;
159
							$subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
160
						}
161

    
162
					$found = false;
163
					foreach($subnets as $subnet)
164
						if(ip_in_subnet($_POST['gateway'], $subnet)) {
165
							$found = true;
166
							break;
167
						}
168

    
169
					if ($found === false)
170
						$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
171
				}
172
			}
173
		}
174

    
175
		if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
176
			if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
177
				$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
178
		}
179
		if (!empty($config['interfaces'][$_POST['interface']]['ipaddrv6'])) {
180
			if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddrv6']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
181
				$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv6 configuration.");
182
		}
183
	}
184
	if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
185
		$input_errors[] = gettext("A valid monitor IP address must be specified.");
186
	}
187
	/* only allow correct IPv4 and IPv6 gateway addresses */
188
	if (($_POST['gateway'] <> "") && is_ipaddr($_POST['gateway']) && $_POST['gateway'] != "dynamic") {
189
		if(is_ipaddrv6($_POST['gateway']) && ($_POST['ipprotocol'] == "inet")) {
190
			$input_errors[] = gettext("The IPv6 gateway address '{$_POST['gateway']}' can not be used as a IPv4 gateway'.");
191
		}
192
		if(is_ipaddrv4($_POST['gateway']) && ($_POST['ipprotocol'] == "inet6")) {
193
			$input_errors[] = gettext("The IPv4 gateway address '{$_POST['gateway']}' can not be used as a IPv6 gateway'.");
194
		}
195
	}
196
	/* only allow correct IPv4 and IPv6 monitor addresses */
197
	if (($_POST['monitor'] <> "") && is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
198
		if(is_ipaddrv6($_POST['monitor']) && ($_POST['ipprotocol'] == "inet")) {
199
			$input_errors[] = gettext("The IPv6 monitor address '{$_POST['monitor']}' can not be used on a IPv4 gateway'.");
200
		}
201
		if(is_ipaddrv4($_POST['monitor']) && ($_POST['ipprotocol'] == "inet6")) {
202
			$input_errors[] = gettext("The IPv4 monitor address '{$_POST['monitor']}' can not be used on a IPv6 gateway'.");
203
		}
204
	}
205

    
206
	if (isset($_POST['name'])) {
207
		/* check for overlaps */
208
		foreach ($a_gateways as $gateway) {
209
			if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
210
				if ($gateway['name'] != $_POST['name'])
211
					$input_errors[] = gettext("Changing name on a gateway is not allowed.");
212
				continue;
213
			}
214
			if($_POST['name'] <> "") {
215
				if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] !== "system")) {
216
					$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
217
					break;
218
				}
219
			}
220
			if(is_ipaddr($_POST['gateway'])) {
221
				if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] !== "system")) {
222
					$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
223
					break;
224
				}
225
			}
226
			if(is_ipaddr($_POST['monitor'])) {
227
				if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] !== "system")) {
228
					$input_errors[] = sprintf(gettext('The monitor IP address "%s" is already in use. You must choose a different monitor IP.'), $_POST['monitor']);
229
					break;
230
				}
231
			}
232
		}
233
	}
234

    
235
	/* input validation of apinger advanced parameters */
236
	if($_POST['latencylow']) {
237
		if (! is_numeric($_POST['latencylow'])) {
238
			$input_errors[] = gettext("The low latency threshold needs to be a numeric value.");
239
		} else {
240
			if ($_POST['latencylow'] < 1) {
241
				$input_errors[] = gettext("The low latency threshold needs to be positive.");
242
			}
243
		}
244
	}
245

    
246
	if($_POST['latencyhigh']) {
247
		if (! is_numeric($_POST['latencyhigh'])) {
248
			$input_errors[] = gettext("The high latency threshold needs to be a numeric value.");
249
		} else {
250
			if ($_POST['latencyhigh'] < 1) {
251
				$input_errors[] = gettext("The high latency threshold needs to be positive.");
252
			}
253
		}
254
	}
255

    
256
	if($_POST['losslow']) {
257
		if (! is_numeric($_POST['losslow'])) {
258
			$input_errors[] = gettext("The low Packet Loss threshold needs to be a numeric value.");
259
		} else {
260
			if ($_POST['losslow'] < 1) {
261
				$input_errors[] = gettext("The low Packet Loss threshold needs to be positive.");
262
			}
263
			if ($_POST['losslow'] >= 100) {
264
				$input_errors[] = gettext("The low Packet Loss threshold needs to be less than 100.");
265
			}
266
		}
267
	}
268

    
269
	if($_POST['losshigh']) {
270
		if (! is_numeric($_POST['losshigh'])) {
271
			$input_errors[] = gettext("The high Packet Loss threshold needs to be a numeric value.");
272
		} else {
273
			if ($_POST['losshigh'] < 1) {
274
				$input_errors[] = gettext("The high Packet Loss threshold needs to be positive.");
275
			}
276
			if ($_POST['losshigh'] > 100) {
277
				$input_errors[] = gettext("The high Packet Loss threshold needs to be 100 or less.");
278
			}
279
		}
280
	}
281

    
282
	if(($_POST['latencylow']) && ($_POST['latencyhigh'])) {
283
		if ((is_numeric($_POST['latencylow'])) && (is_numeric($_POST['latencyhigh']))) {
284
			if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
285
				$input_errors[] = gettext("The high latency threshold needs to be higher than the low latency threshold");
286
			}
287
		}
288
	} else {
289
		if($_POST['latencylow']){
290
			if (is_numeric($_POST['latencylow'])) {
291
				if($_POST['latencylow'] > $apinger_default['latencyhigh']) {
292
					$input_errors[] = gettext(sprintf("The low latency threshold needs to be less than the default high latency threshold (%d)", $apinger_default['latencyhigh']));
293
				}
294
			}
295
		}
296
		if($_POST['latencyhigh']){
297
			if (is_numeric($_POST['latencyhigh'])) {
298
				if($_POST['latencyhigh'] < $apinger_default['latencylow']) {
299
					$input_errors[] = gettext(sprintf("The high latency threshold needs to be higher than the default low latency threshold (%d)", $apinger_default['latencylow']));
300
				}
301
			}
302
		}
303
	}
304

    
305
	if(($_POST['losslow']) && ($_POST['losshigh'])){
306
		if ((is_numeric($_POST['losslow'])) && (is_numeric($_POST['losshigh']))) {
307
			if($_POST['losslow'] > $_POST['losshigh']) {
308
				$input_errors[] = gettext("The high Packet Loss threshold needs to be higher than the low Packet Loss threshold");
309
			}
310
		}
311
	} else {
312
		if($_POST['losslow']){
313
			if (is_numeric($_POST['losslow'])) {
314
				if($_POST['losslow'] > $apinger_default['losshigh']) {
315
					$input_errors[] = gettext(sprintf("The low Packet Loss threshold needs to be less than the default high Packet Loss threshold (%d)", $apinger_default['losshigh']));
316
				}
317
			}
318
		}
319
		if($_POST['losshigh']){
320
			if (is_numeric($_POST['losshigh'])) {
321
				if($_POST['losshigh'] < $apinger_default['losslow']) {
322
					$input_errors[] = gettext(sprintf("The high Packet Loss threshold needs to be higher than the default low Packet Loss threshold (%d)", $apinger_default['losslow']));
323
				}
324
			}
325
		}
326
	}
327

    
328
	if($_POST['interval']) {
329
		if (! is_numeric($_POST['interval'])) {
330
			$input_errors[] = gettext("The probe interval needs to be a numeric value.");
331
		} else {
332
			if ($_POST['interval'] < 1) {
333
				$input_errors[] = gettext("The probe interval needs to be positive.");
334
			}
335
		}
336
	}
337

    
338
	if($_POST['down']) {
339
		if (! is_numeric($_POST['down'])) {
340
			$input_errors[] = gettext("The down time setting needs to be a numeric value.");
341
		} else {
342
			if ($_POST['down'] < 1) {
343
				$input_errors[] = gettext("The down time setting needs to be positive.");
344
			}
345
		}
346
	}
347

    
348
	if(($_POST['interval']) && ($_POST['down'])){
349
		if ((is_numeric($_POST['interval'])) && (is_numeric($_POST['down']))) {
350
			if($_POST['interval'] > $_POST['down']) {
351
				$input_errors[] = gettext("The probe interval needs to be less than the down time setting.");
352
			}
353
		}
354
	} else {
355
		if($_POST['interval']){
356
			if (is_numeric($_POST['interval'])) {
357
				if($_POST['interval'] > $apinger_default['down']) {
358
					$input_errors[] = gettext(sprintf("The probe interval needs to be less than the default down time setting (%d)", $apinger_default['down']));
359
				}
360
			}
361
		}
362
		if($_POST['down']){
363
			if (is_numeric($_POST['down'])) {
364
				if($_POST['down'] < $apinger_default['interval']) {
365
					$input_errors[] = gettext(sprintf("The down time setting needs to be higher than the default probe interval (%d)", $apinger_default['interval']));
366
				}
367
			}
368
		}
369
	}
370

    
371
	if (!$input_errors) {
372
		$reloadif = "";
373
		$gateway = array();
374

    
375
		if (empty($_POST['interface']))
376
			$gateway['interface'] = $pconfig['friendlyiface'];
377
		else
378
			$gateway['interface'] = $_POST['interface'];
379
		if (is_ipaddr($_POST['gateway']))
380
			$gateway['gateway'] = $_POST['gateway'];
381
		else
382
			$gateway['gateway'] = "dynamic";
383
		$gateway['name'] = $_POST['name'];
384
		$gateway['weight'] = $_POST['weight'];
385
		$gateway['ipprotocol'] = $_POST['ipprotocol'];
386
		$gateway['interval'] = $_POST['interval'];
387
		$gateway['descr'] = $_POST['descr'];
388
		if ($_POST['monitor_disable'] == "yes")
389
			$gateway['monitor_disable'] = true;
390
		if (is_ipaddr($_POST['monitor']))
391
			$gateway['monitor'] = $_POST['monitor'];
392

    
393
		/* NOTE: If monitor ip is changed need to cleanup the old static route */
394
		if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$realid]) && is_ipaddr($a_gateway_item[$realid]['monitor']) &&
395
		    $_POST['monitor'] != $a_gateway_item[$realid]['monitor'] && $gateway['gateway'] != $a_gateway_item[$realid]['monitor']) {
396
			if (is_ipaddrv4($a_gateway_item[$realid]['monitor']))
397
				mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$realid]['monitor']));
398
			else
399
				mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$realid]['monitor']));
400
		}
401

    
402
		if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
403
			$i = 0;
404
			/* remove the default gateway bits for all gateways with the same address family */
405
			foreach($a_gateway_item as $gw) {
406
				if ($gateway['ipprotocol'] == $gw['ipprotocol']) {
407
					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
408
					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
409
						$reloadif = $gw['interface'];
410
				}
411
				$i++;
412
			}
413
			$gateway['defaultgw'] = true;
414
		}
415

    
416
		if ($_POST['latencylow'])
417
			$gateway['latencylow'] = $_POST['latencylow'];
418
		if ($_POST['latencyhigh'])
419
			$gateway['latencyhigh'] = $_POST['latencyhigh'];
420
		if ($_POST['losslow'])
421
			$gateway['losslow'] = $_POST['losslow'];
422
		if ($_POST['losshigh'])
423
			$gateway['losshigh'] = $_POST['losshigh'];
424
		if ($_POST['down'])
425
			$gateway['down'] = $_POST['down'];
426

    
427
		/* when saving the manual gateway we use the attribute which has the corresponding id */
428
		if (isset($realid) && $a_gateway_item[$realid])
429
			$a_gateway_item[$realid] = $gateway;
430
		else
431
			$a_gateway_item[] = $gateway;
432

    
433
		mark_subsystem_dirty('staticroutes');
434

    
435
		write_config();
436

    
437
		if($_REQUEST['isAjax']) {
438
			echo $_POST['name'];
439
			exit;
440
		} else if (!empty($reloadif))
441
			send_event("interface reconfigure {$reloadif}");
442

    
443
		header("Location: system_gateways.php");
444
		exit;
445
	} else {
446
		if ($_REQUEST['isAjax']) {
447
			header("HTTP/1.0 500 Internal Server Error");
448
			header("Content-type: text/plain");
449
			foreach ($input_errors as $error) {
450
				echo("$error\n");
451
			}
452
			exit;
453
		}
454

    
455
		$pconfig = $_POST;
456
		if (empty($_POST['friendlyiface']))
457
			$pconfig['friendlyiface'] = $_POST['interface'];
458
	}
459
}
460

    
461

    
462
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway"));
463
$shortcut_section = "gateways";
464

    
465
include("head.inc");
466

    
467
?>
468

    
469
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
470
<?php include("fbegin.inc"); ?>
471
<script type="text/javascript">
472
//<![CDATA[
473
function show_advanced_gateway() {
474
	document.getElementById("showadvgatewaybox").innerHTML='';
475
	aodiv = document.getElementById('showgatewayadv');
476
	aodiv.style.display = "block";
477
}
478
function monitor_change() {
479
	document.iform.monitor.disabled = document.iform.monitor_disable.checked;
480
}
481
//]]>
482
</script>
483
<?php if ($input_errors) print_input_errors($input_errors); ?>
484
	<form action="system_gateways_edit.php" method="post" name="iform" id="iform">
485
	<?php
486

    
487
	/* If this is a system gateway we need this var */
488
	if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
489
		echo "<input type='hidden' name='attribute' id='attribute' value=\"" . htmlspecialchars($pconfig['attribute']) . "\" />\n";
490
	}
491
	echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value=\"" . htmlspecialchars($pconfig['friendlyiface']) . "\" />\n";
492
	?>
493
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="system gateways edit">
494
			<tr>
495
				<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit gateway"); ?></td>
496
			</tr>
497
			<tr>
498
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
499
				<td width="78%" class="vtable">
500
					<select name='interface' class='formselect'>
501
					<?php
502
						$interfaces = get_configured_interface_with_descr(false, true);
503
						foreach ($interfaces as $iface => $ifacename) {
504
							echo "<option value=\"{$iface}\"";
505
							if ($iface == $pconfig['friendlyiface'])
506
								echo " selected='selected'";
507
							echo ">" . htmlspecialchars($ifacename) . "</option>";
508
						}
509
					?>
510
					</select><br/>
511
					<span class="vexpl"><?=gettext("Choose which interface this gateway applies to."); ?></span>
512
				</td>
513
			</tr>
514
			<tr>
515
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Address Family"); ?></td>
516
				<td width="78%" class="vtable">
517
					<select name='ipprotocol' class='formselect' >
518
					<?php
519
						$options = array("inet" => "IPv4", "inet6" => "IPv6");
520
						foreach ($options as $name => $string) {
521
							echo "<option value=\"{$name}\"";
522
							if ($name == $pconfig['ipprotocol'])
523
								echo " selected='selected'";
524
							echo ">" . htmlspecialchars($string) . "</option>\n";
525
						}
526
					?>
527
					</select><br/>
528
					<span class="vexpl"><?=gettext("Choose the Internet Protocol this gateway uses."); ?></span>
529
				</td>
530
			</tr>
531
			<tr>
532
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td>
533
				<td width="78%" class="vtable">
534
					<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
535
					<br/><span class="vexpl"><?=gettext("Gateway name"); ?></span>
536
				</td>
537
			</tr>
538
			<tr>
539
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
540
				<td width="78%" class="vtable">
541
					<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo htmlspecialchars($pconfig['gateway']); ?>" />
542
					<br/><span class="vexpl"><?=gettext("Gateway IP address"); ?></span>
543
				</td>
544
			</tr>
545
			<tr>
546
				<td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
547
				<td width="78%" class="vtable">
548
					<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked=\"checked\""; ?> />
549
					<strong><?=gettext("Default Gateway"); ?></strong><br />
550
					<?=gettext("This will select the above gateway as the default gateway"); ?>
551
				</td>
552
			</tr>
553
			<tr>
554
				<td width="22%" valign="top" class="vncell"><?=gettext("Disable Gateway Monitoring"); ?></td>
555
				<td width="78%" class="vtable">
556
					<input name="monitor_disable" type="checkbox" id="monitor_disable" value="yes" <?php if ($pconfig['monitor_disable'] == true) echo "checked=\"checked\""; ?> onclick="monitor_change()" />
557
					<strong><?=gettext("Disable Gateway Monitoring"); ?></strong><br />
558
					<?=gettext("This will consider this gateway as always being up"); ?>
559
				</td>
560
			</tr>
561
			<tr>
562
				<td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
563
				<td width="78%" class="vtable">
564
					<?php
565
						if ($pconfig['gateway'] == $pconfig['monitor'])
566
							$monitor = "";
567
						else
568
							$monitor = htmlspecialchars($pconfig['monitor']);
569
					?>
570
					<input name="monitor" type="text" id="monitor" value="<?php echo htmlspecialchars($monitor); ?>" size="28" />
571
					<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
572
					<?=gettext("Enter an alternative address here to be used to monitor the link. This is used for the " .
573
					"quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond " .
574
					"to ICMP echo requests (pings)"); ?>.
575
					<br />
576
				</td>
577
			</tr>
578
			<tr>
579
				<td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
580
				<td width="78%" class="vtable">
581
					<?php $showbutton = (!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || (isset($pconfig['weight']) && $pconfig['weight'] > 1) || (isset($pconfig['interval']) && ($pconfig['interval'] > $apinger_default['interval'])) || (isset($pconfig['down']) && !($pconfig['down'] == $apinger_default['down']))); ?>
582
					<div id="showadvgatewaybox" <?php if ($showbutton) echo "style='display:none'"; ?>>
583
						<input type="button" onclick="show_advanced_gateway()" value="Advanced" /><?=gettext(" - Show advanced option"); ?>
584
					</div>
585
					<div id="showgatewayadv" <?php if (!$showbutton) echo "style='display:none'"; ?>>
586
						<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="advanced options">
587
							<tr>
588
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
589
								<td width="78%" class="vtable">
590
									<select name='weight' class='formfldselect' id='weight'>
591
									<?php
592
										for ($i = 1; $i < 6; $i++) {
593
											$selected = "";
594
											if ($pconfig['weight'] == $i)
595
												$selected = "selected='selected'";
596
											echo "<option value='{$i}' {$selected} >{$i}</option>";
597
										}
598
									?>
599
									</select>
600
									<br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br />
601
								</td>
602
							</tr>
603
							<tr>
604
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td>
605
								<td width="78%" class="vtable">
606
									<?=gettext("From");?>
607
									<input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2"
608
										value="<?=htmlspecialchars($pconfig['latencylow']);?>" />
609
									<?=gettext("To");?>
610
									<input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2"
611
										value="<?=htmlspecialchars($pconfig['latencyhigh']);?>" />
612
									<br/><span class="vexpl"><?=gettext(sprintf("Low and high thresholds for latency in milliseconds. Default is %d/%d.", $apinger_default['latencylow'], $apinger_default['latencyhigh']));?></span>
613
								</td>
614
							</tr>
615
							<tr>
616
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td>
617
								<td width="78%" class="vtable">
618
									<?=gettext("From");?>
619
									<input name="losslow" type="text" class="formfld unknown" id="losslow" size="2"
620
										value="<?=htmlspecialchars($pconfig['losslow']);?>" />
621
									<?=gettext("To");?>
622
									<input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2"
623
										value="<?=htmlspecialchars($pconfig['losshigh']);?>" />
624
									<br /><span class="vexpl"><?=gettext(sprintf("Low and high thresholds for packet loss in %%. Default is %d/%d.", $apinger_default['losslow'], $apinger_default['losshigh']));?></span>
625
								</td>
626
							</tr>
627
							<tr>
628
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Probe Interval");?></td>
629
								<td width="78%" class="vtable">
630
									<input name="interval" type="text" class="formfld unknown" id="interval" size="2"
631
										value="<?=htmlspecialchars($pconfig['interval']);?>" />
632
									<br/><span class="vexpl">
633
										<?=gettext(sprintf("How often that an ICMP probe will be sent in seconds. Default is %d.", $apinger_default['interval']));?><br/><br/>
634
										<?=gettext("NOTE: The quality graph is averaged over seconds, not intervals, so as the probe interval is increased the accuracy of the quality graph is decreased.");?>
635
									</span>
636
								</td>
637
							</tr>
638
							<tr>
639
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td>
640
								<td width="78%" class="vtable">
641
									<input name="down" type="text" class="formfld unknown" id="down" size="2"
642
										value="<?=htmlspecialchars($pconfig['down']);?>" />
643
									<br/><span class="vexpl"><?=gettext(sprintf("The number of seconds of failed probes before the alarm will fire. Default is %d.", $apinger_default['down']));?></span>
644
								</td>
645
							</tr>
646
							<tr>
647
								<td colspan="2">
648
									<?= gettext("The probe interval must be less than the down time, otherwise the gateway will seem to go down then come up again at the next probe."); ?><br/><br/>
649
									<?= gettext("The down time defines the length of time before the gateway is marked as down, but the accuracy is controlled by the probe interval. For example, if your down time is 40 seconds but on a 30 second probe interval, only one probe would have to fail before the gateway is marked down at the 40 second mark. By default, the gateway is considered down after 10 seconds, and the probe interval is 1 second, so 10 probes would have to fail before the gateway is marked down."); ?><br/>
650
								</td>
651
							</tr>
652
						</table>
653
					</div>
654
				</td>
655
			</tr>
656
			<tr>
657
				<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
658
				<td width="78%" class="vtable">
659
					<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
660
					<br/><span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span>
661
				</td>
662
			</tr>
663
			<tr>
664
				<td width="22%" valign="top">&nbsp;</td>
665
				<td width="78%">
666
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> <input type="button" value="<?=gettext("Cancel");?>" class="formbtn"  onclick="history.back()" />
667
					<?php if (isset($id) && $a_gateways[$id]): ?>
668
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
669
					<?php endif; ?>
670
				</td>
671
			</tr>
672
		</table>
673
	</form>
674
<?php include("fend.inc"); ?>
675
<script type="text/javascript">
676
//<![CDATA[
677
monitor_change();
678
//]]>
679
</script>
680
</body>
681
</html>
(214-214/246)