#include <wipal/tool/addr.hh>
Public Member Functions | |
addr () | |
addr (const void *a) | |
addr (const std::string &) | |
addr (std::istream &) | |
std::istream & | read (std::istream &) |
void | dump (void *) const |
Comparison operators | |
bool | operator< (const addr &) const |
bool | operator== (const addr &) const |
bool | operator!= (const addr &) const |
Address' bytes access | |
ValueType & | operator[] (unsigned) |
const ValueType & | operator[] (unsigned) const |
Static Public Member Functions | |
static const addr & | null () |
static const addr & | broadcast () |
Protocol-agnostic network address, considered as a sequence of N
values of type ValueType
. For instance, IPv4 addresses are 4 uint8_t, MAC addresses are 6 uint8_t, and IPv6 addresses are 8 uint16_t. HexNotation
indicates whether the address' string representation uses hexadecimal or decimal values. SepNotation
is the character one should use to separate bytes in the string representation.
tool::addr< VT, N, HN, SN >::addr | ( | ) | [inline] |
Construct a null address.
tool::addr< VT, N, HN, SN >::addr | ( | const void * | a | ) | [inline] |
Construct an address from a memory location.
An alternative to using this constructor is to static_cast
the memory location:
typedef addr< // ... > addr_t; void* p = // To some memory containing an address. std::cout << *static_cast<addr_t*> (p) << std::endl;
tool::addr< VT, N, HN, SN >::addr | ( | const std::string & | str | ) | [inline] |
Construct an address from a string representation.
Example:
addr<uint8_t, 6, true, ':'> mac (std::string ("00:16:ec:92:84:b8")); addr<uint8_t, 4, false, '.'> ip4 (std::string ("192.168.1.1"));
tool::addr< VT, N, HN, SN >::addr | ( | std::istream & | is | ) | [inline] |
Construct an address from a stream (the address appears in the stream as a string representation).
addr<uint8_t, 6, true, ':'> a (std::cin); // E.g. with 00:16:ec:92:84:b8 // on standard input.
const addr< VT, N, HN, SN > & tool::addr< VT, N, HN, SN >::broadcast | ( | ) | [inline, static] |
Get a broadcast address (every byte is set to 255).
void tool::addr< VT, N, HN, SN >::dump | ( | void * | a | ) | const [inline] |
Copy to a memory location.
const addr< VT, N, HN, SN > & tool::addr< VT, N, HN, SN >::null | ( | ) | [inline, static] |
Get a null address (every byte is set to 0).
std::istream & tool::addr< VT, N, HN, SN >::read | ( | std::istream & | is | ) | [inline] |
Set the current address according to a string representation read from a stream.