4 #include <initializer_list>
41 memcpy(m_Address, addr,
sizeof(m_Address));
56 template <typename T, typename = typename std::enable_if<std::is_convertible<T, std::string>::value>::type>
69 inline MacAddress(uint8_t firstOctet, uint8_t secondOctet, uint8_t thirdOctet, uint8_t fourthOctet,
70 uint8_t fifthOctet, uint8_t sixthOctet)
72 m_Address[0] = firstOctet;
73 m_Address[1] = secondOctet;
74 m_Address[2] = thirdOctet;
75 m_Address[3] = fourthOctet;
76 m_Address[4] = fifthOctet;
77 m_Address[5] = sixthOctet;
88 if (octets.size() !=
sizeof(m_Address))
90 throw std::invalid_argument(
"Invalid initializer list size, should be 6");
92 std::copy(octets.begin(), octets.end(), std::begin(m_Address));
102 return memcmp(m_Address, other.m_Address,
sizeof(m_Address)) == 0;
123 if (octets.size() !=
sizeof(m_Address))
125 throw std::invalid_argument(
"Invalid initializer list size, should be 6");
128 std::copy(octets.begin(), octets.end(), std::begin(m_Address));
154 *arr =
new uint8_t[
sizeof(m_Address)];
155 memcpy(*arr, m_Address,
sizeof(m_Address));
165 memcpy(arr, m_Address,
sizeof(m_Address));
174 uint8_t m_Address[6] = { 0 };
178 inline std::ostream& operator<<(std::ostream& os,
const pcpp::MacAddress& macAddress)
Definition: MacAddress.h:25
MacAddress & operator=(std::initializer_list< uint8_t > octets)
Definition: MacAddress.h:121
MacAddress(const T &addr)
Definition: MacAddress.h:57
static MacAddress Zero
Definition: MacAddress.h:171
MacAddress(const std::string &addr)
MacAddress(uint8_t firstOctet, uint8_t secondOctet, uint8_t thirdOctet, uint8_t fourthOctet, uint8_t fifthOctet, uint8_t sixthOctet)
Definition: MacAddress.h:69
void copyTo(uint8_t *arr) const
Definition: MacAddress.h:163
bool operator==(const MacAddress &other) const
Definition: MacAddress.h:100
MacAddress(std::initializer_list< uint8_t > octets)
Definition: MacAddress.h:86
const uint8_t * getRawData() const
Definition: MacAddress.h:136
MacAddress(const uint8_t *addr)
Definition: MacAddress.h:39
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:152
std::string toString() const
bool operator!=(const MacAddress &other) const
Definition: MacAddress.h:110
The main namespace for the PcapPlusPlus lib.