15 #include <boost/asio/ip/address.hpp> 27 static constexpr
size_t V6ADDRESS_LEN = 16;
30 static constexpr
size_t V4ADDRESS_LEN = 4;
34 static constexpr
size_t V4ADDRESS_TEXT_MAX_LEN = 15u;
39 static constexpr
size_t V6ADDRESS_TEXT_MAX_LEN = 39u;
54 IOAddress(
const std::string& address_str);
74 IOAddress(
const boost::asio::ip::address& asio_address);
93 std::string
toText()
const;
104 return (asio_address_.is_v4());
126 return (asio_address_.is_v6());
158 std::vector<uint8_t>
toBytes()
const;
166 return (asio_address_ == other.asio_address_);
191 return (asio_address_ < other.asio_address_);
198 return (asio_address_ <= other.asio_address_);
286 boost::asio::ip::address asio_address_;
318 #endif // IO_ADDRESS_H size_t hash_value(const IOAddress &address)
Hash the IOAddress.
IOAddress(const std::string &address_str)
Constructor from string.
bool operator<=(const IOAddress &other) const
Checks if one address is smaller or equal than the other.
bool operator==(const IOAddress &other) const
Compare addresses for equality.
bool equals(const IOAddress &other) const
Compare addresses for equality.
bool operator!=(const IOAddress &other) const
Compare addresses for inequality.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
static IOAddress subtract(const IOAddress &a, const IOAddress &b)
Subtracts one address from another (a - b)
static IOAddress fromBytes(short family, const uint8_t *data)
Creates an address from over wire data.
std::ostream & operator<<(std::ostream &os, const IOAddress &address)
Insert the IOAddress as a string into stream.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
bool isV4Bcast() const
Convenience function to check if it is an IPv4 broadcast address.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
bool operator<(const IOAddress &other) const
Checks if one address is smaller than the other.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
bool isV6Multicast() const
checks whether and address is IPv6 and is multicast
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
Defines the logger used by the top-level component of kea-lfc.
std::string toText() const
Convert the address to a string.
A wrapper interface for the ASIO library.
static const IOAddress & IPV4_BCAST_ADDRESS()
Returns a "255.255.255.255" broadcast address.
The IOAddress class represents an IP addresses (version agnostic)
static IOAddress increase(const IOAddress &addr)
Returns an address increased by one.
bool nequals(const IOAddress &other) const
Compare addresses for inequality.
short getFamily() const
Returns the address family.