41#ifndef _DWMIPV6ADDRESS_HH_
42#define _DWMIPV6ADDRESS_HH_
45 #include <netinet/in.h>
84 operator std::string ()
const;
89 operator struct in6_addr () const;
110 {
return (! (*
this == addr)); }
137 return (
const uint8_t *)&_addr;
143 inline const in6_addr & In6Addr()
const
157 std::istream &
Read(std::istream & is);
162 std::ostream &
Write(std::ostream & os)
const;
213 template <
typename ST>
217 using boost::asio::read, boost::asio::buffer;
218 return ((read(s, buffer(_addr.s6_addr, 16), ec) == 16) && (! ec));
224 template <
typename ST>
226 bool ASIO_Write(ST & s, boost::system::error_code & ec)
const
228 using boost::asio::write, boost::asio::buffer;
229 return ((write(s, buffer(_addr.s6_addr, 16), ec) == 16) && (! ec));
236 bool Read(boost::asio::ip::tcp::socket & s,
237 boost::system::error_code & ec)
244 bool Write(boost::asio::ip::tcp::socket & s,
245 boost::system::error_code & ec)
const
252 bool Read(boost::asio::local::stream_protocol::socket & s,
253 boost::system::error_code & ec)
260 bool Write(boost::asio::local::stream_protocol::socket & s,
261 boost::system::error_code & ec)
const
268 bool Read(boost::asio::generic::stream_protocol::socket & s,
269 boost::system::error_code & ec)
276 bool Write(boost::asio::generic::stream_protocol::socket & s,
277 boost::system::error_code & ec)
const
291 return XXH64(_addr.s6_addr, 16, 0);
295 alignas(8)
struct in6_addr _addr;
Dwm::ASIO class declaration.
This class encapsulates an IPv6 address.
Definition DwmIpv6Address.hh:64
Ipv6Address & operator&=(const Ipv6Address &netmask)
Mask operator.
Ipv6Address(const struct in6_addr &addr)
Construct from an in6_addr.
uint64_t Hash() const
Returns a 64-bit hash value for the Ipv6Address.
Definition DwmIpv6Address.hh:289
size_t Write(FILE *f) const
Writes to a FILE pointer. Returns 1 on success, 0 on failure.
bool Read(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec)
Reads the Ipv6Address from s.
Definition DwmIpv6Address.hh:236
bool IsLinkLocal() const
Returns true if the address is link-local.
ssize_t Read(int fd)
Reads from a file descriptor.
bool Write(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec) const
Writes the Ipv6Address to s.
Definition DwmIpv6Address.hh:260
int BZRead(BZFILE *bzf)
Reads from a BZFILE pointer.
std::istream & Read(std::istream &is)
Reads from an istream. Returns the istream.
Ipv6Address operator&(const Ipv6Address &netmask) const
Mask operator.
int Read(gzFile gzf)
Reads from a gzFile.
bool operator<(const Ipv6Address &addr) const
Less-than operator.
bool Read(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec)
Reads the Ipv6Address from s.
Definition DwmIpv6Address.hh:252
Ipv6Address()
Constructor. Sets address to 0::
bool IsSiteLocal() const
Returns true if the address is site-local.
bool Write(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) const
Writes the Ipv6Address to s.
Definition DwmIpv6Address.hh:244
uint64_t StreamedLength() const
Returns the number of bytes that would be written if we called one of the Write() members.
bool ASIO_Read(ST &s, boost::system::error_code &ec)
Function template intended for boost::asio stream sockets.
Definition DwmIpv6Address.hh:215
bool Write(boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec) const
Writes the Ipv6Address to s.
Definition DwmIpv6Address.hh:276
int BZWrite(BZFILE *bzf) const
Writes to a BZFILE pointer.
ssize_t Write(int fd) const
Writes to a file descriptor.
Ipv6Address(const std::string &addr)
Construct from a string.
bool ASIO_Write(ST &s, boost::system::error_code &ec) const
Function template intended for boost::asio stream sockets.
Definition DwmIpv6Address.hh:226
bool operator>(const Ipv6Address &addr) const
Greater-than operator.
std::ostream & Write(std::ostream &os) const
Writes to an ostream. Returns the ostream.
bool operator==(const Ipv6Address &addr) const
Equal-to operator.
bool Read(boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec)
Reads the Ipv6Address from s.
Definition DwmIpv6Address.hh:268
size_t Read(FILE *f)
Reads from a FILE pointer. Returns 1 on success, 0 on failure.
friend std::ostream & operator<<(std::ostream &os, const Ipv6Address &addr)
Prints an Ipv6Address to an ostream in human-readable form.
int Write(gzFile gzf) const
Writes to a gzFile.
const uint8_t * RawPointer() const
Returns a pointer to the memory containing the address.
Definition DwmIpv6Address.hh:135
bool operator!=(const Ipv6Address &addr) const
Not-equal-to operator.
Definition DwmIpv6Address.hh:109
Concept for the types of ASIO sockets we can utilize.
Definition DwmASIO.hh:68