DHCP available range
-
A marginally improved algorithm to make the range more user friendly:
-
So before it would produce 10.0.0.0-10.0.0.255, now with an ip address of 10.0.0.1 it will produce 10.0.0.2-10.0.0.254. I wonder why the original implementation used the beginning of the subnet? If the ip address of the machine is not at the beginning of the subnet space this can lead to a shortened range, so something different could be done.
$ip = ip2long($ifcfg['ipaddr']); /* remove network address */ $from = ( $ip & gen_subnet_mask_long($ifcfg['subnet']) ) + 1; $from++; /* remove broadcast address */ $to = ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])) - 1; if ($to == $ip) $to--; if ($ip > $from && $ip < $to && ($to - $ip) > 1) { echo long2ip($from) . ' - ' . long2ip($ip - 1) . ', '; $from = $ip + 1; } else if (($to - $ip) == 1) { $to = $ip - 1; } echo long2ip($from); ?> -
So an IP address in the middle at 10.0.0.100 would produce a range 10.0.0.1-10.0.0.99, 10.0.0.101-10.0.0.254, and the end case of an ip address of 10.0.0.254 would yield a range 10.0.0.1-10.0.0.253.
-
Really not sure which file this even belongs in.
Can you start supplying diff -rub patches if you wish for these types of changes to be commited?
Thanks
-
-
Commited, thanks!