The Pedigree Project 0.1
MacAddress.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef MAC_ADDRESS_H
21#define MAC_ADDRESS_H
22
23#include "pedigree/kernel/compiler.h"
24#include "pedigree/kernel/processor/types.h"
25#include "pedigree/kernel/utilities/String.h"
26
28class EXPORTED_PUBLIC MacAddress {
29 public:
30 MacAddress();
31 MacAddress(const MacAddress& other);
32
33 bool valid() const {
34 return m_Valid;
35 }
36
37 void setMac(uint8_t byte, size_t element);
38
40 void setMac(uint8_t element);
41
42 void setMac(const uint16_t* data, bool bSwap = false);
43
44 uint8_t getMac(size_t element) const;
45
46 const uint16_t* getMac() const;
47
48 uint8_t operator[](size_t offset) const;
49
50 MacAddress& operator=(const MacAddress& a);
51
52 MacAddress& operator=(const uint16_t* a);
53
54 String toString();
55
56 private:
57 uint16_t m_Mac[3];
58 bool m_Valid;
59};
60
61#endif