EtcPal
0.4.1
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper for the EtcPal socket address type.
Provides C++ syntactic sugar for working with socket addresses, which contain an IP address and port.
Public Member Functions | |
ETCPAL_CONSTEXPR_14 | SockAddr () noexcept |
Constructs an invalid SockAddr by default. | |
constexpr | SockAddr (const EtcPalSockAddr &c_sa) noexcept |
Construct a SockAddr copied from an instance of the C EtcPalSockAddr type. | |
SockAddr & | operator= (const EtcPalSockAddr &c_sa) noexcept |
Assign an instance of the C EtcPalSockAddr type to an instance of this class. | |
ETCPAL_CONSTEXPR_14 | SockAddr (uint32_t v4_data, uint16_t port) noexcept |
Construct a SockAddr from a raw 32-bit IPv4 representation and port number. More... | |
SockAddr (const uint8_t *v6_data, uint16_t port) noexcept | |
Construct a SockAddr from a raw 16-byte IPv6 representation and port number. More... | |
SockAddr (const uint8_t *v6_data, unsigned long scope_id, uint16_t port) noexcept | |
Construct a Sockaddr from a raw 16-byte IPv6 representation with scope ID and port number. More... | |
ETCPAL_CONSTEXPR_14 | SockAddr (IpAddr ip, uint16_t port) noexcept |
Construct a SockAddr from an IpAddr and port number. More... | |
constexpr const EtcPalSockAddr & | get () const noexcept |
Get a const reference to the underlying C type. | |
ETCPAL_CONSTEXPR_14 EtcPalSockAddr & | get () noexcept |
Get a mutable reference to the underlying C type. | |
std::string | ToString () const |
Convert the IP address and port to a string representation. More... | |
constexpr IpAddr | ip () const noexcept |
Get the IP address from the SockAddr. | |
constexpr uint16_t | port () const noexcept |
Get the port number from the SockAddr. | |
constexpr uint32_t | v4_data () const noexcept |
Get the raw 32-bit representation of the SockAddr's IPv4 address. More... | |
constexpr const uint8_t * | v6_data () const noexcept |
Get the raw 16-byte array representation of the SockAddr's IPv6 address. More... | |
std::array< uint8_t, ETCPAL_IPV6_BYTES > | ToV6Array () const |
Get a 16-byte std::array representation of the SockAddr's IPv6 address. More... | |
constexpr unsigned long | scope_id () const noexcept |
Get the scope ID of the SockAddr's IPv6 address. More... | |
constexpr bool | IsValid () const noexcept |
Whether a SockAddr contains a valid IPv4 or IPv6 address. | |
constexpr IpAddrType | type () const noexcept |
Get the type of the SockAddr's IP address. | |
constexpr bool | IsV4 () const noexcept |
Whether a SockAddr contains a valid IPv4 address. | |
constexpr bool | IsV6 () const noexcept |
Whether a SockAddr contains a valid IPv6 address. | |
bool | IsLinkLocal () const noexcept |
Whether a SockAddr contains a link-local address. | |
bool | IsLoopback () const noexcept |
Whether a SockAddr contains a loopback address. | |
bool | IsMulticast () const noexcept |
Whether a SockAddr contains a multicast address. | |
bool | IsWildcard () const noexcept |
Whether a SockAddr contains a wildcard address. More... | |
void | SetAddress (uint32_t v4_data) noexcept |
Set the IPv4 address data. More... | |
void | SetAddress (const uint8_t *v6_data) noexcept |
Set the IPv6 address data. More... | |
void | SetAddress (const uint8_t *v6_data, unsigned long scope_id) noexcept |
Set the IPv6 address data and scope ID. More... | |
void | SetAddress (const IpAddr &ip) noexcept |
Set the IP address using an IpAddr instance. More... | |
void | SetPort (uint16_t port) noexcept |
Set the port. More... | |
|
noexcept |
Construct a SockAddr from a raw 32-bit IPv4 representation and port number.
[in] | v4_data | The address data in host byte order. |
[in] | port | The port number in host byte order. |
|
inlinenoexcept |
Construct a SockAddr from a raw 16-byte IPv6 representation and port number.
[in] | v6_data | Pointer to the address data, an array of length ETCPAL_IPV6_BYTES. |
[in] | port | The port number in host byte order. |
|
inlinenoexcept |
Construct a Sockaddr from a raw 16-byte IPv6 representation with scope ID and port number.
See IpAddr::scope_id() for more information on scope IDs.
[in] | v6_data | Pointer to the address data, an array of length ETCPAL_IPV6_BYTES. |
[in] | scope_id | The Scope ID value. |
[in] | port | The port number in host byte order. |
|
noexcept |
|
inlinenoexcept |
Whether a SockAddr contains a wildcard address.
See etcpal_ip_is_wildcard() for more information.
|
constexprnoexcept |
Get the scope ID of the SockAddr's IPv6 address.
Scope IDs (sometimes referred to as Zone IDs or Zone Indices) are a lightly-documented portion of IPv6 addressing, but one concrete use is to indicate the network interface index of a link-local IPv6 address. See also Network Interface Indexes.
This function will return undefined data if the SockAddr's type is V4 or Invalid.
|
inlinenoexcept |
|
inlinenoexcept |
Set the IPv6 address data.
Automatically converts this address's type to V6.
[in] | v6_data | Pointer to the address data, an array of length ETCPAL_IPV6_BYTES. |
|
inlinenoexcept |
Set the IPv6 address data and scope ID.
See IpAddr::scope_id() for more information.
[in] | v6_data | Pointer to the address data, an array of length ETCPAL_IPV6_BYTES. |
[in] | scope_id | The address's scope ID. |
|
inlinenoexcept |
Set the IPv4 address data.
Automatically converts this address's type to V4.
[in] | v4_data | The address data in host byte order. |
|
inlinenoexcept |
Set the port.
[in] | port | The port number. |
|
inline |
Convert the IP address and port to a string representation.
The string will be of the form ddd.ddd.ddd.ddd:ppppp for IPv4 addresses, and [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]:ppppp for IPv6 addresses (common conventions and rules for compressing these representations will also apply).
|
inline |
|
constexprnoexcept |
|
constexprnoexcept |