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 (at(0) & 1) != 0;
85 snprintf(s,
sizeof(s),
"%02x%c%02x%c%02x%c%02x%c%02x%c%02x",
86 at(0), sep, at(1), sep, at(2), sep, at(3), sep, at(4), sep, at(5));
88 return std::string(s);
95 unsigned short temp[a.size()];
100 int ret = std::sscanf(str.c_str(),
"%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%n",
101 &temp[0], &sep[0][0], &temp[1], &sep[1][0], &temp[2], &sep[2][0],
102 &temp[3], &sep[3][0], &temp[4], &sep[4][0], &temp[5], &n);
104 if (ret < 11 || static_cast<size_t>(n) != str.length())
107 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 isNull() const
True if this is a null address (00:00:00:00:00:00)
bool isBroadcast() const
True if this is a broadcast address (ff:ff:ff:ff:ff:ff)
std::string toString(char sep=':') const
Converts the address to a human-readable string.
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.
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