diff options
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/www/services_dhcp.php | 21 | ||||
-rwxr-xr-x | usr/local/www/services_dhcp_edit.php | 11 |
2 files changed, 29 insertions, 3 deletions
diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index fcaad50..37e25be 100755 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -343,9 +343,24 @@ if ($_POST) { if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) $input_errors[] = gettext("The range is invalid (first element higher than second element)."); - // TODO: Ensure range and pools do not overlap! - // If we're editing the main range, check pools - // If we're editing a pool, locate parent range and other pools. + if (is_numeric($pool) || ($act == "newpool")) { + $rfrom = $config['dhcpd'][$if]['range']['from']; + $rto = $config['dhcpd'][$if]['range']['to']; + + if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto)) + $input_errors[] = gettext("The specified range must not be within the DHCP range for this interface."); + } + + foreach ($a_pools as $id => $p) { + if (is_numeric($pool) && ($id == $pool)) + continue; + + if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || + is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) { + $input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface."); + break; + } + } /* make sure that the DHCP Relay isn't enabled on this interface */ if (isset($config['dhcrelay']['enable']) && (stristr($config['dhcrelay']['interface'], $if) !== false)) diff --git a/usr/local/www/services_dhcp_edit.php b/usr/local/www/services_dhcp_edit.php index 185f941..3a5e945 100755 --- a/usr/local/www/services_dhcp_edit.php +++ b/usr/local/www/services_dhcp_edit.php @@ -75,6 +75,10 @@ if (!is_array($config['dhcpd'][$if])) if (!is_array($config['dhcpd'][$if]['staticmap'])) $config['dhcpd'][$if]['staticmap'] = array(); +if (!is_array($config['dhcpd'][$if]['pool'])) + $config['dhcpd'][$if]['pool'] = array(); +$a_pools = &$config['dhcpd'][$if]['pool']; + $static_arp_enabled=isset($config['dhcpd'][$if]['staticarp']); $netboot_enabled=isset($config['dhcpd'][$if]['netboot']); $a_maps = &$config['dhcpd'][$if]['staticmap']; @@ -184,6 +188,13 @@ if ($_POST) { $input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface.")); } + foreach ($a_pools as $id => $p) { + if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) { + $input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface."); + break; + } + } + $lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn))); $lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)))); if ((ip2ulong($_POST['ipaddr']) < $lansubnet_start) || |