30 #include <boost/functional/hash.hpp>
44 Address::Address(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
56 std::copy(octets, octets + size(), begin());
68 return (front() & 1) != 0;
80 const auto& a = *
this;
83 std::snprintf(s,
sizeof(s),
84 "%02" PRIx8
"%c%02" PRIx8
"%c%02" PRIx8
"%c%02" PRIx8
"%c%02" PRIx8
"%c%02" PRIx8,
85 a[0], sep, a[1], sep, a[2], sep, a[3], sep, a[4], sep, a[5]);
96 int ret = std::sscanf(str.data(),
97 "%2" SCNx8
"%1[:-]%2" SCNx8
"%1[:-]%2" SCNx8
"%1[:-]"
98 "%2" SCNx8
"%1[:-]%2" SCNx8
"%1[:-]%2" SCNx8
"%n",
99 &a[0], &sep[0][0], &a[1], &sep[1][0], &a[2], &sep[2][0],
100 &a[3], &sep[3][0], &a[4], &sep[4][0], &a[5], &n);
102 if (ret < 11 ||
static_cast<size_t>(n) != str.length())
106 for (
size_t i = 1; i < 5; ++i) {
107 if (sep[i][0] != sep[0][0])
117 return { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
123 return { 0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA };
138 return boost::hash_range(a.cbegin(), a.cend());
Represents an Ethernet hardware address.
Address()
Constructs a null Ethernet address (00:00:00:00:00:00).
std::string toString(char sep=':') const
Converts the address to a human-readable string.
bool isMulticast() const
True if this is a multicast address.
bool isBroadcast() const
True if this is a broadcast address (ff:ff:ff:ff:ff:ff).
bool isNull() const
True if this is a null address (00:00:00:00:00:00).
static Address fromString(const std::string &str)
Creates an Address from a string containing an Ethernet address in hexadecimal notation,...
Address getDefaultMulticastAddress()
Returns the default Ethernet multicast address for NDN.
const size_t ADDR_LEN
Octets in one Ethernet address.
Address getBroadcastAddress()
Returns the Ethernet broadcast address (ff:ff:ff:ff:ff:ff).
std::ostream & operator<<(std::ostream &o, const Address &a)
size_t operator()(const ndn::ethernet::Address &a) const noexcept