diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index f10cac0eda..1c48388a6e 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -1036,11 +1036,9 @@ MasterLoader::MasterLoader(std::istream& stream, if (!add_callback) { isc_throw(isc::InvalidParameter, "Empty add RR callback"); } - boost::shared_ptr - impl(new MasterLoaderImpl("", zone_origin, zone_class, - callbacks, add_callback, options)); - impl->pushStreamSource(stream); - impl_ = impl; + impl_.reset(new MasterLoaderImpl("", zone_origin, zone_class, + callbacks, add_callback, options)); + impl_->pushStreamSource(stream); } MasterLoader::~MasterLoader() { diff --git a/src/lib/dns/master_loader.h b/src/lib/dns/master_loader.h index 48d26664d5..955620a2e1 100644 --- a/src/lib/dns/master_loader.h +++ b/src/lib/dns/master_loader.h @@ -11,7 +11,8 @@ #include #include -#include + +#include namespace isc { namespace dns { @@ -176,7 +177,7 @@ public: private: class MasterLoaderImpl; - boost::shared_ptr impl_; + std::unique_ptr impl_; }; } // end namespace dns diff --git a/src/lib/dns/messagerenderer.h b/src/lib/dns/messagerenderer.h index ec47132a4b..7945796987 100644 --- a/src/lib/dns/messagerenderer.h +++ b/src/lib/dns/messagerenderer.h @@ -9,9 +9,10 @@ #include -#include #include +#include + namespace isc { namespace dns { // forward declarations @@ -384,7 +385,7 @@ public: private: struct MessageRendererImpl; - boost::shared_ptr impl_; + std::unique_ptr impl_; }; } } diff --git a/src/lib/dns/rdata.cc b/src/lib/dns/rdata.cc index dd778a9c17..df48785364 100644 --- a/src/lib/dns/rdata.cc +++ b/src/lib/dns/rdata.cc @@ -207,7 +207,7 @@ Generic::Generic(InputBuffer& buffer, size_t rdata_len) { impl_.reset(new GenericImpl(data)); } -boost::shared_ptr +std::unique_ptr Generic::constructFromLexer(MasterLexer& lexer) { const MasterToken& token = lexer.getNextToken(MasterToken::STRING); if (token.getString() != "\\#") { @@ -266,22 +266,16 @@ Generic::constructFromLexer(MasterLexer& lexer) { << data.size() << " vs. " << rdlen); } - return (boost::shared_ptr(new GenericImpl(data))); + return (std::unique_ptr(new GenericImpl(data))); } -Generic::Generic(const std::string& rdata_string) : - impl_(NULL) { - // We use unique_ptr here because if there is an exception in this - // constructor, the destructor is not called and there could be a - // leak of the GenericImpl that constructFromLexer() returns. - boost::shared_ptr impl_ptr; - +Generic::Generic(const std::string& rdata_string) { try { std::istringstream ss(rdata_string); MasterLexer lexer; lexer.pushSource(ss); - impl_ptr = constructFromLexer(lexer); + impl_ = constructFromLexer(lexer); if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) { isc_throw(InvalidRdataText, "extra input text for unknown RDATA: " @@ -291,8 +285,6 @@ Generic::Generic(const std::string& rdata_string) : isc_throw(InvalidRdataText, "Failed to construct unknown RDATA " "from '" << rdata_string << "': " << ex.what()); } - - impl_ = impl_ptr; } Generic::Generic(MasterLexer& lexer, const Name*, diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h index b04429ab12..01201a8e74 100644 --- a/src/lib/dns/rdata.h +++ b/src/lib/dns/rdata.h @@ -15,6 +15,7 @@ #include +#include #include namespace isc { @@ -381,9 +382,9 @@ public: //@} private: - boost::shared_ptr constructFromLexer(MasterLexer& lexer); + std::unique_ptr constructFromLexer(MasterLexer& lexer); - boost::shared_ptr impl_; + std::unique_ptr impl_; }; /// diff --git a/src/lib/dns/rdataclass.cc b/src/lib/dns/rdataclass.cc index 43c26c5936..adc4e98881 100644 --- a/src/lib/dns/rdataclass.cc +++ b/src/lib/dns/rdataclass.cc @@ -87,7 +87,7 @@ struct TSIGImpl { }; // helper function for string and lexer constructors -boost::shared_ptr +std::unique_ptr TSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { const Name& algorithm = createNameFromLexer(lexer, origin ? origin : &Name::ROOT_NAME()); @@ -181,8 +181,8 @@ TSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { // RFC2845 says Other Data is "empty unless Error == BADTIME". // However, we don't enforce that. - return (boost::shared_ptr(new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac, - orig_id, error, other_data))); + return (std::unique_ptr(new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac, + orig_id, error, other_data))); } /// \brief Constructor from string. @@ -230,18 +230,13 @@ TSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { /// \throw BadValue if MAC or Other Data is not validly encoded in base-64. /// /// \param tsig_str A string containing the RDATA to be created -TSIG::TSIG(const std::string& tsig_str) : impl_(NULL) { - // We use unique_ptr here because if there is an exception in this - // constructor, the destructor is not called and there could be a - // leak of the TSIGImpl that constructFromLexer() returns. - boost::shared_ptr impl_ptr; - +TSIG::TSIG(const std::string& tsig_str) { try { std::istringstream ss(tsig_str); MasterLexer lexer; lexer.pushSource(ss); - impl_ptr = constructFromLexer(lexer, NULL); + impl_ = constructFromLexer(lexer, NULL); if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) { isc_throw(InvalidRdataText, @@ -252,8 +247,6 @@ TSIG::TSIG(const std::string& tsig_str) : impl_(NULL) { "Failed to construct TSIG from '" << tsig_str << "': " << ex.what()); } - - impl_ = impl_ptr; } /// \brief Constructor with a context of MasterLexer. @@ -296,8 +289,7 @@ TSIG::TSIG(MasterLexer& lexer, const Name* origin, /// But this constructor does not use this parameter; if necessary, the caller /// must check consistency between the length parameter and the actual /// RDATA length. -TSIG::TSIG(InputBuffer& buffer, size_t) : - impl_(NULL) { +TSIG::TSIG(InputBuffer& buffer, size_t) { Name algorithm(buffer); uint8_t time_signed_buf[6]; @@ -336,8 +328,7 @@ TSIG::TSIG(InputBuffer& buffer, size_t) : TSIG::TSIG(const Name& algorithm, uint64_t time_signed, uint16_t fudge, uint16_t mac_size, const void* mac, uint16_t original_id, - uint16_t error, uint16_t other_len, const void* other_data) : - impl_(NULL) { + uint16_t error, uint16_t other_len, const void* other_data) { // Time Signed is a 48-bit value. if ((time_signed >> 48) != 0) { isc_throw(OutOfRange, "TSIG Time Signed is too large: " << @@ -715,8 +706,7 @@ OPT::OPT() : /// This constructor cannot be used, and always throws an exception. /// /// \throw InvalidRdataText OPT RR cannot be constructed from text. -OPT::OPT(const std::string&) : - impl_(NULL) { +OPT::OPT(const std::string&) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } @@ -726,14 +716,12 @@ OPT::OPT(const std::string&) : /// /// \throw InvalidRdataText OPT RR cannot be constructed from text. OPT::OPT(MasterLexer&, const Name*, - MasterLoader::Options, MasterLoaderCallbacks&) : - impl_(NULL) { + MasterLoader::Options, MasterLoaderCallbacks&) { isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text"); } -OPT::OPT(InputBuffer& buffer, size_t rdata_len) : - impl_(NULL) { - boost::shared_ptr impl_ptr(new OPTImpl()); +OPT::OPT(InputBuffer& buffer, size_t rdata_len) { + impl_.reset(new OPTImpl()); while (true) { if (rdata_len == 0) { @@ -750,12 +738,12 @@ OPT::OPT(InputBuffer& buffer, size_t rdata_len) : const uint16_t option_length = buffer.readUint16(); rdata_len -= 4; - if (static_cast(impl_ptr->rdlength_ + option_length) < - impl_ptr->rdlength_) { + if (static_cast(impl_->rdlength_ + option_length) < + impl_->rdlength_) { isc_throw(InvalidRdataText, "Option length " << option_length << " would overflow OPT RR RDLEN (currently " - << impl_ptr->rdlength_ << ")."); + << impl_->rdlength_ << ")."); } if (rdata_len < option_length) { @@ -765,12 +753,10 @@ OPT::OPT(InputBuffer& buffer, size_t rdata_len) : boost::shared_ptr > option_data(new std::vector(option_length)); buffer.readData(&(*option_data)[0], option_length); - impl_ptr->pseudo_rrs_.push_back(PseudoRR(option_code, option_data)); - impl_ptr->rdlength_ += option_length; + impl_->pseudo_rrs_.push_back(PseudoRR(option_code, option_data)); + impl_->rdlength_ += option_length; rdata_len -= option_length; } - - impl_ = impl_ptr; } OPT::OPT(const OPT& other) : @@ -983,7 +969,7 @@ struct RRSIGImpl { }; // helper function for string and lexer constructors -boost::shared_ptr +std::unique_ptr RRSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { const RRType covered(lexer.getNextToken(MasterToken::STRING).getString()); const uint32_t algorithm = @@ -1030,9 +1016,9 @@ RRSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { decodeBase64(signature_txt, signature); } - return (boost::shared_ptr(new RRSIGImpl(covered, algorithm, labels, - originalttl, timeexpire, timeinception, - static_cast(tag), signer, signature))); + return (std::unique_ptr(new RRSIGImpl(covered, algorithm, labels, + originalttl, timeexpire, timeinception, + static_cast(tag), signer, signature))); } /// \brief Constructor from string. @@ -1051,8 +1037,7 @@ RRSIG::constructFromLexer(MasterLexer& lexer, const Name* origin) { /// /// \throw Others Exception from the Name constructor. /// \throw InvalidRdataText Other general syntax errors. -RRSIG::RRSIG(const std::string& rrsig_str) : - impl_(NULL) { +RRSIG::RRSIG(const std::string& rrsig_str) { // We use unique_ptr here because if there is an exception in this // constructor, the destructor is not called and there could be a // leak of the RRSIGImpl that constructFromLexer() returns. @@ -1063,7 +1048,7 @@ RRSIG::RRSIG(const std::string& rrsig_str) : MasterLexer lexer; lexer.pushSource(iss); - impl_ptr = constructFromLexer(lexer, NULL); + impl_ = constructFromLexer(lexer, NULL); if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) { isc_throw(InvalidRdataText, "extra input text for RRSIG: " @@ -1073,8 +1058,6 @@ RRSIG::RRSIG(const std::string& rrsig_str) : isc_throw(InvalidRdataText, "Failed to construct RRSIG from '" << rrsig_str << "': " << ex.what()); } - - impl_ = impl_ptr; } /// \brief Constructor with a context of MasterLexer. @@ -1483,7 +1466,7 @@ struct TKEYImpl { }; // helper function for string and lexer constructors -boost::shared_ptr +std::unique_ptr TKEY::constructFromLexer(MasterLexer& lexer, const Name* origin) { const Name& algorithm = createNameFromLexer(lexer, origin ? origin : &Name::ROOT_NAME()); @@ -1578,9 +1561,9 @@ TKEY::constructFromLexer(MasterLexer& lexer, const Name* origin) { // RFC2845 says Other Data is "empty unless Error == BADTIME". // However, we don't enforce that. - return (boost::shared_ptr(new TKEYImpl(algorithm, inception, - expire, mode, error, - key_data, other_data))); + return (std::unique_ptr(new TKEYImpl(algorithm, inception, + expire, mode, error, + key_data, other_data))); } /// \brief Constructor from string. @@ -1635,18 +1618,14 @@ TKEY::constructFromLexer(MasterLexer& lexer, const Name* origin) { /// in base-64. /// /// \param tkey_str A string containing the RDATA to be created -TKEY::TKEY(const std::string& tkey_str) : impl_(0) { - // We use unique_ptr here because if there is an exception in this - // constructor, the destructor is not called and there could be a - // leak of the TKEYImpl that constructFromLexer() returns. - boost::shared_ptr impl_ptr; +TKEY::TKEY(const std::string& tkey_str) { try { std::istringstream ss(tkey_str); MasterLexer lexer; lexer.pushSource(ss); - impl_ptr = constructFromLexer(lexer, 0); + impl_ = constructFromLexer(lexer, 0); if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) { isc_throw(InvalidRdataText, @@ -1657,8 +1636,6 @@ TKEY::TKEY(const std::string& tkey_str) : impl_(0) { "Failed to construct TKEY from '" << tkey_str << "': " << ex.what()); } - - impl_ = impl_ptr; } /// \brief Constructor with a context of MasterLexer. @@ -1701,8 +1678,7 @@ TKEY::TKEY(MasterLexer& lexer, const Name* origin, /// But this constructor does not use this parameter; if necessary, the caller /// must check consistency between the length parameter and the actual /// RDATA length. -TKEY::TKEY(InputBuffer& buffer, size_t) : - impl_(0) { +TKEY::TKEY(InputBuffer& buffer, size_t) { Name algorithm(buffer); const uint32_t inception = buffer.readUint32(); @@ -1731,8 +1707,7 @@ TKEY::TKEY(InputBuffer& buffer, size_t) : TKEY::TKEY(const Name& algorithm, uint32_t inception, uint32_t expire, uint16_t mode, uint16_t error, uint16_t key_len, - const void* key, uint16_t other_len, const void* other_data) : - impl_(0) { + const void* key, uint16_t other_len, const void* other_data) { if ((key_len == 0 && key != 0) || (key_len > 0 && key == 0)) { isc_throw(InvalidParameter, "TKEY Key length and data inconsistent"); } diff --git a/src/lib/dns/rdataclass.h b/src/lib/dns/rdataclass.h index 25eaab8bc0..9e219eed81 100644 --- a/src/lib/dns/rdataclass.h +++ b/src/lib/dns/rdataclass.h @@ -15,10 +15,12 @@ #include #include +#include + +#include #include #include #include -#include namespace isc { namespace dns { @@ -153,9 +155,9 @@ public: /// This method never throws an exception. const void* getOtherData() const; private: - boost::shared_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); + std::unique_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); - boost::shared_ptr impl_; + std::unique_ptr impl_; }; } // end of namespace "any" @@ -263,7 +265,7 @@ public: private: uint16_t code_; - boost::shared_ptr > data_; + boost::shared_ptr> data_; }; /// \brief Append a pseudo RR (option) in this OPT RR. @@ -285,7 +287,7 @@ public: const std::vector& getPseudoRRs() const; private: - boost::shared_ptr impl_; + std::unique_ptr impl_; }; class PTR : public Rdata { @@ -342,9 +344,9 @@ public: const RRType& typeCovered() const; private: // helper function for string and lexer constructors - boost::shared_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); + std::unique_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); - boost::shared_ptr impl_; + std::unique_ptr impl_; }; class SOA : public Rdata { @@ -494,9 +496,9 @@ public: static const uint16_t GSS_API_MODE; private: - boost::shared_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); + std::unique_ptr constructFromLexer(MasterLexer& lexer, const Name* origin); - boost::shared_ptr impl_; + std::unique_ptr impl_; }; class TXT : public Rdata { @@ -517,7 +519,7 @@ public: private: typedef isc::dns::rdata::generic::detail::TXTLikeImpl TXTImpl; - boost::shared_ptr impl_; + std::unique_ptr impl_; }; } // namespace generic diff --git a/src/lib/dns/rrparamregistry.cc b/src/lib/dns/rrparamregistry.cc index 612878b522..f047188e9f 100644 --- a/src/lib/dns/rrparamregistry.cc +++ b/src/lib/dns/rrparamregistry.cc @@ -213,7 +213,90 @@ RRParamRegistry::RRParamRegistry() : impl_(new RRParamRegistryImpl()) { add("OPT", 41, RdataFactoryPtr(new RdataFactory())); add("RRSIG", 46, RdataFactoryPtr(new RdataFactory())); add("TKEY", 249, RdataFactoryPtr(new RdataFactory())); - addType("ANY", 255); + // Meta and non-implemented RR types + addType("MD", 3); + addType("MF", 4); + addType("CNAME", 5); + addType("MB", 7); + addType("MG", 8); + addType("MR", 9); + addType("NULL", 10); + addType("WKS", 11); + addType("HINFO", 13); + addType("MINFO", 14); + addType("MX", 15); + addType("RP", 17); + addType("AFSDB", 18); + addType("X25", 19); + addType("ISDN", 20); + addType("RT", 21); + addType("NSAP", 22); + addType("NSAP-PTR", 23); + addType("SIG", 24); + addType("KEY", 25); + addType("PX", 26); + addType("GPOS", 27); + addType("LOC", 29); + addType("NXT", 30); + addType("EID", 31); + addType("NIMLOC", 32); + addType("SRV", 33); + addType("ATMA", 34); + addType("NAPTR", 35); + addType("KX", 36); + addType("CERT", 37); + addType("A6", 38); + addType("DNAME", 39); + addType("SINK", 40); + addType("APL", 42); + addType("DS", 43); + addType("SSHFP", 44); + addType("IPSECKEY", 45); + addType("NSEC", 47); + addType("DNSKEY", 48); + addType("NSEC3", 50); + addType("NSEC3PARAM", 51); + addType("TLSA", 52); + addType("SMIMEA", 53); + // Unassigned 54 + addType("HIP", 55); + addType("NINFO", 56); + addType("RKEY", 57); + addType("TALINK", 58); + addType("CDS", 59); + addType("CDNSKEY", 60); + addType("OPENPGPKEY", 61); + addType("CSYNC", 62 ); + addType("ZONEMD", 63); + addType("SVCB", 64); + addType("HTTPS", 65); + // Unassigned 66-98 + addType("SPF", 99); + addType("UINFO", 100); + addType("UID", 101); + addType("GID", 102); + addType("UNSPEC", 103); + addType("NID", 104); + addType("L32", 105); + addType("L64", 106); + addType("LP", 107); + addType("EUI48", 108); + addType("EUI64", 109); + // Unassigned 110-248 + addType("IXFR", 251); + addType("AXFR", 252); + addType("MAILB", 253); + addType("MAILA", 254); + addType("ANY", 255); // also known as "*" + addType("URI", 256); + addType("CAA", 257); + addType("AVC", 258); + addType("DOA", 259); + addType("AMTRELAY", 260); + addType("RESINFO", 261); + // Unassigned 262-32767 + addType("TA", 32768); + addType("DLV", 32769); // Meta classes addClass("CH", 3); addClass("NONE", 254);