Parcourir la source

[1144] fixes to address jinmei's review notes

Dima Volodin il y a 13 ans
Parent
commit
eb5023d2a3

+ 15 - 8
src/lib/dns/rdata/generic/detail/ds_like.h

@@ -20,9 +20,6 @@
 #include <string>
 #include <vector>
 
-using namespace std;
-using namespace isc::util;
-
 struct DSImpl {
     // straightforward representation of DS RDATA fields
     DSImpl(uint16_t tag, uint8_t algorithm, uint8_t digest_type,
@@ -48,16 +45,24 @@ public:
 
 	iss >> tag >> algorithm >> digest_type >> &digestbuf;
 	if (iss.bad() || iss.fail()) {
-	    isc_throw(InvalidRdataText, "Invalid DS text");
+	    isc_throw(InvalidRdataText, "Invalid " +
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " text");
 	}
 	if (tag > 0xffff) {
-	    isc_throw(InvalidRdataText, "DS tag out of range");
+	    isc_throw(InvalidRdataText,
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " tag out of range");
 	}
 	if (algorithm > 0xff) {
-	    isc_throw(InvalidRdataText, "DS algorithm out of range");
+	    isc_throw(InvalidRdataText,
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " algorithm out of range");
 	}
 	if (digest_type > 0xff) {
-	    isc_throw(InvalidRdataText, "DS digest type out of range");
+	    isc_throw(InvalidRdataText,
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " digest type out of range");
 	}
 
 	vector<uint8_t> digest;
@@ -68,7 +73,9 @@ public:
 
     DS_LIKE(InputBuffer& buffer, size_t rdata_len) {
 	if (rdata_len < 4) {
-	    isc_throw(InvalidRdataLength, "DS too short");
+	    isc_throw(InvalidRdataLength,
+		      RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+		      " too short");
 	}
 
 	uint16_t tag = buffer.readUint16();

+ 32 - 0
src/lib/dns/rdata/generic/dlv_32769.cc

@@ -15,5 +15,37 @@
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
+DLV::DLV(const std::string& type_str) :
+    DS_LIKE(type_str)
+{}
+
+DLV::DLV(isc::util::InputBuffer& buffer, size_t rdata_len) :
+    DS_LIKE(buffer, rdata_len)
+{}
+
+DLV::DLV(const DLV& other) :
+    DS_LIKE(other)
+{}
+
+std::string DLV::toText() const
+{
+    return DS_LIKE::toText();
+}
+
+void DLV::toWire(isc::util::OutputBuffer& buffer) const
+{
+    DS_LIKE::toWire(buffer);
+}
+
+void DLV::toWire(AbstractMessageRenderer& renderer) const
+{
+    DS_LIKE::toWire(renderer);
+}
+
+int DLV::compare(const Rdata& other) const
+{
+    return DS_LIKE::compare(other);
+}
+
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE

+ 1 - 36
src/lib/dns/rdata/generic/dlv_32769.h

@@ -28,6 +28,7 @@
 #include <dns/name.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
+#include <dns/rrparamregistry.h>
 
 #include <stdio.h>
 #include <time.h>
@@ -46,48 +47,12 @@ using namespace isc::util::encode;
 #include <dns/rdata/generic/detail/ds_like.h>
 
 class DLV : public DS_LIKE<DLV, 32769> {
-    friend class DS_LIKE<DLV, 32769>;
-    static string const id;
-
 public:
     // BEGIN_COMMON_MEMBERS
     // END_COMMON_MEMBERS
 
 };
 
-///    explicit DLV(const std::string& type_str);
-inline DLV::DLV(const std::string& type_str) : DS_LIKE<DLV, 32769>(type_str) {}
-
-///    DLV(isc::util::InputBuffer& buffer, size_t rdata_len);
-inline DLV::DLV(isc::util::InputBuffer& buffer, size_t rdata_len) : DS_LIKE<DLV, 32769>(buffer, rdata_len) {}
-
-///    DLV(const DLV& other);
-inline DLV::DLV(const DLV& other) : DS_LIKE<DLV, 32769>(other) {}
-
-///    virtual std::string toText() const;
-inline std::string DLV::toText() const
-{
-    return DS_LIKE<DLV, 32769>::toText();
-}
-
-///    virtual void toWire(isc::util::OutputBuffer& buffer) const;
-inline void DLV::toWire(isc::util::OutputBuffer& buffer) const
-{
-    DS_LIKE<DLV, 32769>::toWire(buffer);
-}
-
-///    virtual void toWire(AbstractMessageRenderer& renderer) const;
-inline void DLV::toWire(AbstractMessageRenderer& renderer) const
-{
-    DS_LIKE<DLV, 32769>::toWire(renderer);
-}
-
-///    virtual int compare(const Rdata& other) const;
-inline int DLV::compare(const Rdata& other) const
-{
-    return DS_LIKE<DLV, 32769>::compare(other);
-}
-
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE
 // END_HEADER_GUARD

+ 32 - 0
src/lib/dns/rdata/generic/ds_43.cc

@@ -15,5 +15,37 @@
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
+DS::DS(const std::string& type_str) :
+    DS_LIKE(type_str)
+{}
+
+DS::DS(isc::util::InputBuffer& buffer, size_t rdata_len) :
+    DS_LIKE(buffer, rdata_len)
+{}
+
+DS::DS(const DS& other) :
+    DS_LIKE(other)
+{}
+
+std::string DS::toText() const
+{
+    return DS_LIKE::toText();
+}
+
+void DS::toWire(isc::util::OutputBuffer& buffer) const
+{
+    DS_LIKE::toWire(buffer);
+}
+
+void DS::toWire(AbstractMessageRenderer& renderer) const
+{
+    DS_LIKE::toWire(renderer);
+}
+
+int DS::compare(const Rdata& other) const
+{
+    return DS_LIKE::compare(other);
+}
+
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE

+ 1 - 36
src/lib/dns/rdata/generic/ds_43.h

@@ -28,6 +28,7 @@
 #include <dns/name.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
+#include <dns/rrparamregistry.h>
 
 #include <stdio.h>
 #include <time.h>
@@ -46,48 +47,12 @@ using namespace isc::util::encode;
 #include <dns/rdata/generic/detail/ds_like.h>
 
 class DS : public DS_LIKE<DS, 43> {
-    friend class DS_LIKE<DS, 43>;
-    static string const id;
-
 public:
     // BEGIN_COMMON_MEMBERS
     // END_COMMON_MEMBERS
 
 };
 
-///    explicit DS(const std::string& type_str);
-inline DS::DS(const std::string& type_str) : DS_LIKE<DS, 43>(type_str) {}
-
-///    DS(isc::util::InputBuffer& buffer, size_t rdata_len);
-inline DS::DS(isc::util::InputBuffer& buffer, size_t rdata_len) : DS_LIKE<DS, 43>(buffer, rdata_len) {}
-
-///    DS(const DS& other);
-inline DS::DS(const DS& other) : DS_LIKE<DS, 43>(other) {}
-
-///    virtual std::string toText() const;
-inline std::string DS::toText() const
-{
-    return DS_LIKE<DS, 43>::toText();
-}
-
-///    virtual void toWire(isc::util::OutputBuffer& buffer) const;
-inline void DS::toWire(isc::util::OutputBuffer& buffer) const
-{
-    DS_LIKE<DS, 43>::toWire(buffer);
-}
-
-///    virtual void toWire(AbstractMessageRenderer& renderer) const;
-inline void DS::toWire(AbstractMessageRenderer& renderer) const
-{
-    DS_LIKE<DS, 43>::toWire(renderer);
-}
-
-///    virtual int compare(const Rdata& other) const;
-inline int DS::compare(const Rdata& other) const
-{
-    return DS_LIKE<DS, 43>::compare(other);
-}
-
 // END_RDATA_NAMESPACE
 // END_ISC_NAMESPACE
 // END_HEADER_GUARD