13#include <boost/static_assert.hpp> 
   15#include <boost/functional/hash.hpp> 
   19#include <sys/socket.h> 
   20#include <netinet/in.h> 
   22#if BOOST_VERSION < 106600 
   23#error "Boost ASIO older than 1.66 are not supported" 
   26using namespace boost::asio;
 
   27using boost::asio::ip::udp;
 
   28using boost::asio::ip::tcp;
 
   43    boost::system::error_code err;
 
   44    asio_address_ = ip::make_address(address_str, err);
 
   47                  << address_str << 
"': " << err.message());
 
 
   52    asio_address_(asio_address)
 
 
   56    asio_address_(boost::asio::ip::address_v4(v4address)) {
 
 
   62    return (asio_address_.to_string());
 
 
   69    } 
else if ((family != AF_INET) && (family != AF_INET6)) {
 
   74    BOOST_STATIC_ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
 
   75    char addr_str[INET6_ADDRSTRLEN];
 
   76    inet_ntop(family, 
data, addr_str, INET6_ADDRSTRLEN);
 
 
   82    if (asio_address_.is_v4()) {
 
   83        const boost::asio::ip::address_v4::bytes_type bytes4 =
 
   84            asio_address_.to_v4().to_bytes();
 
   85        return (std::vector<uint8_t>(bytes4.begin(), bytes4.end()));
 
   90    const boost::asio::ip::address_v6::bytes_type bytes6 =
 
   91        asio_address_.to_v6().to_bytes();
 
   92    return (std::vector<uint8_t>(bytes6.begin(), bytes6.end()));
 
 
   97    if (asio_address_.is_v4()) {
 
 
  106    if (!asio_address_.is_v6()) {
 
  109    return (asio_address_.to_v6().is_link_local());
 
 
  114    if (!asio_address_.is_v6()) {
 
  117    return (asio_address_.to_v6().is_multicast());
 
 
  122    if (asio_address_.is_v4()) {
 
  123        return (asio_address_.to_v4().to_uint());
 
  126                  << 
" address to IPv4.");
 
 
  148        vector<uint8_t> a_vec = a.
toBytes();
 
  149        vector<uint8_t> b_vec = b.
toBytes();
 
  152        vector<uint8_t> result(V6ADDRESS_LEN,0);
 
  161        for (
int i = a_vec.size() - 1; i >= 0; --i) {
 
  162            result[i] = a_vec[i] - b_vec[i] - carry;
 
  163            carry = (a_vec[i] < b_vec[i] + carry);
 
  166        return (
fromBytes(AF_INET6, &result[0]));
 
 
  172    std::vector<uint8_t> packed(addr.
toBytes());
 
  175    for (
int i = packed.size() - 1; i >= 0; --i) {
 
  177        if (++packed[i] != 0) {
 
 
  187    if (address.
isV4()) {
 
  188        boost::hash<uint32_t> hasher;
 
  189        return (hasher(address.
toUint32()));
 
  191        boost::hash<std::vector<uint8_t> > hasher;
 
  192        return (hasher(address.
toBytes()));
 
 
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic)
static IOAddress subtract(const IOAddress &a, const IOAddress &b)
Subtracts one address from another (a - b)
std::string toText() const
Convert the address to a string.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
bool isV6Multicast() const
checks whether and address is IPv6 and is multicast
static IOAddress increase(const IOAddress &addr)
Returns an address increased by one.
IOAddress(const std::string &address_str)
Constructor from string.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
short getFamily() const
Returns the address family.
static IOAddress fromBytes(short family, const uint8_t *data)
Creates an address from over wire data.
An exception that is thrown if an error occurs within the IO module.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::ostream & operator<<(std::ostream &os, const IOAddress &address)
Insert the IOAddress as a string into stream.
size_t hash_value(const IOAddress &address)
Hash the IOAddress.
Defines the logger used by the top-level component of kea-lfc.
size_t operator()(const IOAddress &io_address) const
A hashing operator.