![]() |
Spicy
|
#include <address.h>
Public Member Functions | |
Address (const std::string &addr) | |
Address (struct in_addr addr4) | |
Address (struct in6_addr addr6) | |
Address (uint32_t addr4) | |
Address (uint64_t addr6a, uint64_t addr6b, AddressFamily family=AddressFamily::IPv6) | |
Address (const Address &)=default | |
Address (Address &&) noexcept=default | |
Address & | operator= (const Address &)=default |
Address & | operator= (Address &&) noexcept=default |
AddressFamily | family () const |
Address | mask (unsigned int width) const |
std::variant< struct in_addr, struct in6_addr > | asInAddr () const |
bool | operator== (const Address &other) const |
bool | operator!= (const Address &other) const |
bool | operator< (const Address &other) const |
operator std::string () const | |
Bytes | pack (ByteOrder fmt) const |
Represents HILTI address type. This treats IPv4 and IPv6 addresses transparently by internally embedding the former into the latter's space.
|
inlineexplicit |
Constructs an address from a IPv4 or IPv6 string representation.
addr | string representation, as in 1.2.3.4 or 2001:db8:85a3:8d3:1319:8a2e:370:7348 . |
InvalidArgument | if it cannot parse the address into a valid IPv4 or IPv6 address. |
|
inlineexplicit |
Constructs an address from a C in_addr
struct.
|
inlineexplicit |
Constructs an address from a C in6_addr
struct.
|
inlineexplicit |
Constructs an address from binary representation of an IPv4 address.
addr4 | IPv4 address in host byte order |
|
inlineexplicit |
Constructs an address from binary representation of an IPv6 address.
addr6a | upper bits of IPv6 address in host byte order |
addr6a | lower bits of IPv6 address in host byte order |
std::variant< struct in_addr, struct in6_addr > Address::asInAddr | ( | ) | const |
Returns the address as in{,6}_addr
depending on whether it's a v4 or v6 value. For an unset address, returns an IPv4 0.0.0.0
.
AddressFamily Address::family | ( | ) | const |
Returns the address family of the address, which can be either IPv4 or IPv6.
Address Address::mask | ( | unsigned int | width | ) | const |
Returns a network prefix by masking out lower bits of the address.
width | number of upper bits to keep. |
Address::operator std::string | ( | ) | const |
Returns a string representation of the address. For addresses in the IPv4 space, this will returns the standard IPv4 notation, whereas IPv6 addresses will be formatted as such. The returned format corresponds to what the corresponding constructor parses.