예제 #1
0
bool IPAddressRange::contains(const Poco::Net::IPAddress& address) const
{
    if (address.family() != _address.family())
    {
        return false;
    }
    else
    {
        return _subnet == (address & _mask);
    }
}
예제 #2
0
static std::array<char, 16> IPv6ToBinary(const Poco::Net::IPAddress & address)
{
	std::array<char, 16> res;

	if (Poco::Net::IPAddress::IPv6 == address.family())
	{
		memcpy(res.data(), address.addr(), 16);
	}
	else if (Poco::Net::IPAddress::IPv4 == address.family())
	{
		/// Преобразуем в IPv6-mapped адрес.
		memset(res.data(), 0, 10);
		res[10] = '\xFF';
		res[11] = '\xFF';
		memcpy(&res[12], address.addr(), 4);
	}
	else
		memset(res.data(), 0, 16);

	return res;
}