From c541004ced57ebe65f6008a8e59b166372f43e12 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 9 Dec 2015 13:28:35 +0100 Subject: [PATCH] add makeOpt infrastructure so we can make DNSRecords with OPT pseudo record in there, ready for insertion --- pdns/dnsrecords.cc | 18 ++++++++++++++++++ pdns/dnsrecords.hh | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 8684c2d75..3f4a069b7 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -531,6 +531,24 @@ bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo) return false; } +DNSRecord makeOpt(int udpsize, int extRCode, int Z) +{ + EDNS0Record stuff; + stuff.extRCode=0; + stuff.version=0; + stuff.Z=htons(Z); + DNSRecord dr; + memcpy(&dr.d_ttl, &stuff, sizeof(stuff)); + dr.d_ttl=ntohl(dr.d_ttl); + dr.d_name=DNSName("."); + dr.d_type = QType::OPT; + dr.d_class=udpsize; + dr.d_place=DNSResourceRecord::ADDITIONAL; + dr.d_content = std::make_shared(); + // if we ever do options, I think we stuff them into OPTRecordContent::data + return dr; +} + void reportBasicTypes() { diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index cc38d1b05..768ddeb23 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -247,6 +247,7 @@ private: class OPTRecordContent : public DNSRecordContent { public: + OPTRecordContent(){} includeboilerplate(OPT) void getData(vector > &opts); private: @@ -704,7 +705,7 @@ struct EDNSOpts class MOADNSParser; bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo); - +DNSRecord makeOpt(int udpsize, int extRCode, int Z); void reportBasicTypes(); void reportOtherTypes(); void reportAllTypes(); -- 2.40.0