libtins 4.5
Loading...
Searching...
No Matches
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*.
 
 IPv6Address (const std::string &addr)
 Constructor from a text representation std::string.
 
 IPv6Address (const_iterator ptr)
 Constructor from a buffer.
 
std::string to_string () const
 Retrieve the string representation of this address.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool operator== (const IPv6Address &rhs) const
 Compares this address for equality.
 
bool operator!= (const IPv6Address &rhs) const
 Compares this address for inequality.
 
bool operator< (const IPv6Address &rhs) const
 Compares this address for less-than inequality.
 
bool operator<= (const IPv6Address &rhs) const
 Compares this address for less-than equality.
 
bool operator> (const IPv6Address &rhs) const
 Compares this address for greater-than inequality.
 
bool operator>= (const IPv6Address &rhs) const
 Compares this address for greater-than equality.
 
template<typename OutputIterator >
OutputIterator copy (OutputIterator iter) const
 Helper function which copies the address into an output iterator.
 
bool is_loopback () const
 Returns true if this is a loopback IPv6 address.
 
bool is_multicast () const
 Returns true if this is a multicast IPv6 address.
 
bool is_local_unicast () const
 Return true if this is a Link-Local unicast IPv6 address.
 
size_t size () const
 Returns the size of an IPv6 Address.
 
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.
 

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.
 

Detailed Description

Represents an IPv6 address.

Member Typedef Documentation

◆ const_iterator

The const iterator type.

◆ iterator

The iterator type.

Constructor & Destructor Documentation

◆ IPv6Address() [1/3]

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

Constructor from a text representation char*.

Parameters
addrThe text representation from which to construct this object.

◆ IPv6Address() [2/3]

Tins::IPv6Address::IPv6Address ( const std::string & addr)

Constructor from a text representation std::string.

Parameters
addrThe text representation from which to construct this object.

◆ IPv6Address() [3/3]

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

◆ begin() [1/2]

iterator Tins::IPv6Address::begin ( )
inline

Returns an iterator to the beginning of this address.

◆ begin() [2/2]

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

Returns a const iterator to the beginning of this address.

◆ copy()

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.

◆ end() [1/2]

iterator Tins::IPv6Address::end ( )
inline

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

◆ end() [2/2]

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

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

◆ from_prefix_length()

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

◆ is_local_unicast()

bool Tins::IPv6Address::is_local_unicast ( ) const

Return true if this is a Link-Local unicast IPv6 address.

This method returns true if this address is in the address range fe80::/10, false otherwise

◆ is_loopback()

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.

◆ is_multicast()

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.

◆ operator!=()

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.

◆ operator&()

IPv6Address Tins::IPv6Address::operator& ( const IPv6Address & rhs) const

Applies a mask to an address

◆ operator<()

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.

◆ operator<=()

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.

◆ operator==()

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.

◆ operator>()

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.

◆ operator>=()

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.

◆ operator|()

IPv6Address Tins::IPv6Address::operator| ( const IPv6Address & rhs) const

or a mask to an address

◆ operator~()

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

not operator (invert)

◆ size()

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

Returns the size of an IPv6 Address.

This returns the value of IPv6Address::address_size

◆ to_string()

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 Symbol Documentation

◆ operator<<

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: