#include <iostream>
#include <string>
#include <boost/cstdint.hpp>
-#include <boost/function.hpp>
#include <boost/array.hpp>
#include <boost/operators.hpp>
-#include "Utils/SafeBool.hh"
+#include "../../../Utils/safe_bool.hh"
#include "INet4Address.hh"
//#include "INet6Address.mpp"
namespace senf {
- /** \brief IpV6 network address
+ /** \brief IPv6 network address
- This implementation of an IpV6 address is based strictly on
+ This implementation of an IPv6 address is based strictly on
<a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>: Internet Protocol
Version 6 (IPv6) Addressing Architecture. This class provides accessors to all the
information fields defined in this document.
- The IpV6 addressing architecture however has several other components defined in other
+ The IPv6 addressing architecture however has several other components defined in other
RFC's. These RFC's should be implemented in additional modules:
\li <a href="http://tools.ietf.org/html/rfc4193">RFC 4193</a>:
<table class="senf">
<tr><th>Prefix</th> <th>Description</th> <th>Definition</th> <th>Note</th></tr>
- <tr><td><tt>::/96</tt></td> <td>IpV4 compatible IpV6 address</td> <td>RFC4291</td> <td>deprecated</td></tr>
- <tr><td><tt>::ffff:0:0/96</tt></td> <td>IpV6 mapped IpV4 address</td> <td>RFC4291</td> <td></td></tr>
+ <tr><td><tt>::/96</tt></td> <td>IPv4 compatible IPv6 address</td> <td>RFC4291</td> <td>deprecated</td></tr>
+ <tr><td><tt>::ffff:0:0/96</tt></td> <td>IPv6 mapped IPv4 address</td> <td>RFC4291</td> <td></td></tr>
<tr><td><tt>2000::/3</tt></td> <td>Global unicast addresses</td> <td>RFC3587</td> <td>only noted, not defined</td></tr>
<tr><td><tt>2001:db8::/32</tt></td> <td>Documentation-only prefix</td> <td>RFC3849</td> <td></td></tr>
<tr><td><tt>2002::/16</tt></td> <td>6to4 addressing</td> <td>RFC3056</td> <td></td></tr>
*/
class INet6Address
: public boost::array<boost::uint8_t,16>,
- public ComparableSafeBool<INet6Address>
+ public comparable_safe_bool<INet6Address>
{
public:
///////////////////////////////////////////////////////////////////////////
// Types
- typedef boost::function<void (INet6Address const &)> Callback;
- ///< Callback for asynchronous from_string call
-
static INet6Address const None; ///< The empty (::0) address
static INet6Address const Loopback; ///< The loopback (::1) address
static INet6Address const AllNodes; ///< The 'all nodes' link-local multicast address
\param[in] s Address literal or hostname
\param[in] resolve If this is set to \c ResolveINet4,
the call will additionally try to interpret \a s as
- an IpV4 address if no valid IpV6 address is
- found. The address will be returned as mapped IpV6
+ an IPv4 address if no valid IPv6 address is
+ found. The address will be returned as mapped IPv6
address. */
- static void from_string(std::string const & s, Callback const & cb,
- Resolve_t resolve = ResolveINet6);
- ///< Convert string to address (async/non-blocking)
- /**< This member works like
- from_string(std::string const &). However unlike
- from_string(std::string const &), this call will not
- block. Instead it will call \a cb passing the
- INet6Address instance as soon as the address has been
- resolved (which may be immediate if the address
- represents an IP literal). \par
- On error, the address passed to \a cb will be empty.
- \param[in] s Address literal or hostname
- \param[in] cb Callback to pass the address to
- \param[in] resolve If this is set to \c ResolveINet4,
- the call will additionally try to interpret \a s as
- an IpV4 address if no valid IpV6 address is
- found. The address will be returned as mapped IpV6
- address.
- \fixme Implement */
-
template <class InputIterator>
static INet6Address from_data(InputIterator i);
///< Construct address from 16 bytes of raw data
network byte order. */
static INet6Address from_inet4address(INet4Address addr);
- ///< Construct an IpV6-mapped IpV4 address
+ ///< Construct an IPv6-mapped IPv4 address
/**< This will construct an address of the form
<tt>::FFFF::w.x.y.z</tt> where <tt>w.x.y.z</tt> is
the INet4Address value. This kind of address is called
- an IpV6-mapped IpV4 address (see
+ an IPv6-mapped IPv4 address (see
<a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>).
\par
- IpV4 compatible IpV6 addresses are not directly
+ IPv4 compatible IPv6 addresses are not directly
supported, they are deprecated in the RFC. */
///@}
///////////////////////////////////////////////////////////////////////////
bool globalScope() const; ///< \c true, if address is global unicast or multicast
bool linkScope() const; ///< \c true, if address is link-local unicast or multicast
- INet4Address inet4address() const; ///< Return embedded IpV4 address
- /**< Returns the IpV4 address embedded within an IpV4
- compatible or IpV4 mapped unicast address. This address
- is given by the last 32 bits of the IpV6 address. \par
- The value returned is only a valid IpV4 address if
+ INet4Address inet4address() const; ///< Return embedded IPv4 address
+ /**< Returns the IPv4 address embedded within an IPv4
+ compatible or IPv4 mapped unicast address. This address
+ is given by the last 32 bits of the IPv6 address. \par
+ The value returned is only a valid IPv4 address if
either ipv4Compatible() or ipv4Mapped() return \c
true. */
- bool ipv4Compatible() const; ///< \c true, if address is IpV4 compatible
- /**< IpV4 compatible IpV6 addresses are deprecated. */
- bool ipv4Mapped() const; ///< \c true, if address is IpV4 mapped
+ bool ipv4Compatible() const; ///< \c true, if address is IPv4 compatible
+ /**< IPv4 compatible IPv6 addresses are deprecated. */
+ bool ipv4Mapped() const; ///< \c true, if address is IPv4 mapped
bool globalMulticastAddr() const; ///< \c true, if T bit is \e not set
/**< Any multicast address with a cleared T bit must be
///@}
- /** \brief Invalid IpV6 address syntax */
- struct SyntaxException : public std::exception
- { virtual char const * what() const throw() { return "Invalid IpV6 address syntax"; } };
+ /** \brief Base-class for INet6Address exceptions */
+ struct AddressException : public std::exception {};
+
+ /** \brief Invalid INet4 address syntax */
+ struct SyntaxException : public AddressException
+ { virtual char const * what() const throw()
+ { return "invalid INet6 address syntax"; } };
+
+ /** \brief Resolver failure */
+ struct UnknownHostnameException : public AddressException
+ { virtual char const * what() const throw()
+ { return "failed to resolve INet6 hostname"; } };
};
/** \brief Output INet6Address instance as it's string representation
: public detail::CheckINet6Network_impl<a0,a1,a2,a3,a4,a5,a6,a7,a8>
{};
- /** \brief IpV6 network prefix
+ /** \brief IPv6 network prefix
- This class represents an IpV6 network prefix in CIDR notation.
+ This class represents an IPv6 network prefix in CIDR notation.
*/
class INet6Network
: public boost::equality_comparable<INet6Network>,
- public ComparableSafeBool<INet6Network>
+ public comparable_safe_bool<INet6Network>
{
public:
///////////////////////////////////////////////////////////////////////////