RAVENNAKIT
Loading...
Searching...
No Matches
rav::MacAddress Class Reference

Represents a MAC address. More...

#include <mac_address.hpp>

Public Member Functions

 MacAddress ()=default
 MacAddress (const uint8_t *bytes)
 Construct a MAC address from a byte array, assuming the array is (at least) 6 bytes long.
 MacAddress (const uint8_t byte0, const uint8_t byte1, const uint8_t byte2, const uint8_t byte3, const uint8_t byte4, const uint8_t byte5)
 Constructs a MAC address from 6 individual bytes.
 MacAddress (const char *str)
 Construct a MAC address from a string.
const std::array< uint8_t, 6 > & bytes () const
bool is_valid () const
std::string to_string (const char *separator=":") const

Friends

bool operator== (const MacAddress &lhs, const MacAddress &rhs)
bool operator!= (const MacAddress &lhs, const MacAddress &rhs)

Detailed Description

Represents a MAC address.

Definition at line 39 of file mac_address.hpp.

Constructor & Destructor Documentation

◆ MacAddress() [1/4]

rav::MacAddress::MacAddress ( )
default

◆ MacAddress() [2/4]

rav::MacAddress::MacAddress ( const uint8_t * bytes)
inlineexplicit

Construct a MAC address from a byte array, assuming the array is (at least) 6 bytes long.

Parameters
bytesThe byte array containing the MAC address.

Definition at line 47 of file mac_address.hpp.

◆ MacAddress() [3/4]

rav::MacAddress::MacAddress ( const uint8_t byte0,
const uint8_t byte1,
const uint8_t byte2,
const uint8_t byte3,
const uint8_t byte4,
const uint8_t byte5 )
inline

Constructs a MAC address from 6 individual bytes.

Parameters
byte0Byte 0
byte1Byte 1
byte2Byte 2
byte3Byte 3
byte4Byte 4
byte5Byte 5

Definition at line 60 of file mac_address.hpp.

◆ MacAddress() [4/4]

rav::MacAddress::MacAddress ( const char * str)
inlineexplicit

Construct a MAC address from a string.

The string must be in the format "00:11:22:33:44:55".

Parameters
strThe string containing the MAC address.

Definition at line 69 of file mac_address.hpp.

Member Function Documentation

◆ bytes()

const std::array< uint8_t, 6 > & rav::MacAddress::bytes ( ) const
inlinenodiscard
Returns
The MAC address as a byte array.

Definition at line 86 of file mac_address.hpp.

◆ is_valid()

bool rav::MacAddress::is_valid ( ) const
inlinenodiscard
Returns
True if the MAC address is valid, false otherwise. A MAC address is considered valid if it is not all zeros.

Definition at line 94 of file mac_address.hpp.

◆ to_string()

std::string rav::MacAddress::to_string ( const char * separator = ":") const
inlinenodiscard
Returns
The MAC address as a string.

Definition at line 103 of file mac_address.hpp.

◆ operator!=

bool operator!= ( const MacAddress & lhs,
const MacAddress & rhs )
friend

Definition at line 114 of file mac_address.hpp.

◆ operator==

bool operator== ( const MacAddress & lhs,
const MacAddress & rhs )
friend

Definition at line 110 of file mac_address.hpp.


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