30 #ifndef TINS_HWADDRESS_H    31 #define TINS_HWADDRESS_H    37 #include <tins/cxxstd.h>    38 #include <tins/macros.h>    42 #endif // TINS_IS_CXX11    51 TINS_API std::string hw_address_to_string(
const uint8_t* ptr, 
size_t count);
    53 TINS_API 
void string_to_hw_address(
const std::string& hw_addr, uint8_t* output,
    56 TINS_API 
bool hw_address_equal_compare(
const uint8_t* start1, 
const uint8_t* end1,
    57                                       const uint8_t* start2);
    59 TINS_API 
bool hw_address_lt_compare(
const uint8_t* start1, 
const uint8_t* end1,
    60                                     const uint8_t* start2, 
const uint8_t* end2);
    62 TINS_API 
bool hw_address_gt_compare(
const uint8_t* start1, 
const uint8_t* end1,
    63                                     const uint8_t* start2, 
const uint8_t* end2);
   112     static const size_t address_size = n;
   136             std::memcpy(buffer_, ptr, address_size);
   139             std::memset(buffer_, 0, address_size);
   155         Internals::string_to_hw_address(address, buffer_, n);
   173         Internals::string_to_hw_address(address, buffer_, n);
   190         size_t copy_threshold = i < n ? i : n;
   191         for (
size_t index = 0; index < n; ++index) {
   192             if (index < copy_threshold) {
   193                 buffer_[index] = rhs[index];
   196                 buffer_[index] = storage_type();
   228         return buffer_ + address_size;
   237     const_iterator 
end()
 const {
   238         return buffer_ + address_size;
   249         return Internals::hw_address_equal_compare(begin(), end(), rhs.
begin());
   260         return !(*
this == rhs);
   271         return Internals::hw_address_lt_compare(begin(), end(), rhs.
begin(), rhs.
end());
   282         return !operator>(rhs);
   293         return Internals::hw_address_gt_compare(begin(), end(), rhs.
begin(), rhs.
end());
   304         return !operator<(rhs);
   315         for (
size_t i = 0; i < n; ++i) {
   316             output[i] = output[i] & mask[i];
   329        for (
size_t i = 0; i < n; ++i) {
   330            output[i] = output[i] | mask[i];
   341        for (
size_t i = 0; i < n; ++i) {
   342            output[i] = ~output[i];
   360         return* 
this == broadcast;
   367         return (*begin() & 0x01);
   374         return !is_broadcast() && !is_multicast();
   383         return Internals::hw_address_to_string(buffer_, size());
   430     template<
typename OutputIterator>
   431     OutputIterator 
copy(OutputIterator output)
 const {
   432         for (const_iterator iter = begin(); iter != end(); ++iter) {
   441         for (
size_t i = 0; i < n; ++i) {
   447     storage_type buffer_[n];
   460 struct hash<
Tins::HWAddress<n>> {
   462         return std::hash<std::string>()(addr.
to_string());
   467 #endif // TINS_IS_CXX11   469 #endif // TINS_HWADDRESS_H bool is_unicast() const 
Indicates whether this is an unicast address. 
Definition: hw_address.h:373
HWAddress(const std::string &address)
Constructs an address from a hex-notation address. 
Definition: hw_address.h:154
const_iterator begin() const 
Retrieves a const iterator pointing to the begining of the address. 
Definition: hw_address.h:217
HWAddress operator|(const HWAddress &mask) const 
Apply a mask to this address. 
Definition: hw_address.h:327
HWAddress operator~() const 
not operator 
Definition: hw_address.h:339
uint8_t storage_type
The type of the elements stored in the hardware address. 
Definition: hw_address.h:96
friend std::ostream & operator<<(std::ostream &os, const HWAddress &addr)
Writes this HWAddress in hex-notation to a std::ostream. 
Definition: hw_address.h:411
storage_type operator[](size_t i) const 
Retrieves the i-th storage_type in this address. 
Definition: hw_address.h:391
Definition: hw_address.h:456
bool operator<=(const HWAddress &rhs) const 
Compares this HWAddress for less-than equality. 
Definition: hw_address.h:281
iterator begin()
Retrieves an iterator pointing to the begining of the address. 
Definition: hw_address.h:207
size_t size() const 
Retrieves the size of this address. 
Definition: hw_address.h:352
bool operator>(const HWAddress &rhs) const 
Compares this HWAddress for greater-than inequality. 
Definition: hw_address.h:292
bool is_broadcast() const 
Indicates whether this is a broadcast address. 
Definition: hw_address.h:359
storage_type & operator[](size_t i)
Retrieves the i-th storage_type in this address. 
Definition: hw_address.h:400
Represents a hardware address. 
Definition: hw_address.h:91
bool operator!=(const HWAddress &rhs) const 
Compares this HWAddress for in-equality. 
Definition: hw_address.h:259
HWAddress(const char(&address)[i])
Overload provided basically for string literals. 
Definition: hw_address.h:172
The Tins namespace. 
Definition: address_range.h:38
bool operator==(const HWAddress &rhs) const 
Compares this HWAddress for equality. 
Definition: hw_address.h:248
iterator end()
Retrieves an iterator pointing one-past-the-end of the address. 
Definition: hw_address.h:227
HWAddress(const HWAddress< i > &rhs)
Copy construct from a HWAddress of length i. 
Definition: hw_address.h:189
bool operator<(const HWAddress &rhs) const 
Compares this HWAddress for less-than inequality. 
Definition: hw_address.h:270
std::string to_string() const 
Convert this address to a hex-notation std::string address. 
Definition: hw_address.h:382
bool operator>=(const HWAddress &rhs) const 
Compares this HWAddress for greater-than equality. 
Definition: hw_address.h:303
const_iterator end() const 
Retrieves a const iterator pointing one-past-the-end of the address. 
Definition: hw_address.h:237
HWAddress(const storage_type *ptr=0)
Constructor from a const storage_type*. 
Definition: hw_address.h:134
storage_type * iterator
The random access iterator type. 
Definition: hw_address.h:101
static const HWAddress< n > broadcast
The broadcast address. 
Definition: hw_address.h:117
OutputIterator copy(OutputIterator output) const 
Helper function which copies the address into an output iterator. 
Definition: hw_address.h:431
bool is_multicast() const 
Indicates whether this is a multicast address. 
Definition: hw_address.h:366
HWAddress operator&(const HWAddress &mask) const 
Apply a mask to this address. 
Definition: hw_address.h:313
const storage_type * const_iterator
Const iterator type. 
Definition: hw_address.h:106