PcapPlusPlus  19.12
pcpp::IPv6Address Class Reference

#include <IpAddress.h>

Inheritance diagram for pcpp::IPv6Address:
pcpp::IPAddress

Public Member Functions

 IPv6Address (uint8_t *addressAsUintArr)
 
 IPv6Address (char *addressAsString)
 
 IPv6Address (std::string addressAsString)
 
 IPv6Address (const IPv6Address &other)
 
AddressType getType () const
 
IPAddressclone () const
 
in6_addr * toIn6Addr () const
 
void copyTo (uint8_t **arr, size_t &length) const
 
void copyTo (uint8_t *arr) const
 
bool operator== (const IPv6Address &other) const
 
bool operator!= (const IPv6Address &other) const
 
IPv6Addressoperator= (const IPv6Address &other)
 
- Public Member Functions inherited from pcpp::IPAddress
std::string toString () const
 
bool isValid () const
 
bool equals (const IPAddress *other) const
 

Static Public Attributes

static IPv6Address Zero
 

Additional Inherited Members

- Public Types inherited from pcpp::IPAddress
enum  AddressType { IPv4AddressType, IPv6AddressType }
 
- Static Public Member Functions inherited from pcpp::IPAddress
static Ptr_t fromString (char *addressAsString)
 
static Ptr_t fromString (std::string addressAsString)
 

Detailed Description

Represents an IPv6 address (of type xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx). An instance of this class can be constructed from string, 16-byte array or from the in6_addr struct. It can be converted or copied to each of these types

Constructor & Destructor Documentation

◆ IPv6Address() [1/4]

pcpp::IPv6Address::IPv6Address ( uint8_t *  addressAsUintArr)

A constructor that creates an instance of the class out of a 16-Byte long byte array. Array size must be 16 bytes, otherwise instance will be invalid, meaning isValid() will return false

Parameters
addressAsUintArrA 16-byte array containing address value

◆ IPv6Address() [2/4]

pcpp::IPv6Address::IPv6Address ( char *  addressAsString)

A constructor that creates an instance of the class out of string (char*) value. If the string doesn't represent a valid IPv6 address, instance will be invalid, meaning isValid() will return false

Parameters
[in]addressAsStringThe string (char*) representation of the address

◆ IPv6Address() [3/4]

pcpp::IPv6Address::IPv6Address ( std::string  addressAsString)

A constructor that creates an instance of the class out of string std::string value If the string doesn't represent a valid IPv6 address, instance will be invalid, meaning isValid() will return false

Parameters
[in]addressAsStringThe string std::string representation of the address

◆ IPv6Address() [4/4]

pcpp::IPv6Address::IPv6Address ( const IPv6Address other)

A copy constructor for this class

Member Function Documentation

◆ clone()

IPAddress* pcpp::IPv6Address::clone ( ) const
virtual

Clone the object

Returns
A newly allocated instance which is a clone of the current instance

Implements pcpp::IPAddress.

◆ copyTo() [1/2]

void pcpp::IPv6Address::copyTo ( uint8_t **  arr,
size_t &  length 
) const

Allocates a byte array and copies address value into it. Array deallocation is user responsibility

Parameters
[in]arrA pointer to where array will be allocated
[out]lengthReturns the length in bytes of the array that was allocated

◆ copyTo() [2/2]

void pcpp::IPv6Address::copyTo ( uint8_t *  arr) const

Gets a pointer to an already allocated byte array and copies the address value to it. This method assumes array allocated size is at least 16 (the size of an IPv6 address)

Parameters
[in]arrA pointer to the array which address will be copied to

◆ getType()

AddressType pcpp::IPv6Address::getType ( ) const
inlinevirtual
Returns
IPv6AddressType

Implements pcpp::IPAddress.

◆ operator!=()

bool pcpp::IPv6Address::operator!= ( const IPv6Address other) const

Overload of the non-equal operator

Returns
true if 2 addresses are not equal. False otherwise

◆ operator=()

IPv6Address& pcpp::IPv6Address::operator= ( const IPv6Address other)

Overload of the assignment operator

◆ operator==()

bool pcpp::IPv6Address::operator== ( const IPv6Address other) const

Overload of the comparison operator

Returns
true if 2 addresses are equal. False otherwise

◆ toIn6Addr()

in6_addr* pcpp::IPv6Address::toIn6Addr ( ) const
inline

Returns a in6_addr struct pointer representing the IPv6 address

Returns
a in6_addr struct pointer representing the IPv6 address

Member Data Documentation

◆ Zero

IPv6Address pcpp::IPv6Address::Zero
static

A static value representing a zero value of IPv6 address, meaning address of value "0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0"