21 #include <sys/types.h> 22 #include <sys/socket.h> 23 #include <netinet/in.h> 24 #include <arpa/inet.h> 26 #include <boost/lexical_cast.hpp> 42 if (::inet_pton(AF_INET6,s.c_str(),&ina) > 0)
54 struct hostent entbuf;
56 struct hostent * ent (0);
58 ::gethostbyname2_r(s.c_str(), AF_INET6, &entbuf, buffer,
sizeof(buffer), &ent, &herr);
63 static boost::mutex mutex;
64 boost::mutex::scoped_lock lock(mutex);
66 struct hostent * ent (::gethostbyname(s.c_str()));
70 if (ent && ent->h_addrtype == AF_INET6)
73 &reinterpret_cast<in6_addr*>(*(ent->h_addr_list))->s6_addr[0]);
83 std::copy((*this).begin(), (*this).end(), &ina.s6_addr[0]);
92 addr[8] = mac[0] ^ 0x2;
108 addr[8] = eui[0] ^ 0x2;
109 std::copy(eui.begin()+1, eui.end(), addr.begin()+9);
123 std::copy(addr.begin(),addr.end(),&ina.s6_addr[0]);
124 ::inet_ntop(AF_INET6,&ina,buffer,
sizeof(buffer));
125 buffer[
sizeof(buffer)-1] = 0;
139 is.setstate(std::ios::failbit);
154 using boost::lambda::_1;
155 using boost::lambda::_2;
156 std::string::size_type i (s.find(
'/'));
157 if (i == std::string::npos)
160 prefix_len_ = prefix_len_checked( boost::lexical_cast<unsigned>(std::string(s,i+1)));
161 }
catch (boost::bad_lexical_cast
const &) {
165 detail::apply_mask(prefix_len_, address_.begin(), address_.end(), _1 &= _2);
177 is.setstate(std::ios::failbit);
MACAddress public header.
static INet6Address from_string(std::string const &s, Resolve_t resolve=ResolveINet6)
Convert string to address.
static EUI64 from_data(InputIterator i)
Construct EUI-64 from 8 data octets.
std::ostream & operator<<(std::ostream &os, Packet const &packet)
INet6Address public header.
static INet6Address const Loopback
The loopback (::1) address.
in6_addr toin6_addr() const
get the linux in6_addr struct (convenience only)
std::istream & operator>>(std::istream &is, INet4SocketAddress &addr)
static INet6Address const AllNodes
The 'all nodes' link-local multicast address.
static INet6Address from_inet4address(INet4Address const &addr)
Construct an INet6-mapped INet4 address.
INet6Network()
Construct empty (::/0) network.
AddressExceptions public header.
static INet6Address const AllRouters
The 'all routers' link-local multicast address.
static INet4Address from_string(std::string const &s)
Convert string to address.
EUI64 id() const
Return interface id (EUID-64)
static INet6Address from_data(InputIterator i)
Construct address from 16 bytes of raw data.
Base-class for Address exceptions.
static INet6Address from_eui64(EUI64 const &eui)
Construct link-local INet6 address.
static INet6Address const None
The empty (::0) address.
static INet6Address from_mac(MACAddress const &mac)
Construct a link-local INet6 address.