Ethernet MAC address.
More...
#include <senf/Socket/Protocols/Raw/MACAddress.hh>
|
(Note that these are not member functions.)
|
std::ostream & | operator<< (std::ostream &os, MACAddress const &mac) |
| Output MAC instance as it's string representation. More...
|
|
std::istream & | operator>> (std::istream &is, MACAddress &mac) |
| Try to initialize MACAddress instance from a string representation sets std::ios::failbit on the stream if an error occurred. More...
|
|
Ethernet MAC address.
The Ethernet MAC is modeled as a fixed-size container/sequence of 6 bytes. A MACAddress can be converted from/to the following representations
Since MACAddress is based on boost::array
, you can access the raw data bytes of the address using begin()
, end()
or operator
[]:
std::vector<char> data;
data.resize(6);
std::copy(
mac.begin(),
mac.end(), data.begin());
\par "Implementation note:" We awkwardly need to use static named constructors (<tt>from_</tt> members)
instead of ordinarily overloaded constructors for one simple reason: <tt>char *</tt>
doubles as string literal and as arbitrary data iterator. The iterator constructor can
therefore not be distinguished from initialization with a string literal. Therefore we
need to disambiguate using the named constructors.
Definition at line 72 of file MACAddress.hh.
◆ MACAddress() [1/3]
senf::MACAddress::MACAddress |
( |
| ) |
|
Construct zero-initialized address.
◆ MACAddress() [2/3]
Construct uninitialized (!) address.
◆ MACAddress() [3/3]
senf::MACAddress::MACAddress |
( |
std::uint64_t const & |
v | ) |
|
|
explicit |
◆ broadcast()
bool senf::MACAddress::broadcast |
( |
| ) |
const |
true
, if address is the broadcast address
◆ eui64()
std::uint64_t senf::MACAddress::eui64 |
( |
| ) |
const |
Build EUI-64 from the MAC address.
◆ from_data()
template<class InputIterator >
static MACAddress senf::MACAddress::from_data |
( |
InputIterator |
i | ) |
|
|
static |
Construct address from raw data.
Copies the data from i into the MAC address.
- Precondition
- The input range at i must have a size of at least 6 elements.
◆ from_eui64()
Construct address from EUI-64.
This constructor takes an EUI-64 value and converts it to a MAC address. This conversion is only possible, if the EUI-64 is MAC compatible: the 4th/5th byte (in transmission order) must be 0xFFFE.
- Exceptions
-
Definition at line 41 of file MACAddress.cc.
◆ from_string()
Construct address from string representation.
The string representation must exactly match the form dd:dd:dd:dd:dd:dd
where d
is any hexadecimal digit. In place of ':', '-' is also accepted as a delimiter.
- Exceptions
-
Definition at line 34 of file MACAddress.cc.
◆ hash()
void senf::MACAddress::hash |
( |
std::uint64_t * |
hash, |
|
|
std::uint16_t const & |
otherKey = 0 |
|
) |
| const |
computes a fast uint64 hash mixing in another 16bit value
◆ hash32()
std::uint32_t const& senf::MACAddress::hash32 |
( |
| ) |
const |
◆ local() [1/2]
bool senf::MACAddress::local |
( |
| ) |
const |
true
, if address is locally administered
◆ local() [2/2]
void senf::MACAddress::local |
( |
bool |
flag | ) |
|
◆ multicast() [1/2]
bool senf::MACAddress::multicast |
( |
| ) |
const |
true
, if address is a group/multicast address
◆ multicast() [2/2]
void senf::MACAddress::multicast |
( |
bool |
flag | ) |
|
◆ nic() [1/2]
std::uint32_t senf::MACAddress::nic |
( |
| ) |
const |
Return last 3 bytes of the address.
◆ nic() [2/2]
void senf::MACAddress::nic |
( |
std::uint32_t |
oui | ) |
|
Sets last 3 bytes of the address.
◆ operator bool()
senf::MACAddress::operator bool |
( |
| ) |
const |
|
explicit |
true
, if address is not the zero address
◆ operator<()
bool senf::MACAddress::operator< |
( |
MACAddress const & |
other | ) |
const |
◆ operator==()
bool senf::MACAddress::operator== |
( |
EUI64 const & |
eui64 | ) |
const |
◆ oui() [1/2]
std::uint32_t senf::MACAddress::oui |
( |
| ) |
const |
Return first 3 bytes of the address.
◆ oui() [2/2]
void senf::MACAddress::oui |
( |
std::uint32_t |
oui | ) |
|
Sets first 3 bytes of the address.
◆ uint64()
std::uint64_t senf::MACAddress::uint64 |
( |
| ) |
const |
Return MAC address as uint64 value.
◆ operator<<()
std::ostream & operator<< |
( |
std::ostream & |
os, |
|
|
MACAddress const & |
mac |
|
) |
| |
|
related |
Output MAC instance as it's string representation.
◆ operator>>()
std::istream & operator>> |
( |
std::istream & |
is, |
|
|
MACAddress & |
mac |
|
) |
| |
|
related |
◆ Broadcast
◆ None
The documentation for this struct was generated from the following files: