--- services_router_advertisements.php.orig 2013-09-12 00:20:11.000000000 +0200 +++ services_router_advertisements.php 2014-06-01 03:40:58.757814500 +0200 @@ -98,13 +98,16 @@ $pconfig['radomainsearchlist'] = $config['dhcpdv6'][$if]['radomainsearchlist']; list($pconfig['radns1'],$pconfig['radns2']) = $config['dhcpdv6'][$if]['radnsserver']; $pconfig['rasamednsasdhcp6'] = isset($config['dhcpdv6'][$if]['rasamednsasdhcp6']); $pconfig['subnets'] = $config['dhcpdv6'][$if]['subnets']['item']; + $pconfig['routes'] = $config['dhcpdv6'][$if]['routes']['item']; } if (!is_array($pconfig['subnets'])) $pconfig['subnets'] = array(); +if (!is_array($pconfig['routes'])) + $pconfig['routes'] = array(); $advertise_modes = array("disabled" => "Disabled", "router" => "Router Only", "unmanaged" => "Unmanaged", "managed" => "Managed", @@ -116,10 +119,15 @@ $subnets_help = gettext("Subnets are specified in CIDR format. " . "Select the CIDR mask that pertains to each entry. " . "/128 specifies a single IPv6 host; /64 specifies a normal IPv6 network; etc. " . "If no subnets are specified here, the Router Advertisement (RA) Daemon will advertise to the subnet to which the router's interface is assigned."); + +$routes_help = gettext("Routes are specified in CIDR format. " . + "Enter subnets to which routes should be advertised, and their priority. " . + "If you need a default route, specify it with ::/0 here. " . + "If no routes are specified here, the Router Advertisement (RA) Daemon will advertise only the default route."); if ($_POST) { unset($input_errors); $pconfig = $_POST; @@ -142,11 +150,34 @@ $pconfig['subnets'][] = $address . "/" . $bits; if (!is_ipaddrv6($address)) $input_errors[] = sprintf(gettext("An invalid subnet or alias was specified. [%s/%s]"), $address, $bits); } } + + $pconfig['routes'] = array(); + for ($x = 0; $x < 5000; $x += 1) { + $address = trim($_POST['route_address' . $x]); + if ($address === "") + continue; + + $bits = trim($_POST['route_bits' . $x]); + if ($bits === "") + $bits = "128"; + + $priority = trim($_POST['route_priority' . $x]); + if ($priority === "") + $priority = "medium"; + if (is_alias($address)) { + $pconfig['routes'][] = array('destination' => $address); + } else { + $pconfig['routes'][] = array('destination' => $address . "/" . $bits, 'priority' => $priority); + if (!is_ipaddrv6($address)) + $input_errors[] = sprintf(gettext("An invalid route was specified. [%s/%s]"), $address, $bits); + } + } + if (($_POST['radns1'] && !is_ipaddrv6($_POST['radns1'])) || ($_POST['radns2'] && !is_ipaddrv6($_POST['radns2']))) $input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS servers."); if ($_POST['radomainsearchlist']) { $domain_array=preg_split("/[ ;]+/",$_POST['radomainsearchlist']); foreach ($domain_array as $curdomain) { @@ -177,10 +208,16 @@ if (count($pconfig['subnets'])) { $config['dhcpdv6'][$if]['subnets']['item'] = $pconfig['subnets']; } else { unset($config['dhcpdv6'][$if]['subnets']); } + if (count($pconfig['routes'])) { + $config['dhcpdv6'][$if]['routes']['item'] = $pconfig['routes']; + } else { + unset($config['dhcpdv6'][$if]['routes']); + } + write_config(); $retval = services_radvd_configure(); $savemsg = get_std_save_message($retval); } @@ -200,22 +237,62 @@
@@ -343,15 +420,69 @@ } ?>
- " /> +
+ + + + + + +
+ + + + + + + + + + + +
+ + + + + + + " /> +
+ +
+ " />
@@ -424,10 +555,13 @@ var objAlias = []; function createAutoSuggest () { objAlias.push(new AutoSuggestControl(document.getElementById('subnet_address'), new StateSuggestions(addressarray))); + + objAlias.push(new AutoSuggestControl(document.getElementById('route_address'), new StateSuggestions(addressarray))); + new AutoSuggestControl(document.getElementById('radns1'), new StateSuggestions(addressarray)); new AutoSuggestControl(document.getElementById('radns2'), new StateSuggestions(addressarray)); } setTimeout(createAutoSuggest, 500); //]]>