20#include "pedigree/kernel/network/MacAddress.h"
21#include "pedigree/kernel/utilities/StaticString.h"
22#include "pedigree/kernel/utilities/utility.h"
24MacAddress::MacAddress() : m_Mac(), m_Valid(false) {
29 m_Valid = other.valid();
31 setMac(other.getMac());
35void MacAddress::setMac(uint8_t
byte,
size_t element) {
44 m_Mac[element] |= word;
49void MacAddress::setMac(uint8_t element) {
50 ByteSet(m_Mac, element, 6);
54void MacAddress::setMac(
const uint16_t* data,
bool bSwap) {
57 for (i = 0; i < 3; i++)
58 m_Mac[i] = BIG_TO_HOST16(data[i]);
60 MemoryCopy(m_Mac, data, 6);
65uint8_t MacAddress::getMac(
size_t element)
const {
66 size_t realElement = element / 2;
70 uint16_t word = m_Mac[realElement];
77const uint16_t* MacAddress::getMac()
const {
81uint8_t MacAddress::operator[](
size_t offset)
const {
83 return getMac(offset);
94MacAddress& MacAddress::operator=(
const uint16_t* a) {
99String MacAddress::toString() {
101 for (
int i = 0; i < 6; i++) {
102 str.append(getMac(i), 16, 2,
'0');
106 return String(
static_cast<const char*
>(str));