25 #include <arpa/inet.h>
31 #if (defined HAVE_LIBNL3) || (defined HAVE_LIBNL)
42 : _address(VADDR_ANY), _service(), _scope(), _family(AF_UNSPEC)
47 : _address(VADDR_ANY), _service(), _scope(), _family(family)
55 : _address(address), _service(), _scope(), _family(family)
63 : _address(address), _service(service), _scope(), _family(family)
67 vaddress::vaddress(
const std::string &address,
const std::string &service,
const std::string &scope, sa_family_t family)
68 : _address(address), _service(service), _scope(scope), _family(family)
78 if (_address < dhs._address)
return true;
79 if (_scope < dhs._scope)
return true;
86 if (_address != obj._address)
return true;
87 if (_scope != obj._scope)
return true;
93 if (_address != obj._address)
return false;
94 if (_scope != obj._scope)
return false;
110 if (_family != AF_UNSPEC)
113 struct addrinfo hints;
114 memset(&hints, 0,
sizeof(
struct addrinfo));
115 hints.ai_family = PF_UNSPEC;
116 hints.ai_socktype = SOCK_DGRAM;
118 struct addrinfo *res;
126 address = this->
address().c_str();
129 service = this->
service().c_str();
132 if ((ret = ::getaddrinfo(address, service, &hints, &res)) != 0)
134 throw address_exception(
"getaddrinfo(): " + std::string(gai_strerror(ret)));
137 sa_family_t fam =
static_cast<sa_family_t
>(res->ai_family);
145 if (_scope.length() == 0)
throw scope_not_set();
151 if (_address.length() == 0)
throw address_not_set();
152 if (
isAny())
throw address_not_set();
158 if (_service.length() == 0)
throw service_not_set();
169 std::stringstream ss;
181 ss <<
" (" << scope <<
")";