make getRR also set the section correctly

This commit is contained in:
bert hubert
2018-10-11 13:57:21 +02:00
parent 356f79e225
commit bffb7ebb23
2 changed files with 8 additions and 0 deletions

View File

@ -88,6 +88,13 @@ bool DNSMessageReader::getRR(DNSSection& section, DNSName& name, DNSType& type,
{
if(payloadpos == payload.size())
return false;
if(rrpos < ntohs(dh.ancount))
section = DNSSection::Answer;
else if(rrpos < ntohs(dh.ancount) + ntohs(dh.nscount))
section = DNSSection::Authority;
else
section = DNSSection::Additional;
++rrpos;
name = getName();
type=(DNSType)getUInt16();
/* uint16_t lclass = */ getUInt16(); // class

View File

@ -18,6 +18,7 @@ public:
struct dnsheader dh=dnsheader{}; //!< the DNS header
std::vector<uint8_t> payload; //!< The payload
uint16_t payloadpos{0}; //!< Current position of processing
uint16_t rrpos{0}; //!< Used in getRR to set section correctly
uint16_t d_endofrecord;
//! are we at the end of a record?
bool eor() const { return payloadpos == d_endofrecord; }