20 #include "pedigree/kernel/network/MacAddress.h" 21 #include "pedigree/kernel/utilities/StaticString.h" 22 #include "pedigree/kernel/utilities/utility.h" 24 MacAddress::MacAddress() : m_Mac(), m_Valid(false)
31 m_Valid = other.valid();
34 setMac(other.getMac());
38 void MacAddress::setMac(uint8_t byte,
size_t element)
50 m_Mac[element] |= word;
56 void MacAddress::setMac(uint8_t element)
58 ByteSet(m_Mac, element, 6);
62 void MacAddress::setMac(
const uint16_t *data,
bool bSwap)
67 for (i = 0; i < 3; i++)
68 m_Mac[i] = BIG_TO_HOST16(data[i]);
71 MemoryCopy(m_Mac, data, 6);
76 uint8_t MacAddress::getMac(
size_t element)
const 78 size_t realElement = element / 2;
82 uint16_t word = m_Mac[realElement];
89 const uint16_t *MacAddress::getMac()
const 94 uint8_t MacAddress::operator[](
size_t offset)
const 97 return getMac(offset);
109 MacAddress &MacAddress::operator=(
const uint16_t *a)
115 String MacAddress::toString()
118 for (
int i = 0; i < 6; i++)
120 str.append(getMac(i), 16, 2,
'0');
124 return String(static_cast<const char *>(str));