24 #include <boost/functional/hash.hpp> 38 Address::Address(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
50 std::copy(octets, octets + size(), begin());
62 return (at(0) & 1) != 0;
79 snprintf(s,
sizeof(s),
"%02x%c%02x%c%02x%c%02x%c%02x%c%02x",
80 at(0), sep, at(1), sep, at(2), sep, at(3), sep, at(4), sep, at(5));
82 return std::string(s);
89 unsigned short temp[a.size()];
94 int ret = std::sscanf(str.c_str(),
"%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%1[:-]%2hx%n",
95 &temp[0], &sep[0][0], &temp[1], &sep[1][0], &temp[2], &sep[2][0],
96 &temp[3], &sep[3][0], &temp[4], &sep[4][0], &temp[5], &n);
98 if (ret < 11 || static_cast<size_t>(n) != str.length())
101 for (
size_t i = 0; i < a.size(); ++i)
104 if (i < 5 && sep[i][0] != sep[0][0])
111 a[i] =
static_cast<uint8_t
>(temp[i]);
120 return { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
126 return { 0x01, 0x00, 0x5E, 0x00, 0x17, 0xAA };
143 return boost::hash_range(a.cbegin(), a.cend());
Copyright (c) 2011-2015 Regents of the University of California.
const size_t ADDR_LEN
Octets in one Ethernet address.
represents an Ethernet hardware address
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.
Address getBroadcastAddress()
Returns the Ethernet broadcast address (ff:ff:ff:ff:ff:ff)
size_t operator()(const ndn::util::ethernet::Address &a) const noexcept
Address getDefaultMulticastAddress()
Returns the default Ethernet multicast address for NDN.
Address()
Constructs a null Ethernet address (00:00:00:00:00:00)
bool isBroadcast() const
True if this is a broadcast address (ff:ff:ff:ff:ff:ff)
std::ostream & operator<<(std::ostream &o, const Address &a)
bool isNull() const
True if this is a null address (00:00:00:00:00:00)
bool isMulticast() const
True if this is a multicast address.
std::string toString(char sep=':') const
Converts the address to a human-readable string.