A class that parses a DNS Message. More...
#include <dnsmessages.hh>
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 §ion, 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} |
A class that parses a DNS Message.
DNSMessageReader::DNSMessageReader | ( | const char * | input, |
uint16_t | length | ||
) |
|
inline |
|
inline |
are we at the end of a record?
|
inline |
Convenience function that returns next size bytes of the message, or from pos.
bool DNSMessageReader::getEDNS | ( | uint16_t * | newsize, |
bool * | doBit | ||
) | const |
Returns true if there was an EDNS record, plus copies details.
|
inline |
Convenience form of xfrName that returns its result.
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.
|
inline |
Convenience form that returns the next 16 bit integer.
|
inline |
Convenience form that returns the next 8 bit integer, or from pos.
void DNSMessageReader::skipRRs | ( | int | n | ) |
Skip over n RRs.
|
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
|
inline |
|
inline |
For symmetry, this reads a type.
|
inline |
Gets the next 16 bit unsigned integer from the message.
|
inline |
Gets the next 32 bit unsigned integer from the message.
|
inline |
Gets the next 8 bit unsigned integer from the message, or the one from 'pos'.
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} |
DNSName DNSMessageReader::d_qname |
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.