diff options
author | Mukund Sivaraman <muks@isc.org> | 2013-02-21 17:58:58 +0100 |
---|---|---|
committer | Mukund Sivaraman <muks@isc.org> | 2013-02-21 18:13:51 +0100 |
commit | 9fa47fa572b5db2de51f67728c999561473fe731 (patch) | |
tree | d5b195424ef053f37e7f1ffc314b3274545cba90 /src | |
parent | [master] remove generated file from dist tarball (diff) | |
download | kea-9fa47fa572b5db2de51f67728c999561473fe731.tar.xz kea-9fa47fa572b5db2de51f67728c999561473fe731.zip |
[2386] Add DS and DLV implementations
Diffstat (limited to 'src')
-rwxr-xr-x | src/lib/dns/gen-rdatacode.py.in | 2 | ||||
-rw-r--r-- | src/lib/dns/rdata/generic/detail/ds_like.h | 35 | ||||
-rw-r--r-- | src/lib/dns/rdata/generic/dlv_32769.cc | 5 | ||||
-rw-r--r-- | src/lib/dns/rdata/generic/ds_43.cc | 5 | ||||
-rw-r--r-- | src/lib/dns/tests/rdata_ds_like_unittest.cc | 12 |
5 files changed, 58 insertions, 1 deletions
diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in index b385bf4192..db9a0df4bf 100755 --- a/src/lib/dns/gen-rdatacode.py.in +++ b/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'), diff --git a/src/lib/dns/rdata/generic/detail/ds_like.h b/src/lib/dns/rdata/generic/detail/ds_like.h index 333de4c010..a73ee29be8 100644 --- a/src/lib/dns/rdata/generic/detail/ds_like.h +++ b/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. diff --git a/src/lib/dns/rdata/generic/dlv_32769.cc b/src/lib/dns/rdata/generic/dlv_32769.cc index a3db998ebd..89a62e1b82 100644 --- a/src/lib/dns/rdata/generic/dlv_32769.cc +++ b/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. diff --git a/src/lib/dns/rdata/generic/ds_43.cc b/src/lib/dns/rdata/generic/ds_43.cc index 4234f9d575..349238870d 100644 --- a/src/lib/dns/rdata/generic/ds_43.cc +++ b/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_)) {} diff --git a/src/lib/dns/tests/rdata_ds_like_unittest.cc b/src/lib/dns/tests/rdata_ds_like_unittest.cc index 28a2e174f8..d30c923f51 100644 --- a/src/lib/dns/tests/rdata_ds_like_unittest.cc +++ b/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) { |