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 
29 {
30  public:
31  MacAddress();
32  MacAddress(const MacAddress &other);
33 
34  bool valid() const
35  {
36  return m_Valid;
37  }
38 
39  void setMac(uint8_t byte, size_t element);
40 
42  void setMac(uint8_t element);
43 
44  void setMac(const uint16_t *data, bool bSwap = false);
45 
46  uint8_t getMac(size_t element) const;
47 
48  const uint16_t *getMac() const;
49 
50  uint8_t operator[](size_t offset) const;
51 
52  MacAddress &operator=(const MacAddress &a);
53 
54  MacAddress &operator=(const uint16_t *a);
55 
56  operator const uint16_t *() const
57  {
58  return getMac();
59  }
60 
61  String toString();
62 
63  private:
64  uint16_t m_Mac[3];
65  bool m_Valid;
66 };
67 
68 #endif
Definition: String.h:49