poolRepository = $em->getRepository(Pool::class); } /** * Retorna el primer pool donde se encuentra el lease * * @param Lease4 $lease * * @return Pool */ public function getPoolFromLease(Lease4 $lease) { $address = ip2long($lease->getAddress()); $pools = $this->poolRepository->findAll(); foreach ($pools as $pool) { $firstIp = ip2long($pool->getFirstIp()); $lastIp = ip2long($pool->getLastIp()); if ($firstIp <= $address && $address <= $lastIp) { return $pool; } } return null; } /** * Retorna el primer pool donde se encuentra la $fixedIP * * @param string $fixedIP * * @return Pool */ public function getPoolFromFixedIP($fixedIP) { $address = ip2long($fixedIP); $pools = $this->poolRepository->findAll(); foreach ($pools as $pool) { $firstIp = ip2long($pool->getFirstIp()); $lastIp = ip2long($pool->getLastIp()); if ($firstIp <= $address && $address <= $lastIp) { return $pool; } } return null; } /** * @param HostType $hostType * * @return array */ public function getStaticPoolIPRange(HostType $hostType = null) { $count = 1; $range = []; $pools = $this->poolRepository->findAllStaticByHostType($hostType); foreach ($pools as $pool) { $range[] = $pool->getFirstIp(); $firstIp = ip2long($pool->getFirstIp()); $lastIp = ip2long($pool->getLastIp()); $currentIP = $firstIp + 1; while ($currentIP <= $lastIp) { $range[] = long2ip($currentIP); $currentIP++; } } sort($range); return $range; } }