|
| HWAddress (const storage_type *ptr=0) |
| Constructor from a const storage_type*.
|
|
| HWAddress (const std::string &address) |
| Constructs an address from a hex-notation address.
|
|
template<size_t i> |
| HWAddress (const char(&address)[i]) |
| Overload provided basically for string literals.
|
|
template<size_t i> |
| HWAddress (const HWAddress< i > &rhs) |
| Copy construct from a HWAddress of length i.
|
|
iterator | begin () |
| Retrieves an iterator pointing to the begining of the address.
|
|
const_iterator | begin () const |
| Retrieves a const iterator pointing to the begining of the address.
|
|
iterator | end () |
| Retrieves an iterator pointing one-past-the-end of the address.
|
|
const_iterator | end () const |
| Retrieves a const iterator pointing one-past-the-end of the address.
|
|
bool | operator== (const HWAddress &rhs) const |
| Compares this HWAddress for equality.
|
|
bool | operator!= (const HWAddress &rhs) const |
| Compares this HWAddress for in-equality.
|
|
bool | operator< (const HWAddress &rhs) const |
| Compares this HWAddress for less-than inequality.
|
|
bool | operator<= (const HWAddress &rhs) const |
| Compares this HWAddress for less-than equality.
|
|
bool | operator> (const HWAddress &rhs) const |
| Compares this HWAddress for greater-than inequality.
|
|
bool | operator>= (const HWAddress &rhs) const |
| Compares this HWAddress for greater-than equality.
|
|
HWAddress | operator& (const HWAddress &mask) const |
| Apply a mask to this address.
|
|
HWAddress | operator| (const HWAddress &mask) const |
| Apply a mask to this address.
|
|
HWAddress | operator~ () const |
| not operator
|
|
size_t | size () const |
| Retrieves the size of this address.
|
|
bool | is_broadcast () const |
| Indicates whether this is a broadcast address.
|
|
bool | is_multicast () const |
| Indicates whether this is a multicast address.
|
|
bool | is_unicast () const |
| Indicates whether this is an unicast address.
|
|
std::string | to_string () const |
| Convert this address to a hex-notation std::string address.
|
|
storage_type | operator[] (size_t i) const |
| Retrieves the i-th storage_type in this address.
|
|
storage_type & | operator[] (size_t i) |
| Retrieves the i-th storage_type in this address.
|
|
template<typename OutputIterator > |
OutputIterator | copy (OutputIterator output) const |
| Helper function which copies the address into an output iterator.
|
|
template<size_t n>
class Tins::HWAddress< n >
Represents a hardware address.
This class represents a hardware (MAC) address. It can be constructed from it's string representation and you can iterate over the bytes that compose it.
For example:
for(auto element : address) {
}
Represents a hardware address.
Definition resolve_utils.h:43
Constructor from a const storage_type*.
If no pointer or a null pointer is provided, the address is initialized to 00:00:00:00:00:00.
This constructor is very usefull when passing zero initialized addresses as arguments to other functions. You can use a literal 0, which will be implicitly converted to the empty address.
If a pointer is provided, address_size storage_type elements are copied from the pointer, into the internal address representation.
- Parameters
-
ptr | The pointer from which to construct this address. |
template<size_t n>
template<size_t i>
Copy construct from a HWAddress of length i.
If i is lower or equal than address_size, then i storage_type elements are copied, and the last (n - i) are initialized to the default storage_type value(0 most of the times).
If i is larger than address_size, then only the first address_size elements are copied.
- Parameters
-
template<size_t n>
template<typename OutputIterator >
Helper function which copies the address into an output iterator.
This is the same as:
std::copy(begin(), end(), iter);
But since some PDUs return a HWAddress<> by value, this function can be used to avoid temporaries.
- Parameters
-
output | The output iterator in which to store this address. |
- Returns
- OutputIterator pointing to one-past the last position written.