PcapPlusPlus  21.11
pcpp::IDnsResourceData Class Referenceabstract

#include <DnsResourceData.h>

Inheritance diagram for pcpp::IDnsResourceData:
pcpp::GenericDnsResourceData pcpp::IPv4DnsResourceData pcpp::IPv6DnsResourceData pcpp::MxDnsResourceData pcpp::StringDnsResourceData

Public Member Functions

virtual ~IDnsResourceData ()
 
template<class IDnsResourceDataType >
bool isTypeOf () const
 
template<class IDnsResourceDataType >
IDnsResourceDataType * castAs ()
 
virtual std::string toString () const =0
 
virtual bool toByteArr (uint8_t *arr, size_t &arrLength, IDnsResource *dnsResource) const =0
 

Detailed Description

A wrapper class for storing DNS RR (resource record) data. This is the base class which introduces several abstract methods for derived classes to implement for setting and retrieving the stored data. Each derived class will store different type of DNS RR data and implement these methods accordingly (for example: IPv4/IPv6 addresses, MX data, hostnames, raw byte data etc.)

Constructor & Destructor Documentation

◆ ~IDnsResourceData()

virtual pcpp::IDnsResourceData::~IDnsResourceData ( )
inlinevirtual

A virtual d'tor, does nothing

Member Function Documentation

◆ castAs()

template<class IDnsResourceDataType >
IDnsResourceDataType* pcpp::IDnsResourceData::castAs ( )
inline

A templated method which take a class that derives from IDnsResourceData as the template argument and tries to cast the current instance as that type

Returns
A pointer to the current instance casted as the requested type or NULL if this instance isn't of this type

◆ isTypeOf()

template<class IDnsResourceDataType >
bool pcpp::IDnsResourceData::isTypeOf ( ) const
inline

A templated method which takes a class that derives from IDnsResourceData as the template argument and checks whether this instance is of this type

Returns
True if this instance is of the requested type, false otherwise

◆ toByteArr()

virtual bool pcpp::IDnsResourceData::toByteArr ( uint8_t *  arr,
size_t &  arrLength,
IDnsResource dnsResource 
) const
pure 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

Implemented in pcpp::GenericDnsResourceData, pcpp::MxDnsResourceData, pcpp::IPv6DnsResourceData, pcpp::IPv4DnsResourceData, and pcpp::StringDnsResourceData.

◆ toString()

virtual std::string pcpp::IDnsResourceData::toString ( ) const
pure virtual
Returns
A string that represents the current DNS RR data

Implemented in pcpp::GenericDnsResourceData, pcpp::MxDnsResourceData, pcpp::IPv6DnsResourceData, pcpp::IPv4DnsResourceData, and pcpp::StringDnsResourceData.