From f3475477e8126653364d89717486bf49f276353f Mon Sep 17 00:00:00 2001 From: Darren Embry Date: Fri, 8 Jun 2012 15:37:50 -0400 Subject: split dhcpv6 server and ra #2361 --- usr/local/www/services_dhcpv6.php | 10 - usr/local/www/services_router_advertisements.php | 773 +---------------------- 2 files changed, 27 insertions(+), 756 deletions(-) diff --git a/usr/local/www/services_dhcpv6.php b/usr/local/www/services_dhcpv6.php index 55f323f..325f04b 100644 --- a/usr/local/www/services_dhcpv6.php +++ b/usr/local/www/services_dhcpv6.php @@ -150,16 +150,6 @@ function is_inrange($test, $start, $end) { return false; } -$advertise_modes = array("disabled" => "Disabled", - "router" => "Router Only", - "unmanaged" => "Unmanaged", - "managed" => "Managed", - "assist" => "Assisted"); -$priority_modes = array("low" => "Low", - "medium" => "Normal", - "high" => "High"); -$carplist = get_configured_carp_interface_list(); - if ($_POST) { unset($input_errors); diff --git a/usr/local/www/services_router_advertisements.php b/usr/local/www/services_router_advertisements.php index 5ba1ed0..0603540 100644 --- a/usr/local/www/services_router_advertisements.php +++ b/usr/local/www/services_router_advertisements.php @@ -1,8 +1,8 @@ . All rights reserved. @@ -38,10 +38,10 @@ */ ##|+PRIV -##|*IDENT=page-services-dhcpv6server -##|*NAME=Services: DHCPv6 server page -##|*DESCR=Allow access to the 'Services: DHCPv6 server' page. -##|*MATCH=services_dhcpv6.php* +##|*IDENT=page-services-router-advertisements +##|*NAME=Services: Router advertisementspage +##|*DESCR=Allow access to the 'Services: Router Advertisements' page. +##|*MATCH=services_router_advertisements.php* ##|-PRIV require("guiconfig.inc"); @@ -71,7 +71,8 @@ if($config['installedpackages']['olsrd']) { } if (!$_GET['if']) - $savemsg = "" . gettext("The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses") . ".

" . gettext("Only interfaces configured with a static IP will be shown") . ".

"; + $savemsg = "

" . gettext("The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses") . ".

" . + "

" . gettext("Only interfaces configured with a static IP will be shown") . ".

"; $iflist = get_configured_interface_with_descr(); @@ -94,75 +95,16 @@ if (is_array($config['dhcpdv6'][$if])){ if($pconfig['rapriority'] == "") $pconfig['rapriority'] = "medium"; $pconfig['rainterface'] = $config['dhcpdv6'][$if]['rainterface']; - /* DHCPv6 */ - if (is_array($config['dhcpdv6'][$if]['range'])) { - $pconfig['range_from'] = $config['dhcpdv6'][$if]['range']['from']; - $pconfig['range_to'] = $config['dhcpdv6'][$if]['range']['to']; - } - if (is_array($config['dhcpdv6'][$if]['prefixrange'])) { - $pconfig['prefixrange_from'] = $config['dhcpdv6'][$if]['prefixrange']['from']; - $pconfig['prefixrange_to'] = $config['dhcpdv6'][$if]['prefixrange']['to']; - $pconfig['prefixrange_length'] = $config['dhcpdv6'][$if]['prefixrange']['prefixlength']; - } - $pconfig['deftime'] = $config['dhcpdv6'][$if]['defaultleasetime']; - $pconfig['maxtime'] = $config['dhcpdv6'][$if]['maxleasetime']; - $pconfig['domain'] = $config['dhcpdv6'][$if]['domain']; - $pconfig['domainsearchlist'] = $config['dhcpdv6'][$if]['domainsearchlist']; - list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpdv6'][$if]['winsserver']; - list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpdv6'][$if]['dnsserver']; - $pconfig['enable'] = isset($config['dhcpdv6'][$if]['enable']); - $pconfig['denyunknown'] = isset($config['dhcpdv6'][$if]['denyunknown']); - $pconfig['ddnsdomain'] = $config['dhcpdv6'][$if]['ddnsdomain']; - $pconfig['ddnsupdate'] = isset($config['dhcpdv6'][$if]['ddnsupdate']); - list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpdv6'][$if]['ntpserver']; - $pconfig['tftp'] = $config['dhcpdv6'][$if]['tftp']; - $pconfig['ldap'] = $config['dhcpdv6'][$if]['ldap']; - $pconfig['netboot'] = isset($config['dhcpdv6'][$if]['netboot']); - $pconfig['nextserver'] = $config['dhcpdv6'][$if]['nextserver']; - $pconfig['filename'] = $config['dhcpdv6'][$if]['filename']; - $pconfig['rootpath'] = $config['dhcpdv6'][$if]['rootpath']; - $pconfig['netmask'] = $config['dhcpdv6'][$if]['netmask']; - $pconfig['numberoptions'] = $config['dhcpdv6'][$if]['numberoptions']; - $pconfig['dhcpv6leaseinlocaltime'] = $config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime']; - if (!is_array($config['dhcpdv6'][$if]['staticmap'])) - $config['dhcpdv6'][$if]['staticmap'] = array(); - $a_maps = &$config['dhcpdv6'][$if]['staticmap']; -} - -$ifcfgip = get_interface_ipv6($if); -$ifcfgsn = get_interface_subnetv6($if); - -/* set the enabled flag which will tell us if DHCP relay is enabled - * on any interface. We will use this to disable DHCP server since - * the two are not compatible with each other. - */ - -$dhcrelay_enabled = false; -$dhcrelaycfg = $config['dhcrelay6']; - -if(is_array($dhcrelaycfg)) { - foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { - if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) && - (!link_interface_to_bridge($dhcrelayif))) - $dhcrelay_enabled = true; - } -} - -function is_inrange($test, $start, $end) { - if ( (inet_pton($test) < inet_pton($end)) && (inet_pton($test) > inet_pton($start)) ) - return true; - else - return false; } $advertise_modes = array("disabled" => "Disabled", - "router" => "Router Only", - "unmanaged" => "Unmanaged", - "managed" => "Managed", - "assist" => "Assisted"); + "router" => "Router Only", + "unmanaged" => "Unmanaged", + "managed" => "Managed", + "assist" => "Assisted"); $priority_modes = array("low" => "Low", - "medium" => "Normal", - "high" => "High"); + "medium" => "Normal", + "high" => "High"); $carplist = get_configured_carp_interface_list(); if ($_POST) { @@ -171,322 +113,31 @@ if ($_POST) { $pconfig = $_POST; - $numberoptions = array(); - for($x=0; $x<99; $x++) { - if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) { - $numbervalue = array(); - $numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]); - $numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]); - $numberoptions['item'][] = $numbervalue; - } - } - // Reload the new pconfig variable that the forum uses. - $pconfig['numberoptions'] = $numberoptions; - - /* input validation */ - if ($_POST['enable']) { - $reqdfields = explode(" ", "range_from range_to"); - $reqdfieldsn = array(gettext("Range begin"),gettext("Range end")); - - do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - - if (($_POST['prefixrange_from'] && !is_ipaddrv6($_POST['prefixrange_from']))) - $input_errors[] = gettext("A valid range must be specified."); - if (($_POST['prefixrange_to'] && !is_ipaddrv6($_POST['prefixrange_to']))) - $input_errors[] = gettext("A valid prefix range must be specified."); - if (($_POST['range_from'] && !is_ipaddrv6($_POST['range_from']))) - $input_errors[] = gettext("A valid range must be specified."); - if (($_POST['range_to'] && !is_ipaddrv6($_POST['range_to']))) - $input_errors[] = gettext("A valid range must be specified."); - if (($_POST['gateway'] && !is_ipaddrv6($_POST['gateway']))) - $input_errors[] = gettext("A valid IPv6 address must be specified for the gateway."); - if (($_POST['dns1'] && !is_ipaddrv6($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv6($_POST['dns2']))) - $input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS servers."); - - if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) - $input_errors[] = gettext("The default lease time must be at least 60 seconds."); - if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) - $input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time."); - if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) - $input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration."); - if ($_POST['domainsearchlist']) { - $domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']); - foreach ($domain_array as $curdomain) { - if (!is_domain($curdomain)) { - $input_errors[] = gettext("A valid domain search list must be specified."); - break; - } - } - } - - if (($_POST['ntp1'] && !is_ipaddrv6($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv6($_POST['ntp2']))) - $input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers."); - if (($_POST['domain'] && !is_domain($_POST['domain']))) - $input_errors[] = gettext("A valid domain name must be specified for the DNS domain."); - if ($_POST['tftp'] && !is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp'])) - $input_errors[] = gettext("A valid IPv6 address or hostname must be specified for the TFTP server."); - if (($_POST['nextserver'] && !is_ipaddrv6($_POST['nextserver']))) - $input_errors[] = gettext("A valid IPv6 address must be specified for the network boot server."); - - // Disallow a range that includes the virtualip - if (is_array($config['virtualip']['vip'])) { - foreach($config['virtualip']['vip'] as $vip) { - if($vip['interface'] == $if) - if($vip['subnetv6'] && is_inrange($vip['subnetv6'], $_POST['range_from'], $_POST['range_to'])) - $input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IPv6 address %s."),$vip['subnetv6']); - } - } - - $noip = false; - if(is_array($a_maps)) - foreach ($a_maps as $map) - if (empty($map['ipaddrv6'])) - $noip = true; - if (!$input_errors) { - /* make sure the range lies within the current subnet */ - $subnet_start = gen_subnetv6($ifcfgip, $ifcfgsn); - $subnet_end = gen_subnetv6_max($ifcfgip, $ifcfgsn); - - if ((! is_inrange($_POST['range_from'], $subnet_start, $subnet_end)) || - (! is_inrange($_POST['range_to'], $subnet_start, $subnet_end))) { - $input_errors[] = gettext("The specified range lies outside of the current subnet."); - } - - /* "from" cannot be higher than "to" */ - if (inet_pton($_POST['range_from']) > inet_pton($_POST['range_to'])) - $input_errors[] = gettext("The range is invalid (first element higher than second element)."); - - /* make sure that the DHCP Relay isn't enabled on this interface */ - if (isset($config['dhcrelay'][$if]['enable'])) - $input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]); - - - /* Verify static mappings do not overlap: - - available DHCP range - - prefix delegation range (FIXME: still need to be completed) */ - $dynsubnet_start = inet_pton($_POST['range_from']); - $dynsubnet_end = inet_pton($_POST['range_to']); - - if(is_array($a_maps)) { - foreach ($a_maps as $map) { - if (empty($map['ipaddrv6'])) - continue; - if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) && - (inet_pton($map['ipaddrv6']) < $dynsubnet_end)) { - $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings.")); - break; - } - } - } - } - } - if (!$input_errors) { if (!is_array($config['dhcpdv6'][$if])) $config['dhcpdv6'][$if] = array(); - if (!is_array($config['dhcpdv6'][$if]['range'])) - $config['dhcpdv6'][$if]['range'] = array(); - if (!is_array($config['dhcpdv6'][$if]['prefixrange'])) - $config['dhcpdv6'][$if]['prefixrange'] = array(); $config['dhcpdv6'][$if]['ramode'] = $_POST['ramode']; $config['dhcpdv6'][$if]['rapriority'] = $_POST['rapriority']; $config['dhcpdv6'][$if]['rainterface'] = $_POST['rainterface']; - $config['dhcpdv6'][$if]['range']['from'] = $_POST['range_from']; - $config['dhcpdv6'][$if]['range']['to'] = $_POST['range_to']; - $config['dhcpdv6'][$if]['prefixrange']['from'] = $_POST['prefixrange_from']; - $config['dhcpdv6'][$if]['prefixrange']['to'] = $_POST['prefixrange_to']; - $config['dhcpdv6'][$if]['prefixrange']['prefixlength'] = $_POST['prefixrange_length']; - $config['dhcpdv6'][$if]['defaultleasetime'] = $_POST['deftime']; - $config['dhcpdv6'][$if]['maxleasetime'] = $_POST['maxtime']; - $config['dhcpdv6'][$if]['netmask'] = $_POST['netmask']; - $previous = $config['dhcpdv6'][$if]['failover_peerip']; - if($previous <> $_POST['failover_peerip']) - mwexec("/bin/rm -rf /var/dhcpd/var/db/*"); - - $config['dhcpdv6'][$if]['failover_peerip'] = $_POST['failover_peerip']; - - unset($config['dhcpdv6'][$if]['winsserver']); - - unset($config['dhcpdv6'][$if]['dnsserver']); - if ($_POST['dns1']) - $config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns1']; - if ($_POST['dns2']) - $config['dhcpdv6'][$if]['dnsserver'][] = $_POST['dns2']; - - $config['dhcpdv6'][$if]['domain'] = $_POST['domain']; - $config['dhcpdv6'][$if]['domainsearchlist'] = $_POST['domainsearchlist']; - $config['dhcpdv6'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false; - $config['dhcpdv6'][$if]['enable'] = ($_POST['enable']) ? true : false; - $config['dhcpdv6'][$if]['ddnsdomain'] = $_POST['ddnsdomain']; - $config['dhcpdv6'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false; - - unset($config['dhcpdv6'][$if]['ntpserver']); - if ($_POST['ntp1']) - $config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp1']; - if ($_POST['ntp2']) - $config['dhcpdv6'][$if]['ntpserver'][] = $_POST['ntp2']; - - $config['dhcpdv6'][$if]['tftp'] = $_POST['tftp']; - $config['dhcpdv6'][$if]['ldap'] = $_POST['ldap']; - $config['dhcpdv6'][$if]['netboot'] = ($_POST['netboot']) ? true : false; - $config['dhcpdv6'][$if]['nextserver'] = $_POST['nextserver']; - $config['dhcpdv6'][$if]['filename'] = $_POST['filename']; - $config['dhcpdv6'][$if]['rootpath'] = $_POST['rootpath']; - $config['dhcpdv6'][$if]['dhcpv6leaseinlocaltime'] = $_POST['dhcpv6leaseinlocaltime']; - - // Handle the custom options rowhelper - if(isset($config['dhcpdv6'][$if]['numberoptions']['item'])) - unset($config['dhcpdv6'][$if]['numberoptions']['item']); - - $config['dhcpdv6'][$if]['numberoptions'] = $numberoptions; - write_config(); - - $retval = 0; - $retvaldhcp = 0; - $retvaldns = 0; - /* Stop DHCPv6 so we can cleanup leases */ - killbyname("dhcpd -6"); - // dhcp_clean_leases(); - /* dnsmasq_configure calls dhcpd_configure */ - /* no need to restart dhcpd twice */ - if (isset($config['dnsmasq']['regdhcpstatic'])) { - $retvaldns = services_dnsmasq_configure(); - if ($retvaldns == 0) { - clear_subsystem_dirty('hosts'); - clear_subsystem_dirty('staticmaps'); - } - } else { - $retvaldhcp = services_dhcpd_configure(); - if ($retvaldhcp == 0) - clear_subsystem_dirty('staticmaps'); - } - if($retvaldhcp == 1 || $retvaldns == 1) - $retval = 1; + $retval = services_radvd_configure(); $savemsg = get_std_save_message($retval); } } -if ($_GET['act'] == "del") { - if ($a_maps[$_GET['id']]) { - unset($a_maps[$_GET['id']]); - write_config(); - if(isset($config['dhcpdv6'][$if]['enable'])) { - mark_subsystem_dirty('staticmapsv6'); - if (isset($config['dnsmasq']['regdhcpstaticv6'])) - mark_subsystem_dirty('hosts'); - } - header("Location: services_dhcpv6.php?if={$if}"); - exit; - } -} - -$pgtitle = array(gettext("Services"),gettext("DHCPv6 server")); -$statusurl = "status_dhcpv6_leases.php"; -$logurl = "diag_logs_dhcp.php"; +$pgtitle = array(gettext("Services"),gettext("Router advertisements")); include("head.inc"); ?> - - - - - - -
+ -"; - echo ""; - exit; - } -?> -

-" . gettext("You must apply the changes in order for them to take effect."));?>
- + - -
+ +
@@ -570,394 +229,16 @@ include("head.inc");
  - - " onclick="enable_change(true)"> -
-


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- onClick="enable_change(false);"> -
  - > -
-
- + + " />
- bits -
- - - - -
- -
- -    -
- -    -   
- -
-
-
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
-
- -
- - - - - - - - - -
- > - - - - -
  - - -
-
-
- "> - -
- -
-
- "> - -
- -
-
- "> - -
- -
-
- "> - -
- -
-
- "> - -
- - -
  - - " onclick="enable_change(true)"> -
 


-
,

-
-
-

-
- - - - - - - - - - - "" or $mapent['ipaddrv6'] <> ""): ?> - - - - - - - - - - - - - -
- - - - - -
-
- - -   - -   - -   - - - - - - -
')">
-
- - - - - -
-
- -- cgit v1.1