Commit 3365c6e5 authored by Franco Fichtner's avatar Franco Fichtner

src: configure ra send behaviour; closes #945

(cherry picked from commit 7077a7c7)
(cherry picked from commit cd3a1b3e)
(cherry picked from commit 5faaa75a)
(cherry picked from commit ef34f1a2)
(cherry picked from commit 9f6112a5)
(cherry picked from commit 95cb2f9d)
(cherry picked from commit 8d10efac)
parent ac374ea0
......@@ -165,9 +165,9 @@ function services_radvd_configure($blacklist = array())
$radvdconf .= "# Generated for DHCPv6 Server $dhcpv6if\n";
$radvdconf .= "interface {$realif} {\n";
$radvdconf .= "\tAdvSendAdvert on;\n";
$radvdconf .= "\tMinRtrAdvInterval 225;\n";
$radvdconf .= "\tMaxRtrAdvInterval 300;\n";
$radvdconf .= sprintf("\tAdvSendAdvert %s;\n", !empty($dhcpv6ifconf['ranosend']) ? 'off' : 'on');
$radvdconf .= sprintf("\tMinRtrAdvInterval %s;\n", !empty($dhcpv6ifconf['ramininterval']) ? $dhcpv6ifconf['ramininterval'] : '200');
$radvdconf .= sprintf("\tMaxRtrAdvInterval %s;\n", !empty($dhcpv6ifconf['ramaxinterval']) ? $dhcpv6ifconf['ramaxinterval'] : '600');
$mtu = legacy_interface_stats($realif)['mtu'];
if (is_numeric($mtu)) {
$radvdconf .= "\tAdvLinkMTU {$mtu};\n";
......
......@@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
$pconfig = array();
$config_copy_fieldsnames = array('ramode', 'rapriority', 'rainterface', 'radomainsearchlist', 'subnets');
$config_copy_fieldsnames = array('ramode', 'rapriority', 'rainterface', 'ramininterval', 'ramaxinterval', 'radomainsearchlist', 'subnets');
foreach ($config_copy_fieldsnames as $fieldname) {
if (isset($config['dhcpdv6'][$if][$fieldname])) {
$pconfig[$fieldname] = $config['dhcpdv6'][$if][$fieldname];
......@@ -56,6 +56,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
// boolean
$pconfig['rasamednsasdhcp6'] = isset($config['dhcpdv6'][$if]['rasamednsasdhcp6']);
if (empty($config['dhcpdv6'][$if]['ranosend'])) {
$pconfig['rasend'] = true;
}
// defaults
if (empty($pconfig['ramininterval'])) {
$pconfig['ramininterval'] = 200;
}
if (empty($pconfig['ramaxinterval'])) {
$pconfig['ramaxinterval'] = 600;
}
// arrays
$pconfig['radns1'] = !empty($config['dhcpdv6'][$if]['radnsserver'][0]) ? $config['dhcpdv6'][$if]['radnsserver'][0] : null;
$pconfig['radns2'] = !empty($config['dhcpdv6'][$if]['radnsserver'][1]) ? $config['dhcpdv6'][$if]['radnsserver'][1] : null;
......@@ -95,15 +107,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
if (!is_numericint($pconfig['ramaxinterval']) || $pconfig['ramaxinterval'] < 4 || $pconfig['ramaxinterval'] > 1800) {
$input_errors[] = gettext(sprintf('Maximum interval must be between %s and %s seconds.', 4, 1800));
// chain this validation, we use the former value for calculation */
} elseif (!is_numericint($pconfig['ramininterval']) || $pconfig['ramininterval'] < 3 || $pconfig['ramininterval'] > intval($pconfig['ramaxinterval'] * 0.75)) {
$input_errors[] = gettext(sprintf('Minimum interval must be between %s and %s seconds.', 3, intval($pconfig['ramaxinterval'] * 0.75)));
}
if (count($input_errors) == 0) {
if (!is_array($config['dhcpdv6'][$if])) {
$config['dhcpdv6'][$if] = array();
}
$config['dhcpdv6'][$if]['ramode'] = $pconfig['ramode'];
$config['dhcpdv6'][$if]['rapriority'] = $pconfig['rapriority'];
$config['dhcpdv6'][$if]['rainterface'] = $pconfig['rainterface'];
$config['dhcpdv6'][$if]['ramininterval'] = $pconfig['ramininterval'];
$config['dhcpdv6'][$if]['ramaxinterval'] = $pconfig['ramaxinterval'];
# flipped in GUI on purpose
if (empty($pconfig['rasend'])) {
$config['dhcpdv6'][$if]['ranosend'] = true;
} elseif (isset($config['dhcpdv6'][$if]['ranosend'])) {
unset($config['dhcpdv6'][$if]['ranosend']);
}
$config['dhcpdv6'][$if]['radomainsearchlist'] = $pconfig['radomainsearchlist'];
$config['dhcpdv6'][$if]['radnsserver'] = array();
......@@ -123,9 +150,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
write_config();
services_radvd_configure();
get_std_save_message();
header("Location: services_router_advertisements.php?if={$if}");
exit;
$savemsg = get_std_save_message();
}
}
......@@ -353,6 +378,33 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_rasend" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('RA Sending') ?></td>
<td>
<input id="rasend" name="rasend" type="checkbox" value="yes" <?= !empty($pconfig['rasend']) ? 'checked="checked"' : '' ?>/>
<div class="hidden" for="help_for_rasend">
<?= gettext('Enable the periodic sending of router advertisements and responding to router solicitations.') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_ramininterval" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Minimum Interval') ?></td>
<td>
<input name="ramininterval" type="text" id="ramininterval" size="28" value="<?=$pconfig['ramininterval'];?>" />
<div class="hidden" for="help_for_ramininterval">
<?= gettext('The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds.') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_ramaxinterval" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext('Maximum Interval') ?></td>
<td>
<input name="ramaxinterval" type="text" id="ramaxinterval" size="28" value="<?=$pconfig['ramaxinterval'];?>" />
<div class="hidden" for="help_for_ramaxinterval">
<?= gettext('The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds.') ?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment