Browse Source

[2386] Add DS and DLV implementations

Mukund Sivaraman 12 years ago
parent
commit
9fa47fa572

+ 2 - 0
src/lib/dns/gen-rdatacode.py.in

@@ -34,7 +34,9 @@ import sys
 #     new_rdata_factory_users = [('a', 'in'), ('a', 'ch'), ('soa', 'generic')]
 new_rdata_factory_users = [('aaaa', 'in'),
                            ('cname', 'generic'),
+                           ('dlv', 'generic'),
                            ('dname', 'generic'),
+                           ('ds', 'generic'),
                            ('hinfo', 'generic'),
                            ('naptr', 'generic'),
                            ('mx', 'generic'),

+ 35 - 0
src/lib/dns/rdata/generic/detail/ds_like.h

@@ -101,6 +101,41 @@ public:
         decodeHex(digestbuf.str(), digest_);
     }
 
+    DSLikeImpl(MasterLexer& lexer, const Name*, MasterLoader::Options,
+               MasterLoaderCallbacks&)
+    {
+        const uint32_t tag =
+            lexer.getNextToken(MasterToken::NUMBER).getNumber();
+        if (tag > 0xffff) {
+            isc_throw(InvalidRdataText,
+                      "Invalid " << RRType(typeCode) << " tag: " << tag);
+        }
+
+        const uint32_t algorithm =
+            lexer.getNextToken(MasterToken::NUMBER).getNumber();
+        if (algorithm > 0xff) {
+            isc_throw(InvalidRdataText,
+                      "Invalid " << RRType(typeCode) << " algorithm: "
+                      << algorithm);
+        }
+
+        const uint32_t digest_type =
+            lexer.getNextToken(MasterToken::NUMBER).getNumber();
+        if (digest_type > 0xff) {
+            isc_throw(InvalidRdataText,
+                      "Invalid " << RRType(typeCode) << " digest type: "
+                      << digest_type);
+        }
+
+        const std::string digest =
+            lexer.getNextToken(MasterToken::STRING).getString();
+
+        tag_ = tag;
+        algorithm_ = algorithm;
+        digest_type_ = digest_type;
+        decodeHex(digest, digest_);
+    }
+
     /// \brief Constructor from wire-format data.
     ///
     /// \param buffer A buffer storing the wire format data.

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

@@ -45,6 +45,11 @@ DLV::DLV(InputBuffer& buffer, size_t rdata_len) :
     impl_(new DLVImpl(buffer, rdata_len))
 {}
 
+DLV::DLV(MasterLexer& lexer, const Name* origin, MasterLoader::Options options,
+         MasterLoaderCallbacks& callbacks) :
+    impl_(new DLVImpl(lexer, origin, options, callbacks))
+{}
+
 /// \brief Copy constructor
 ///
 /// A copy of the implementation object is allocated and constructed.

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

@@ -39,6 +39,11 @@ DS::DS(InputBuffer& buffer, size_t rdata_len) :
     impl_(new DSImpl(buffer, rdata_len))
 {}
 
+DS::DS(MasterLexer& lexer, const Name* origin, MasterLoader::Options options,
+       MasterLoaderCallbacks& callbacks) :
+    impl_(new DSImpl(lexer, origin, options, callbacks))
+{}
+
 DS::DS(const DS& source) :
     Rdata(), impl_(new DSImpl(*source.impl_))
 {}

+ 11 - 1
src/lib/dns/tests/rdata_ds_like_unittest.cc

@@ -91,8 +91,18 @@ TYPED_TEST(Rdata_DS_LIKE_Test, createFromLexer_DS_LIKE) {
                                      ds_like_txt)));
 
     // Exceptions cause NULL to be returned.
+
+    // Bad tag
+    EXPECT_FALSE(test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
+                                             "65536 5 2 BEEF"));
+
+    // Bad algorithm
+    EXPECT_FALSE(test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
+                                             "1024 256 2 BEEF"));
+
+    // Bad digest type
     EXPECT_FALSE(test::createRdataUsingLexer(RRTYPE<TypeParam>(), RRClass::IN(),
-                                             "99999 5 2 BEEF"));
+                                             "2048 2 256 BEEF"));
 }
 
 TYPED_TEST(Rdata_DS_LIKE_Test, assignment_DS_LIKE) {