30#ifndef TINS_HWADDRESS_H
31#define TINS_HWADDRESS_H
37#include <tins/cxxstd.h>
38#include <tins/macros.h>
51TINS_API std::string hw_address_to_string(
const uint8_t* ptr,
size_t count);
53TINS_API
void string_to_hw_address(
const std::string& hw_addr, uint8_t* output,
56TINS_API
bool hw_address_equal_compare(
const uint8_t* start1,
const uint8_t* end1,
57 const uint8_t* start2);
59TINS_API
bool hw_address_lt_compare(
const uint8_t* start1,
const uint8_t* end1,
60 const uint8_t* start2,
const uint8_t* end2);
62TINS_API
bool hw_address_gt_compare(
const uint8_t* start1,
const uint8_t* end1,
63 const uint8_t* start2,
const uint8_t* end2);
155 Internals::string_to_hw_address(address, buffer_,
n);
173 Internals::string_to_hw_address(address, buffer_,
n);
191 for (
size_t index = 0; index <
n; ++index) {
193 buffer_[index] =
rhs[index];
260 return !(*
this ==
rhs);
315 for (
size_t i = 0;
i <
n; ++
i) {
329 for (
size_t i = 0;
i <
n; ++
i) {
341 for (
size_t i = 0;
i <
n; ++
i) {
367 return (*
begin() & 0x01);
383 return Internals::hw_address_to_string(buffer_,
size());
412 return os <<
addr.to_string();
430 template<
typename OutputIterator>
441 for (
size_t i = 0;
i <
n; ++
i) {
444 return HWAddress<n>(buffer);
460struct hash<
Tins::HWAddress<n>> {
462 return std::hash<std::string>()(addr.to_string());
Represents a range of addresses.
Definition address_range.h:167
const_iterator end() const
Returns an interator to the end of this range.
Definition address_range.h:249
const_iterator begin() const
Returns an interator to the beginning of this range.
Definition address_range.h:237
Represents a hardware address.
Definition hw_address.h:91
uint8_t storage_type
The type of the elements stored in the hardware address.
Definition hw_address.h:96
const_iterator end() const
Retrieves a const iterator pointing one-past-the-end of the address.
Definition hw_address.h:237
iterator end()
Retrieves an iterator pointing one-past-the-end of the address.
Definition hw_address.h:227
bool is_multicast() const
Indicates whether this is a multicast address.
Definition hw_address.h:366
OutputIterator copy(OutputIterator output) const
Helper function which copies the address into an output iterator.
Definition hw_address.h:431
bool operator>(const HWAddress &rhs) const
Compares this HWAddress for greater-than inequality.
Definition hw_address.h:292
static const size_t address_size
Non-member constant indicating the amount of storage_type elements in this address.
Definition hw_address.h:112
bool operator>=(const HWAddress &rhs) const
Compares this HWAddress for greater-than equality.
Definition hw_address.h:303
bool operator==(const HWAddress &rhs) const
Compares this HWAddress for equality.
Definition hw_address.h:248
storage_type * iterator
The random access iterator type.
Definition hw_address.h:101
const storage_type * const_iterator
Const iterator type.
Definition hw_address.h:106
const_iterator begin() const
Retrieves a const iterator pointing to the begining of the address.
Definition hw_address.h:217
bool operator<=(const HWAddress &rhs) const
Compares this HWAddress for less-than equality.
Definition hw_address.h:281
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
HWAddress operator|(const HWAddress &mask) const
Apply a mask to this address.
Definition hw_address.h:327
bool is_broadcast() const
Indicates whether this is a broadcast address.
Definition hw_address.h:359
bool is_unicast() const
Indicates whether this is an unicast address.
Definition hw_address.h:373
bool operator!=(const HWAddress &rhs) const
Compares this HWAddress for in-equality.
Definition hw_address.h:259
size_t size() const
Retrieves the size of this address.
Definition hw_address.h:352
HWAddress operator~() const
not operator
Definition hw_address.h:339
HWAddress operator&(const HWAddress &mask) const
Apply a mask to this address.
Definition hw_address.h:313
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 less-than inequality.
Definition hw_address.h:270
HWAddress(const HWAddress< i > &rhs)
Copy construct from a HWAddress of length i.
Definition hw_address.h:189
storage_type operator[](size_t i) const
Retrieves the i-th storage_type in this address.
Definition hw_address.h:391
iterator begin()
Retrieves an iterator pointing to the begining of the address.
Definition hw_address.h:207
storage_type & operator[](size_t i)
Retrieves the i-th storage_type in this address.
Definition hw_address.h:400
HWAddress(const char(&address)[i])
Overload provided basically for string literals.
Definition hw_address.h:172
HWAddress(const storage_type *ptr=0)
Constructor from a const storage_type*.
Definition hw_address.h:134
static const HWAddress< n > broadcast
The broadcast address.
Definition hw_address.h:117
HWAddress(const std::string &address)
Constructs an address from a hex-notation address.
Definition hw_address.h:154
The Tins namespace.
Definition address_range.h:38