Project

General

Profile

Download (38.1 KB) Statistics
| Branch: | Tag: | Revision:
1 0b844b73 Renato Botelho
<?php
2 124aee67 Chris Buechler
/* $Id$ */
3 d173230c Seth Mos
/*
4
	system_gateways_edit.php
5 5721595b Chris Buechler
	part of pfSense (https://www.pfsense.org)
6 0b844b73 Renato Botelho
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 6317d31d Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 d173230c Seth Mos
	All rights reserved.
10 0b844b73 Renato Botelho
11 d173230c Seth Mos
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 0b844b73 Renato Botelho
14 d173230c Seth Mos
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 0b844b73 Renato Botelho
17 d173230c Seth Mos
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 0b844b73 Renato Botelho
21 d173230c Seth Mos
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32 1d333258 Scott Ullrich
/*
33
	pfSense_MODULE:	routing
34
*/
35 d173230c Seth Mos
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-system-gateways-editgateway
38
##|*NAME=System: Gateways: Edit Gateway page
39
##|*DESCR=Allow access to the 'System: Gateways: Edit Gateway' page.
40
##|*MATCH=system_gateways_edit.php*
41
##|-PRIV
42
43 124aee67 Chris Buechler
require("guiconfig.inc");
44 4666b787 Ermal Lu?i
require("pkg-utils.inc");
45 d173230c Seth Mos
46 62424bdb Renato Botelho
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_gateways.php');
47
48 96ef7db0 Renato Botelho
$a_gateways = return_gateways_array(true, false, true);
49 87f0be87 Chris Buechler
$a_gateways_arr = array();
50
foreach($a_gateways as $gw) {
51
	$a_gateways_arr[] = $gw;
52
}
53
$a_gateways = $a_gateways_arr;
54 d173230c Seth Mos
55 616e1956 Seth Mos
if (!is_array($config['gateways']['gateway_item']))
56 0b844b73 Renato Botelho
	$config['gateways']['gateway_item'] = array();
57
58 616e1956 Seth Mos
$a_gateway_item = &$config['gateways']['gateway_item'];
59 eb233517 Phil Davis
$apinger_default = return_apinger_defaults();
60 616e1956 Seth Mos
61 e41ec584 Renato Botelho
if (is_numericint($_GET['id']))
62
	$id = $_GET['id'];
63
if (isset($_POST['id']) && is_numericint($_POST['id']))
64 d173230c Seth Mos
	$id = $_POST['id'];
65
66 e41ec584 Renato Botelho
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
67 d173230c Seth Mos
	$id = $_GET['dup'];
68
69
if (isset($id) && $a_gateways[$id]) {
70 bb849003 Ermal
	$pconfig = array();
71 e90db2b4 Ermal Lu?i
	$pconfig['name'] = $a_gateways[$id]['name'];
72 5f53260a Ermal
	$pconfig['weight'] = $a_gateways[$id]['weight'];
73 f7203985 Ermal
	$pconfig['interval'] = $a_gateways[$id]['interval'];
74 3c6787ed N0YB
	$pconfig['avg_delay_samples'] = $a_gateways[$id]['avg_delay_samples'];
75
	$pconfig['avg_delay_samples_calculated'] = isset($a_gateways[$id]['avg_delay_samples_calculated']);
76
	$pconfig['avg_loss_samples'] = $a_gateways[$id]['avg_loss_samples'];
77
	$pconfig['avg_loss_samples_calculated'] = isset($a_gateways[$id]['avg_loss_samples_calculated']);
78
	$pconfig['avg_loss_delay_samples'] = $a_gateways[$id]['avg_loss_delay_samples'];
79
	$pconfig['avg_loss_delay_samples_calculated'] = isset($a_gateways[$id]['avg_loss_delay_samples_calculated']);
80 e90db2b4 Ermal Lu?i
	$pconfig['interface'] = $a_gateways[$id]['interface'];
81 883c53c9 Ermal Lu?i
	$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
82 c1d36d26 smos
	$pconfig['ipprotocol'] = $a_gateways[$id]['ipprotocol'];
83 d44d26c1 Ermal
	if (isset($a_gateways[$id]['dynamic']))
84
		$pconfig['dynamic'] = true;
85
	$pconfig['gateway'] = $a_gateways[$id]['gateway'];
86 883c53c9 Ermal Lu?i
	$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
87 81f19476 Renato Botelho
	$pconfig['force_down'] = isset($a_gateways[$id]['force_down']);
88 23d9f686 Renato Botelho
	$pconfig['latencylow'] = $a_gateways[$id]['latencylow'];
89
	$pconfig['latencyhigh'] = $a_gateways[$id]['latencyhigh'];
90
	$pconfig['losslow'] = $a_gateways[$id]['losslow'];
91
	$pconfig['losshigh'] = $a_gateways[$id]['losshigh'];
92
	$pconfig['down'] = $a_gateways[$id]['down'];
93 99c61352 Ermal
	$pconfig['monitor'] = $a_gateways[$id]['monitor'];
94 33c06ef7 Ermal
	$pconfig['monitor_disable'] = isset($a_gateways[$id]['monitor_disable']);
95 e90db2b4 Ermal Lu?i
	$pconfig['descr'] = $a_gateways[$id]['descr'];
96
	$pconfig['attribute'] = $a_gateways[$id]['attribute'];
97 96ef7db0 Renato Botelho
	$pconfig['disabled'] = isset($a_gateways[$id]['disabled']);
98 d173230c Seth Mos
}
99
100 e41ec584 Renato Botelho
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
101 d173230c Seth Mos
	unset($id);
102 124aee67 Chris Buechler
	unset($pconfig['attribute']);
103
}
104 d173230c Seth Mos
105 23d9f686 Renato Botelho
if (isset($id) && $a_gateways[$id])
106
	$realid = $a_gateways[$id]['attribute'];
107
108 d173230c Seth Mos
if ($_POST) {
109
110
	unset($input_errors);
111
112
	/* input validation */
113 d44d26c1 Ermal
	$reqdfields = explode(" ", "name interface");
114
	$reqdfieldsn = array(gettext("Name"), gettext("Interface"));
115 883c53c9 Ermal Lu?i
116 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
117 883c53c9 Ermal Lu?i
118 d173230c Seth Mos
	if (! isset($_POST['name'])) {
119
		$input_errors[] = "A valid gateway name must be specified.";
120
	}
121 31ace93c Seth Mos
	if (! is_validaliasname($_POST['name'])) {
122 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("The gateway name must not contain invalid characters.");
123 31ace93c Seth Mos
	}
124 87f0be87 Chris Buechler
	/* skip system gateways which have been automatically added */
125 283d78c6 Darren Embry
	if (($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($_POST['attribute'] !== "system")) && ($_POST['gateway'] != "dynamic")) {
126 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid gateway IP address must be specified.");
127 87f0be87 Chris Buechler
	}
128 15a13dab Scott Ullrich
129 d44d26c1 Ermal
	if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && !$_REQUEST['isAjax']) {
130 9e80d14c Seth Mos
		if(is_ipaddrv4($_POST['gateway'])) {
131 47593ac6 Seth Mos
			$parent_ip = get_interface_ip($_POST['interface']);
132 e227df57 Ermal Lu?i
			$parent_sn = get_interface_subnet($_POST['interface']);
133 9e80d14c Seth Mos
			if(empty($parent_ip) || empty($parent_sn)) {
134 bf755503 Renato Botelho
				$input_errors[] = gettext("Cannot add IPv4 Gateway Address because no IPv4 address could be found on the interface.");
135 9e80d14c Seth Mos
			} else {
136 55705b33 Renato Botelho
				$subnets = array(gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn);
137
				$vips = link_interface_to_vips($_POST['interface']);
138
				if (is_array($vips))
139
					foreach($vips as $vip) {
140
						if (!is_ipaddrv4($vip['subnet']))
141
							continue;
142
						$subnets[] = gen_subnet($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
143
					}
144
145
				$found = false;
146
				foreach($subnets as $subnet)
147
					if(ip_in_subnet($_POST['gateway'], $subnet)) {
148
						$found = true;
149
						break;
150
					}
151
152
				if ($found === false)
153
					$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
154 e227df57 Ermal Lu?i
			}
155 e7d3b8f4 Seth Mos
		}
156 b5b5bcc0 Ermal
		else if(is_ipaddrv6($_POST['gateway'])) {
157 2a9cb3b2 smos
			/* do not do a subnet match on a link local address, it's valid */
158 db7a628c Renato Botelho
			if(!is_linklocal($_POST['gateway'])) {
159 2a9cb3b2 smos
				$parent_ip = get_interface_ipv6($_POST['interface']);
160
				$parent_sn = get_interface_subnetv6($_POST['interface']);
161
				if(empty($parent_ip) || empty($parent_sn)) {
162 bf755503 Renato Botelho
					$input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
163 2a9cb3b2 smos
				} else {
164 55705b33 Renato Botelho
					$subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
165
					$vips = link_interface_to_vips($_POST['interface']);
166
					if (is_array($vips))
167
						foreach($vips as $vip) {
168
							if (!is_ipaddrv6($vip['subnet']))
169
								continue;
170
							$subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
171
						}
172
173
					$found = false;
174
					foreach($subnets as $subnet)
175
						if(ip_in_subnet($_POST['gateway'], $subnet)) {
176
							$found = true;
177
							break;
178
						}
179
180
					if ($found === false)
181
						$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
182 35af7141 smos
				}
183 7617e245 Seth Mos
			}
184
		}
185 9e80d14c Seth Mos
186
		if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
187
			if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
188
				$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
189
		}
190
		if (!empty($config['interfaces'][$_POST['interface']]['ipaddrv6'])) {
191
			if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddrv6']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
192
				$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv6 configuration.");
193
		}
194 e7d3b8f4 Seth Mos
	}
195 883c53c9 Ermal Lu?i
	if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
196 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid monitor IP address must be specified.");
197 d173230c Seth Mos
	}
198 2972b3e7 smos
	/* only allow correct IPv4 and IPv6 gateway addresses */
199
	if (($_POST['gateway'] <> "") && is_ipaddr($_POST['gateway']) && $_POST['gateway'] != "dynamic") {
200
		if(is_ipaddrv6($_POST['gateway']) && ($_POST['ipprotocol'] == "inet")) {
201
			$input_errors[] = gettext("The IPv6 gateway address '{$_POST['gateway']}' can not be used as a IPv4 gateway'.");
202
		}
203
		if(is_ipaddrv4($_POST['gateway']) && ($_POST['ipprotocol'] == "inet6")) {
204
			$input_errors[] = gettext("The IPv4 gateway address '{$_POST['gateway']}' can not be used as a IPv6 gateway'.");
205
		}
206
	}
207
	/* only allow correct IPv4 and IPv6 monitor addresses */
208 9e80d14c Seth Mos
	if (($_POST['monitor'] <> "") && is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
209 2972b3e7 smos
		if(is_ipaddrv6($_POST['monitor']) && ($_POST['ipprotocol'] == "inet")) {
210
			$input_errors[] = gettext("The IPv6 monitor address '{$_POST['monitor']}' can not be used on a IPv4 gateway'.");
211 c1d36d26 smos
		}
212 2972b3e7 smos
		if(is_ipaddrv4($_POST['monitor']) && ($_POST['ipprotocol'] == "inet6")) {
213
			$input_errors[] = gettext("The IPv4 monitor address '{$_POST['monitor']}' can not be used on a IPv6 gateway'.");
214 9e80d14c Seth Mos
		}
215
	}
216 d173230c Seth Mos
217 8b060357 Seth Mos
	if (isset($_POST['name'])) {
218 31ace93c Seth Mos
		/* check for overlaps */
219
		foreach ($a_gateways as $gateway) {
220 2328dcc5 Seth Mos
			if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
221 23fafd14 Ermal
				if ($gateway['name'] != $_POST['name'])
222 33802679 Chris Buechler
					$input_errors[] = gettext("Changing name on a gateway is not allowed.");
223 31ace93c Seth Mos
				continue;
224
			}
225 2328dcc5 Seth Mos
			if($_POST['name'] <> "") {
226 283d78c6 Darren Embry
				if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] !== "system")) {
227 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
228 2328dcc5 Seth Mos
					break;
229
				}
230
			}
231
			if(is_ipaddr($_POST['gateway'])) {
232 283d78c6 Darren Embry
				if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] !== "system")) {
233 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
234 2328dcc5 Seth Mos
					break;
235
				}
236 31ace93c Seth Mos
			}
237 2328dcc5 Seth Mos
			if(is_ipaddr($_POST['monitor'])) {
238 283d78c6 Darren Embry
				if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] !== "system")) {
239 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The monitor IP address "%s" is already in use. You must choose a different monitor IP.'), $_POST['monitor']);
240 2328dcc5 Seth Mos
					break;
241
				}
242 31ace93c Seth Mos
			}
243 d173230c Seth Mos
		}
244
	}
245
246 eb233517 Phil Davis
	/* input validation of apinger advanced parameters */
247
	if($_POST['latencylow']) {
248
		if (! is_numeric($_POST['latencylow'])) {
249
			$input_errors[] = gettext("The low latency threshold needs to be a numeric value.");
250
		} else {
251
			if ($_POST['latencylow'] < 1) {
252
				$input_errors[] = gettext("The low latency threshold needs to be positive.");
253
			}
254
		}
255
	}
256
257
	if($_POST['latencyhigh']) {
258
		if (! is_numeric($_POST['latencyhigh'])) {
259
			$input_errors[] = gettext("The high latency threshold needs to be a numeric value.");
260
		} else {
261
			if ($_POST['latencyhigh'] < 1) {
262
				$input_errors[] = gettext("The high latency threshold needs to be positive.");
263
			}
264
		}
265
	}
266
267
	if($_POST['losslow']) {
268
		if (! is_numeric($_POST['losslow'])) {
269
			$input_errors[] = gettext("The low Packet Loss threshold needs to be a numeric value.");
270
		} else {
271
			if ($_POST['losslow'] < 1) {
272
				$input_errors[] = gettext("The low Packet Loss threshold needs to be positive.");
273
			}
274
			if ($_POST['losslow'] >= 100) {
275
				$input_errors[] = gettext("The low Packet Loss threshold needs to be less than 100.");
276
			}
277
		}
278
	}
279
280
	if($_POST['losshigh']) {
281
		if (! is_numeric($_POST['losshigh'])) {
282
			$input_errors[] = gettext("The high Packet Loss threshold needs to be a numeric value.");
283
		} else {
284
			if ($_POST['losshigh'] < 1) {
285
				$input_errors[] = gettext("The high Packet Loss threshold needs to be positive.");
286
			}
287
			if ($_POST['losshigh'] > 100) {
288
				$input_errors[] = gettext("The high Packet Loss threshold needs to be 100 or less.");
289
			}
290
		}
291
	}
292
293
	if(($_POST['latencylow']) && ($_POST['latencyhigh'])) {
294
		if ((is_numeric($_POST['latencylow'])) && (is_numeric($_POST['latencyhigh']))) {
295
			if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
296
				$input_errors[] = gettext("The high latency threshold needs to be higher than the low latency threshold");
297
			}
298
		}
299
	} else {
300
		if($_POST['latencylow']){
301
			if (is_numeric($_POST['latencylow'])) {
302
				if($_POST['latencylow'] > $apinger_default['latencyhigh']) {
303
					$input_errors[] = gettext(sprintf("The low latency threshold needs to be less than the default high latency threshold (%d)", $apinger_default['latencyhigh']));
304
				}
305
			}
306
		}
307
		if($_POST['latencyhigh']){
308
			if (is_numeric($_POST['latencyhigh'])) {
309
				if($_POST['latencyhigh'] < $apinger_default['latencylow']) {
310
					$input_errors[] = gettext(sprintf("The high latency threshold needs to be higher than the default low latency threshold (%d)", $apinger_default['latencylow']));
311
				}
312
			}
313
		}
314
	}
315
316
	if(($_POST['losslow']) && ($_POST['losshigh'])){
317
		if ((is_numeric($_POST['losslow'])) && (is_numeric($_POST['losshigh']))) {
318
			if($_POST['losslow'] > $_POST['losshigh']) {
319
				$input_errors[] = gettext("The high Packet Loss threshold needs to be higher than the low Packet Loss threshold");
320
			}
321
		}
322
	} else {
323
		if($_POST['losslow']){
324
			if (is_numeric($_POST['losslow'])) {
325
				if($_POST['losslow'] > $apinger_default['losshigh']) {
326
					$input_errors[] = gettext(sprintf("The low Packet Loss threshold needs to be less than the default high Packet Loss threshold (%d)", $apinger_default['losshigh']));
327
				}
328
			}
329
		}
330
		if($_POST['losshigh']){
331
			if (is_numeric($_POST['losshigh'])) {
332
				if($_POST['losshigh'] < $apinger_default['losslow']) {
333
					$input_errors[] = gettext(sprintf("The high Packet Loss threshold needs to be higher than the default low Packet Loss threshold (%d)", $apinger_default['losslow']));
334
				}
335
			}
336
		}
337
	}
338
339
	if($_POST['interval']) {
340
		if (! is_numeric($_POST['interval'])) {
341 490cd438 Phil Davis
			$input_errors[] = gettext("The probe interval needs to be a numeric value.");
342 eb233517 Phil Davis
		} else {
343
			if ($_POST['interval'] < 1) {
344 490cd438 Phil Davis
				$input_errors[] = gettext("The probe interval needs to be positive.");
345 eb233517 Phil Davis
			}
346
		}
347
	}
348
349 023920e7 Ermal
	if($_POST['down']) {
350 eb233517 Phil Davis
		if (! is_numeric($_POST['down'])) {
351
			$input_errors[] = gettext("The down time setting needs to be a numeric value.");
352
		} else {
353
			if ($_POST['down'] < 1) {
354
				$input_errors[] = gettext("The down time setting needs to be positive.");
355
			}
356
		}
357
	}
358
359
	if(($_POST['interval']) && ($_POST['down'])){
360
		if ((is_numeric($_POST['interval'])) && (is_numeric($_POST['down']))) {
361
			if($_POST['interval'] > $_POST['down']) {
362 490cd438 Phil Davis
				$input_errors[] = gettext("The probe interval needs to be less than the down time setting.");
363 eb233517 Phil Davis
			}
364
		}
365
	} else {
366
		if($_POST['interval']){
367
			if (is_numeric($_POST['interval'])) {
368
				if($_POST['interval'] > $apinger_default['down']) {
369 490cd438 Phil Davis
					$input_errors[] = gettext(sprintf("The probe interval needs to be less than the default down time setting (%d)", $apinger_default['down']));
370 eb233517 Phil Davis
				}
371
			}
372
		}
373
		if($_POST['down']){
374
			if (is_numeric($_POST['down'])) {
375
				if($_POST['down'] < $apinger_default['interval']) {
376 490cd438 Phil Davis
					$input_errors[] = gettext(sprintf("The down time setting needs to be higher than the default probe interval (%d)", $apinger_default['interval']));
377 eb233517 Phil Davis
				}
378
			}
379
		}
380
	}
381 023920e7 Ermal
382 3c6787ed N0YB
	if($_POST['avg_delay_samples']) {
383
		if (! is_numeric($_POST['avg_delay_samples'])) {
384
			$input_errors[] = gettext("The average delay replies qty needs to be a numeric value.");
385
		} else {
386
			if ($_POST['avg_delay_samples'] < 1) {
387
				$input_errors[] = gettext("The average delay replies qty needs to be positive.");
388
			}
389
		}
390
	}
391
392
	if($_POST['avg_loss_samples']) {
393
		if (! is_numeric($_POST['avg_loss_samples'])) {
394
			$input_errors[] = gettext("The average packet loss probes qty needs to be a numeric value.");
395
		} else {
396
			if ($_POST['avg_loss_samples'] < 1) {
397
				$input_errors[] = gettext("The average packet loss probes qty needs to be positive.");
398
			}
399
		}
400
	}
401
402
	if($_POST['avg_loss_delay_samples']) {
403
		if (! is_numeric($_POST['avg_loss_delay_samples'])) {
404
			$input_errors[] = gettext("The lost probe delay needs to be a numeric value.");
405
		} else {
406
			if ($_POST['avg_loss_delay_samples'] < 1) {
407
				$input_errors[] = gettext("The lost probe delay needs to be positive.");
408
			}
409
		}
410
	}
411
412 d173230c Seth Mos
	if (!$input_errors) {
413 c6865c5e Ermal
		$reloadif = "";
414 d44d26c1 Ermal
		$gateway = array();
415
416
		if (empty($_POST['interface']))
417
			$gateway['interface'] = $pconfig['friendlyiface'];
418
		else
419 3befe730 Ermal
			$gateway['interface'] = $_POST['interface'];
420 d44d26c1 Ermal
		if (is_ipaddr($_POST['gateway']))
421
			$gateway['gateway'] = $_POST['gateway'];
422
		else
423
			$gateway['gateway'] = "dynamic";
424
		$gateway['name'] = $_POST['name'];
425
		$gateway['weight'] = $_POST['weight'];
426 e02caf4a smos
		$gateway['ipprotocol'] = $_POST['ipprotocol'];
427 f7203985 Ermal
		$gateway['interval'] = $_POST['interval'];
428 3c6787ed N0YB
429
		$gateway['avg_delay_samples'] = $_POST['avg_delay_samples'];
430
		if ($_POST['avg_delay_samples_calculated'] == "yes" || $_POST['avg_delay_samples_calculated'] == "on")
431
			$gateway['avg_delay_samples_calculated'] = true;
432
433
		$gateway['avg_loss_samples'] = $_POST['avg_loss_samples'];
434
		if ($_POST['avg_loss_samples_calculated'] == "yes" || $_POST['avg_loss_samples_calculated'] == "on")
435
			$gateway['avg_loss_samples_calculated'] = true;
436
437
		$gateway['avg_loss_delay_samples'] = $_POST['avg_loss_delay_samples'];
438
		if ($_POST['avg_loss_delay_samples_calculated'] == "yes" || $_POST['avg_loss_delay_samples_calculated'] == "on")
439
			$gateway['avg_loss_delay_samples_calculated'] = true;
440
441 d44d26c1 Ermal
		$gateway['descr'] = $_POST['descr'];
442 33c06ef7 Ermal
		if ($_POST['monitor_disable'] == "yes")
443
			$gateway['monitor_disable'] = true;
444 81f19476 Renato Botelho
		if ($_POST['force_down'] == "yes")
445
			$gateway['force_down'] = true;
446 fcd01c8a Renato Botelho
		if (is_ipaddr($_POST['monitor']))
447 d44d26c1 Ermal
			$gateway['monitor'] = $_POST['monitor'];
448 fcd01c8a Renato Botelho
449
		/* NOTE: If monitor ip is changed need to cleanup the old static route */
450
		if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$realid]) && is_ipaddr($a_gateway_item[$realid]['monitor']) &&
451
		    $_POST['monitor'] != $a_gateway_item[$realid]['monitor'] && $gateway['gateway'] != $a_gateway_item[$realid]['monitor']) {
452
			if (is_ipaddrv4($a_gateway_item[$realid]['monitor']))
453
				mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$realid]['monitor']));
454
			else
455
				mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$realid]['monitor']));
456 32a9eb18 Ermal
		}
457 d44d26c1 Ermal
458
		if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
459
			$i = 0;
460 2f14d021 Seth Mos
			/* remove the default gateway bits for all gateways with the same address family */
461 a531d687 Ermal
			foreach($a_gateway_item as $gw) {
462 beb7cd97 Renato Botelho
				if ($gateway['ipprotocol'] == $gw['ipprotocol']) {
463 2f14d021 Seth Mos
					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
464
					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
465
						$reloadif = $gw['interface'];
466
				}
467 d44d26c1 Ermal
				$i++;
468 bb849003 Ermal
			}
469 d44d26c1 Ermal
			$gateway['defaultgw'] = true;
470 124aee67 Chris Buechler
		}
471 d44d26c1 Ermal
472
		if ($_POST['latencylow'])
473
			$gateway['latencylow'] = $_POST['latencylow'];
474
		if ($_POST['latencyhigh'])
475 0b844b73 Renato Botelho
			$gateway['latencyhigh'] = $_POST['latencyhigh'];
476 d44d26c1 Ermal
		if ($_POST['losslow'])
477 a0edece9 Darren Embry
			$gateway['losslow'] = $_POST['losslow'];
478 d44d26c1 Ermal
		if ($_POST['losshigh'])
479 0b844b73 Renato Botelho
			$gateway['losshigh'] = $_POST['losshigh'];
480 d44d26c1 Ermal
		if ($_POST['down'])
481 0b844b73 Renato Botelho
			$gateway['down'] = $_POST['down'];
482 d44d26c1 Ermal
483 96ef7db0 Renato Botelho
		if(isset($_POST['disabled']))
484
			$gateway['disabled'] = true;
485
		else
486
			unset($gateway['disabled']);
487
488 d44d26c1 Ermal
		/* when saving the manual gateway we use the attribute which has the corresponding id */
489 23d9f686 Renato Botelho
		if (isset($realid) && $a_gateway_item[$realid])
490
			$a_gateway_item[$realid] = $gateway;
491 d44d26c1 Ermal
		else
492
			$a_gateway_item[] = $gateway;
493
494 a368a026 Ermal Lu?i
		mark_subsystem_dirty('staticroutes');
495 0b844b73 Renato Botelho
496 d173230c Seth Mos
		write_config();
497 d44d26c1 Ermal
498 ad862220 Charlie
		if($_REQUEST['isAjax']) {
499
			echo $_POST['name'];
500
			exit;
501 c6865c5e Ermal
		} else if (!empty($reloadif))
502
			send_event("interface reconfigure {$reloadif}");
503 0b844b73 Renato Botelho
504 d173230c Seth Mos
		header("Location: system_gateways.php");
505
		exit;
506 ea939fc3 Ermal
	} else {
507 a0edece9 Darren Embry
		if ($_REQUEST['isAjax']) {
508
			header("HTTP/1.0 500 Internal Server Error");
509
			header("Content-type: text/plain");
510
			foreach ($input_errors as $error) {
511
				echo("$error\n");
512
			}
513
			exit;
514
		}
515 0b844b73 Renato Botelho
516 883c53c9 Ermal Lu?i
		$pconfig = $_POST;
517 ea939fc3 Ermal
		if (empty($_POST['friendlyiface']))
518
			$pconfig['friendlyiface'] = $_POST['interface'];
519
	}
520 d173230c Seth Mos
}
521
522 2328dcc5 Seth Mos
523 df152a88 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway"));
524 b32dd0a6 jim-p
$shortcut_section = "gateways";
525 02ca24c9 jim-p
526 d173230c Seth Mos
include("head.inc");
527
528
?>
529
530
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
531
<?php include("fbegin.inc"); ?>
532 a1dccfc6 Colin Fleming
<script type="text/javascript">
533
//<![CDATA[
534 023920e7 Ermal
function show_advanced_gateway() {
535 0b844b73 Renato Botelho
	document.getElementById("showadvgatewaybox").innerHTML='';
536
	aodiv = document.getElementById('showgatewayadv');
537
	aodiv.style.display = "block";
538 023920e7 Ermal
}
539 33c06ef7 Ermal
function monitor_change() {
540 0b844b73 Renato Botelho
	document.iform.monitor.disabled = document.iform.monitor_disable.checked;
541 33c06ef7 Ermal
}
542 3c6787ed N0YB
543 ec5c28cd N0YB
function interval_change(interval_obj) {
544
	valid_value(interval_obj, 1, 86400);
545 3c6787ed N0YB
	calculate_state_change();
546
547
	calculated_change(document.iform.avg_delay_samples_calculated, document.iform.avg_delay_samples);
548
	calculated_change(document.iform.avg_loss_samples_calculated, document.iform.avg_loss_samples);
549
	calculated_change(document.iform.avg_loss_delay_samples_calculated, document.iform.avg_loss_delay_samples);
550
}
551
552
function samples_change(calculated_obj, samples_obj) {
553
	calculated_change(calculated_obj, samples_obj);
554
}
555
556
function calculated_change(calculated_obj, samples_obj) {
557
	switch (samples_obj.name) {
558
559
	case 'avg_delay_samples':
560
		// How many replies should be used to compute average delay 
561
		// for controlling "delay" alarms.
562
		// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
563
		if (calculated_obj.checked && (document.iform.interval.value > 0))
564
			samples_obj.value = 60 * (1/6) / Math.pow(document.iform.interval.value, 0.333);	// Calculate & Round to Integer
565
		valid_value(samples_obj, 1, 100);
566
		break;
567
568
	case 'avg_loss_samples':
569
		// How many probes should be used to compute average loss.
570
		// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
571
		if (calculated_obj.checked && (document.iform.interval.value > 0))
572
			samples_obj.value = 60 / document.iform.interval.value;	// Calculate & Round to Integer
573
		valid_value(samples_obj, 1, 1000);
574
		break;
575
576
	case 'avg_loss_delay_samples':
577
		// The delay (in samples) after which loss is computed
578
		// without this delays larger than interval would be treated as loss.
579
		// Calculate a reasonable value based on gateway probe interval and RRD 1 minute average graph step size (60).
580
		if (calculated_obj.checked && (document.iform.interval.value > 0))
581
			samples_obj.value = 60 * (1/3) / document.iform.interval.value;	// Calculate & Round to Integer
582
		valid_value(samples_obj, 1, 200);
583
		break;
584
	default:
585
	}
586 ec5c28cd N0YB
587
	calculate_state_change();
588 3c6787ed N0YB
}
589
590
function valid_value(object, min, max) {
591
	if (object.value) {
592
		object.value = Math.round(object.value);		// Round to integer
593
		if (object.value < min)  object.value = min;	// Min Value
594
		if (object.value > max)  object.value = max;	// Max Value
595
		if (isNaN(object.value)) object.value =  '';	// Empty Value
596
	}
597
}
598
599
function calculate_state_change() {
600
	if (document.iform.interval.value > 0) {
601
		document.iform.avg_delay_samples_calculated.disabled = false;
602
		document.iform.avg_loss_samples_calculated.disabled = false;
603
		document.iform.avg_loss_delay_samples_calculated.disabled = false;
604 ec5c28cd N0YB
605
		document.iform.avg_delay_samples.disabled = document.iform.avg_delay_samples_calculated.checked;
606
		document.iform.avg_loss_samples.disabled = document.iform.avg_loss_samples_calculated.checked;
607
		document.iform.avg_loss_delay_samples.disabled = document.iform.avg_loss_delay_samples_calculated.checked;
608 3c6787ed N0YB
	}
609
	else {
610
		document.iform.avg_delay_samples_calculated.disabled = true;
611
		document.iform.avg_loss_samples_calculated.disabled = true;
612
		document.iform.avg_loss_delay_samples_calculated.disabled = true;
613
		document.iform.interval.value = '';
614 ec5c28cd N0YB
615
		document.iform.avg_delay_samples.disabled = false;
616
		document.iform.avg_loss_samples.disabled = false;
617
		document.iform.avg_loss_delay_samples.disabled = false;
618
619
		document.iform.avg_delay_samples_calculated.checked = false;
620
		document.iform.avg_loss_samples_calculated.checked = false;
621
		document.iform.avg_loss_delay_samples_calculated.checked = false;
622 3c6787ed N0YB
	}
623
}
624 ec5c28cd N0YB
625
function enable_change() {
626
	document.iform.avg_delay_samples.disabled = false;
627
	document.iform.avg_loss_samples.disabled = false;
628
	document.iform.avg_loss_delay_samples.disabled = false;
629
}
630 a1dccfc6 Colin Fleming
//]]>
631 883c53c9 Ermal Lu?i
</script>
632 d173230c Seth Mos
<?php if ($input_errors) print_input_errors($input_errors); ?>
633 0b844b73 Renato Botelho
	<form action="system_gateways_edit.php" method="post" name="iform" id="iform">
634 124aee67 Chris Buechler
	<?php
635 e9df5769 Seth Mos
636
	/* If this is a system gateway we need this var */
637 124aee67 Chris Buechler
	if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
638 605ae553 Renato Botelho
		echo "<input type='hidden' name='attribute' id='attribute' value=\"" . htmlspecialchars($pconfig['attribute']) . "\" />\n";
639 124aee67 Chris Buechler
	}
640 605ae553 Renato Botelho
	echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value=\"" . htmlspecialchars($pconfig['friendlyiface']) . "\" />\n";
641 124aee67 Chris Buechler
	?>
642 a1dccfc6 Colin Fleming
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="system gateways edit">
643 0b844b73 Renato Botelho
			<tr>
644
				<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit gateway"); ?></td>
645
			</tr>
646 96ef7db0 Renato Botelho
			<tr>
647
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
648
				<td width="78%" class="vtable">
649
					<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
650
					<strong><?=gettext("Disable this gateway");?></strong><br />
651
					<span class="vexpl"><?=gettext("Set this option to disable this gateway without removing it from the list.");?></span>
652
				</td>
653
			</tr>
654 0b844b73 Renato Botelho
			<tr>
655
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
656
				<td width="78%" class="vtable">
657 a1dccfc6 Colin Fleming
					<select name='interface' class='formselect'>
658 0b844b73 Renato Botelho
					<?php
659
						$interfaces = get_configured_interface_with_descr(false, true);
660
						foreach ($interfaces as $iface => $ifacename) {
661
							echo "<option value=\"{$iface}\"";
662
							if ($iface == $pconfig['friendlyiface'])
663 a1dccfc6 Colin Fleming
								echo " selected='selected'";
664 0b844b73 Renato Botelho
							echo ">" . htmlspecialchars($ifacename) . "</option>";
665
						}
666
					?>
667 8cd558b6 ayvis
					</select><br />
668 0b844b73 Renato Botelho
					<span class="vexpl"><?=gettext("Choose which interface this gateway applies to."); ?></span>
669
				</td>
670
			</tr>
671
			<tr>
672
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Address Family"); ?></td>
673
				<td width="78%" class="vtable">
674
					<select name='ipprotocol' class='formselect' >
675
					<?php
676
						$options = array("inet" => "IPv4", "inet6" => "IPv6");
677
						foreach ($options as $name => $string) {
678
							echo "<option value=\"{$name}\"";
679
							if ($name == $pconfig['ipprotocol'])
680 a1dccfc6 Colin Fleming
								echo " selected='selected'";
681 0b844b73 Renato Botelho
							echo ">" . htmlspecialchars($string) . "</option>\n";
682
						}
683
					?>
684 8cd558b6 ayvis
					</select><br />
685 0b844b73 Renato Botelho
					<span class="vexpl"><?=gettext("Choose the Internet Protocol this gateway uses."); ?></span>
686
				</td>
687
			</tr>
688
			<tr>
689
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td>
690
				<td width="78%" class="vtable">
691 a1dccfc6 Colin Fleming
					<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" />
692 8cd558b6 ayvis
					<br /><span class="vexpl"><?=gettext("Gateway name"); ?></span>
693 0b844b73 Renato Botelho
				</td>
694
			</tr>
695
			<tr>
696
				<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
697
				<td width="78%" class="vtable">
698 a1dccfc6 Colin Fleming
					<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo htmlspecialchars($pconfig['gateway']); ?>" />
699 8cd558b6 ayvis
					<br /><span class="vexpl"><?=gettext("Gateway IP address"); ?></span>
700 0b844b73 Renato Botelho
				</td>
701
			</tr>
702 023920e7 Ermal
			<tr>
703 0b844b73 Renato Botelho
				<td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
704
				<td width="78%" class="vtable">
705 a1dccfc6 Colin Fleming
					<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked=\"checked\""; ?> />
706 0b844b73 Renato Botelho
					<strong><?=gettext("Default Gateway"); ?></strong><br />
707
					<?=gettext("This will select the above gateway as the default gateway"); ?>
708
				</td>
709
			</tr>
710
			<tr>
711
				<td width="22%" valign="top" class="vncell"><?=gettext("Disable Gateway Monitoring"); ?></td>
712
				<td width="78%" class="vtable">
713 a1dccfc6 Colin Fleming
					<input name="monitor_disable" type="checkbox" id="monitor_disable" value="yes" <?php if ($pconfig['monitor_disable'] == true) echo "checked=\"checked\""; ?> onclick="monitor_change()" />
714 0b844b73 Renato Botelho
					<strong><?=gettext("Disable Gateway Monitoring"); ?></strong><br />
715
					<?=gettext("This will consider this gateway as always being up"); ?>
716
				</td>
717
			</tr>
718
			<tr>
719
				<td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
720
				<td width="78%" class="vtable">
721
					<?php
722
						if ($pconfig['gateway'] == $pconfig['monitor'])
723
							$monitor = "";
724
						else
725
							$monitor = htmlspecialchars($pconfig['monitor']);
726
					?>
727
					<input name="monitor" type="text" id="monitor" value="<?php echo htmlspecialchars($monitor); ?>" size="28" />
728
					<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
729
					<?=gettext("Enter an alternative address here to be used to monitor the link. This is used for the " .
730
					"quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond " .
731 a1dccfc6 Colin Fleming
					"to ICMP echo requests (pings)"); ?>.
732 0b844b73 Renato Botelho
					<br />
733
				</td>
734 023920e7 Ermal
			</tr>
735 81f19476 Renato Botelho
			<tr>
736
				<td width="22%" valign="top" class="vncell"><?=gettext("Mark Gateway as Down"); ?></td>
737
				<td width="78%" class="vtable">
738
					<input name="force_down" type="checkbox" id="force_down" value="yes" <?php if ($pconfig['force_down'] == true) echo "checked=\"checked\""; ?> />
739
					<strong><?=gettext("Mark Gateway as Down"); ?></strong><br />
740
					<?=gettext("This will force this gateway to be considered Down"); ?>
741
				</td>
742
			</tr>
743 023920e7 Ermal
			<tr>
744 0b844b73 Renato Botelho
				<td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
745 ec9bb09f jim-p
				<td width="78%" class="vtable">
746 0b844b73 Renato Botelho
					<?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']))); ?>
747
					<div id="showadvgatewaybox" <?php if ($showbutton) echo "style='display:none'"; ?>>
748 a1dccfc6 Colin Fleming
						<input type="button" onclick="show_advanced_gateway()" value="Advanced" /><?=gettext(" - Show advanced option"); ?>
749 0b844b73 Renato Botelho
					</div>
750
					<div id="showgatewayadv" <?php if (!$showbutton) echo "style='display:none'"; ?>>
751 a1dccfc6 Colin Fleming
						<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="advanced options">
752 0b844b73 Renato Botelho
							<tr>
753
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
754
								<td width="78%" class="vtable">
755
									<select name='weight' class='formfldselect' id='weight'>
756
									<?php
757
										for ($i = 1; $i < 6; $i++) {
758
											$selected = "";
759
											if ($pconfig['weight'] == $i)
760 a1dccfc6 Colin Fleming
												$selected = "selected='selected'";
761 0b844b73 Renato Botelho
											echo "<option value='{$i}' {$selected} >{$i}</option>";
762
										}
763
									?>
764
									</select>
765
									<br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br />
766
								</td>
767
							</tr>
768
							<tr>
769
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td>
770
								<td width="78%" class="vtable">
771
									<?=gettext("From");?>
772
									<input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2"
773 a1dccfc6 Colin Fleming
										value="<?=htmlspecialchars($pconfig['latencylow']);?>" />
774 0b844b73 Renato Botelho
									<?=gettext("To");?>
775
									<input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2"
776 a1dccfc6 Colin Fleming
										value="<?=htmlspecialchars($pconfig['latencyhigh']);?>" />
777 8cd558b6 ayvis
									<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>
778 0b844b73 Renato Botelho
								</td>
779
							</tr>
780
							<tr>
781
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td>
782
								<td width="78%" class="vtable">
783
									<?=gettext("From");?>
784
									<input name="losslow" type="text" class="formfld unknown" id="losslow" size="2"
785 a1dccfc6 Colin Fleming
										value="<?=htmlspecialchars($pconfig['losslow']);?>" />
786 0b844b73 Renato Botelho
									<?=gettext("To");?>
787
									<input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2"
788 a1dccfc6 Colin Fleming
										value="<?=htmlspecialchars($pconfig['losshigh']);?>" />
789
									<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>
790 0b844b73 Renato Botelho
								</td>
791
							</tr>
792
							<tr>
793 490cd438 Phil Davis
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Probe Interval");?></td>
794 0b844b73 Renato Botelho
								<td width="78%" class="vtable">
795
									<input name="interval" type="text" class="formfld unknown" id="interval" size="2"
796 ec5c28cd N0YB
										value="<?=htmlspecialchars($pconfig['interval']);?>" onchange="interval_change(this)" />
797 8cd558b6 ayvis
									<br /><span class="vexpl">
798
										<?=gettext(sprintf("How often that an ICMP probe will be sent in seconds. Default is %d.", $apinger_default['interval']));?><br /><br />
799 490cd438 Phil Davis
										<?=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.");?>
800 0b844b73 Renato Botelho
									</span>
801
								</td>
802
							</tr>
803
							<tr>
804
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td>
805
								<td width="78%" class="vtable">
806
									<input name="down" type="text" class="formfld unknown" id="down" size="2"
807 a1dccfc6 Colin Fleming
										value="<?=htmlspecialchars($pconfig['down']);?>" />
808 8cd558b6 ayvis
									<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>
809 0b844b73 Renato Botelho
								</td>
810
							</tr>
811 3c6787ed N0YB
							<tr>
812
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Average Delay Replies Qty");?></td>
813
								<td width="78%" class="vtable">
814
									<input name="avg_delay_samples" type="text" class="formfld unknown" id="avg_delay_samples" size="2"
815
										value="<?=htmlspecialchars($pconfig['avg_delay_samples']);?>" onchange="samples_change(document.iform.avg_delay_samples_calculated, this)" /> 
816
									<input name="avg_delay_samples_calculated" type="checkbox" id="avg_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_delay_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_delay_samples)" />
817
										<?=gettext("Use calculated value."); ?>
818 8cd558b6 ayvis
									<br /><span class="vexpl"><?=gettext(sprintf("How many replies should be used to compute average delay for controlling \"delay\" alarms?  Default is %d.", $apinger_default['avg_delay_samples']));?><br /><br /></span>
819 3c6787ed N0YB
								</td>
820
							</tr>
821
							<tr>
822
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Average Packet Loss Probes Qty");?></td>
823
								<td width="78%" class="vtable">
824
									<input name="avg_loss_samples" type="text" class="formfld unknown" id="avg_loss_samples" size="2"
825
										value="<?=htmlspecialchars($pconfig['avg_loss_samples']);?>" onchange="samples_change(document.iform.avg_loss_samples_calculated, this)" />
826
									<input name="avg_loss_samples_calculated" type="checkbox" id="avg_loss_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_loss_samples)" />
827
										<?=gettext("Use calculated value."); ?>
828 8cd558b6 ayvis
									<br /><span class="vexpl"><?=gettext(sprintf("How many probes should be useds to compute average packet loss?  Default is %d.", $apinger_default['avg_loss_samples']));?><br /><br /></span>
829 3c6787ed N0YB
								</td>
830
							</tr>
831
							<tr>
832
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Lost Probe Delay");?></td>
833
								<td width="78%" class="vtable">
834
									<input name="avg_loss_delay_samples" type="text" class="formfld unknown" id="avg_loss_delay_samples" size="2"
835
										value="<?=htmlspecialchars($pconfig['avg_loss_delay_samples']);?>" onchange="samples_change(document.iform.avg_loss_delay_samples_calculated, this)" />
836
									<input name="avg_loss_delay_samples_calculated" type="checkbox" id="avg_loss_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_delay_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_loss_delay_samples)" />
837
										<?=gettext("Use calculated value."); ?>
838 8cd558b6 ayvis
									<br /><span class="vexpl"><?=gettext(sprintf("The delay (in qty of probe samples) after which loss is computed.  Without this, delays longer than the probe interval would be treated as packet loss.  Default is %d.", $apinger_default['avg_loss_delay_samples']));?><br /><br /></span>
839 3c6787ed N0YB
								</td>
840
							</tr>
841 0b844b73 Renato Botelho
							<tr>
842
								<td colspan="2">
843 8cd558b6 ayvis
									<?= 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 />
844
									<?= 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 />
845 0b844b73 Renato Botelho
								</td>
846
							</tr>
847
						</table>
848
					</div>
849 ec9bb09f jim-p
				</td>
850
			</tr>
851 f7203985 Ermal
			<tr>
852 0b844b73 Renato Botelho
				<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
853 ec9bb09f jim-p
				<td width="78%" class="vtable">
854 a1dccfc6 Colin Fleming
					<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
855 8cd558b6 ayvis
					<br /><span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span>
856 ec9bb09f jim-p
				</td>
857
			</tr>
858
			<tr>
859 0b844b73 Renato Botelho
				<td width="22%" valign="top">&nbsp;</td>
860
				<td width="78%">
861 62424bdb Renato Botelho
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change()" />
862
					<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
863 0b844b73 Renato Botelho
					<?php if (isset($id) && $a_gateways[$id]): ?>
864 a1dccfc6 Colin Fleming
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
865 0b844b73 Renato Botelho
					<?php endif; ?>
866 ec9bb09f jim-p
				</td>
867
			</tr>
868 0b844b73 Renato Botelho
		</table>
869
	</form>
870 d173230c Seth Mos
<?php include("fend.inc"); ?>
871 a1dccfc6 Colin Fleming
<script type="text/javascript">
872
//<![CDATA[
873 33c06ef7 Ermal
monitor_change();
874 3c6787ed N0YB
calculate_state_change();
875 a1dccfc6 Colin Fleming
//]]>
876 d173230c Seth Mos
</script>
877
</body>
878 60037e00 bcyrill
</html>