You are here

private function IpAddress::calcCidr4 in IP address fields 8

Same name and namespace in other branches
  1. 2.0.x src/IpAddress.php \Drupal\field_ipaddress\IpAddress::calcCidr4()

Calculates the IP range for an IPv4 CIDR formatted range.

See also

https://stackoverflow.com/questions/15961557/calculate-ip-range-using-ph...

1 call to IpAddress::calcCidr4()
IpAddress::parse in src/IpAddress.php
Find if the value given is an IP, IP range, or other.

File

src/IpAddress.php, line 208

Class

IpAddress
IpTools class.

Namespace

Drupal\field_ipaddress

Code

private function calcCidr4($ip, $prefix) {
  $this->start = long2ip(ip2long($ip) & -1 << 32 - (int) $prefix);
  $this->end = long2ip(ip2long($this->start) + pow(2, 32 - (int) $prefix) - 1);
}