A network hardware (MAC) address. More...

#include <MacAddress.h>

Public Types

using Octets = uint8_t[6]
 

Public Member Functions

 MacAddress ()=default
 
 MacAddress (const Octets &octets)
 
 MacAddress (const String &s)
 Create a MAC address from valid string. e.g. 01:02:03:04:05:06 Separators are optional. More...
 
void getOctets (Octets &octets) const
 Get the octets of the MAC address. More...
 
void setOctets (const Octets &octets)
 Set the octets of the MAC address. More...
 
const uint8_t & operator[] (unsigned index) const
 Get the octet at the given index in the MAC address. More...
 
uint8_t & operator[] (unsigned index)
 Get a reference to the octet at the given index in the MAC address. More...
 
String toString (char sep=':') const
 Return a String representation of the MacAddress. More...
 
 operator String () const
 
bool operator== (const MacAddress &other) const
 Equality operator. More...
 
bool operator!= (const MacAddress &other) const
 Inequality operator. More...
 
bool operator! () const
 Test if this is a null address (00:00:00:00:00:00). More...
 
 operator bool_type () const
 Safe bool operator, returns true if address is non-null. More...
 
void clear ()
 Clear address to null value. More...
 
uint32_t getHash () const
 Generate a simple 32-bit hash from the MAC address. More...
 

Detailed Description

A network hardware (MAC) address.

Author
Mark Lindner
mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t Sming integration

Member Typedef Documentation

◆ Octets

using MacAddress::Octets = uint8_t[6]

Constructor & Destructor Documentation

◆ MacAddress() [1/3]

MacAddress::MacAddress ( )
default

◆ MacAddress() [2/3]

MacAddress::MacAddress ( const Octets octets)
inline

◆ MacAddress() [3/3]

MacAddress::MacAddress ( const String s)

Create a MAC address from valid string. e.g. 01:02:03:04:05:06 Separators are optional.

Member Function Documentation

◆ clear()

void MacAddress::clear ( void  )
inline

Clear address to null value.

◆ getHash()

uint32_t MacAddress::getHash ( ) const

Generate a simple 32-bit hash from the MAC address.

Return values
uint32_tThe hash
Note
This does not uniquely identify the key

◆ getOctets()

void MacAddress::getOctets ( Octets octets) const
inline

Get the octets of the MAC address.

◆ operator bool_type()

MacAddress::operator bool_type ( ) const
inline

Safe bool operator, returns true if address is non-null.

◆ operator String()

MacAddress::operator String ( ) const
inline

◆ operator!()

bool MacAddress::operator! ( ) const

Test if this is a null address (00:00:00:00:00:00).

◆ operator!=()

bool MacAddress::operator!= ( const MacAddress other) const
inline

Inequality operator.

◆ operator==()

bool MacAddress::operator== ( const MacAddress other) const
inline

Equality operator.

◆ operator[]() [1/2]

uint8_t& MacAddress::operator[] ( unsigned  index)

Get a reference to the octet at the given index in the MAC address.

Parameters
indexThe index.
Return values
uint8_t&A writeable reference to the octet at the given index.

◆ operator[]() [2/2]

const uint8_t& MacAddress::operator[] ( unsigned  index) const
inline

Get the octet at the given index in the MAC address.

Parameters
indexThe index.
Return values
constuint8_t& Read-only reference to the octet at the given index.

◆ setOctets()

void MacAddress::setOctets ( const Octets octets)
inline

Set the octets of the MAC address.

◆ toString()

String MacAddress::toString ( char  sep = ':') const

Return a String representation of the MacAddress.

Parameters
sepCharacter to insert between octets
Note
Various conventions exist for display MAC addresses.
  • The IEEE standard specifies '-', "01-02-03-04-05-06"
  • A more common convention (as used in linux) is ':', "01:02:03:04:05:06"
  • To omit the separator use '\0', "010203040506"

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