This class encapsulates an IPv6 network prefix. More...
#include <DwmIpv6Prefix.hh>
Public Member Functions | |
| Ipv6Prefix () | |
| Constructor. | |
| Ipv6Prefix (const std::string &prefix) | |
| Construct from a string. | |
| Ipv6Prefix (const Ipv6Address &network, uint8_t maskLength) | |
| Construct from an IPv6 network address and netmask length. | |
| Ipv6Prefix (const Ipv6Prefix &prefix) | |
| Copy constructor. | |
| Ipv6Address | Network () const |
| Returns the network address. | |
| const in6_addr & | In6Addr () const |
| Ipv6Address | Netmask () const |
| Returns the netmask. | |
| uint8_t | MaskLength () const |
| Returns the netmask length. | |
| uint8_t | MaskLength (uint8_t maskLen) |
| Sets and returns the netmask length. | |
| bool | Set (const Ipv6Address &network, uint8_t maskLength) |
| Set the prefix using a network address and netmask length. | |
| bool | operator< (const Ipv6Prefix &prefix) const |
| Less-than operator. | |
| bool | operator> (const Ipv6Prefix &prefix) const |
| Greater-than operator. | |
| bool | operator== (const Ipv6Prefix &prefix) const |
| Equal-to operator. | |
| bool | operator!= (const Ipv6Prefix &prefix) const |
| Not-equal-to operator. | |
| bool | Contains (const Ipv6Address &addr) const |
Returns true if addr falls within the prefix. | |
| ssize_t | Read (int fd) |
| Reads the prefix from a file descriptor. | |
| ssize_t | Write (int fd) const |
| Writes the prefix to a file descriptor. | |
| size_t | Read (FILE *f) |
| Reads the prefix from a FILE pointer. | |
| size_t | Write (FILE *f) const |
| Writes the prefix to a FILE pointer. | |
| std::istream & | Read (std::istream &is) |
| Reads the prefix from an istream. Returns the istream. | |
| std::ostream & | Write (std::ostream &os) const |
| Writes the prefix to an ostream. Returns the ostream. | |
| int | Read (gzFile gzf) |
| Reads the prefix from a gzFile. | |
| int | Write (gzFile gzf) const |
| Writes the prefix to a gzFile. | |
| int | BZRead (BZFILE *bzf) |
| Reads the prefix from a BZFILE pointer. | |
| int | BZWrite (BZFILE *bzf) const |
| Writes the prefix to a BZFILE pointer. | |
| bool | Read (boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) |
Reads the prefix from s. | |
| bool | Write (boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) const |
Writes the prefix to s. | |
| bool | Read (boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec) |
Reads the prefix from s. | |
| bool | Write (boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec) const |
Writes the prefix to s. | |
| bool | Read (boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec) |
Reads the prefix from s. | |
| bool | Write (boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec) const |
Writes the prefix to s. | |
| uint64_t | StreamedLength () const |
| std::string | ToString () const |
| Returns a string representation of the prefix in the usual form, for example "1234:5678::/32". | |
| uint64_t | Hash () const |
| Given that the number of IPv6 addresses I typically deal with is nowhere near 4 billion, a 32-bit hash is sufficient if its distribution is effective. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Ipv6Prefix &prefix) |
| Prints a prefix to an ostream in the usual colon-delimited form. | |
This class encapsulates an IPv6 network prefix.
| Dwm::Ipv6Prefix::Ipv6Prefix | ( | const Ipv6Address & | network, |
| uint8_t | maskLength ) |
Construct from an IPv6 network address and netmask length.
The network address may be a host address; this constructor will apply the netmask.
|
inline |
Given that the number of IPv6 addresses I typically deal with is nowhere near 4 billion, a 32-bit hash is sufficient if its distribution is effective.
And it's faster on small 32-bit platforms. Hence I'm currently using XXH32(), and only on the non-zero bytes of the address. Yes, that means I'll have collisions for some prefixes but it's a small (near 0) number in my usage. I'm looking for average speed here.
| bool Dwm::Ipv6Prefix::Read | ( | boost::asio::generic::stream_protocol::socket & | s, |
| boost::system::error_code & | ec ) |
Reads the prefix from s.
Returns true on success, false on failure.
| bool Dwm::Ipv6Prefix::Read | ( | boost::asio::ip::tcp::socket & | s, |
| boost::system::error_code & | ec ) |
Reads the prefix from s.
Returns true on success, false on failure.
| bool Dwm::Ipv6Prefix::Read | ( | boost::asio::local::stream_protocol::socket & | s, |
| boost::system::error_code & | ec ) |
Reads the prefix from s.
Returns true on success, false on failure.
| size_t Dwm::Ipv6Prefix::Read | ( | FILE * | f | ) |
Reads the prefix from a FILE pointer.
Returns 1 on success, 0 on failure.
| bool Dwm::Ipv6Prefix::Set | ( | const Ipv6Address & | network, |
| uint8_t | maskLength ) |
Set the prefix using a network address and netmask length.
Returns true on success, false on failure.
| bool Dwm::Ipv6Prefix::Write | ( | boost::asio::generic::stream_protocol::socket & | s, |
| boost::system::error_code & | ec ) const |
Writes the prefix to s.
Returns true on success, false on failure.
| bool Dwm::Ipv6Prefix::Write | ( | boost::asio::ip::tcp::socket & | s, |
| boost::system::error_code & | ec ) const |
Writes the prefix to s.
Returns true on success, false on failure.
| bool Dwm::Ipv6Prefix::Write | ( | boost::asio::local::stream_protocol::socket & | s, |
| boost::system::error_code & | ec ) const |
Writes the prefix to s.
Returns true on success, false on failure.
| size_t Dwm::Ipv6Prefix::Write | ( | FILE * | f | ) | const |
Writes the prefix to a FILE pointer.
Returns 1 on success, 0 on failure.