+// $Id$
+//
// Copyright (C) 2007
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
INet4Address represents a simple IP address. It is modelled as a fixed-size
container/sequence of 4 bytes.
+ \implementation 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.
+
\todo Add additional classes for CIDR addresses and networks and network math.
+ \ingroup addr_group
*/
class INet4Address
: public boost::array<boost::uint8_t,4>,
{
public:
+ ///////////////////////////////////////////////////////////////////////////
+ // Types
+
typedef uint32_t address_type; ///< Address representation as number in host byte order
typedef uint32_t inaddr_type; ///< Legacy address representation in network byte order
typedef boost::function<void (INet4Address const &)> Callback;
enum NoInit_t { noinit };
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Structors and default members
+ ///@{
+
INet4Address(); ///< Construct an empty address
- INet4Address(NoInit_t); ///< Construct uninitialized (!) address
+ explicit INet4Address(NoInit_t); ///< Construct uninitialized (!) address
explicit INet4Address(address_type value);
///< Construct an address constant
code to convert a network byte order address in an
integer number into an INet4Address. */
+ ///@}
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Accessors
+ ///@{
+
bool local() const; ///< \c true, if address is locally administered
/**< This call checks, if the address is within one of the
IANA private ranges. */
host byte order. This representation allows simple
network math operations. */
+ ////@}
+
struct SyntaxException : public std::exception
{ virtual char const * what() const throw() { return "invalid INet4 address syntax"; } };