Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ola::network::MACAddress Class Reference

Detailed Description

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)
MACAddressoperator= (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 MACAddressFromString (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)

Constructor & Destructor Documentation

ola::network::MACAddress::MACAddress ( const uint8_t  address[LENGTH])
explicit

Construct a new MAC address from binary data.

Parameters
addressa pointer to the memory containing the MAC address data. The data should be most significant byte first.

Member Function Documentation

MACAddress * ola::network::MACAddress::FromString ( const std::string &  address)
static

Convert a string to a MACAddress object.

Parameters
addressa string in the form 'nn:nn:nn:nn:nn:nn' or 'nn.nn.nn.nn.nn.nn'
Returns
a pointer to a MACAddress object if it worked, NULL otherwise
bool ola::network::MACAddress::FromString ( const std::string &  address,
MACAddress target 
)
static

Convert a string to a MACAddress object.

Parameters
addressa string in the form 'nn:nn:nn:nn:nn:nn' or 'nn.nn.nn.nn.nn.nn'
[out]targeta pointer to a MACAddress object
Returns
true if it worked, false otherwise
bool ola::network::MACAddress::Pack ( uint8_t *  buffer,
unsigned int  length 
) const
inline

Write the binary representation of the MAC address to memory.

Parameters
buffera pointer to memory to write the MAC address to
lengththe size of the memory block, should be at least LENGTH.
Returns
true if length was >= LENGTH, false otherwise.
string ola::network::MACAddress::ToString ( ) const

Convert a mac address to a human readable string.

Returns
a string

ether_ntoa_r doesn't exist on Mac, so can't use it; ether_ntoa isn't thread safe


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