Open Lighting Architecture
0.9.2
|
Represents a MAC Address.
All methods use network byte order unless otherwise mentioned. TODO(Peter): Is the above actually true for MAC addresses?
Public Types | |
enum | { LENGTH = 6 } |
Public Member Functions | |
MACAddress (const uint8_t address[LENGTH]) | |
Construct a new MAC address from binary data. | |
MACAddress (const MACAddress &other) | |
MACAddress & | operator= (const MACAddress &other) |
bool | operator== (const MACAddress &other) const |
bool | operator!= (const MACAddress &other) const |
bool | operator< (const MACAddress &other) const |
Order addresses. Note that this won't order how humans expect because ether_addr is in network byte order. TODO(Peter): Check if this is actually true for MAC Addresses. | |
bool | operator> (const MACAddress &other) const |
void | Get (uint8_t ptr[LENGTH]) const |
bool | Pack (uint8_t *buffer, unsigned int length) const |
Write the binary representation of the MAC address to memory. | |
std::string | ToString () const |
Convert a mac address to a human readable string. |
Static Public Member Functions | |
static MACAddress * | FromString (const std::string &address) |
Convert a string to a MACAddress object. | |
static bool | FromString (const std::string &address, MACAddress *target) |
Convert a string to a MACAddress object. | |
static MACAddress | FromStringOrDie (const std::string &address) |
Friends | |
std::ostream & | operator<< (std::ostream &out, const MACAddress &address) |
|
explicit |
Construct a new MAC address from binary data.
address | a pointer to the memory containing the MAC address data. The data should be most significant byte first. |
|
static |
Convert a string to a MACAddress object.
address | a string in the form 'nn:nn:nn:nn:nn:nn' or 'nn.nn.nn.nn.nn.nn' |
|
static |
Convert a string to a MACAddress object.
address | a string in the form 'nn:nn:nn:nn:nn:nn' or 'nn.nn.nn.nn.nn.nn' | |
[out] | target | a pointer to a MACAddress object |
|
inline |
Write the binary representation of the MAC address to memory.
buffer | a pointer to memory to write the MAC address to |
length | the size of the memory block, should be at least LENGTH. |
string ola::network::MACAddress::ToString | ( | ) | const |
Convert a mac address to a human readable string.
ether_ntoa_r doesn't exist on Mac, so can't use it; ether_ntoa isn't thread safe