tdns
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | List of all members
DNSMessageReader Class Reference

A class that parses a DNS Message. More...

#include <dnsmessages.hh>

Collaboration diagram for DNSMessageReader:
[legend]

Public Member Functions

 DNSMessageReader (const char *input, uint16_t length)
 
 DNSMessageReader (const std::string &str)
 
bool eor () const
 are we at the end of a record? More...
 
void getQuestion (DNSName &name, DNSType &type) const
 Copies the qname and type to you. More...
 
bool getEDNS (uint16_t *newsize, bool *doBit) const
 Returns true if there was an EDNS record, plus copies details. More...
 
bool getRR (DNSSection &section, DNSName &name, DNSType &type, uint32_t &ttl, std::unique_ptr< RRGen > &content)
 Puts the next RR in content, unless at 'end of message', in which case it returns false. More...
 
void skipRRs (int n)
 Skip over n RRs. More...
 
void xfrName (DNSName &ret, uint16_t *pos=0)
 
DNSName getName (uint16_t *pos=0)
 Convenience form of xfrName that returns its result. More...
 
void xfrUInt8 (uint8_t &res, uint16_t *pos=0)
 Gets the next 8 bit unsigned integer from the message, or the one from 'pos'. More...
 
uint8_t getUInt8 (uint16_t *pos=0)
 Convenience form that returns the next 8 bit integer, or from pos. More...
 
void xfrUInt16 (uint16_t &res)
 Gets the next 16 bit unsigned integer from the message. More...
 
void xfrType (DNSType &type)
 For symmetry, this reads a type. More...
 
uint16_t getUInt16 ()
 Convenience form that returns the next 16 bit integer. More...
 
void xfrUInt32 (uint32_t &res)
 Gets the next 32 bit unsigned integer from the message. More...
 
void xfrTxt (std::string &blob)
 
void xfrBlob (std::string &blob, int size, uint16_t *pos=0)
 Gets the next size bytes from the message, of from pos. More...
 
std::string getBlob (int size, uint16_t *pos=0)
 Convenience function that returns next size bytes of the message, or from pos. More...
 

Public Attributes

struct dnsheader dh =dnsheader{}
 the DNS header More...
 
std::vector< uint8_t > payload
 The payload. More...
 
uint16_t payloadpos {0}
 Current position of processing. More...
 
uint16_t rrpos {0}
 Used in getRR to set section correctly. More...
 
uint16_t d_endofrecord
 
uint8_t d_ednsVersion {0}
 
DNSName d_qname
 
DNSType d_qtype {(DNSType)0}
 
DNSClass d_qclass {(DNSClass)0}
 
uint16_t d_bufsize
 
bool d_doBit {false}
 
bool d_haveEDNS {false}
 

Detailed Description

A class that parses a DNS Message.

Constructor & Destructor Documentation

DNSMessageReader::DNSMessageReader ( const char *  input,
uint16_t  length 
)
DNSMessageReader::DNSMessageReader ( const std::string &  str)
inline

Member Function Documentation

bool DNSMessageReader::eor ( ) const
inline

are we at the end of a record?

std::string DNSMessageReader::getBlob ( int  size,
uint16_t *  pos = 0 
)
inline

Convenience function that returns next size bytes of the message, or from pos.

Here is the call graph for this function:

bool DNSMessageReader::getEDNS ( uint16_t *  newsize,
bool *  doBit 
) const

Returns true if there was an EDNS record, plus copies details.

DNSName DNSMessageReader::getName ( uint16_t *  pos = 0)
inline

Convenience form of xfrName that returns its result.

void DNSMessageReader::getQuestion ( DNSName name,
DNSType type 
) const

Copies the qname and type to you.

bool DNSMessageReader::getRR ( DNSSection &  section,
DNSName name,
DNSType type,
uint32_t &  ttl,
std::unique_ptr< RRGen > &  content 
)

Puts the next RR in content, unless at 'end of message', in which case it returns false.

uint16_t DNSMessageReader::getUInt16 ( )
inline

Convenience form that returns the next 16 bit integer.

Here is the call graph for this function:

uint8_t DNSMessageReader::getUInt8 ( uint16_t *  pos = 0)
inline

Convenience form that returns the next 8 bit integer, or from pos.

Here is the call graph for this function:

void DNSMessageReader::skipRRs ( int  n)

Skip over n RRs.

void DNSMessageReader::xfrBlob ( std::string &  blob,
int  size,
uint16_t *  pos = 0 
)
inline

Gets the next size bytes from the message, of from pos.

void DNSMessageReader::xfrName ( DNSName ret,
uint16_t *  pos = 0 
)

put the next name in ret, or copy it from pos

Here is the call graph for this function:

void DNSMessageReader::xfrTxt ( std::string &  blob)
inline

Here is the call graph for this function:

void DNSMessageReader::xfrType ( DNSType type)
inline

For symmetry, this reads a type.

Here is the call graph for this function:

void DNSMessageReader::xfrUInt16 ( uint16_t &  res)
inline

Gets the next 16 bit unsigned integer from the message.

void DNSMessageReader::xfrUInt32 ( uint32_t &  res)
inline

Gets the next 32 bit unsigned integer from the message.

void DNSMessageReader::xfrUInt8 ( uint8_t &  res,
uint16_t *  pos = 0 
)
inline

Gets the next 8 bit unsigned integer from the message, or the one from 'pos'.

Member Data Documentation

uint16_t DNSMessageReader::d_bufsize
bool DNSMessageReader::d_doBit {false}
uint8_t DNSMessageReader::d_ednsVersion {0}
uint16_t DNSMessageReader::d_endofrecord
bool DNSMessageReader::d_haveEDNS {false}
DNSClass DNSMessageReader::d_qclass {(DNSClass)0}
DNSName DNSMessageReader::d_qname
DNSType DNSMessageReader::d_qtype {(DNSType)0}
struct dnsheader DNSMessageReader::dh =dnsheader{}

the DNS header

std::vector<uint8_t> DNSMessageReader::payload

The payload.

uint16_t DNSMessageReader::payloadpos {0}

Current position of processing.

uint16_t DNSMessageReader::rrpos {0}

Used in getRR to set section correctly.


The documentation for this class was generated from the following files: