]> granicus.if.org Git - pdns/commitdiff
add makeOpt infrastructure so we can make DNSRecords with OPT pseudo record in there...
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 9 Dec 2015 12:28:35 +0000 (13:28 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 9 Dec 2015 12:28:35 +0000 (13:28 +0100)
pdns/dnsrecords.cc
pdns/dnsrecords.hh

index 8684c2d75f17ea729af5cf6298918bee51c9c429..3f4a069b750949d50ec94092b34ad727c918b5b4 100644 (file)
@@ -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<OPTRecordContent>();
+  // if we ever do options, I think we stuff them into OPTRecordContent::data
+  return dr;
+}
+
 
 void reportBasicTypes()
 {
index cc38d1b05d61136d60cba28036d1f7f0d37c14b7..768ddeb2379690e7f08cb6fc69d01d1b5a2babec 100644 (file)
@@ -247,6 +247,7 @@ private:
 class OPTRecordContent : public DNSRecordContent
 {
 public:
+  OPTRecordContent(){}
   includeboilerplate(OPT)
   void getData(vector<pair<uint16_t, string> > &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();