30 #include <boost/functional/hash.hpp> 43 Address::Address(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
55 std::copy(octets, octets + size(), begin());
67 return (at(0) & 1) != 0;
84 snprintf(s,
sizeof(s),
"%02x%c%02x%c%02x%c%02x%c%02x%c%02x",
85 at(0), sep, at(1), sep, at(2), sep, at(3), sep, at(4), sep, at(5));
87 return std::string(s);
94 unsigned short temp[a.size()];
99 int ret = std::sscanf(str.c_str(),
"%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%n",
100 &temp[0], &sep[0][0], &temp[1], &sep[1][0], &temp[2], &sep[2][0],
101 &temp[3], &sep[3][0], &temp[4], &sep[4][0], &temp[5], &n);
103 if (ret < 11 || static_cast<size_t>(n) != str.length())
106 for (
size_t i = 0; i < a.size(); ++i)
109 if (i < 5 && sep[i][0] != sep[0][0])
116 a[i] =
static_cast<uint8_t
>(temp[i]);
125 return { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
131 return { 0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA };
146 return boost::hash_range(a.cbegin(), a.cend());
static Address fromString(const std::string &str)
Creates an Address from a string containing an Ethernet address in hexadecimal notation, with colons or hyphens as separators.
Copyright (c) 2011-2015 Regents of the University of California.
std::ostream & operator<<(std::ostream &o, const Address &a)
const size_t ADDR_LEN
Octets in one Ethernet address.
bool isBroadcast() const
True if this is a broadcast address (ff:ff:ff:ff:ff:ff)
Address getDefaultMulticastAddress()
Returns the default Ethernet multicast address for NDN.
Address getBroadcastAddress()
Returns the Ethernet broadcast address (ff:ff:ff:ff:ff:ff)
bool isMulticast() const
True if this is a multicast address.
std::string toString(char sep= ':') const
Converts the address to a human-readable string.
represents an Ethernet hardware address
Address()
Constructs a null Ethernet address (00:00:00:00:00:00)
size_t operator()(const ndn::ethernet::Address &a) const noexcept
bool isNull() const
True if this is a null address (00:00:00:00:00:00)