]> granicus.if.org Git - pdns/commitdiff
in this commit, we remove d_qtype from the DNSRecordContent base class. This slims...
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 13 Nov 2015 10:17:23 +0000 (11:17 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 13 Nov 2015 10:17:23 +0000 (11:17 +0100)
pdns/dnsparser.cc
pdns/dnsparser.hh
pdns/dnsrecords.cc
pdns/dnsrecords.hh
pdns/nsecrecords.cc
pdns/pdns_recursor.cc
pdns/qtype.hh
pdns/sillyrecords.cc

index 245909d6bf6bbd18bad4d48535cf8f949152ab6b..f0917757009b18da1ed2379b018562e5ce746a05 100644 (file)
@@ -32,12 +32,12 @@ class UnknownRecordContent : public DNSRecordContent
 {
 public:
   UnknownRecordContent(const DNSRecord& dr, PacketReader& pr) 
-    : DNSRecordContent(dr.d_type), d_dr(dr)
+    : d_dr(dr)
   {
     pr.copyRecord(d_record, dr.d_clen);
   }
 
-  UnknownRecordContent(const string& zone) : DNSRecordContent(0)
+  UnknownRecordContent(const string& zone) 
   {
     // parse the input
     vector<string> parts;
@@ -75,6 +75,11 @@ public:
   {
     pw.xfrBlob(string(d_record.begin(),d_record.end()));
   }
+
+  uint16_t getType() const override 
+  {
+    return d_dr.d_type;
+  }
 private:
   DNSRecord d_dr;
   vector<uint8_t> d_record;
index 0834c3b7a102aa5fc8a1710fd9769b19ee3fd5f9..d108e8548b3124a88814c30941fc19ae2d2a8ed1 100644 (file)
@@ -179,7 +179,7 @@ public:
     if(lowerCase)
       pw.setLowercase(true);
 
-    pw.startRecord(qname, d_qtype);
+    pw.startRecord(qname, this->getType());
     this->toPacket(pw);
     pw.commit();
     
@@ -234,19 +234,7 @@ public:
     return iter->second;
   }
 
-  explicit DNSRecordContent(uint16_t type) : d_qtype(type)
-  {
-  }
-  
-  
-  DNSRecordContent& operator=(const DNSRecordContent& orig) 
-  {
-    const_cast<uint16_t&>(d_qtype) = orig.d_qtype; // **COUGH**
-    return *this;
-  }
-
-  
-  const uint16_t d_qtype;
+  virtual uint16_t getType() const = 0;
 
 protected:
   typedef std::map<std::pair<uint16_t, uint16_t>, makerfunc_t* > typemap_t;
index 7dd3442b41ba07e80ae8baa1917e0ace3cbfb15f..9c03ce64c0a387d36d81dce0925775ddcd53647e 100644 (file)
@@ -91,17 +91,17 @@ DNSResourceRecord::DNSResourceRecord(const DNSRecord &p) {
 
 boilerplate_conv(A, QType::A, conv.xfrIP(d_ip));
 
-ARecordContent::ARecordContent(uint32_t ip) : DNSRecordContent(QType::A)
+ARecordContent::ARecordContent(uint32_t ip) 
 {
   d_ip = ip;
 }
 
-ARecordContent::ARecordContent(const ComboAddress& ca) : DNSRecordContent(QType::A)
+ARecordContent::ARecordContent(const ComboAddress& ca) 
 {
   d_ip = ca.sin4.sin_addr.s_addr;
 }
 
-AAAARecordContent::AAAARecordContent(const ComboAddress& ca) : DNSRecordContent(QType::AAAA)
+AAAARecordContent::AAAARecordContent(const ComboAddress& ca) 
 {
   d_ip6.assign((const char*)ca.sin6.sin6_addr.s6_addr, 16);
 }
@@ -189,7 +189,7 @@ boilerplate_conv(TSIG, QType::TSIG,
                  if (size>0) conv.xfrBlobNoSpaces(d_otherData, size);
                  );
 
-MXRecordContent::MXRecordContent(uint16_t preference, const DNSName& mxname) : DNSRecordContent(QType::MX), d_preference(preference), d_mxname(mxname)
+MXRecordContent::MXRecordContent(uint16_t preference, const DNSName& mxname) d_preference(preference), d_mxname(mxname)
 {
 }
 
@@ -256,7 +256,7 @@ boilerplate_conv(NAPTR, QType::NAPTR,
 
 
 SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const DNSName& target) 
-: DNSRecordContent(QType::SRV), d_weight(weight), d_port(port), d_target(target), d_preference(preference)
+: d_weight(weight), d_port(port), d_target(target), d_preference(preference)
 {}
 
 boilerplate_conv(SRV, QType::SRV, 
@@ -265,7 +265,7 @@ boilerplate_conv(SRV, QType::SRV,
                  )
 
 SOARecordContent::SOARecordContent(const DNSName& mname, const DNSName& rname, const struct soatimes& st) 
-: DNSRecordContent(QType::SOA), d_mname(mname), d_rname(rname)
+: d_mname(mname), d_rname(rname)
 {
   d_st=st;
 }
@@ -308,7 +308,7 @@ boilerplate_conv(OPENPGPKEY, 61,
                  )
 
 #undef DS
-DSRecordContent::DSRecordContent() : DNSRecordContent(43) {}
+DSRecordContent::DSRecordContent() {}
 boilerplate_conv(DS, 43, 
                  conv.xfr16BitInt(d_tag); 
                  conv.xfr8BitInt(d_algorithm); 
@@ -316,7 +316,7 @@ boilerplate_conv(DS, 43,
                  conv.xfrHexBlob(d_digest, true); // keep reading across spaces
                  )
 
-CDSRecordContent::CDSRecordContent() : DNSRecordContent(59) {}
+CDSRecordContent::CDSRecordContent() {}
 boilerplate_conv(CDS, 59, 
                  conv.xfr16BitInt(d_tag); 
                  conv.xfr8BitInt(d_algorithm); 
@@ -324,7 +324,7 @@ boilerplate_conv(CDS, 59,
                  conv.xfrHexBlob(d_digest, true); // keep reading across spaces
                  )
 
-DLVRecordContent::DLVRecordContent() : DNSRecordContent(32769) {}
+DLVRecordContent::DLVRecordContent() {}
 boilerplate_conv(DLV,32769 , 
                  conv.xfr16BitInt(d_tag); 
                  conv.xfr8BitInt(d_algorithm); 
@@ -351,7 +351,7 @@ boilerplate_conv(RRSIG, 46,
                  conv.xfrBlob(d_signature);
                  )
                  
-RRSIGRecordContent::RRSIGRecordContent() : DNSRecordContent(46) {}
+RRSIGRecordContent::RRSIGRecordContent() {}
 
 boilerplate_conv(DNSKEY, 48, 
                  conv.xfr16BitInt(d_flags); 
@@ -359,7 +359,7 @@ boilerplate_conv(DNSKEY, 48,
                  conv.xfr8BitInt(d_algorithm); 
                  conv.xfrBlob(d_key);
                  )
-DNSKEYRecordContent::DNSKEYRecordContent() : DNSRecordContent(48) {}
+DNSKEYRecordContent::DNSKEYRecordContent() {}
 
 boilerplate_conv(CDNSKEY, 60, 
                  conv.xfr16BitInt(d_flags); 
@@ -367,14 +367,14 @@ boilerplate_conv(CDNSKEY, 60,
                  conv.xfr8BitInt(d_algorithm); 
                  conv.xfrBlob(d_key);
                  )
-CDNSKEYRecordContent::CDNSKEYRecordContent() : DNSRecordContent(60) {}
+CDNSKEYRecordContent::CDNSKEYRecordContent() {}
 
 boilerplate_conv(RKEY, 57, 
                  conv.xfr16BitInt(d_flags); 
                  conv.xfr8BitInt(d_protocol); 
                  conv.xfrBlob(d_key);
                  )
-RKEYRecordContent::RKEYRecordContent() : DNSRecordContent(57) {}
+RKEYRecordContent::RKEYRecordContent() {}
 
 /* EUI48 start */
 void EUI48RecordContent::report(void) 
@@ -474,7 +474,7 @@ boilerplate_conv(TKEY, QType::TKEY,
                  conv.xfr16BitInt(d_othersize);
                  if (d_othersize>0) conv.xfrBlobNoSpaces(d_other, d_othersize);
                  )
-TKEYRecordContent::TKEYRecordContent() : DNSRecordContent(QType::TKEY) { d_othersize = 0; } // fix CID#1288932
+TKEYRecordContent::TKEYRecordContent() { d_othersize = 0; } // fix CID#1288932
 
 uint16_t DNSKEYRecordContent::getTag()
 {
index 6ff7b535d2d2a5b5d867c3b381b8329b6f4c7993..b396fc05f361e92fba8205b8fa1cd6de7a0921ea 100644 (file)
@@ -39,6 +39,7 @@
   static DNSRecordContent* make(const string& zonedata);                                         \
   string getZoneRepresentation() const;                                                          \
   void toPacket(DNSPacketWriter& pw);                                                            \
+  uint16_t getType() const override { return QType::RNAME; }                                   \
   template<class Convertor> void xfrPacket(Convertor& conv);                             
 
 class NAPTRRecordContent : public DNSRecordContent
@@ -142,7 +143,7 @@ class TSIGRecordContent : public DNSRecordContent
 {
 public:
   includeboilerplate(TSIG)
-  TSIGRecordContent() : DNSRecordContent(QType::TSIG) {}
+  TSIGRecordContent() {}
 
   uint16_t d_origID;
   uint16_t d_fudge;
@@ -180,7 +181,7 @@ class NSRecordContent : public DNSRecordContent
 {
 public:
   includeboilerplate(NS)
-  explicit NSRecordContent(const DNSName& content) : DNSRecordContent(QType::NS), d_content(content){}
+  explicit NSRecordContent(const DNSName& content) : d_content(content){}
   DNSName getNS() const { return d_content; } 
 private:
   DNSName d_content;
@@ -445,7 +446,7 @@ class NSECRecordContent : public DNSRecordContent
 {
 public:
   static void report(void);
-  NSECRecordContent() : DNSRecordContent(47)
+  NSECRecordContent()
   {}
   NSECRecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone?
 
@@ -453,6 +454,10 @@ public:
   static DNSRecordContent* make(const string& content);
   string getZoneRepresentation() const;
   void toPacket(DNSPacketWriter& pw);
+  uint16_t getType() const override
+  {
+    return QType::NSEC;
+  }
   DNSName d_next;
   std::set<uint16_t> d_set;
 private:
@@ -462,7 +467,7 @@ class NSEC3RecordContent : public DNSRecordContent
 {
 public:
   static void report(void);
-  NSEC3RecordContent() : DNSRecordContent(50)
+  NSEC3RecordContent() 
   {}
   NSEC3RecordContent(const string& content, const string& zone=""); //FIXME400: DNSName& zone?
 
@@ -479,6 +484,12 @@ public:
   uint8_t d_saltlength;
   uint8_t d_nexthashlength;
 
+  uint16_t getType() const override
+  {
+    return QType::NSEC3;
+  }
+
+
 private:
 };
 
@@ -487,7 +498,7 @@ class NSEC3PARAMRecordContent : public DNSRecordContent
 {
 public:
   static void report(void);
-  NSEC3PARAMRecordContent() : DNSRecordContent(51)
+  NSEC3PARAMRecordContent()
   {}
   NSEC3PARAMRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone?
 
@@ -496,6 +507,11 @@ public:
   string getZoneRepresentation() const;
   void toPacket(DNSPacketWriter& pw);
 
+  uint16_t getType() const override
+  {
+    return QType::NSEC3PARAM;
+  }
+
 
   uint8_t d_algorithm, d_flags;
   uint16_t d_iterations;
@@ -508,7 +524,7 @@ class LOCRecordContent : public DNSRecordContent
 {
 public:
   static void report(void);
-  LOCRecordContent() : DNSRecordContent(QType::LOC)
+  LOCRecordContent() 
   {}
   LOCRecordContent(const string& content, const string& zone="");
 
@@ -519,7 +535,11 @@ public:
 
   uint8_t d_version, d_size, d_horizpre, d_vertpre;
   uint32_t d_latitude, d_longitude, d_altitude;
-  
+  uint16_t getType() const override
+  {
+    return QType::LOC;
+  }
+
 private:
 };
 
@@ -528,7 +548,7 @@ class WKSRecordContent : public DNSRecordContent
 {
 public:
   static void report(void);
-  WKSRecordContent() : DNSRecordContent(QType::WKS)
+  WKSRecordContent() 
   {}
   WKSRecordContent(const string& content, const string& zone=""); // FIXME400: DNSName& zone?
 
@@ -545,12 +565,13 @@ private:
 class EUI48RecordContent : public DNSRecordContent 
 {
 public:
-  EUI48RecordContent() : DNSRecordContent(QType::EUI48) {};
+  EUI48RecordContent() {};
   static void report(void);
   static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
   static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
   void toPacket(DNSPacketWriter& pw);
   string getZoneRepresentation() const;
+  uint16_t getType() const override { return QType::EUI48; }
 private:
  // storage for the bytes
  uint8_t d_eui48[6]; 
@@ -559,12 +580,13 @@ private:
 class EUI64RecordContent : public DNSRecordContent
 {
 public:
-  EUI64RecordContent() : DNSRecordContent(QType::EUI64) {};
+  EUI64RecordContent() {};
   static void report(void);
   static DNSRecordContent* make(const DNSRecord &dr, PacketReader& pr);
   static DNSRecordContent* make(const string& zone); // FIXME400: DNSName& zone?
   void toPacket(DNSPacketWriter& pw);
   string getZoneRepresentation() const;
+  uint16_t getType() const override { return QType::EUI64; }
 private:
  // storage for the bytes
  uint8_t d_eui64[8];
@@ -597,7 +619,7 @@ RNAME##RecordContent::DNSRecordContent* RNAME##RecordContent::make(const DNSReco
   return new RNAME##RecordContent(dr, pr);                                                         \
 }                                                                                                  \
                                                                                                    \
-RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr) : DNSRecordContent(RTYPE) \
+RNAME##RecordContent::RNAME##RecordContent(const DNSRecord& dr, PacketReader& pr)                  \
 {                                                                                                  \
   doRecordCheck(dr);                                                                               \
   xfrPacket(pr);                                                                                   \
@@ -624,7 +646,7 @@ void RNAME##RecordContent::unreport(void)
   unregist(254, RTYPE);                                                                            \
 }                                                                                                  \
                                                                                                    \
-RNAME##RecordContent::RNAME##RecordContent(const string& zoneData) : DNSRecordContent(RTYPE)       \
+RNAME##RecordContent::RNAME##RecordContent(const string& zoneData)                                 \
 {                                                                                                  \
   try {                                                                                            \
     RecordTextReader rtr(zoneData);                                                                \
index 119b05f85e984db1d688552d38c4286f35a4f759..1bfe97dafd2948d3880406a6187c26a02db397f2 100644 (file)
@@ -13,7 +13,7 @@ DNSRecordContent* NSECRecordContent::make(const string& content)
   return new NSECRecordContent(content);
 }
 
-NSECRecordContent::NSECRecordContent(const string& content, const string& zone) : DNSRecordContent(47)
+NSECRecordContent::NSECRecordContent(const string& content, const string& zone) 
 {
   RecordTextReader rtr(content, zone);
   rtr.xfrName(d_next);
@@ -120,7 +120,7 @@ DNSRecordContent* NSEC3RecordContent::make(const string& content)
   return new NSEC3RecordContent(content);
 }
 
-NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone) : DNSRecordContent(50)
+NSEC3RecordContent::NSEC3RecordContent(const string& content, const string& zone)
 {
   RecordTextReader rtr(content, zone);
   rtr.xfr8BitInt(d_algorithm);
@@ -257,7 +257,7 @@ DNSRecordContent* NSEC3PARAMRecordContent::make(const string& content)
   return new NSEC3PARAMRecordContent(content);
 }
 
-NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) : DNSRecordContent(51)
+NSEC3PARAMRecordContent::NSEC3PARAMRecordContent(const string& content, const string& zone) 
 {
   RecordTextReader rtr(content, zone);
   rtr.xfr8BitInt(d_algorithm); 
index f018abce85fba3de6428b9b8601fb864f390011b..3d3a3751761e947dc75efaac7ed5df399e32eaa3 100644 (file)
@@ -683,7 +683,7 @@ void startDoResolve(void *p)
     case DNSFilterEngine::PolicyKind::Custom:
       res=RCode::NoError;
       spoofed.d_name=dc->d_mdp.d_qname;
-      spoofed.d_type=dfepol.d_custom->d_qtype;
+      spoofed.d_type=dfepol.d_custom->getType();
       spoofed.d_ttl = 1234;
       spoofed.d_class = 1;
       spoofed.d_content = dfepol.d_custom;
@@ -742,7 +742,7 @@ void startDoResolve(void *p)
       case DNSFilterEngine::PolicyKind::Custom:
        res=RCode::NoError;
        spoofed.d_name=dc->d_mdp.d_qname;
-       spoofed.d_type=dfepol.d_custom->d_qtype;
+       spoofed.d_type=dfepol.d_custom->getType();
        spoofed.d_ttl = 1234;
        spoofed.d_class = 1;
        spoofed.d_content = dfepol.d_custom;
@@ -2093,7 +2093,6 @@ void  parseEDNSSubnetWhitelist(const std::string& wlist)
 
 int serviceMain(int argc, char*argv[])
 {
-
   L.setName(s_programname);
   L.setLoglevel((Logger::Urgency)(6)); // info and up
 
index 6c420cb25ebd4843b8fd47bf3c349c6c8bc32f97..bdd9cc271c3d0858447044a4eee537e2a0cf1505 100644 (file)
@@ -81,7 +81,7 @@ public:
 #undef DS
   enum typeenum : uint16_t {A=1, NS=2, CNAME=5, SOA=6, MR=9, WKS=11, PTR=12, HINFO=13, MINFO=14, MX=15, TXT=16, RP=17, AFSDB=18, SIG=24, KEY=25, AAAA=28, LOC=29, SRV=33, NAPTR=35, KX=36,
                 CERT=37, A6=38, DNAME=39, OPT=41, DS=43, SSHFP=44, IPSECKEY=45, RRSIG=46, NSEC=47, DNSKEY=48, DHCID=49, NSEC3=50, NSEC3PARAM=51,
-                TLSA=52, CDS=59, CDNSKEY=60, OPENPGPKEY=61, SPF=99, EUI48=108, EUI64=109, TKEY=249, TSIG=250, IXFR=251, AXFR=252, MAILB=253, MAILA=254, ANY=255, ADDR=259,
+      TLSA=52, RKEY=57, CDS=59, CDNSKEY=60, OPENPGPKEY=61, SPF=99, EUI48=108, EUI64=109, TKEY=249, TSIG=250, IXFR=251, AXFR=252, MAILB=253, MAILA=254, ANY=255, ADDR=259,
                 ALIAS=260, DLV=32769};
   typedef pair<string,uint16_t> namenum;
   static vector<namenum> names;
@@ -153,6 +153,7 @@ private:
       qtype_insert("NSEC3", 50);
       qtype_insert("NSEC3PARAM", 51);
       qtype_insert("TLSA", 52);
+      qtype_insert("RKEY", 57);
       qtype_insert("CDS", 59);
       qtype_insert("CDNSKEY", 60);
       qtype_insert("OPENPGPKEY", 61);
index 0009dea9c8573200b1d2f1853467fcba87b5d44f..3a4109dfae86cce4efe5d178248fd7d3b744a42a 100644 (file)
@@ -189,7 +189,7 @@ LOCRecordContent::DNSRecordContent* LOCRecordContent::make(const DNSRecord &dr,
   return ret;
 }
 
-LOCRecordContent::LOCRecordContent(const string& content, const string& zone) : DNSRecordContent(QType::LOC)
+LOCRecordContent::LOCRecordContent(const string& content, const string& zone) 
 {
   // 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m
   // convert this to d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude