26 using std::invalid_argument;
46 memcpy(bytes + 2, v6addr.
bytes() + 12, 4);
51 static const char hexValues[] =
"0123456789abcdef";
54 result[0] = hexValues[
getByte(0) >> 4];
55 result[1] = hexValues[
getByte(0) & 0xf];
57 result[3] = hexValues[
getByte(1) >> 4];
58 result[4] = hexValues[
getByte(1) & 0xf];
60 result[6] = hexValues[
getByte(2) >> 4];
61 result[7] = hexValues[
getByte(2) & 0xf];
63 result[9] = hexValues[
getByte(3) >> 4];
64 result[10] = hexValues[
getByte(3) & 0xf];
66 result[12] = hexValues[
getByte(4) >> 4];
67 result[13] = hexValues[
getByte(4) & 0xf];
69 result[15] = hexValues[
getByte(5) >> 4];
70 result[16] = hexValues[
getByte(5) & 0xf];
76 auto isSeparatorChar = [](
char c) {
return c ==
':' ||
c ==
'-'; };
80 for (
unsigned int byteIndex = 0; byteIndex <
SIZE; ++byteIndex) {
82 throw invalid_argument(
83 sformat(
"invalid MAC address '{}': not enough digits", str));
87 if (byteIndex != 0 && isSeparatorChar(*p)) {
90 throw invalid_argument(
91 sformat(
"invalid MAC address '{}': not enough digits", str));
98 throw invalid_argument(
99 sformat(
"invalid MAC address '{}': contains non-hex digit", str));
105 if (p == str.
end()) {
113 if (isSeparatorChar(*p)) {
117 throw invalid_argument(
118 sformat(
"invalid MAC address '{}': contains non-hex digit", str));
125 parsed[byteIndex] = (upper << 4) | lower;
128 if (p != str.
end()) {
130 throw invalid_argument(
131 sformat(
"invalid MAC address '{}': found trailing characters", str));
141 throw invalid_argument(
142 sformat(
"MAC address must be 6 bytes long, got ", value.
size()));
std::string toString() const
const unsigned char * bytes() const
std::string sformat(StringPiece fmt, Args &&...args)
static constexpr size_t SIZE
constexpr size_type size() const
—— Concurrent Priority Queue Implementation ——
static MacAddress createMulticast(IPAddressV6 addr)
static const MacAddress ZERO
void parse(StringPiece str)
const std::array< unsigned char, 256 > hexTable
const uint8_t * bytes() const
static const MacAddress BROADCAST
constexpr Iter end() const
static MacAddress fromBinary(ByteRange value)
constexpr Iter begin() const
void setFromBinary(ByteRange value)
Range< const unsigned char * > ByteRange
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
uint64_t getByte(size_t index) const
std::ostream & operator<<(std::ostream &out, dynamic const &d)