You are here

private function AutobanController::cidrMatch in Automatic IP ban (Autoban) 8

Is IP address in subnet?

Parameters

string $ip: IP address for match check.

string $network: IP subnet.

string $cidr: CIDR.

Return value

bool IP mathes for subnet.

1 call to AutobanController::cidrMatch()
AutobanController::whitelistIp in src/Controller/AutobanController.php
Is IP address in whitelist?

File

src/Controller/AutobanController.php, line 383

Class

AutobanController
Provides an Autoban functional.

Namespace

Drupal\autoban\Controller

Code

private function cidrMatch($ip, $network, $cidr) {
  return (ip2long($ip) & ~((1 << 32 - $cidr) - 1)) == ip2long($network);
}