libtins  4.0
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...
 
bool operator<= (const IPv6Address &rhs) const
 Compares this address for less-than equality. More...
 
bool operator> (const IPv6Address &rhs) const
 Compares this address for greater-than inequality. More...
 
bool operator>= (const IPv6Address &rhs) const
 Compares this address for greater-than equality. 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...
 
size_t size () const
 Returns the size of an IPv6 Address. More...
 
IPv6Address operator& (const IPv6Address &rhs) const
 
IPv6Address operator| (const IPv6Address &rhs) const
 
IPv6Address operator~ () const
 

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...
 

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.
IPv6Address Tins::IPv6Address::operator& ( const IPv6Address rhs) const

Applies a mask to an address

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 less-than equality.

Parameters
rhsThe address to be compared to.
Returns
bool indicating whether this address is equal or 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.
bool Tins::IPv6Address::operator> ( const IPv6Address rhs) const
inline

Compares this address for greater-than inequality.

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

Compares this address for greater-than equality.

Parameters
rhsThe address to be compared to.
Returns
bool indicating whether this address is equal or greater-than rhs.
IPv6Address Tins::IPv6Address::operator| ( const IPv6Address rhs) const

or a mask to an address

IPv6Address Tins::IPv6Address::operator~ ( ) const

not operator (invert)

size_t Tins::IPv6Address::size ( ) const
inline

Returns the size of an IPv6 Address.

This returns the value of IPv6Address::address_size

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 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: