Determines if a given IP is with a defined range

@param ipv4 $ipGiven
@param ipv4 $ipStart
@param ipv4 $ipEnd
@return string
196471
public function checkIpIsInRange($ipGiven, $ipStart, $ipEnd)
    {
        $sReturn     = 'out';
        $startNo     = $this->convertIpToNumber($ipStart);
        $endNo       = $this->convertIpToNumber($ipEnd);
        $evaluatedNo = $this->convertIpToNumber($ipGiven);
        if ($sReturn == 'out') {
            if (($evaluatedNo >= $startNo) && ($evaluatedNo <= $endNo)) {
                $sReturn = 'in';
            }
        }
        return $sReturn;
    }
689274
public function isIpWhitelisted($ipAddress)
    {
        // determine whether this IP is IPv4 or IPv6
        $isIpv4Address = filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
        return $this->isIpInWhitelist(
            ($isIpv4Address) ? $this->ipv4Whitelist : $this->ipv6Whitelist,
            $ipAddress
        );
    }
771648
public static boolean isIPv4(final String ip) {
        if (StringUtils.isBlank(ip)) {
            return false;
        }

        final String regex = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
        final Pattern pattern = Pattern.compile(regex);
        final Matcher matcher = pattern.matcher(ip);

        return matcher.matches();
    }
48533
public static function isIpInCidr(string $ip, string $cidr): bool
    {
        if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            throw new \UnexpectedValueException(
                "invalid value for ip; expecting an IPv4 address"
            );
        }

        list($range, $netmask) = static::parseCidr($cidr);
        $netmask = ~((1 << (32 - $netmask)) - 1);
        return ((ip2long($ip) & $netmask) === ip2long($range));
    }
705529
protected boolean ipInRange(String ipAddress, String range) {
        IpAddressMatcher addressMatcher = new IpAddressMatcher(range);
        return addressMatcher.matches(ipAddress);
    }
1146928
public boolean inRange(InetAddress ip) throws FilterException {
        Iterator iter = ranges.iterator();
        while (iter.hasNext()) {
            IPAddressRange range = (IPAddressRange) iter.next();
            if (range.inRange(ip)) {
                return true;
            }
        }

        return false;
    }
1096382
protected function resolveIpAddress(): string
    {
        $ipAddressResolver = Config::get('audit.resolver.ip_address');

        if (is_subclass_of($ipAddressResolver, IpAddressResolver::class)) {
            return call_user_func([$ipAddressResolver, 'resolve']);
        }

        throw new AuditingException('Invalid IpAddressResolver implementation');
    }
1223273
public static function isIpIn($ipAddr, $net, $mask)
	{
		// doesn't check for the return value of ip2long
		$ipAddr	= ip2long($ipAddr);
		$rede	= ip2long($net);
		$mask	= ip2long($mask);
		$res	= $ipAddr & $mask;	// AND
		return ($res == $rede);
	}
1043189
protected function getRangeType(AddressInterface $ip)
    {
        $comparableIP = $ip->getComparableString();
        $rs = $this->connection->executeQuery(
            '
                SELECT
                    lcirType
                FROM
                    LoginControlIpRanges
                WHERE
                    lcirIpFrom <= ? AND ? <= lcirIpTo
                    AND (lcirExpires IS NULL OR lcirExpires > ' . $this->connection->getDatabasePlatform()->getNowExpression() . ')
            ',
            [$comparableIP, $comparableIP]
        );
        $type = null;
        while (($col = $rs->fetchColumn()) !== false) {
            $type = (int) $col;
            if (($type & static::IPRANGEFLAG_WHITELIST) === static::IPRANGEFLAG_WHITELIST) {
                break;
            }
        }
        $rs->closeCursor();

        return $type;
    }
863354
def create_ip_range(self, network_view, start_ip, end_ip, network,
                        disable, range_extattrs):
        """"""
        return obj.IPRange.create(self.connector,
                                  network_view=network_view,
                                  start_addr=start_ip,
                                  end_addr=end_ip,
                                  cidr=network,
                                  disable=disable,
                                  extattrs=range_extattrs,
                                  check_if_exists=False)
246318
protected function isInside ($ip, $name, $range)
	{
		
		// Single IP

		if (!is_array ($range))
		{
			if ($ip == $range)
			{
				return TRUE;
			}
		}

		// CIDR

		elseif (strpos ($name, '/') !== FALSE)
		{
			if (($ip & $range[1]) == ($range[0] & $range[1]))
			{
				return TRUE;
			}
		}

		// Start-End

		elseif (strpos ($name, '-') !== FALSE)
		{
			if (($ip >= $range[0]) && ($ip <= $range[1]))
			{
				return TRUE;
			}
		}
		
		// Not inside any range
		
		return FALSE;
		
	}
626070
private function inRange($ip, $cidr, $range)
    {
        $ipVersion = $this->getIpVersion($ip);
        $binIp = $this->ip2bin($ip);

        $parts = explode('/', $range);
        $net = array_shift($parts);
        $range_cidr = array_shift($parts);


        $netVersion = $this->getIpVersion($net);
        if ($ipVersion !== $netVersion) {
            return false;
        }
        if ($range_cidr === null) {
            $range_cidr = $netVersion === 4 ? static::IPV4_ADDRESS_LENGTH : static::IPV6_ADDRESS_LENGTH;
        }

        $binNet = $this->ip2bin($net);
        if (substr($binIp, 0, $range_cidr) === substr($binNet, 0, $range_cidr) && $cidr >= $range_cidr) {
            return true;
        }
        return false;
    }
402318
public function isWhitelisted(AddressInterface $ip = null)
    {
        if ($ip === null) {
            $ip = $this->getRequestIPAddress();
        }
        $rangeType = $this->getRangeType($ip);

        return $rangeType !== null && ($rangeType & static::IPRANGEFLAG_WHITELIST) === static::IPRANGEFLAG_WHITELIST;
    }
975755
func IPInRange(start, stop, ip net.IP) bool {
	return !(IPLess(ip, start) || IPLess(stop, ip))
}
152299
public function getAddressInfo($ipAddress)
    {
        // This test is a trick to determine if we have a valid IPv4 address, the
        // only kind we can handle at the moment.
        $long = ip2long($ipAddress);
        if ($long == -1 || $long === false) {
            return null;
        }
        $result = $this->gateway->get(
            'ipv4address',
            ['ip_address' => $ipAddress, '_max_results' => 1]
        );
        return (isset($result[0])) ? $result[0] : null;
    }
554453
public static function ip_in_range(string $ip, $min, $max=null) {
		ref\sanitize::ip($ip, true);
		if (! \is_string($min)) {
			return false;
		}

		// Bad IP.
		if (! $ip) {
			return false;
		}

		// Is $min a range?
		if (false !== \strpos($min, '/')) {
			if (false === ($range = format::cidr_to_range($min))) {
				return false;
			}
			$min = $range['min'];
			$max = $range['max'];
		}
		// Max is required otherwise.
		elseif (null === $max) {
			return false;
		}

		// Convert everything to a number.
		ref\format::ip_to_number($ip);
		ref\format::ip_to_number($min);
		ref\format::ip_to_number($max);

		if (
			(false !== $ip) &&
			(false !== $min) &&
			(false !== $max)
		) {
			return static::in_range($ip, $min, $max);
		}

		return false;
	}
125372
public static boolean isIPv4orIPv6Address(String _ipAddress) {
        return IPV4_PATTERN.matcher(_ipAddress).matches() || IPV6_PATTERN.matcher(_ipAddress).matches();
    }