1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
system_gateways_edit.php
|
5
|
part of pfSense (http://pfsense.com)
|
6
|
|
7
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_MODULE: routing
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-system-gateways-editgateway
|
37
|
##|*NAME=System: Gateways: Edit Gateway page
|
38
|
##|*DESCR=Allow access to the 'System: Gateways: Edit Gateway' page.
|
39
|
##|*MATCH=system_gateways_edit.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require("pkg-utils.inc");
|
44
|
|
45
|
$a_gateways = return_gateways_array(true);
|
46
|
$a_gateways_arr = array();
|
47
|
foreach($a_gateways as $gw) {
|
48
|
$a_gateways_arr[] = $gw;
|
49
|
}
|
50
|
$a_gateways = $a_gateways_arr;
|
51
|
|
52
|
if (!is_array($config['gateways']['gateway_item']))
|
53
|
$config['gateways']['gateway_item'] = array();
|
54
|
|
55
|
$a_gateway_item = &$config['gateways']['gateway_item'];
|
56
|
|
57
|
$id = $_GET['id'];
|
58
|
if (isset($_POST['id']))
|
59
|
$id = $_POST['id'];
|
60
|
|
61
|
if (isset($_GET['dup'])) {
|
62
|
$id = $_GET['dup'];
|
63
|
}
|
64
|
|
65
|
if (isset($id) && $a_gateways[$id]) {
|
66
|
$pconfig = array();
|
67
|
$pconfig['name'] = $a_gateways[$id]['name'];
|
68
|
$pconfig['weight'] = $a_gateways[$id]['weight'];
|
69
|
$pconfig['interval'] = $a_gateways[$id]['interval'];
|
70
|
$pconfig['interface'] = $a_gateways[$id]['interface'];
|
71
|
$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
|
72
|
$pconfig['ipprotocol'] = $a_gateways[$id]['ipprotocol'];
|
73
|
if (isset($a_gateways[$id]['dynamic']))
|
74
|
$pconfig['dynamic'] = true;
|
75
|
$pconfig['gateway'] = $a_gateways[$id]['gateway'];
|
76
|
$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
|
77
|
$pconfig['latencylow'] = $a_gateway_item[$id]['latencylow'];
|
78
|
$pconfig['latencyhigh'] = $a_gateway_item[$id]['latencyhigh'];
|
79
|
$pconfig['losslow'] = $a_gateway_item[$id]['losslow'];
|
80
|
$pconfig['losshigh'] = $a_gateway_item[$id]['losshigh'];
|
81
|
$pconfig['down'] = $a_gateway_item[$id]['down'];
|
82
|
$pconfig['monitor'] = $a_gateways[$id]['monitor'];
|
83
|
$pconfig['monitor_disable'] = isset($a_gateways[$id]['monitor_disable']);
|
84
|
$pconfig['descr'] = $a_gateways[$id]['descr'];
|
85
|
$pconfig['attribute'] = $a_gateways[$id]['attribute'];
|
86
|
}
|
87
|
|
88
|
if (isset($_GET['dup'])) {
|
89
|
unset($id);
|
90
|
unset($pconfig['attribute']);
|
91
|
}
|
92
|
|
93
|
if ($_POST) {
|
94
|
|
95
|
unset($input_errors);
|
96
|
|
97
|
/* input validation */
|
98
|
$reqdfields = explode(" ", "name interface");
|
99
|
$reqdfieldsn = array(gettext("Name"), gettext("Interface"));
|
100
|
|
101
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
102
|
|
103
|
if (! isset($_POST['name'])) {
|
104
|
$input_errors[] = "A valid gateway name must be specified.";
|
105
|
}
|
106
|
if (! is_validaliasname($_POST['name'])) {
|
107
|
$input_errors[] = gettext("The gateway name must not contain invalid characters.");
|
108
|
}
|
109
|
/* skip system gateways which have been automatically added */
|
110
|
if (($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($_POST['attribute'] !== "system")) && ($_POST['gateway'] != "dynamic")) {
|
111
|
$input_errors[] = gettext("A valid gateway IP address must be specified.");
|
112
|
}
|
113
|
|
114
|
if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && !$_REQUEST['isAjax']) {
|
115
|
if(is_ipaddrv4($_POST['gateway'])) {
|
116
|
$parent_ip = get_interface_ip($_POST['interface']);
|
117
|
$parent_sn = get_interface_subnet($_POST['interface']);
|
118
|
if(empty($parent_ip) || empty($parent_sn)) {
|
119
|
$input_errors[] = gettext("You can not use a IPv6 Gateway Address on a IPv4 only interface.");
|
120
|
} else {
|
121
|
$subnet = gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn;
|
122
|
if(!ip_in_subnet($_POST['gateway'], $subnet))
|
123
|
$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within the chosen interface's subnet '%2\$s'."), $_POST['gateway'],$subnet);
|
124
|
}
|
125
|
}
|
126
|
if(is_ipaddrv6($_POST['gateway'])) {
|
127
|
/* do not do a subnet match on a link local address, it's valid */
|
128
|
if(! preg_match("/fe80::/", $_POST['gateway'])) {
|
129
|
$parent_ip = get_interface_ipv6($_POST['interface']);
|
130
|
$parent_sn = get_interface_subnetv6($_POST['interface']);
|
131
|
if(empty($parent_ip) || empty($parent_sn)) {
|
132
|
$input_errors[] = gettext("You can not use a IPv4 Gateway Address on a IPv6 only interface.");
|
133
|
} else {
|
134
|
$subnet = gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn;
|
135
|
if(!ip_in_subnet($_POST['gateway'], $subnet))
|
136
|
$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within the chosen interface's subnet '%2\$s'."), $_POST['gateway'],$subnet);
|
137
|
}
|
138
|
}
|
139
|
}
|
140
|
|
141
|
if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
|
142
|
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
|
143
|
$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
|
144
|
}
|
145
|
if (!empty($config['interfaces'][$_POST['interface']]['ipaddrv6'])) {
|
146
|
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddrv6']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
|
147
|
$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv6 configuration.");
|
148
|
}
|
149
|
}
|
150
|
if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
|
151
|
$input_errors[] = gettext("A valid monitor IP address must be specified.");
|
152
|
}
|
153
|
if (($_POST['monitor'] <> "") && is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
|
154
|
/* check if we can figure out the address family */
|
155
|
if(is_ipaddrv6($_POST['monitor']) && (interface_has_gatewayv6($_POST['interface'])) && $_POST['gateway'] != "dynamic") {
|
156
|
$input_errors[] = gettext("The IPv6 monitor address '{$_POST['monitor']}' can not be used with a IPv4 gateway'.");
|
157
|
}
|
158
|
if(is_ipaddrv4($_POST['monitor']) && (interface_has_gateway($_POST['interface'])) && $_POST['gateway'] != "dynamic") {
|
159
|
$input_errors[] = gettext("The IPv6 monitor address '{$_POST['monitor']}' can not be used with a IPv4 gateway'.");
|
160
|
}
|
161
|
}
|
162
|
|
163
|
if (isset($_POST['name'])) {
|
164
|
/* check for overlaps */
|
165
|
foreach ($a_gateways as $gateway) {
|
166
|
if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
|
167
|
if ($gateway['name'] != $_POST['name'])
|
168
|
$input_errors[] = gettext("Changing name on a gateway is not allowed.");
|
169
|
continue;
|
170
|
}
|
171
|
if($_POST['name'] <> "") {
|
172
|
if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] !== "system")) {
|
173
|
$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
|
174
|
break;
|
175
|
}
|
176
|
}
|
177
|
if(is_ipaddr($_POST['gateway'])) {
|
178
|
if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] !== "system")) {
|
179
|
$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
|
180
|
break;
|
181
|
}
|
182
|
}
|
183
|
if(is_ipaddr($_POST['monitor'])) {
|
184
|
if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] !== "system")) {
|
185
|
$input_errors[] = sprintf(gettext('The monitor IP address "%s" is already in use. You must choose a different monitor IP.'), $_POST['monitor']);
|
186
|
break;
|
187
|
}
|
188
|
}
|
189
|
}
|
190
|
}
|
191
|
|
192
|
/* input validation */
|
193
|
if($_POST['latencylow']) {
|
194
|
if (! is_numeric($_POST['latencylow'])) {
|
195
|
$input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
|
196
|
}
|
197
|
}
|
198
|
|
199
|
if($_POST['latencyhigh']) {
|
200
|
if (! is_numeric($_POST['latencyhigh'])) {
|
201
|
$input_errors[] = gettext("The high latency watermark needs to be a numeric value.");
|
202
|
}
|
203
|
}
|
204
|
if($_POST['losslow']) {
|
205
|
if (! is_numeric($_POST['losslow'])) {
|
206
|
$input_errors[] = gettext("The low loss watermark needs to be a numeric value.");
|
207
|
}
|
208
|
}
|
209
|
if($_POST['losshigh']) {
|
210
|
if (! is_numeric($_POST['losshigh'])) {
|
211
|
$input_errors[] = gettext("The high loss watermark needs to be a numeric value.");
|
212
|
}
|
213
|
}
|
214
|
|
215
|
if(($_POST['latencylow']) && ($_POST['latencyhigh'])){
|
216
|
if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
|
217
|
$input_errors[] = gettext("The High latency watermark needs to be higher then the low latency watermark");
|
218
|
}
|
219
|
}
|
220
|
|
221
|
if(($_POST['losslow']) && ($_POST['losshigh'])){
|
222
|
if($_POST['losslow'] > $_POST['losshigh']) {
|
223
|
$input_errors[] = gettext("The High packet loss watermark needs to be higher then the low packet loss watermark");
|
224
|
}
|
225
|
}
|
226
|
if($_POST['down']) {
|
227
|
if (! is_numeric($_POST['down']) || $_POST['down'] < 1) {
|
228
|
$input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
|
229
|
}
|
230
|
}
|
231
|
|
232
|
if (!$input_errors) {
|
233
|
$reloadif = "";
|
234
|
$gateway = array();
|
235
|
|
236
|
if (empty($_POST['interface']))
|
237
|
$gateway['interface'] = $pconfig['friendlyiface'];
|
238
|
else
|
239
|
$gateway['interface'] = $_POST['interface'];
|
240
|
if (is_ipaddr($_POST['gateway']))
|
241
|
$gateway['gateway'] = $_POST['gateway'];
|
242
|
else
|
243
|
$gateway['gateway'] = "dynamic";
|
244
|
$gateway['name'] = $_POST['name'];
|
245
|
$gateway['weight'] = $_POST['weight'];
|
246
|
$gateway['ipprotocol'] = $_POST['ipprotocol'];
|
247
|
$gateway['interval'] = $_POST['interval'];
|
248
|
$gateway['descr'] = $_POST['descr'];
|
249
|
if ($_POST['monitor_disable'] == "yes")
|
250
|
$gateway['monitor_disable'] = true;
|
251
|
else if (is_ipaddr($_POST['monitor']))
|
252
|
$gateway['monitor'] = $_POST['monitor'];
|
253
|
|
254
|
if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
|
255
|
$i = 0;
|
256
|
/* remove the default gateway bits for all gateways with the same address family */
|
257
|
foreach($a_gateway_item as $gw) {
|
258
|
if(is_ipaddrv4($gateway['gateway']) && is_ipaddrv4($gw['gateway'])) {
|
259
|
unset($config['gateways']['gateway_item'][$i]['defaultgw']);
|
260
|
if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
|
261
|
$reloadif = $gw['interface'];
|
262
|
}
|
263
|
if(is_ipaddrv6($gateway['gateway']) && is_ipaddrv6($gw['gateway'])) {
|
264
|
unset($config['gateways']['gateway_item'][$i]['defaultgw']);
|
265
|
if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
|
266
|
$reloadif = $gw['interface'];
|
267
|
}
|
268
|
$i++;
|
269
|
}
|
270
|
$gateway['defaultgw'] = true;
|
271
|
}
|
272
|
|
273
|
if ($_POST['latencylow'])
|
274
|
$gateway['latencylow'] = $_POST['latencylow'];
|
275
|
if ($_POST['latencyhigh'])
|
276
|
$gateway['latencyhigh'] = $_POST['latencyhigh'];
|
277
|
if ($_POST['losslow'])
|
278
|
$gateway['losslow'] = $_POST['losslow'];
|
279
|
if ($_POST['losshigh'])
|
280
|
$gateway['losshigh'] = $_POST['losshigh'];
|
281
|
if ($_POST['down'])
|
282
|
$gateway['down'] = $_POST['down'];
|
283
|
|
284
|
/* when saving the manual gateway we use the attribute which has the corresponding id */
|
285
|
if (isset($id) && $a_gateway_item[$id])
|
286
|
$a_gateway_item[$id] = $gateway;
|
287
|
else
|
288
|
$a_gateway_item[] = $gateway;
|
289
|
|
290
|
mark_subsystem_dirty('staticroutes');
|
291
|
|
292
|
write_config();
|
293
|
|
294
|
if($_REQUEST['isAjax']) {
|
295
|
echo $_POST['name'];
|
296
|
exit;
|
297
|
} else if (!empty($reloadif))
|
298
|
send_event("interface reconfigure {$reloadif}");
|
299
|
|
300
|
header("Location: system_gateways.php");
|
301
|
exit;
|
302
|
} else {
|
303
|
if ($_REQUEST['isAjax']) {
|
304
|
header("HTTP/1.0 500 Internal Server Error");
|
305
|
header("Content-type: text/plain");
|
306
|
foreach ($input_errors as $error) {
|
307
|
echo("$error\n");
|
308
|
}
|
309
|
exit;
|
310
|
}
|
311
|
|
312
|
$pconfig = $_POST;
|
313
|
if (empty($_POST['friendlyiface']))
|
314
|
$pconfig['friendlyiface'] = $_POST['interface'];
|
315
|
}
|
316
|
}
|
317
|
|
318
|
|
319
|
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway"));
|
320
|
$statusurl = "status_gateways.php";
|
321
|
|
322
|
include("head.inc");
|
323
|
|
324
|
?>
|
325
|
|
326
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
327
|
<?php include("fbegin.inc"); ?>
|
328
|
<script language="JavaScript">
|
329
|
function show_advanced_gateway() {
|
330
|
document.getElementById("showadvgatewaybox").innerHTML='';
|
331
|
aodiv = document.getElementById('showgatewayadv');
|
332
|
aodiv.style.display = "block";
|
333
|
}
|
334
|
function monitor_change() {
|
335
|
document.iform.monitor.disabled = document.iform.monitor_disable.checked;
|
336
|
}
|
337
|
</script>
|
338
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
339
|
<form action="system_gateways_edit.php" method="post" name="iform" id="iform">
|
340
|
<?php
|
341
|
|
342
|
/* If this is a system gateway we need this var */
|
343
|
if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
|
344
|
echo "<input type='hidden' name='attribute' id='attribute' value='{$pconfig['attribute']}' >\n";
|
345
|
}
|
346
|
echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value='{$pconfig['friendlyiface']}' >\n";
|
347
|
?>
|
348
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
349
|
<tr>
|
350
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit gateway"); ?></td>
|
351
|
</tr>
|
352
|
<tr>
|
353
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
|
354
|
<td width="78%" class="vtable">
|
355
|
<select name='interface' class='formselect' >
|
356
|
|
357
|
<?php
|
358
|
$interfaces = get_configured_interface_with_descr(false, true);
|
359
|
foreach ($interfaces as $iface => $ifacename) {
|
360
|
echo "<option value=\"{$iface}\"";
|
361
|
if ($iface == $pconfig['friendlyiface'])
|
362
|
echo " selected";
|
363
|
echo ">" . htmlspecialchars($ifacename) . "</option>";
|
364
|
}
|
365
|
if (is_package_installed("openbgpd") == 1) {
|
366
|
echo "<option value=\"bgpd\"";
|
367
|
if ($pconfig['interface'] == "bgpd")
|
368
|
echo " selected";
|
369
|
echo ">" . gettext("Use BGPD") . "</option>";
|
370
|
}
|
371
|
?>
|
372
|
</select> <br>
|
373
|
<span class="vexpl"><?=gettext("Choose which interface this gateway applies to."); ?></span></td>
|
374
|
</tr>
|
375
|
<tr>
|
376
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Address Family"); ?></td>
|
377
|
<td width="78%" class="vtable">
|
378
|
<select name='ipprotocol' class='formselect' >
|
379
|
<?php
|
380
|
$options = array("inet" => "IPv4", "inet6" => "IPv6");
|
381
|
foreach ($options as $name => $string) {
|
382
|
echo "<option value=\"{$name}\"";
|
383
|
if ($name == $pconfig['ipprotocol'])
|
384
|
echo " selected";
|
385
|
echo ">" . htmlspecialchars($string) . "</option>\n";
|
386
|
}
|
387
|
?>
|
388
|
</select> <br>
|
389
|
<span class="vexpl"><?=gettext("Choose the Internet Protocol this gateway uses."); ?></span></td>
|
390
|
<tr>
|
391
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td>
|
392
|
<td width="78%" class="vtable">
|
393
|
<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>">
|
394
|
<br> <span class="vexpl"><?=gettext("Gateway name"); ?></span></td>
|
395
|
</tr>
|
396
|
<tr>
|
397
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
|
398
|
<td width="78%" class="vtable">
|
399
|
<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo $pconfig['gateway']; ?>">
|
400
|
<br> <span class="vexpl"><?=gettext("Gateway IP address"); ?></span></td>
|
401
|
</tr>
|
402
|
<tr>
|
403
|
<td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
|
404
|
<td width="78%" class="vtable">
|
405
|
<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked"; ?> />
|
406
|
<strong><?=gettext("Default Gateway"); ?></strong><br />
|
407
|
<?=gettext("This will select the above gateway as the default gateway"); ?>
|
408
|
</td>
|
409
|
</tr>
|
410
|
<tr>
|
411
|
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Gateway Monitoring"); ?></td>
|
412
|
<td width="78%" class="vtable">
|
413
|
<input name="monitor_disable" type="checkbox" id="monitor_disable" value="yes" <?php if ($pconfig['monitor_disable'] == true) echo "checked"; ?> onClick="monitor_change()" />
|
414
|
<strong><?=gettext("Disable Gateway Monitoring"); ?></strong><br />
|
415
|
<?=gettext("This will consider this gateway as always being up"); ?>
|
416
|
</td>
|
417
|
</tr>
|
418
|
<tr>
|
419
|
<td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
|
420
|
<td width="78%" class="vtable">
|
421
|
<?php
|
422
|
if ($pconfig['gateway'] == $pconfig['monitor'])
|
423
|
$monitor = "";
|
424
|
else
|
425
|
$monitor = htmlspecialchars($pconfig['monitor']);
|
426
|
?>
|
427
|
<input name="monitor" type="text" id="monitor" value="<?php echo $monitor; ?>" size="28" />
|
428
|
<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
|
429
|
<?=gettext("Enter an alternative address here to be used to monitor the link. This is used for the " .
|
430
|
"quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond " .
|
431
|
"to ICMP echo requests (pings)"); ?>.</strong>
|
432
|
<br />
|
433
|
</td>
|
434
|
</tr>
|
435
|
<tr>
|
436
|
<td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
|
437
|
<td width="78%" class="vtable">
|
438
|
<?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'])); ?>
|
439
|
<div id="showadvgatewaybox" <? if ($showbutton) echo "style='display:none'"; ?>>
|
440
|
<input type="button" onClick="show_advanced_gateway()" value="Advanced"></input> - Show advanced option</a>
|
441
|
</div>
|
442
|
<div id="showgatewayadv" <? if (!$showbutton) echo "style='display:none'"; ?>>
|
443
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
|
444
|
<tr>
|
445
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
|
446
|
<td width="78%" class="vtable">
|
447
|
<select name='weight' class='formfldselect' id='weight'>
|
448
|
<?php
|
449
|
for ($i = 1; $i < 6; $i++) {
|
450
|
$selected = "";
|
451
|
if ($pconfig['weight'] == $i)
|
452
|
$selected = "selected";
|
453
|
echo "<option value='{$i}' {$selected} >{$i}</option>";
|
454
|
}
|
455
|
?>
|
456
|
</select>
|
457
|
<br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br />
|
458
|
</td>
|
459
|
</tr>
|
460
|
<tr>
|
461
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td>
|
462
|
<td width="78%" class="vtable">
|
463
|
<?=gettext("From");?>
|
464
|
<input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2"
|
465
|
value="<?=htmlspecialchars($pconfig['latencylow']);?>">
|
466
|
<?=gettext("To");?>
|
467
|
<input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2"
|
468
|
value="<?=htmlspecialchars($pconfig['latencyhigh']);?>">
|
469
|
<br> <span class="vexpl"><?=gettext("These define the low and high water marks for latency in milliseconds. Default is 100/200.");?></span></td>
|
470
|
</td>
|
471
|
</tr>
|
472
|
<tr>
|
473
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td>
|
474
|
<td width="78%" class="vtable">
|
475
|
<?=gettext("From");?>
|
476
|
<input name="losslow" type="text" class="formfld unknown" id="losslow" size="2"
|
477
|
value="<?=htmlspecialchars($pconfig['losslow']);?>">
|
478
|
<?=gettext("To");?>
|
479
|
<input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2"
|
480
|
value="<?=htmlspecialchars($pconfig['losshigh']);?>">
|
481
|
<br> <span class="vexpl"><?=gettext("These define the low and high water marks for packet loss in %. Default is 10/20.");?></span></td>
|
482
|
</td>
|
483
|
</tr>
|
484
|
<tr>
|
485
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Frequency Probe");?></td>
|
486
|
<td width="78%" class="vtable">
|
487
|
<input name="interval" type="text" class="formfld unknown" id="interval" size="2"
|
488
|
value="<?=htmlspecialchars($pconfig['interval']);?>">
|
489
|
<br><span class="vexpl">
|
490
|
<?=gettext("This defines how often that an icmp probe will be sent in seconds. Default is 1.");?><br/><br/>
|
491
|
<?=gettext("NOTE: The quality graph is averaged over seconds, not intervals, so as the frequency probe is increased the accuracy of the quality graph is decreased.");?>
|
492
|
</span></td>
|
493
|
</td>
|
494
|
</tr>
|
495
|
<tr>
|
496
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td>
|
497
|
<td width="78%" class="vtable">
|
498
|
<input name="down" type="text" class="formfld unknown" id="down" size="2"
|
499
|
value="<?=htmlspecialchars($pconfig['down']);?>">
|
500
|
<br> <span class="vexpl"><?=gettext("This defines the number of bad probes before the alarm will fire. Default is 10.");?></span></td>
|
501
|
</td>
|
502
|
</tr>
|
503
|
<tr>
|
504
|
<td colspan="2">
|
505
|
<?= gettext("NOTE: The total time before a gateway is down is the product of the Frequency Probe and the Down fields. By default this is 1*10=10 seconds."); ?><br/>
|
506
|
<?php if (is_numeric($pconfig['interval']) || is_numeric($pconfig['down'])) {
|
507
|
echo "<br/>";
|
508
|
$interval = is_numeric($pconfig['interval']) ? $pconfig['interval'] : 1;
|
509
|
$down = is_numeric($pconfig['down']) ? $pconfig['down'] : 10;
|
510
|
echo gettext(sprintf("With the current configuration, the total time before this gateway would be considered down would be: %d*%d=%d seconds.", $interval, $down, $interval*$down));
|
511
|
} ?>
|
512
|
</td>
|
513
|
</tr>
|
514
|
</table>
|
515
|
</div>
|
516
|
</td>
|
517
|
</tr>
|
518
|
<tr>
|
519
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
520
|
<td width="78%" class="vtable">
|
521
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
522
|
<br> <span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span></td>
|
523
|
</tr>
|
524
|
<tr>
|
525
|
<td width="22%" valign="top"> </td>
|
526
|
<td width="78%">
|
527
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>"> <input type="button" value="<?=gettext("Cancel");?>" class="formbtn" onclick="history.back()">
|
528
|
<?php if (isset($id) && $a_gateways[$id]): ?>
|
529
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
|
530
|
<?php endif; ?>
|
531
|
</td>
|
532
|
</tr>
|
533
|
</table>
|
534
|
</form>
|
535
|
<?php include("fend.inc"); ?>
|
536
|
<script language="JavaScript">
|
537
|
monitor_change();
|
538
|
</script>
|
539
|
</body>
|
540
|
</html>
|