PcapPlusPlus  20.08
pcpp::IPAddress Class Reference

‍** More...

#include <IpAddress.h>

Public Types

enum  AddressType { IPv4AddressType, IPv6AddressType }
 

Public Member Functions

 IPAddress ()
 
 IPAddress (const IPv4Address &addr)
 
 IPAddress (const IPv6Address &addr)
 
 IPAddress (const std::string &addrAsString)
 
IPAddressoperator= (const IPv4Address &addr)
 
IPAddressoperator= (const IPv6Address &addr)
 
AddressType getType () const
 
std::string toString () const
 
bool isValid () const
 
bool isIPv4 () const
 
bool isIPv6 () const
 
const IPv4AddressgetIPv4 () const
 
const IPv6AddressgetIPv6 () const
 
bool operator== (const IPAddress &rhs) const
 
bool operator< (const IPAddress &rhs) const
 
bool operator!= (const IPAddress &rhs) const
 

Detailed Description

‍**

Member Enumeration Documentation

◆ AddressType

An enum representing the address type: IPv4 or IPv6

Enumerator
IPv4AddressType 

IPv4 address type

IPv6AddressType 

IPv6 address type

Constructor & Destructor Documentation

◆ IPAddress() [1/4]

pcpp::IPAddress::IPAddress ( )
inline

A default constructor that creates an instance of the class with unspecified IPv4 address

◆ IPAddress() [2/4]

pcpp::IPAddress::IPAddress ( const IPv4Address addr)
inline

A constructor that creates an instance of the class out of IPv4Address.

Parameters
[in]addrA const reference to instance of IPv4Address

◆ IPAddress() [3/4]

pcpp::IPAddress::IPAddress ( const IPv6Address addr)
inline

A constructor that creates an instance of the class out of IPv6Address.

Parameters
[in]addrA const reference to instance of IPv6Address

◆ IPAddress() [4/4]

pcpp::IPAddress::IPAddress ( const std::string &  addrAsString)

A constructor that creates an instance of the class out of std::string value If the string doesn't represent a valid IPv4 or IPv6 address, an instance will store an unspecified address

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

Member Function Documentation

◆ getIPv4()

const IPv4Address& pcpp::IPAddress::getIPv4 ( ) const
inline

Get a reference to IPv4 address instance

Returns
The const reference to IPv4Address instance

◆ getIPv6()

const IPv6Address& pcpp::IPAddress::getIPv6 ( ) const
inline

Get a reference to IPv6 address instance

Returns
The const reference to IPv6Address instance

◆ getType()

AddressType pcpp::IPAddress::getType ( ) const
inline

Gets the address type: IPv4 or IPv6

Returns
The address type

◆ isIPv4()

bool pcpp::IPAddress::isIPv4 ( ) const
inline

Determine whether the object contains an IP version 4 address

◆ isIPv6()

bool pcpp::IPAddress::isIPv6 ( ) const
inline

Determine whether the object contains an IP version 6 address

◆ isValid()

bool pcpp::IPAddress::isValid ( ) const
inline

Determine whether the address is unspecified

◆ operator!=()

bool pcpp::IPAddress::operator!= ( const IPAddress rhs) const
inline

Overload of the not-equal-to operator

◆ operator<()

bool pcpp::IPAddress::operator< ( const IPAddress rhs) const
inline

Overload of the less-than operator

◆ operator=() [1/2]

IPAddress & pcpp::IPAddress::operator= ( const IPv4Address addr)
inline

Overload of an assignment operator.

Parameters
[in]addrA const reference to instance of IPv4Address

◆ operator=() [2/2]

IPAddress & pcpp::IPAddress::operator= ( const IPv6Address addr)
inline

Overload of an assignment operator.

Parameters
[in]addrA const reference to instance of IPv6Address

◆ operator==()

bool pcpp::IPAddress::operator== ( const IPAddress rhs) const
inline

Overload of the equal-to operator

◆ toString()

std::string pcpp::IPAddress::toString ( ) const
inline

Returns a std::string representation of the address

Returns
A string representation of the address