4 #include <initializer_list>
33 memcpy(m_Address, addr,
sizeof(m_Address));
44 template <typename T, typename = typename std::enable_if<std::is_convertible<T, std::string>::value>::type>
55 inline MacAddress(uint8_t firstOctet, uint8_t secondOctet, uint8_t thirdOctet, uint8_t fourthOctet,
56 uint8_t fifthOctet, uint8_t sixthOctet)
58 m_Address[0] = firstOctet;
59 m_Address[1] = secondOctet;
60 m_Address[2] = thirdOctet;
61 m_Address[3] = fourthOctet;
62 m_Address[4] = fifthOctet;
63 m_Address[5] = sixthOctet;
72 if (octets.size() !=
sizeof(m_Address))
74 throw std::invalid_argument(
"Invalid initializer list size, should be 6");
76 std::copy(octets.begin(), octets.end(), std::begin(m_Address));
84 return memcmp(m_Address, other.m_Address,
sizeof(m_Address)) == 0;
101 if (octets.size() !=
sizeof(m_Address))
103 throw std::invalid_argument(
"Invalid initializer list size, should be 6");
106 std::copy(octets.begin(), octets.end(), std::begin(m_Address));
126 *arr =
new uint8_t[
sizeof(m_Address)];
127 memcpy(*arr, m_Address,
sizeof(m_Address));
135 memcpy(arr, m_Address,
sizeof(m_Address));
142 uint8_t m_Address[6] = { 0 };
145 inline std::ostream& operator<<(std::ostream& os,
const pcpp::MacAddress& macAddress)
Definition: MacAddress.h:21
MacAddress & operator=(std::initializer_list< uint8_t > octets)
Definition: MacAddress.h:99
MacAddress(const T &addr)
Definition: MacAddress.h:45
static MacAddress Zero
A static value representing a zero value of MAC address, meaning address of value "00:00:00:00:00:00"...
Definition: MacAddress.h:139
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:55
void copyTo(uint8_t *arr) const
Definition: MacAddress.h:133
bool operator==(const MacAddress &other) const
Definition: MacAddress.h:82
MacAddress(std::initializer_list< uint8_t > octets)
Definition: MacAddress.h:70
const uint8_t * getRawData() const
Definition: MacAddress.h:112
MacAddress(const uint8_t *addr)
Definition: MacAddress.h:31
void copyTo(uint8_t **arr) const
Definition: MacAddress.h:124
std::string toString() const
bool operator!=(const MacAddress &other) const
Definition: MacAddress.h:90
The main namespace for the PcapPlusPlus lib.