From: bert hubert Date: Wed, 9 Dec 2015 12:28:35 +0000 (+0100) Subject: add makeOpt infrastructure so we can make DNSRecords with OPT pseudo record in there... X-Git-Tag: dnsdist-1.0.0-alpha1~91 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c541004ced57ebe65f6008a8e59b166372f43e12;p=pdns add makeOpt infrastructure so we can make DNSRecords with OPT pseudo record in there, ready for insertion --- 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();