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