35 #ifndef _DATASPEED_CAN_USB_MAC_ADDR_H 36 #define _DATASPEED_CAN_USB_MAC_ADDR_H 64 std::string
toString(
bool upper =
false)
const {
66 ss << std::setfill(
'0') << std::hex;
67 if (upper) { ss << std::uppercase; }
68 ss << std::setw(2) << (
unsigned int)
addr_[0] <<
":";
69 ss << std::setw(2) << (
unsigned int)
addr_[1] <<
":";
70 ss << std::setw(2) << (
unsigned int)
addr_[2] <<
":";
71 ss << std::setw(2) << (
unsigned int)
addr_[3] <<
":";
72 ss << std::setw(2) << (
unsigned int)
addr_[4] <<
":";
73 ss << std::setw(2) << (
unsigned int)
addr_[5];
78 return (this->
mac0() == other.
mac0())
87 bool match(
const std::string& str)
const {
89 std::string
mac2 = str;
92 std::transform(mac1.begin(), mac1.end(), mac1.begin(), ::toupper);
93 std::transform(mac2.begin(), mac2.end(), mac2.begin(), ::toupper);
96 mac1.erase(std::remove(mac1.begin(), mac1.end(),
':'), mac1.end());
97 mac2.erase(std::remove(mac2.begin(), mac2.end(),
':'), mac2.end());
100 if ((mac1.length() == 12) && (mac2.length() == 12)) {
102 if ((mac1 !=
"000000000000") && (mac2 !=
"000000000000")) {
104 if ((mac1 !=
"FFFFFFFFFFFF") && (mac2 !=
"FFFFFFFFFFFF")) {
126 #endif // _DATASPEED_CAN_USB_MAC_ADDR_H
bool match(const MacAddr &other) const
MacAddr(uint8_t mac0, uint8_t mac1, uint8_t mac2, uint8_t mac3, uint8_t mac4, uint8_t mac5)
bool match(const std::string &str) const
MacAddr(const uint8_t *addr)
std::string toString(bool upper=false) const