function _field_ipaddress_minimum_cidr_prefix in IP address fields 7
Calculates the minimum CIDR prefix for a given IP address. The IP address is assumed to be the start of the block.
1 call to _field_ipaddress_minimum_cidr_prefix()
- _field_ipaddress_validate_cidr in ./
field_ipaddress.module - Validate a CIDR input.
File
- ./
field_ipaddress.module, line 328
Code
function _field_ipaddress_minimum_cidr_prefix($ibase, $tbit) {
while ($tbit > 0) {
$im = pow(2, 32) - pow(2, 32 - ($tbit - 1));
$imand = $ibase & $im;
if ($imand != $ibase) {
break;
}
$tbit--;
}
return $tbit;
}