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