function _field_ipaddress_cidr2long in IP address fields 7
Converts a CIDR into a start address and end address.
1 call to _field_ipaddress_cidr2long()
- _field_ipaddress_validate_cidr in ./
field_ipaddress.module - Validate a CIDR input.
File
- ./
field_ipaddress.module, line 344
Code
function _field_ipaddress_cidr2long($cidr) {
list($ip, $bits) = explode('/', $cidr);
$start = long2ip(ip2long($ip));
$end = long2ip(ip2long($ip) + pow(2, 32 - $bits) - 1);
if ($start === '0.0.0.0' || $end === '0.0.0.0') {
return FALSE;
}
else {
return array(
'start' => ip2long($start),
'end' => ip2long($end),
);
}
}