18#if defined(PROMEKI_PLATFORM_WINDOWS)
21#elif !defined(PROMEKI_PLATFORM_EMSCRIPTEN)
22# include <netinet/in.h>
90 for(
size_t i = 0;
i < 16; ++
i) _addr[
i] = bytes[
i];
103 bool isLinkLocal()
const {
return _addr[0] == 0xFE && (_addr[1] & 0xC0) == 0x80; }
109 bool isSiteLocal()
const {
return _addr[0] == 0xFE && (_addr[1] & 0xC0) == 0xC0; }
164#if !defined(PROMEKI_PLATFORM_EMSCRIPTEN)
188 return _addr ==
other._addr && _scopeId ==
other._scopeId;
195 if(
cmp != 0)
return cmp < 0;
196 return _scopeId <
other._scopeId;
bool isZero() const
Returns true if all elements are zero.
Definition array.h:297
T * data()
Returns a mutable pointer to the underlying contiguous storage.
Definition array.h:281
Lightweight error code wrapper for the promeki library.
Definition error.h:39
IPv4 network address.
Definition ipv4address.h:51
IPv6 network address.
Definition ipv6address.h:52
uint32_t scopeId() const
Returns the scope ID.
Definition ipv6address.h:115
Ipv4Address toIpv4() const
Extracts the IPv4 address from an IPv4-mapped IPv6 address.
const uint8_t * raw() const
Returns a pointer to the raw byte data.
Definition ipv6address.h:133
static Ipv6Address any()
Returns the any address (::).
Definition ipv6address.h:71
Ipv6Address(const uint8_t *bytes)
Constructs from a raw byte pointer (copies 16 bytes).
Definition ipv6address.h:89
bool operator!=(const Ipv6Address &other) const
Returns true if the addresses are not equal.
Definition ipv6address.h:191
Ipv6Address(const DataFormat &bytes)
Constructs from raw 16-byte data.
Definition ipv6address.h:83
static Result< Ipv6Address > fromString(const String &str)
Parses an IPv6 address from colon-hex notation.
void setScopeId(uint32_t id)
Sets the scope ID.
Definition ipv6address.h:121
bool isSiteLocal() const
Returns true if this is a site-local address (fec0::/10, deprecated).
Definition ipv6address.h:109
bool operator==(const Ipv6Address &other) const
Returns true if both addresses are equal (includes scope ID).
Definition ipv6address.h:187
const DataFormat & data() const
Returns a const reference to the raw 16-byte data.
Definition ipv6address.h:127
String toString() const
Returns a canonical string representation.
bool isLinkLocal() const
Returns true if this is a link-local address (fe80::/10).
Definition ipv6address.h:103
Array< uint8_t, 16 > DataFormat
Raw 16-byte storage format for an IPv6 address.
Definition ipv6address.h:55
bool isNull() const
Returns true if all bytes are zero and scope ID is zero.
Definition ipv6address.h:94
Error toSockAddr(struct sockaddr_in6 *sa) const
Fills a sockaddr_in6 with this address.
static Ipv6Address loopback()
Returns the loopback address (::1).
MacAddress multicastMac() const
Returns the Ethernet multicast MAC address for this IPv6 multicast address.
static Result< Ipv6Address > fromSockAddr(const struct sockaddr_in6 *sa)
Constructs from a sockaddr_in6 structure.
Ipv6Address()
Default constructor. Creates a null (all-zero) address.
Definition ipv6address.h:77
bool isV4Mapped() const
Returns true if this is an IPv4-mapped address (::%ffff:0:0/96).
bool isMulticast() const
Returns true if this is a multicast address (ff00::/8).
Definition ipv6address.h:100
bool isLoopback() const
Returns true if this is the loopback address (::1).
bool operator<(const Ipv6Address &other) const
Less-than comparison for ordering (lexicographic, then scope).
Definition ipv6address.h:193
Dynamic array container wrapping std::vector.
Definition list.h:40
T * data() noexcept
Returns a pointer to the underlying contiguous storage.
Definition list.h:286
IEEE 802 MAC (Ethernet hardware) address.
Definition macaddress.h:44
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Formatted text I/O with encoding awareness.
Definition textstream.h:54
TextStream & operator<<(TextStream &stream, const Ipv6Address &addr)
Writes a colon-hex IPv6 address to the stream.
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19