PcapPlusPlus  19.12
pcpp::IDnsResource Class Referenceabstract

#include <DnsResource.h>

Inheritance diagram for pcpp::IDnsResource:
pcpp::DnsQuery pcpp::DnsResource

Public Member Functions

DnsType getDnsType () const
 
void setDnsType (DnsType newType)
 
DnsClass getDnsClass () const
 
void setDnsClass (DnsClass newClass)
 
std::string getName () const
 
size_t getNameOffset () const
 
bool setName (const std::string &newName)
 
virtual size_t getSize () const =0
 
virtual DnsResourceType getType () const =0
 

Detailed Description

An abstract class for representing all types of DNS records. This class gives access to all available record data such as DNS type, class, name, type of record, etc. The DnsLayer holds an instance of (inherited type of) this class for each DNS record in the DNS packet

Member Function Documentation

◆ getDnsClass()

DnsClass pcpp::IDnsResource::getDnsClass ( ) const
Returns
The DNS class of this record

◆ getDnsType()

DnsType pcpp::IDnsResource::getDnsType ( ) const
Returns
The DNS type of this record

◆ getName()

std::string pcpp::IDnsResource::getName ( ) const
inline
Returns
The name of this record

◆ getNameOffset()

size_t pcpp::IDnsResource::getNameOffset ( ) const
inline
Returns
The record name's offset in the packet

◆ getSize()

virtual size_t pcpp::IDnsResource::getSize ( ) const
pure virtual
Returns
The total size in bytes of this record

Implemented in pcpp::DnsResource, and pcpp::DnsQuery.

◆ getType()

virtual DnsResourceType pcpp::IDnsResource::getType ( ) const
pure virtual
Returns
The type of this record (query, answer, authority, additional)

Implemented in pcpp::DnsResource, and pcpp::DnsQuery.

◆ setDnsClass()

void pcpp::IDnsResource::setDnsClass ( DnsClass  newClass)

Set DNS class for this record

Parameters
[in]newClassThe class to set

◆ setDnsType()

void pcpp::IDnsResource::setDnsType ( DnsType  newType)

Set DNS type for this record

Parameters
[in]newTypeThe type to set

◆ setName()

bool pcpp::IDnsResource::setName ( const std::string &  newName)

Set the name of this record. The input name can be a standard hostname (e.g 'google.com'), or it may contain a pointer to another string in the packet (as explained here: http://www.zytrax.com/books/dns/ch15/#name). The pointer is used to reduce the DNS packet size and avoid unnecessary duplications. In case you want to use a pointer in your string you should use the following format: 'some.domain.#{offset}' where '#{offset}' is a the offset from the start of the layer. For example: if the string 'yahoo.com' already appears in offset 12 in the packet and you want to set the name of the current record to '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.
Please notice the new name can be shorter or longer of the old name, so this method can cause the packet to be shorten or extended

Parameters
[in]newNameThe name to set
Returns
True if name was set successfully or false if input string is malformed or if an error occurred