Revision 731de711
Added by Pierre POMES over 13 years ago
usr/local/www/services_dhcpv6.php | ||
---|---|---|
144 | 144 |
} |
145 | 145 |
} |
146 | 146 |
|
147 |
/* FIXME needs v6 code, use in subnet v6? */ |
|
148 | 147 |
function is_inrange($test, $start, $end) { |
149 |
if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
|
|
148 |
if ( (inet_pton($test) < inet_pton($end)) && (inet_pton($test) > inet_pton($start)) )
|
|
150 | 149 |
return true; |
151 | 150 |
else |
152 | 151 |
return false; |
... | ... | |
233 | 232 |
$noip = true; |
234 | 233 |
if (!$input_errors) { |
235 | 234 |
/* make sure the range lies within the current subnet */ |
236 |
/* FIXME change for ipv6 subnet */ |
|
237 | 235 |
$subnet_start = gen_subnetv6($ifcfgip, $ifcfgsn); |
238 | 236 |
$subnet_end = gen_subnetv6_max($ifcfgip, $ifcfgsn); |
239 | 237 |
|
240 |
if((! ip_in_subnet($_POST['range_from'], $subnet_start)) || (! ip_in_subnet($_POST['range_to'], $subnet_start))) { |
|
238 |
if ((! is_inrange($_POST['range_from'], $subnet_start, $subnet_end)) || |
|
239 |
(! is_inrange($_POST['range_to'], $subnet_start, $subnet_end))) { |
|
241 | 240 |
$input_errors[] = gettext("The specified range lies outside of the current subnet."); |
242 | 241 |
} |
243 | 242 |
|
244 |
/* no idea how to do this yet
|
|
245 |
if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
|
|
243 |
/* "from" cannot be higher than "to" */
|
|
244 |
if (inet_pton($_POST['range_from']) > inet_pton($_POST['range_to']))
|
|
246 | 245 |
$input_errors[] = gettext("The range is invalid (first element higher than second element)."); |
247 |
*/ |
|
248 | 246 |
|
249 | 247 |
/* make sure that the DHCP Relay isn't enabled on this interface */ |
250 | 248 |
if (isset($config['dhcrelay'][$if]['enable'])) |
251 | 249 |
$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."),$iflist[$if]); |
252 | 250 |
|
253 |
// $dynsubnet_start = ip2ulong($_POST['range_from']); |
|
254 |
// $dynsubnet_end = ip2ulong($_POST['range_to']); |
|
255 |
/* FIX later. Also applies to prefix delegation |
|
251 |
|
|
252 |
/* Verify static mappings do not overlap: |
|
253 |
- available DHCP range |
|
254 |
- prefix delegation range (FIXME: still need to be completed) */ |
|
255 |
$dynsubnet_start = inet_pton($_POST['range_from']); |
|
256 |
$dynsubnet_end = inet_pton($_POST['range_to']); |
|
257 |
|
|
256 | 258 |
if(is_array($a_maps)) { |
257 | 259 |
foreach ($a_maps as $map) { |
258 | 260 |
if (empty($map['ipaddrv6'])) |
259 | 261 |
continue; |
260 |
if ((ip2ulong($map['ipaddrv6']) > $dynsubnet_start) &&
|
|
261 |
(ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
|
|
262 |
if ((inet_pton($map['ipaddrv6']) > $dynsubnet_start) &&
|
|
263 |
(inet_pton($map['ipaddr']) < $dynsubnet_end)) {
|
|
262 | 264 |
$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings.")); |
263 | 265 |
break; |
264 | 266 |
} |
265 | 267 |
} |
266 | 268 |
} |
267 |
*/ |
|
268 | 269 |
} |
269 | 270 |
} |
270 | 271 |
|
Also available in: Unified diff
Fix some checks in dhcpv6 screen. Still need to validate static mappings against delegated networks