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_;
303 operator<<(std::ostream& os,
const IOAddress& address);
318 #endif // IO_ADDRESS_H
bool isV4Bcast() const
Convenience function to check if it is an IPv4 broadcast address.
size_t hash_value(const IOAddress &address)
Hash the IOAddress.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
bool operator<=(const IOAddress &other) const
Checks if one address is smaller or equal than the other.
IOAddress(const std::string &address_str)
Constructor from string.
bool operator<(const IOAddress &other) const
Checks if one address is smaller than the other.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
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.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
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.
Defines the logger used by the top-level component of kea-dhcp-ddns.
A wrapper interface for the ASIO library.
static const IOAddress & IPV4_BCAST_ADDRESS()
Returns a "255.255.255.255" broadcast address.
std::string toText() const
Convert the address to a string.
bool equals(const IOAddress &other) const
Compare addresses for equality.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV6Multicast() const
checks whether and address is IPv6 and is multicast
The IOAddress class represents an IP addresses (version agnostic)
bool operator!=(const IOAddress &other) const
Compare addresses for inequality.
bool nequals(const IOAddress &other) const
Compare addresses for inequality.
bool operator==(const IOAddress &other) const
Compare addresses for equality.
short getFamily() const
Returns the address family.
static IOAddress increase(const IOAddress &addr)
Returns an address increased by one.