114 bool isNull()
const {
return _addr.isZero(); }
125 for(
size_t i = 0;
i < 6; ++
i) {
126 if(_addr[
i] != 0xFF)
return false;
159 return _addr[0] == 0x01 && _addr[1] == 0x00 &&
160 _addr[2] == 0x5E && (_addr[3] & 0x80) == 0;
170 return _addr[0] == 0x33 && _addr[1] == 0x33;
229 return std::memcmp(_addr.data(),
other._addr.
data(), 6) < 0;
IPv4 network address.
Definition ipv4address.h:51
IPv6 network address.
Definition ipv6address.h:52
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
MacAddress(const DataFormat &bytes)
Constructs from raw 6-byte data.
Definition macaddress.h:97
MacAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f)
Constructs from six individual octets.
Definition macaddress.h:108
bool isBroadcast() const
Returns true if this is the Ethernet broadcast address (ff:ff:ff:ff:ff:ff).
Definition macaddress.h:124
bool isIpv4Multicast() const
Returns true if this is an IPv4 multicast MAC address.
Definition macaddress.h:158
bool isUnicast() const
Returns true if this is a unicast address.
Definition macaddress.h:178
static MacAddress broadcast()
Returns the Ethernet broadcast address (ff:ff:ff:ff:ff:ff).
const DataFormat & data() const
Returns a const reference to the raw 6-byte data.
Definition macaddress.h:192
bool operator==(const MacAddress &other) const
Returns true if both addresses are equal.
Definition macaddress.h:224
MacAddress()
Default constructor. Creates a null (00:00:00:00:00:00) address.
Definition macaddress.h:91
bool isNull() const
Returns true if all bytes are zero.
Definition macaddress.h:114
bool isLocallyAdministered() const
Returns true if this is a locally-administered address.
Definition macaddress.h:186
String toString(char separator) const
Returns a hex string with a custom separator.
bool operator<(const MacAddress &other) const
Less-than comparison for ordering (lexicographic).
Definition macaddress.h:228
uint8_t octet(int index) const
Returns a single octet of the address.
Definition macaddress.h:205
const uint8_t * raw() const
Returns a pointer to the raw byte data.
Definition macaddress.h:198
bool isMulticast() const
Returns true if this is a group (multicast) address.
Definition macaddress.h:140
String toString() const
Returns a colon-separated hex string.
static MacAddress fromIpv4Multicast(const Ipv4Address &addr)
Computes the multicast MAC address for an IPv4 multicast address.
bool isIpv6Multicast() const
Returns true if this is an IPv6 multicast MAC address.
Definition macaddress.h:169
bool operator!=(const MacAddress &other) const
Returns true if the addresses are not equal.
Definition macaddress.h:226
bool isGroupMulticast() const
Returns true if this is a group multicast address but NOT broadcast.
Definition macaddress.h:149
static MacAddress fromIpv6Multicast(const Ipv6Address &addr)
Computes the multicast MAC address for an IPv6 multicast address.
static Result< MacAddress > fromString(const String &str)
Parses a MAC address from a string.
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 MacAddress &addr)
Writes a colon-separated MAC 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