PcapPlusPlus  20.08+
pcpp::IPv4DnsResourceData Class Reference

#include <DnsResourceData.h>

Inheritance diagram for pcpp::IPv4DnsResourceData:
pcpp::IDnsResourceData

Public Member Functions

 IPv4DnsResourceData (const uint8_t *dataPtr, size_t dataLen)
 
 IPv4DnsResourceData (const IPv4Address &addr)
 
 IPv4DnsResourceData (const std::string &addrAsString)
 
bool operator== (const IPv4DnsResourceData &other) const
 
IPv4Address getIpAddress () const
 
std::string toString () const
 
bool toByteArr (uint8_t *arr, size_t &arrLength, IDnsResource *dnsResource) const
 
- Public Member Functions inherited from pcpp::IDnsResourceData
virtual ~IDnsResourceData ()
 
template<class IDnsResourceDataType >
bool isTypeOf () const
 
template<class IDnsResourceDataType >
IDnsResourceDataType * castAs ()
 

Detailed Description

A class that represents DNS RR IPv4 data, mainly used in DNS RRs of type DNS_TYPE_A

Constructor & Destructor Documentation

◆ IPv4DnsResourceData() [1/3]

pcpp::IPv4DnsResourceData::IPv4DnsResourceData ( const uint8_t *  dataPtr,
size_t  dataLen 
)

A c'tor for this class

Parameters
[in]dataPtrA byte array of size 4 that contains an IPv4 address (each byte represents 1 octet)
[in]dataLenThe byte array size, expected to be 4

◆ IPv4DnsResourceData() [2/3]

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

A c'tor for this class

Parameters
[in]addrThe IPv4 address to store in this object

◆ IPv4DnsResourceData() [3/3]

pcpp::IPv4DnsResourceData::IPv4DnsResourceData ( const std::string &  addrAsString)
inline

A c'tor for this class

Parameters
[in]addrAsStringA string representation of an IPv4 address to store in this object

Member Function Documentation

◆ getIpAddress()

IPv4Address pcpp::IPv4DnsResourceData::getIpAddress ( ) const
inline
Returns
The IPv4 address stored in this object

◆ operator==()

bool pcpp::IPv4DnsResourceData::operator== ( const IPv4DnsResourceData other) const
inline

Equality operator overload for this class that compares the IPv4 addresses stored in each object

Parameters
[in]otherThe object to compare with
Returns
True if IPv4 addresses are the same in both objects, false otherwise

◆ toByteArr()

bool pcpp::IPv4DnsResourceData::toByteArr ( uint8_t *  arr,
size_t &  arrLength,
IDnsResource dnsResource 
) const
virtual

Convert the DNS RR data into a byte array

Parameters
[out]arrA pointer to a pre-allocated byte array where the result will be written to
[out]arrLengthA reference to a 2-byte number where the result array length will be written to
[in]dnsResourceA pointer to a DNS resource object where this DNS RR data will be stored
Returns
True if the DNS RR data was successfully converted into a byte array and written to the given array or false if stored DNS RR data is invalid or if it could not be written to the given array

Implements pcpp::IDnsResourceData.

◆ toString()

std::string pcpp::IPv4DnsResourceData::toString ( ) const
inlinevirtual
Returns
A string that represents the current DNS RR data

Implements pcpp::IDnsResourceData.