128-bit IP address of an IPv6 endpoint.
More...
#include <GREM/networking/Endpoint.hpp>
|
| constexpr | IPv6Address (const in6_addr &sin6_addr) noexcept |
| | Construct an IPv6 address from a native in6_addr structure.
|
| constexpr | IPv6Address (uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4, uint8_t byte5, uint8_t byte6, uint8_t byte7, uint8_t byte8, uint8_t byte9, uint8_t byte10, uint8_t byte11, uint8_t byte12, uint8_t byte13, uint8_t byte14, uint8_t byte15) noexcept |
| | Construct an IPv6 address from its 16 constituent bytes, specified in the same order as in a string representation.
|
| constexpr Array< uint8_t, 16 > | toBigEndianBytes () const noexcept |
| | Convert this IPv6 address to an array of 16 bytes in network byte order.
|
| constexpr bool | isAny () const noexcept |
| | Check if the value of this IPv4 address is equal to the ANY address (::).
|
| constexpr bool | isLoopback () const noexcept |
| | Check if this IPv6 address is equal to the LOOPBACK address (::1).
|
| constexpr in6_addr * | get () noexcept |
| | Get a pointer to the underlying native in6_addr structure of the IPv6 address.
|
| constexpr const in6_addr * | get () const noexcept |
| | Get a pointer to the underlying native in6_addr structure of the IPv6 address.
|
| constexpr bool | operator== (const IPv6Address &other) const noexcept |
| | Compare this address to another for equality.
|
| constexpr std::strong_ordering | operator<=> (const IPv6Address &other) const noexcept |
| | Compare this address to another.
|
|
| static Optional< IPv6Address > | parse (CStringView string, std::error_code &errorCode) noexcept |
| | Parse an IPv6 address from an ASCII string representation.
|
| static IPv6Address | parse (CStringView string) |
| | Parse an IPv6 address from an ASCII string representation, throwing an exception on failure.
|
| static Optional< IPv6Address > | resolve (const char *hostName, const char *service, std::error_code &errorCode) |
| | Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
|
| static IPv6Address | resolve (const char *hostName, const char *service) |
| | Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
|
| static Optional< IPv6Address > | resolve (CStringView host, std::error_code &errorCode) |
| | Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
|
| static IPv6Address | resolve (CStringView host) |
| | Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
|
| static Optional< IPv6Address > | getLocalAddress (std::error_code &errorCode) |
| | Get the IPv6 address of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname().
|
| static IPv6Address | getLocalAddress () |
| | Get the IPv6 address of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname(), throwing an exception on failure.
|
|
| static const IPv6Address | ANY {detail::IPV6_ADDRESS_ANY} |
| | Value representing any IPv6 address (::).
|
| static const IPv6Address | LOOPBACK {detail::IPV6_ADDRESS_LOOPBACK} |
| | Value of the IPv6 loopback address (::1).
|
128-bit IP address of an IPv6 endpoint.
◆ IPv6Address() [1/2]
| grem::networking::IPv6Address::IPv6Address |
( |
const in6_addr & | sin6_addr | ) |
|
|
inlineexplicitconstexprnoexcept |
Construct an IPv6 address from a native in6_addr structure.
- Parameters
-
| sin6_addr | in6_addr structure to construct the IPv6 address from. |
◆ IPv6Address() [2/2]
| grem::networking::IPv6Address::IPv6Address |
( |
uint8_t | byte0, |
|
|
uint8_t | byte1, |
|
|
uint8_t | byte2, |
|
|
uint8_t | byte3, |
|
|
uint8_t | byte4, |
|
|
uint8_t | byte5, |
|
|
uint8_t | byte6, |
|
|
uint8_t | byte7, |
|
|
uint8_t | byte8, |
|
|
uint8_t | byte9, |
|
|
uint8_t | byte10, |
|
|
uint8_t | byte11, |
|
|
uint8_t | byte12, |
|
|
uint8_t | byte13, |
|
|
uint8_t | byte14, |
|
|
uint8_t | byte15 ) |
|
inlineconstexprnoexcept |
Construct an IPv6 address from its 16 constituent bytes, specified in the same order as in a string representation.
- Parameters
-
| byte0 | first byte value. |
| byte1 | second byte value. |
| byte2 | third byte value. |
| byte3 | fourth byte value. |
| byte4 | fifth byte value. |
| byte5 | sixth byte value. |
| byte6 | seventh byte value. |
| byte7 | eighth byte value. |
| byte8 | ninth byte value. |
| byte9 | tenth byte value. |
| byte10 | eleventh byte value. |
| byte11 | twelvth byte value. |
| byte12 | thirteenth byte value. |
| byte13 | fourteenth byte value. |
| byte14 | fifteenth byte value. |
| byte15 | sixteenth byte value. |
◆ parse() [1/2]
Parse an IPv6 address from an ASCII string representation.
- Parameters
-
| string | string containing the IPv6 address representation to parse. |
| errorCode | error code that is filled in on failure to parse a valid IPv6 address, or cleared on success. |
- Returns
- the parsed IPv6 address, or an empty optional if parsing failed.
◆ parse() [2/2]
Parse an IPv6 address from an ASCII string representation, throwing an exception on failure.
- Parameters
-
| string | string containing the IPv6 address representation to parse. |
- Returns
- the parsed IPv6 address.
- Exceptions
-
| networking::Error | on failure to parse a valid IPv6 address. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [1/4]
| Optional< IPv6Address > grem::networking::IPv6Address::resolve |
( |
const char * | hostName, |
|
|
const char * | service, |
|
|
std::error_code & | errorCode ) |
|
staticnodiscard |
Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
- Parameters
-
| hostName | null-terminated domain name or address string of the host to look up, e.g. "example.com" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr. |
| service | null-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr. |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
- Returns
- the resolved IPv6 address, or an empty optional if resolution failed.
◆ resolve() [2/4]
| IPv6Address grem::networking::IPv6Address::resolve |
( |
const char * | hostName, |
|
|
const char * | service ) |
|
staticnodiscard |
Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
- Parameters
-
| hostName | null-terminated domain name or address string of the host to look up, e.g. "example.com" or "::1", or nullptr to look up by service only. Must not be nullptr if service is nullptr. |
| service | null-terminated service or port string of the host to look up, e.g. "http" or "80", or nullptr to look up by host name only. Must not be nullptr if hostName is nullptr. |
- Returns
- the resolved IPv6 address.
- Exceptions
-
| networking::Error | on failure to resolve the host. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [3/4]
Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup.
- Parameters
-
| host | combined host name and service string separated by a colon, with the host enclosed in square brackets if it's an IPv6 address, e.g. "example.com:http" or "[::1]:80", or a host name-only string with no colon or no square brackets, e.g. "example.com" or "::1". |
| errorCode | error code that is filled in on failure to resolve the host, or cleared on success. |
- Returns
- the resolved IPv6 address, or an empty optional if resolution failed.
- Exceptions
-
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
◆ resolve() [4/4]
Resolve the IPv6 address of a host through the Domain Name System (DNS) using a getaddrinfo() lookup, throwing an exception on failure.
- Parameters
-
| host | combined host name and service string separated by a colon, with the host enclosed in square brackets if it's an IPv6 address, e.g. "example.com:http" or "[::1]:80", or a host name-only string with no colon or no square brackets, e.g. "example.com" or "::1". |
- Returns
- the resolved IPv6 address.
- Exceptions
-
| networking::Error | on failure to resolve the host. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
◆ getLocalAddress() [1/2]
| Optional< IPv6Address > grem::networking::IPv6Address::getLocalAddress |
( |
std::error_code & | errorCode | ) |
|
|
staticnodiscard |
Get the IPv6 address of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname().
- Parameters
-
| errorCode | error code that is filled in on failure to get the local address, or cleared on success. |
- Returns
- the local IPv6 address, or an empty optional on failure.
◆ getLocalAddress() [2/2]
| IPv6Address grem::networking::IPv6Address::getLocalAddress |
( |
| ) |
|
|
staticnodiscard |
Get the IPv6 address of the local host by calling connect() on a temporary connectionless socket to the loopback address on port 9 (the "Discard" service) and querying its local address with getsockname(), throwing an exception on failure.
- Returns
- the local IPv6 address.
- Exceptions
-
| networking::Error | on failure to get the local address. |
| std::bad_alloc | on allocation failure. |
◆ toBigEndianBytes()
| Array< uint8_t, 16 > grem::networking::IPv6Address::toBigEndianBytes |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Convert this IPv6 address to an array of 16 bytes in network byte order.
- Returns
- a big-endian array of the 16 byte values of the address.
◆ isAny()
| bool grem::networking::IPv6Address::isAny |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Check if the value of this IPv4 address is equal to the ANY address (::).
- Returns
- *this == IPv6Address::ANY.
◆ isLoopback()
| bool grem::networking::IPv6Address::isLoopback |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Check if this IPv6 address is equal to the LOOPBACK address (::1).
- Returns
- *this == IPv6Address::LOOPBACK.
◆ get() [1/2]
| in6_addr * grem::networking::IPv6Address::get |
( |
| ) |
|
|
inlinenodiscardconstexprnoexcept |
Get a pointer to the underlying native in6_addr structure of the IPv6 address.
- Returns
- a non-owning pointer to the underlying in6_addr structure.
◆ get() [2/2]
| const in6_addr * grem::networking::IPv6Address::get |
( |
| ) |
const |
|
inlinenodiscardconstexprnoexcept |
Get a pointer to the underlying native in6_addr structure of the IPv6 address.
- Returns
- a non-owning read-only pointer to the underlying in6_addr structure.
◆ operator==()
| bool grem::networking::IPv6Address::operator== |
( |
const IPv6Address & | other | ) |
const |
|
inlinenodiscardconstexprnoexcept |
Compare this address to another for equality.
- Parameters
-
| other | the address to compare this one to. |
- Returns
- true if the addresses are equal, false otherwise.
◆ operator<=>()
| std::strong_ordering grem::networking::IPv6Address::operator<=> |
( |
const IPv6Address & | other | ) |
const |
|
inlinenodiscardconstexprnoexcept |
Compare this address to another.
- Parameters
-
| other | the address to compare this one to. |
- Returns
- a strong ordering between the two addresses, based on the lexicographical ordering of their big-endian byte value arrays.
◆ ANY
| IPv6Address grem::networking::IPv6Address::ANY {detail::IPV6_ADDRESS_ANY} |
|
inlinestaticconstexpr |
Value representing any IPv6 address (::).
◆ LOOPBACK
| IPv6Address grem::networking::IPv6Address::LOOPBACK {detail::IPV6_ADDRESS_LOOPBACK} |
|
inlinestaticconstexpr |
Value of the IPv6 loopback address (::1).
The documentation for this class was generated from the following file: