libtins  4.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
Tins::IPv6Address Class Reference

#include <ipv6_address.h>

Public Types

typedef uint8_t * iterator
 
typedef const uint8_t * const_iterator
 

Public Member Functions

 IPv6Address ()
 Default constructor. Initializes this IPv6 address to "::".
 
 IPv6Address (const char *addr)
 Constructor from a text representation char*. More...
 
 IPv6Address (const std::string &addr)
 Constructor from a text representation std::string. More...
 
 IPv6Address (const_iterator ptr)
 Constructor from a buffer. More...
 
std::string to_string () const
 Retrieve the string representation of this address. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool operator== (const IPv6Address &rhs) const
 Compares this address for equality. More...
 
bool operator!= (const IPv6Address &rhs) const
 Compares this address for inequality. More...
 
bool operator< (const IPv6Address &rhs) const
 Compares this address for less-than inequality. More...
 
template<typename OutputIterator >
OutputIterator copy (OutputIterator iter) const
 Helper function which copies the address into an output iterator. More...
 
bool is_loopback () const
 Returns true if this is a loopback IPv6 address. More...
 
bool is_multicast () const
 Returns true if this is a multicast IPv6 address. More...
 

Static Public Member Functions

static IPv6Address from_prefix_length (uint32_t prefix_length)
 Constructs an IPv6 address from a prefix length. More...
 

Static Public Attributes

static const size_t address_size = 16
 

Friends

TINS_API friend std::ostream & operator<< (std::ostream &os, const IPv6Address &addr)
 Writes this address in hex-notation to a std::ostream. More...
 
TINS_API friend IPv6Address operator& (const IPv6Address &lhs, const IPv6Address &rhs)
 

Detailed Description

Represents an IPv6 address.

Member Typedef Documentation

typedef const uint8_t* Tins::IPv6Address::const_iterator

The const iterator type.

typedef uint8_t* Tins::IPv6Address::iterator

The iterator type.

Constructor & Destructor Documentation

Tins::IPv6Address::IPv6Address ( const char *  addr)

Constructor from a text representation char*.

Parameters
addrThe text representation from which to construct this object.
Tins::IPv6Address::IPv6Address ( const std::string &  addr)

Constructor from a text representation std::string.

Parameters
addrThe text representation from which to construct this object.
Tins::IPv6Address::IPv6Address ( const_iterator  ptr)

Constructor from a buffer.

The ptr parameter must be at least address_size bytes long.

Parameters
ptrThe buffer from which to construct this object.

Member Function Documentation

iterator Tins::IPv6Address::begin ( )
inline

Returns an iterator to the beginning of this address.

const_iterator Tins::IPv6Address::begin ( ) const
inline

Returns a const iterator to the beginning of this address.

template<typename OutputIterator >
OutputIterator Tins::IPv6Address::copy ( OutputIterator  iter) const
inline

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 IPv6Address by value, this function can be used to avoid temporaries.

Parameters
iterThe output iterator in which to store this address.
Returns
OutputIterator pointing to one-past the last position written.
iterator Tins::IPv6Address::end ( )
inline

Returns an iterator to the one-past-the-end element of this address.

const_iterator Tins::IPv6Address::end ( ) const
inline

Returns a const iterator to the one-past-the-end element of this address.

IPv6Address Tins::IPv6Address::from_prefix_length ( uint32_t  prefix_length)
static

Constructs an IPv6 address from a prefix length.

Parameters
prefix_lengthThe length of the prefix
bool Tins::IPv6Address::is_loopback ( ) const

Returns true if this is a loopback IPv6 address.

This method returns true if this address is the ::1/128 address, false otherwise.

bool Tins::IPv6Address::is_multicast ( ) const

Returns true if this is a multicast IPv6 address.

This method returns true if this address is in the address range ff00::/8, false otherwise.

bool Tins::IPv6Address::operator!= ( const IPv6Address rhs) const
inline

Compares this address for inequality.

Parameters
rhsThe address to be compared to.
Returns
bool indicating whether addresses are distinct.
bool Tins::IPv6Address::operator< ( const IPv6Address rhs) const
inline

Compares this address for less-than inequality.

Parameters
rhsThe address to be compared to.
Returns
bool indicating whether this address is less-than rhs.
bool Tins::IPv6Address::operator== ( const IPv6Address rhs) const
inline

Compares this address for equality.

Parameters
rhsThe address to be compared to.
Returns
bool indicating whether addresses are equal.
string Tins::IPv6Address::to_string ( ) const

Retrieve the string representation of this address.

Returns
std::string containing the representation of this address.

Friends And Related Function Documentation

TINS_API friend IPv6Address operator& ( const IPv6Address lhs,
const IPv6Address rhs 
)
friend

Applies a mask to an address

TINS_API friend std::ostream& operator<< ( std::ostream &  os,
const IPv6Address addr 
)
friend

Writes this address in hex-notation to a std::ostream.

Parameters
osThe stream in which to write the address.
addrThe parameter to be written.
Returns
std::ostream& pointing to the os parameter.

The documentation for this class was generated from the following files: