From fbe2359127898ace4b5f025dd0a7e1435b1b161a Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 1 Oct 2015 21:45:49 +0200 Subject: [PATCH] further DNSRecord/DNSResourceRecord conversion infra --- pdns/dnsparser.cc | 9 +++++++++ pdns/dnsparser.hh | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index e5a151923..d1752d3b3 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -207,6 +207,15 @@ DNSRecordContent::zmakermap_t& DNSRecordContent::getZmakermap() return zmakermap; } +DNSRecord::DNSRecord(const DNSResourceRecord& rr) +{ + d_name = rr.qname; + d_type = rr.qtype.getCode(); + d_ttl = rr.ttl; + d_class = rr.qclass; + d_content = std::shared_ptr(DNSRecordContent::mastermake(d_type, rr.qclass, rr.content)); +} + void MOADNSParser::init(const char *packet, unsigned int len) { if(len < sizeof(dnsheader)) diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index 9c02b8079..2a3e26986 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -263,13 +263,15 @@ protected: struct DNSRecord { + DNSRecord() = default; + explicit DNSRecord(const DNSResourceRecord& rr); DNSName d_name; std::shared_ptr d_content; uint16_t d_type; uint16_t d_class; uint32_t d_ttl; uint16_t d_clen; - enum : uint8_t {Answer=1, Nameserver, Additional} d_place; + enum Place : uint8_t {Answer=1, Nameserver=2, Additional=3} d_place; bool operator<(const DNSRecord& rhs) const { -- 2.40.0