Browse Source

[1307] added a new accessor method, getNextName(), to rdata::generic::NSEC.
this is necessary for NSEC query handling.

JINMEI Tatuya 13 years ago
parent
commit
03265efc1c

+ 5 - 0
src/lib/dns/rdata/generic/nsec_47.cc

@@ -178,6 +178,11 @@ NSEC::toWire(AbstractMessageRenderer& renderer) const {
     renderer.writeData(&impl_->typebits_[0], impl_->typebits_.size());
     renderer.writeData(&impl_->typebits_[0], impl_->typebits_.size());
 }
 }
 
 
+const Name&
+NSEC::getNextName() const {
+    return (impl_->nextname_);
+}
+
 int
 int
 NSEC::compare(const Rdata& other) const {
 NSEC::compare(const Rdata& other) const {
     const NSEC& other_nsec = dynamic_cast<const NSEC&>(other);
     const NSEC& other_nsec = dynamic_cast<const NSEC&>(other);

+ 10 - 0
src/lib/dns/rdata/generic/nsec_47.h

@@ -38,6 +38,16 @@ public:
     // END_COMMON_MEMBERS
     // END_COMMON_MEMBERS
     NSEC& operator=(const NSEC& source);
     NSEC& operator=(const NSEC& source);
     ~NSEC();
     ~NSEC();
+
+    // specialized methods
+
+    /// Return the next domain name.
+    ///
+    /// \exception std::bad_alloc Resource allocation failure in name copy.
+    ///
+    /// \return The next domain name field in the form of \c Name object.
+    const Name& getNextName() const;
+
 private:
 private:
     NSECImpl* impl_;
     NSECImpl* impl_;
 };
 };

+ 6 - 0
src/lib/dns/tests/rdata_nsec_unittest.cc

@@ -89,4 +89,10 @@ TEST_F(Rdata_NSEC_Test, assign) {
     EXPECT_EQ(0, rdata_nsec.compare(rdata_nsec2));
     EXPECT_EQ(0, rdata_nsec.compare(rdata_nsec2));
 }
 }
 
 
+TEST_F(Rdata_NSEC_Test, getNextName) {
+    // The implementation is quite trivial, so we simply check it's actually
+    // defined and does work as intended in a simple case.
+    EXPECT_EQ(Name("www2.isc.org"), generic::NSEC((nsec_txt)).getNextName());
+}
+
 }
 }