PcapPlusPlus
MacAddress.h
Go to the documentation of this file.
1 #ifndef PCAPPP_MACADDRESS
2 #define PCAPPP_MACADDRESS
3 
4 #include <stdint.h>
5 #include <string>
6 #include <memory>
7 
9 
14 namespace pcpp
15 {
16 
21  class MacAddress
22  {
23  public:
30  MacAddress(uint8_t* addr);
31 
37  MacAddress(const char* addr);
38 
44  MacAddress(const std::string& addr);
45 
55  MacAddress(uint8_t firstOctest, uint8_t secondOctet, uint8_t thirdOctet, uint8_t fourthOctet, uint8_t fifthOctet, uint8_t sixthOctet);
56 
60  MacAddress(const MacAddress& other);
61 
65  MacAddress& operator=(const MacAddress& other);
66 
71  inline bool operator==(const MacAddress& other)
72  {
73  for (int i = 0; i < 6; i++)
74  if (m_Address[i] != other.m_Address[i])
75  return false;
76  return true;
77  }
78 
83  inline bool operator!=(const MacAddress& other) {return !operator==(other);}
84 
90  bool isValid() { return m_IsValid; }
91 
96  std::string toString();
97 
102  void copyTo(uint8_t** arr);
103 
109  void copyTo(uint8_t* arr) const;
110 
114  static MacAddress Zero;
115  private:
116  uint8_t m_Address[6];
117  bool m_IsValid;
118  void init(const char* addr);
119  };
120 
121 } // namespace pcpp
122 
123 #endif /* PCAPPP_MACADDRESS */
bool operator!=(const MacAddress &other)
Definition: MacAddress.h:83
std::string toString()
The main namespace for the PcapPlusPlus lib.
bool operator==(const MacAddress &other)
Definition: MacAddress.h:71
static MacAddress Zero
Definition: MacAddress.h:114
bool isValid()
Definition: MacAddress.h:90
Definition: MacAddress.h:21
MacAddress(uint8_t *addr)
void copyTo(uint8_t **arr)
MacAddress & operator=(const MacAddress &other)