IPv6 network address. More...
#include <ipv6address.h>
Public Types | |
| using | DataFormat = Array< uint8_t, 16 > |
| Raw 16-byte storage format for an IPv6 address. | |
Public Member Functions | |
| Ipv6Address () | |
| Default constructor. Creates a null (all-zero) address. | |
| Ipv6Address (const DataFormat &bytes) | |
| Constructs from raw 16-byte data. | |
| Ipv6Address (const uint8_t *bytes) | |
| Constructs from a raw byte pointer (copies 16 bytes). | |
| bool | isNull () const |
| Returns true if all bytes are zero and scope ID is zero. | |
| bool | isLoopback () const |
| Returns true if this is the loopback address (::1). | |
| bool | isMulticast () const |
| Returns true if this is a multicast address (ff00::/8). | |
| bool | isLinkLocal () const |
| Returns true if this is a link-local address (fe80::/10). | |
| bool | isV4Mapped () const |
| Returns true if this is an IPv4-mapped address (::%ffff:0:0/96). | |
| bool | isSiteLocal () const |
| Returns true if this is a site-local address (fec0::/10, deprecated). | |
| uint32_t | scopeId () const |
| Returns the scope ID. | |
| void | setScopeId (uint32_t id) |
| Sets the scope ID. | |
| const DataFormat & | data () const |
| Returns a const reference to the raw 16-byte data. | |
| const uint8_t * | raw () const |
| Returns a pointer to the raw byte data. | |
| String | toString () const |
| Returns a canonical string representation. | |
| Ipv4Address | toIpv4 () const |
| Extracts the IPv4 address from an IPv4-mapped IPv6 address. | |
| MacAddress | multicastMac () const |
| Returns the Ethernet multicast MAC address for this IPv6 multicast address. | |
| Error | toSockAddr (struct sockaddr_in6 *sa) const |
| Fills a sockaddr_in6 with this address. | |
| bool | operator== (const Ipv6Address &other) const |
| Returns true if both addresses are equal (includes scope ID). | |
| bool | operator!= (const Ipv6Address &other) const |
| Returns true if the addresses are not equal. | |
| bool | operator< (const Ipv6Address &other) const |
| Less-than comparison for ordering (lexicographic, then scope). | |
Static Public Member Functions | |
| static Result< Ipv6Address > | fromString (const String &str) |
| Parses an IPv6 address from colon-hex notation. | |
| static Ipv6Address | any () |
| Returns the any address (::). | |
| static Ipv6Address | loopback () |
| Returns the loopback address (::1). | |
| static Result< Ipv6Address > | fromSockAddr (const struct sockaddr_in6 *sa) |
| Constructs from a sockaddr_in6 structure. | |
IPv6 network address.
Simple value type representing a 128-bit IPv6 address stored in network byte order. Provides parsing (RFC 5952), formatting, scope ID support, and classification (loopback, multicast, etc.).
This class is purely computational and requires no platform-specific headers or system calls.
This class is not thread-safe. Concurrent access to a single instance requires external synchronization.
|
inlineexplicit |
Constructs from raw 16-byte data.
| bytes | The 16 bytes of the IPv6 address in network byte order. |
Constructs from a raw byte pointer (copies 16 bytes).
| bytes | Pointer to 16 bytes in network byte order. |
|
inline |
Returns a const reference to the raw 16-byte data.
|
static |
Constructs from a sockaddr_in6 structure.
| sa | Pointer to a sockaddr_in6. Must have sin6_family == AF_INET6. |
|
static |
Parses an IPv6 address from colon-hex notation.
Accepts standard colon-hex formats including "::" compression and optional "%scope" suffix. Also accepts IPv4-mapped notation (e.g. "::%%ffff:192.168.1.1").
| str | The string to parse. |
| MacAddress Ipv6Address::multicastMac | ( | ) | const |
Returns the Ethernet multicast MAC address for this IPv6 multicast address.
Maps this address to its multicast MAC (33:33 + low 32 bits) per RFC 2464.
Returns a pointer to the raw byte data.
|
inline |
Returns the scope ID.
Sets the scope ID.
| id | The numeric scope ID. |
| Ipv4Address Ipv6Address::toIpv4 | ( | ) | const |
Extracts the IPv4 address from an IPv4-mapped IPv6 address.
Only valid when isV4Mapped() is true. Returns a null Ipv4Address otherwise.
| Error Ipv6Address::toSockAddr | ( | struct sockaddr_in6 * | sa | ) | const |
Fills a sockaddr_in6 with this address.
Sets sin6_family, sin6_addr, and sin6_scope_id. The port field (sin6_port) is set to zero; callers should set it separately.
| [out] | sa | The structure to fill. |
| String Ipv6Address::toString | ( | ) | const |
Returns a canonical string representation.
Uses "::" compression for the longest run of zero groups per RFC 5952. Does not include the scope ID suffix.