INet6 network address. More...
#include <senf/Socket/Protocols/INet/INet6Address.hh>
Public Types | |
enum | Resolve_t { ResolveINet6, ResolveINet4 } |
enum | ScopeId { InterfaceScope = 1, LinkScope = 2, AdminScope = 4, SiteScope = 5, OrganizationScope = 8, GlobalScope = 14, ReservedScope = 0, UnassignedScope = 6 } |
Possible scope values. More... | |
Static Public Attributes | |
static INet6Address const | None |
The empty (::0) address. More... | |
static INet6Address const | Loopback |
The loopback (::1) address. More... | |
static INet6Address const | AllNodes |
The 'all nodes' link-local multicast address. More... | |
static INet6Address const | AllRouters |
The 'all routers' link-local multicast address. More... | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, INet6Address const &addr) |
Output INet6Address instance as it's string representation. More... | |
std::istream & | operator>> (std::istream &is, INet6Address &addr) |
Try to initialize INet6Address instance from a string representation. More... | |
Structors and default members | |
INet6Address (senf::NoInit_t) | |
Construct uninitialized (!) address. More... | |
INet6Address (boost::uint16_t a0=0u, boost::uint16_t a1=0u, boost::uint16_t a2=0u, boost::uint16_t a3=0u, boost::uint16_t a4=0u, boost::uint16_t a5=0u, boost::uint16_t a6=0u, boost::uint16_t a7=0u) | |
Construct an address constant. More... | |
in6_addr | toin6_addr () const |
get the linux in6_addr struct (convenience only) More... | |
static INet6Address | from_in6addr (in6_addr const &in6addr) |
Construct from std C struct. More... | |
static INet6Address | from_string (std::string const &s, Resolve_t resolve=ResolveINet6) |
Convert string to address. More... | |
template<class InputIterator > | |
static INet6Address | from_data (InputIterator i) |
Construct address from 16 bytes of raw data. More... | |
static INet6Address | from_inet4address (INet4Address const &addr) |
Construct an INet6-mapped INet4 address. More... | |
static INet6Address | from_mac (MACAddress const &mac) |
Construct a link-local INet6 address. More... | |
static INet6Address | from_eui64 (EUI64 const &eui) |
Construct link-local INet6 address. More... | |
Accessors | |
INet6Network | network () const |
Return /64 Network of this address. More... | |
bool | hasEUI64 () const |
true , if address is based on an EUID-64 More... | |
EUI64 | id () const |
Return interface id (EUID-64) More... | |
bool | universalId () const |
true , if the id() is universally assigned More... | |
bool | groupId () const |
true , if the id()'s group bit is set More... | |
bool | unicast () const |
true , if address is unicast More... | |
bool | multicast () const |
true , if address is multicast More... | |
ScopeId | scope () const |
Get address's scope. More... | |
bool | globalScope () const |
true , if address is global unicast or multicast More... | |
bool | linkScope () const |
true , if address is link-local unicast or multicast More... | |
INet4Address | inet4address () const |
Return embedded INet4 address. More... | |
bool | inet4Compatible () const |
true , if address is INet4 compatible More... | |
bool | inet4Mapped () const |
true , if address is INet4 mapped More... | |
bool | globalMulticastAddr () const |
true , if T bit is not set More... | |
bool | prefixMulticastAddr () const |
true , if P bit is set More... | |
bool | embeddedRpAddr () const |
true , if R bit is set More... | |
bool | boolean_test () const |
true , if address != '::' (None) More... | |
Mutators | |
void | network (boost::uint64_t net) |
Set network part of address. More... | |
void | id (boost::uint64_t id) |
Set interface id part of address. More... | |
Additional Inherited Members | |
Public Member Functions inherited from senf::comparable_safe_bool< INet6Address > | |
operator bool_type () const | |
bool | operator! () const |
Protected Types inherited from senf::safe_bool_base | |
typedef void(safe_bool_base::* | bool_type) () const |
Protected Member Functions inherited from senf::comparable_safe_bool< INet6Address > | |
~comparable_safe_bool () | |
Protected Member Functions inherited from senf::safe_bool_base | |
void | this_type_does_not_support_comparisons () const |
safe_bool_base () | |
safe_bool_base (const safe_bool_base &) | |
safe_bool_base & | operator= (const safe_bool_base &) |
~safe_bool_base () | |
INet6 network address.
This implementation of an INet6 address is based strictly on RFC 4291: Internet Protocol Version 6 (INet6) Addressing Architecture. This class provides accessors to all the information fields defined in this document.
The INet6 addressing architecture however has several other components defined in other RFC's. These RFC's should be implemented in additional modules:
Here an overview of well-known prefixes:
Prefix | Description | Definition | Note |
---|---|---|---|
::/96 | INet4 compatible INet6 address | RFC4291 | deprecated |
::ffff:0:0/96 | INet6 mapped INet4 address | RFC4291 | |
2000::/3 | Global unicast addresses | RFC3587 | only noted, not defined |
2001:db8::/32 | Documentation-only prefix | RFC3849 | |
2002::/16 | 6to4 addressing | RFC3056 | |
fc00::/7 | ULA | RFC4193 | |
fe80::/64 | Link-local addresses | RFC4291 | |
fec0::/10 | Site-local addresses | RFC4291 | deprecated |
ff00::/8 | Multicast | RFC4291 | |
ff00::/12 | Globally allocated multicast | RFC4291 | |
ff10::/12 | Locally allocated multicast | RFC4291 | |
ff30::/12 | Unicast prefix based multicast | RFC3306 | |
ff70::/12 | Multicast address with embedded RP | RFC3956 |
The following statements all create the same INet6 address 2001:db8::a0b1:1a2b:3dff:fe4e:5f00
:
Since INet6Address class is based on \c boost::array and is built as a fixed-size sequence of 16 bytes, you can access the raw data bytes of the address (in network byte order) using \c begin(), \c end() or \c operator[]
\see CheckINet6Network \n INet6Network \par "Implementation note:" We awkwardly need to use static named constructors (<tt>from_</tt> members) instead of ordinarily overloaded constructors for one simple reason: <tt>char *</tt> doubles as string literal and as arbitrary data iterator. The iterator constructor can therefore not be distinguished from initialization with a string literal. Therefore we need to disambiguate using the named constructors.
Definition at line 119 of file INet6Address.hh.
Enumerator | |
---|---|
ResolveINet6 | |
ResolveINet4 |
Definition at line 132 of file INet6Address.hh.
Possible scope values.
List of all possible scope values. This list includes all scope values defined for multicast addresses in RFC 4291. The values LinkScope, SiteScope and GlobalScope are also used with unicast addresses.
Definition at line 141 of file INet6Address.hh.
|
explicit |
Construct uninitialized (!) address.
|
explicit |
Construct an address constant.
bool senf::INet6Address::boolean_test | ( | ) | const |
true
, if address != '::' (None)
bool senf::INet6Address::embeddedRpAddr | ( | ) | const |
|
static |
Construct address from 16 bytes of raw data.
from_data will build an address from 16 bytes of raw data as accessed by the iterator. The data must be in network byte order.
|
static |
Construct link-local INet6 address.
This will construct a link local address of the form fe80::xxxx:xxxx:xxxx:xxxx
.
Definition at line 103 of file INet6Address.cc.
|
static |
Construct from std C struct.
|
static |
Construct an INet6-mapped INet4 address.
This will construct an address of the form ::FFFF::w.x.y.z
where w.x.y.z
is the INet4Address value. This kind of address is called an INet6-mapped INet4 address (see RFC 4291).
|
static |
Construct a link-local INet6 address.
This will construct a link local address of the form fe80::xxxx:xxff:fexx:xxxx
.
Definition at line 87 of file INet6Address.cc.
|
static |
Convert string to address.
This member will try to convert the given string into an IP address. from_string() supports all standard IP literal representations as well as hostnames.
AddressSyntaxException | if the address cannot be converted for some reason |
UnknownHostnameException | if the hostname cannot be resolved |
[in] | s | Address literal or hostname |
[in] | resolve | If this is set to ResolveINet4 , the call will additionally try to interpret s as an INet4 address if no valid INet6 address is found. The address will be returned as mapped INet6 address. |
Definition at line 38 of file INet6Address.cc.
bool senf::INet6Address::globalMulticastAddr | ( | ) | const |
true
, if T bit is not set
Any multicast address with a cleared T bit must be globally assigned. See RFC 4291.
bool senf::INet6Address::globalScope | ( | ) | const |
true
, if address is global unicast or multicast
bool senf::INet6Address::groupId | ( | ) | const |
true
, if the id()'s group bit is set
bool senf::INet6Address::hasEUI64 | ( | ) | const |
true
, if address is based on an EUID-64
senf::EUI64 senf::INet6Address::id | ( | ) | const |
Return interface id (EUID-64)
Definition at line 113 of file INet6Address.cc.
void senf::INet6Address::id | ( | boost::uint64_t | id | ) |
Set interface id part of address.
INet4Address senf::INet6Address::inet4address | ( | ) | const |
Return embedded INet4 address.
Returns the INet4 address embedded within an INet4 compatible or INet4 mapped unicast address. This address is given by the last 32 bits of the INet6 address.
true
. bool senf::INet6Address::inet4Compatible | ( | ) | const |
true
, if address is INet4 compatible
INet4 compatible INet6 addresses are deprecated.
bool senf::INet6Address::inet4Mapped | ( | ) | const |
true
, if address is INet4 mapped
bool senf::INet6Address::linkScope | ( | ) | const |
true
, if address is link-local unicast or multicast
bool senf::INet6Address::multicast | ( | ) | const |
true
, if address is multicast
To support a linux specific extension, INet4 multicast addressed mapped to INet6 are also interpreted as multicast addresses. This is NOT part of the standard, however the standard officially only allows unicast v4 addresses to be mapped to v6 so this does not collide with any standard conforming use.
INet6Network senf::INet6Address::network | ( | ) | const |
Return /64
Network of this address.
void senf::INet6Address::network | ( | boost::uint64_t | net | ) |
Set network part of address.
bool senf::INet6Address::prefixMulticastAddr | ( | ) | const |
ScopeId senf::INet6Address::scope | ( | ) | const |
Get address's scope.
The scope of an address is one of the ScopeId values. We need to differentiate between unicast and multicast addresses: unicast addresses only have local, site or global scope (where site scope is deprecated), multicast address can have a number of scope values of which local, site and global are a few. See the ScopeId enumerators.
in6_addr senf::INet6Address::toin6_addr | ( | ) | const |
get the linux in6_addr struct (convenience only)
Definition at line 81 of file INet6Address.cc.
bool senf::INet6Address::unicast | ( | ) | const |
true
, if address is unicast
bool senf::INet6Address::universalId | ( | ) | const |
true
, if the id() is universally assigned
|
related |
Output INet6Address instance as it's string representation.
|
related |
Try to initialize INet6Address instance from a string representation.
sets std::ios::failbit on the stream if an error occurred
|
static |
The 'all nodes' link-local multicast address.
Definition at line 129 of file INet6Address.hh.
|
static |
The 'all routers' link-local multicast address.
Definition at line 130 of file INet6Address.hh.
|
static |
The loopback (::1) address.
Definition at line 128 of file INet6Address.hh.
|
static |
The empty (::0) address.
Definition at line 127 of file INet6Address.hh.