PcapPlusPlus
pcpp::StringDnsResourceData Class Reference

#include <DnsResourceData.h>

Inheritance diagram for pcpp::StringDnsResourceData:
pcpp::IDnsResourceData

Public Member Functions

 StringDnsResourceData (const std::string &data)
 
bool operator== (const StringDnsResourceData &other) const
 
std::string toString ()
 
bool toByteArr (uint8_t *arr, size_t &arrLength, IDnsResource *dnsResource)
 
- 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 string data, mainly used in DNS RRs that store hostnames (like CNAME, DNAME, NS, etc.)

Constructor & Destructor Documentation

◆ StringDnsResourceData()

pcpp::StringDnsResourceData::StringDnsResourceData ( const std::string &  data)
inline

A c'tor for this class

Parameters
[in]dataThe string data to store in this object. If this string represents a hostname it's possible to include a pointer to another string in the DNS layer (as explained here: http://www.zytrax.com/books/dns/ch15/#name). These pointers are often used to reduce the DNS packet size and avoid unnecessary duplications. The way to include pointers in a hostname string is to use the following format: 'some.domain.#{offset}' where '#{offset}' is the offset from the start of the DNS layer. For example: if the string 'yahoo.com' already appears in offset 12 in the packet and you want to set the DNS RR data as 'my.subdomain.yahoo.com' you may use the following string: 'my.subdomain.#12'. This will result in writing 'my.subdomain' and a pointer to offset 12

Member Function Documentation

◆ operator==()

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

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

Parameters
[in]otherThe object to compare with
Returns
True if the string data is the same in both objects, false otherwise

◆ toByteArr()

bool pcpp::StringDnsResourceData::toByteArr ( uint8_t *  arr,
size_t &  arrLength,
IDnsResource dnsResource 
)
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::StringDnsResourceData::toString ( )
inlinevirtual
Returns
A string that represents the current DNS RR data

Implements pcpp::IDnsResourceData.