Skip to content

Commit

Permalink
Add convenience method to determine if a MAC address is globally uniq…
Browse files Browse the repository at this point in the history
…ue or locally assigned.
  • Loading branch information
tsilia committed Feb 23, 2020
1 parent ce409db commit d69ae12
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/tins/hw_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,20 @@ class HWAddress {
return !is_broadcast() && !is_multicast();
}

/**
* \brief Indicates whether this is a globally unique address.
*/
bool is_globally_unique() const {
return !is_locally_assigned();
}

/**
* \brief Indicates whether this is a locally assigned address.
*/
bool is_locally_assigned() const {
return (*begin() & 0x02);
}

/**
* \brief Convert this address to a hex-notation std::string address.
*
Expand Down

0 comments on commit d69ae12

Please sign in to comment.