Open Lighting Architecture: ola::network::MACAddress Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ola::network::MACAddress Class Reference
Network

## 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)
| 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)

## Constructor & Destructor Documentation

## ◆ MACAddress()

ola::network::MACAddress::MACAddress | ( | const uint8_t * | address | ) |
| explicit

Construct a new MAC address from binary data.

Parameters

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

## Member Function Documentation

## ◆ FromString() [1/2]

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

Convert a string to a MACAddress object.

Parameters

  address | a 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

## ◆ FromString() [2/2]

bool ola::network::MACAddress::FromString | ( | const std::string & | address,
|  | MACAddress * | target )
| static

Convert a string to a MACAddress object.

Parameters

  | 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

Returns
  true if it worked, false otherwise

## ◆ Pack()

bool ola::network::MACAddress::Pack | ( | uint8_t * | buffer,
|  | unsigned int | length ) const
| inline

Write the binary representation of the MAC address to memory.

Parameters

  buffer | a pointer to memory to write the MAC address to
  length | the size of the memory block, should be at least LENGTH.

Returns
  true if length was >= LENGTH, false otherwise.

## ◆ ToString()

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:

- include/ola/network/MACAddress.h
- common/network/MACAddress.cpp