11#include <userver/utils/encoding/hex.hpp>
13USERVER_NAMESPACE_BEGIN
20template <std::size_t N>
21class MacaddrBase final {
22 static_assert(N == 6 || N == 8,
"Address can only be 6 or 8 bytes size");
25 using OctetsType = std::array<
unsigned char, N>;
27 MacaddrBase() =
default;
29 explicit MacaddrBase(
const OctetsType& macaddr)
noexcept : macaddr_(macaddr) {}
32 const OctetsType&
GetOctets()
const noexcept {
return macaddr_; }
34 friend bool operator==(
const MacaddrBase<N>& a,
const MacaddrBase<N>& b)
noexcept {
35 return a.GetOctets() == b.GetOctets();
38 friend bool operator!=(
const MacaddrBase<N>& a,
const MacaddrBase<N>& b)
noexcept {
return !(a == b); }
41 OctetsType macaddr_ = {0};
47using Macaddr = MacaddrBase<6>;
52using Macaddr8 = MacaddrBase<8>;