idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::net::ip6_addr Class Reference

IPv6 address value type. More...

Public Member Functions

constexpr ip6_addr () noexcept=default
 Constructs a zero-initialized IPv6 address (::).
 
constexpr ip6_addr (std::array< uint32_t, 4 > words, uint8_t zone=0) noexcept
 Constructs an IPv6 address from four 32-bit words.
 
constexpr const std::array< uint32_t, 4 > & addr () const noexcept
 Returns the four 32-bit words of the address.
 
constexpr uint8_t zone () const noexcept
 Returns the zone ID.
 
constexpr bool is_any () const noexcept
 Tests whether this is a zero (unset) address.
 
constexpr bool operator== (const ip6_addr &) const noexcept=default
 Compares two IPv6 addresses for equality (including zone).
 

Static Public Member Functions

static std::optional< ip6_addrparse (std::string_view s) noexcept
 Parses an IPv6 address from its text representation.
 

Detailed Description

IPv6 address value type.

Stores an IPv6 address as four 32-bit words plus an optional zone ID.

auto addr = idfxx::net::ip6_addr({0xfe800000, 0, 0, 1});
auto s = idfxx::to_string(addr); // "fe80::1"
IPv6 address value type.
Definition net.hpp:121
constexpr const std::array< uint32_t, 4 > & addr() const noexcept
Returns the four 32-bit words of the address.
Definition net.hpp:163
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
Definition cpu.hpp:52
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

Definition at line 121 of file net.hpp.

Constructor & Destructor Documentation

◆ ip6_addr() [1/2]

constexpr idfxx::net::ip6_addr::ip6_addr ( )
constexprdefaultnoexcept

Constructs a zero-initialized IPv6 address (::).

◆ ip6_addr() [2/2]

constexpr idfxx::net::ip6_addr::ip6_addr ( std::array< uint32_t, 4 >  words,
uint8_t  zone = 0 
)
inlineexplicitconstexprnoexcept

Constructs an IPv6 address from four 32-bit words.

Parameters
wordsThe four 32-bit words of the IPv6 address.
zoneOptional zone ID (default 0).

Definition at line 154 of file net.hpp.

Member Function Documentation

◆ addr()

constexpr const std::array< uint32_t, 4 > & idfxx::net::ip6_addr::addr ( ) const
inlineconstexprnoexcept

Returns the four 32-bit words of the address.

Returns
Reference to the address words array.

Definition at line 163 of file net.hpp.

◆ is_any()

constexpr bool idfxx::net::ip6_addr::is_any ( ) const
inlineconstexprnoexcept

Tests whether this is a zero (unset) address.

Returns
True if all address words are zero.

Definition at line 177 of file net.hpp.

◆ operator==()

constexpr bool idfxx::net::ip6_addr::operator== ( const ip6_addr ) const
constexprdefaultnoexcept

Compares two IPv6 addresses for equality (including zone).

◆ parse()

static std::optional< ip6_addr > idfxx::net::ip6_addr::parse ( std::string_view  s)
staticnoexcept

Parses an IPv6 address from its text representation.

Accepts standard colon-separated hex format with optional :: compression and an optional zone suffix (e.g. "fe80::1%3"). Each group is 1–4 hex digits. Exactly one :: may appear, representing one or more consecutive all-zero groups.

Parameters
sThe string to parse (e.g. "2001:db8::1", "::1", "fe80::1%3").
Returns
The parsed address, or std::nullopt if the string is not valid.
auto addr = idfxx::net::ip6_addr::parse("fe80::1%3");
if (addr) {
// use *addr
}
static std::optional< ip6_addr > parse(std::string_view s) noexcept
Parses an IPv6 address from its text representation.

◆ zone()

constexpr uint8_t idfxx::net::ip6_addr::zone ( ) const
inlineconstexprnoexcept

Returns the zone ID.

Returns
The zone ID.

Definition at line 170 of file net.hpp.


The documentation for this class was generated from the following file: