EtcPal
0.4.1
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper class for the EtcPal IP address type.
Provides C++ syntactic sugar for working with IP addresses.
Public Member Functions | |
ETCPAL_CONSTEXPR_14 | IpAddr () noexcept |
Constructs an invalid IP address by default. | |
constexpr | IpAddr (const EtcPalIpAddr &c_ip) noexcept |
Construct an IP address copied from an instance of the C EtcPalIpAddr type. | |
IpAddr & | operator= (const EtcPalIpAddr &c_ip) noexcept |
Assign an instance of the C EtcPalIpAddr type to an instance of this class. | |
ETCPAL_CONSTEXPR_14 | IpAddr (uint32_t v4_data) noexcept |
Construct an IPv4 address from its raw 32-bit representation. More... | |
IpAddr (const uint8_t *v6_data) noexcept | |
Construct an IPv6 address from its raw 16-byte array representation. More... | |
IpAddr (const uint8_t *v6_data, unsigned long scope_id) noexcept | |
Construct an IPv6 address from its raw 16-bytes array representation and scope ID. More... | |
constexpr const EtcPalIpAddr & | get () const noexcept |
Get a const reference to the underlying C type. | |
ETCPAL_CONSTEXPR_14 EtcPalIpAddr & | get () noexcept |
Get a mutable reference to the underlying C type. | |
std::string | ToString () const |
Convert the IP address to a string representation. More... | |
constexpr uint32_t | v4_data () const noexcept |
Get the raw 32-bit representation of an IPv4 address. More... | |
constexpr const uint8_t * | v6_data () const noexcept |
Get the raw 16-byte array representation of an IPv6 address. More... | |
std::array< uint8_t, ETCPAL_IPV6_BYTES > | ToV6Array () const |
Get a 16-byte std::array representation of an IPv6 address. More... | |
constexpr unsigned long | scope_id () const noexcept |
Get the scope ID of an IPv6 address. More... | |
constexpr bool | IsValid () const noexcept |
Whether an IpAddr contains a valid IPv4 or IPv6 address. | |
constexpr IpAddrType | type () const noexcept |
Get the type of the IP address. | |
constexpr bool | IsV4 () const noexcept |
Whether an IpAddr contains a valid IPv4 address. | |
constexpr bool | IsV6 () const noexcept |
Whether an IpAddr contains a valid IPv6 address. | |
bool | IsLinkLocal () const noexcept |
Whether an IpAddr contains a link-local address. | |
bool | IsLoopback () const noexcept |
Whether an IpAddr contains a loopback address. | |
bool | IsMulticast () const noexcept |
Whether an IpAddr contains a multicast address. | |
bool | IsWildcard () const noexcept |
Whether an IpAddr contains a wildcard address. More... | |
unsigned int | MaskLength () const noexcept |
The number of consecutive set bits in a netmask. 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... | |
Static Public Member Functions | |
static IpAddr | FromString (const char *ip_str) noexcept |
Construct an IpAddr from a string representation. More... | |
static IpAddr | FromString (const std::string &ip_str) noexcept |
Construct an IpAddr from a string representation. More... | |
static IpAddr | WildcardV4 () noexcept |
Construct a wildcard IPv4 address. More... | |
static IpAddr | WildcardV6 () noexcept |
Construct a wildcard IPv6 address. More... | |
static IpAddr | Wildcard (IpAddrType type) noexcept |
Construct a wildcard address of the type specified. More... | |
static IpAddr | NetmaskV4 (unsigned int mask_length) noexcept |
Construct an IPv4 netmask given a length in bits. More... | |
static IpAddr | NetmaskV6 (unsigned int mask_length) noexcept |
Construct an IPv6 netmask given a length in bits. More... | |
static IpAddr | Netmask (IpAddrType type, unsigned int mask_length) noexcept |
Construct a netmask of the type specifed given a length in bits. More... | |
|
noexcept |
Construct an IPv4 address from its raw 32-bit representation.
[in] | v4_data | The address data in host byte order. |
|
inlineexplicitnoexcept |
Construct an IPv6 address from its raw 16-byte array representation.
[in] | v6_data | Pointer to the address data, an array of length ETCPAL_IPV6_BYTES. |
|
inlinenoexcept |
Construct an IPv6 address from its raw 16-bytes array representation and scope ID.
See 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. |
|
inlinestaticnoexcept |
Construct an IpAddr from a string representation.
See etcpal_string_to_ip() for more information.
|
inlinestaticnoexcept |
Construct an IpAddr from a string representation.
See etcpal_string_to_ip() for more information.
|
inlinenoexcept |
Whether an IpAddr contains a wildcard address.
See etcpal_ip_is_wildcard() for more information.
|
inlinenoexcept |
The number of consecutive set bits in a netmask.
See etcpal_ip_mask_length() for more information.
|
inlinestaticnoexcept |
Construct a netmask of the type specifed given a length in bits.
See etcpal_ip_mask_from_length() for more information.
|
inlinestaticnoexcept |
Construct an IPv4 netmask given a length in bits.
See etcpal_ip_mask_from_length() for more information.
|
inlinestaticnoexcept |
Construct an IPv6 netmask given a length in bits.
See etcpal_ip_mask_from_length() for more information.
|
constexprnoexcept |
Get the scope ID of an 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 IpAddr's type is V4 or Invalid.
|
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 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. |
|
inline |
Convert the IP address to a string representation.
See etcpal_ip_to_string() for more information.
|
inline |
Get a 16-byte std::array representation of an IPv6 address.
Copies the data into a new array. This function will return undefined data if the IpAddr's type is V4 or Invalid.
|
constexprnoexcept |
Get the raw 32-bit representation of an IPv4 address.
This function will return undefined data if the IpAddr's type is V6 or Invalid.
|
constexprnoexcept |
|
inlinestaticnoexcept |
Construct a wildcard address of the type specified.
See etcpal_ip_set_wildcard() for more information.
|
inlinestaticnoexcept |
Construct a wildcard IPv4 address.
See etcpal_ip_set_wildcard() for more information.
|
inlinestaticnoexcept |
Construct a wildcard IPv6 address.
See etcpal_ip_set_wildcard() for more information.