2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 21:18:02 +00:00

[#3208] added not implemented types

This commit is contained in:
Razvan Becheriu 2024-03-08 19:23:56 +02:00
parent 0e811f7805
commit 77a396e9f9
8 changed files with 142 additions and 89 deletions

View File

@ -1036,11 +1036,9 @@ MasterLoader::MasterLoader(std::istream& stream,
if (!add_callback) {
isc_throw(isc::InvalidParameter, "Empty add RR callback");
}
boost::shared_ptr<MasterLoaderImpl>
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() {

View File

@ -11,7 +11,8 @@
#include <dns/master_loader_callbacks.h>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <memory>
namespace isc {
namespace dns {
@ -176,7 +177,7 @@ public:
private:
class MasterLoaderImpl;
boost::shared_ptr<MasterLoaderImpl> impl_;
std::unique_ptr<MasterLoaderImpl> impl_;
};
} // end namespace dns

View File

@ -9,9 +9,10 @@
#include <util/buffer.h>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <memory>
namespace isc {
namespace dns {
// forward declarations
@ -384,7 +385,7 @@ public:
private:
struct MessageRendererImpl;
boost::shared_ptr<MessageRendererImpl> impl_;
std::unique_ptr<MessageRendererImpl> impl_;
};
}
}

View File

@ -207,7 +207,7 @@ Generic::Generic(InputBuffer& buffer, size_t rdata_len) {
impl_.reset(new GenericImpl(data));
}
boost::shared_ptr<GenericImpl>
std::unique_ptr<GenericImpl>
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<GenericImpl>(new GenericImpl(data)));
return (std::unique_ptr<GenericImpl>(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<GenericImpl> 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*,

View File

@ -15,6 +15,7 @@
#include <boost/shared_ptr.hpp>
#include <memory>
#include <stdint.h>
namespace isc {
@ -381,9 +382,9 @@ public:
//@}
private:
boost::shared_ptr<GenericImpl> constructFromLexer(MasterLexer& lexer);
std::unique_ptr<GenericImpl> constructFromLexer(MasterLexer& lexer);
boost::shared_ptr<GenericImpl> impl_;
std::unique_ptr<GenericImpl> impl_;
};
///

View File

@ -87,7 +87,7 @@ struct TSIGImpl {
};
// helper function for string and lexer constructors
boost::shared_ptr<TSIGImpl>
std::unique_ptr<TSIGImpl>
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<TSIGImpl>(new TSIGImpl(canonical_algorithm_name, time_signed, fudge, mac,
orig_id, error, other_data)));
return (std::unique_ptr<TSIGImpl>(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<TSIGImpl> 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<OPTImpl> 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<uint16_t>(impl_ptr->rdlength_ + option_length) <
impl_ptr->rdlength_) {
if (static_cast<uint16_t>(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<std::vector<uint8_t> >
option_data(new std::vector<uint8_t>(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<RRSIGImpl>
std::unique_ptr<RRSIGImpl>
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<RRSIGImpl>(new RRSIGImpl(covered, algorithm, labels,
originalttl, timeexpire, timeinception,
static_cast<uint16_t>(tag), signer, signature)));
return (std::unique_ptr<RRSIGImpl>(new RRSIGImpl(covered, algorithm, labels,
originalttl, timeexpire, timeinception,
static_cast<uint16_t>(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<TKEYImpl>
std::unique_ptr<TKEYImpl>
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<TKEYImpl>(new TKEYImpl(algorithm, inception,
expire, mode, error,
key_data, other_data)));
return (std::unique_ptr<TKEYImpl>(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<TKEYImpl> 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");
}

View File

@ -15,10 +15,12 @@
#include <dns/serial.h>
#include <util/buffer.h>
#include <boost/shared_ptr.hpp>
#include <memory>
#include <stdint.h>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
namespace isc {
namespace dns {
@ -153,9 +155,9 @@ public:
/// This method never throws an exception.
const void* getOtherData() const;
private:
boost::shared_ptr<TSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
std::unique_ptr<TSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
boost::shared_ptr<TSIGImpl> impl_;
std::unique_ptr<TSIGImpl> impl_;
};
} // end of namespace "any"
@ -263,7 +265,7 @@ public:
private:
uint16_t code_;
boost::shared_ptr<std::vector<uint8_t> > data_;
boost::shared_ptr<std::vector<uint8_t>> data_;
};
/// \brief Append a pseudo RR (option) in this OPT RR.
@ -285,7 +287,7 @@ public:
const std::vector<PseudoRR>& getPseudoRRs() const;
private:
boost::shared_ptr<OPTImpl> impl_;
std::unique_ptr<OPTImpl> 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<RRSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
std::unique_ptr<RRSIGImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
boost::shared_ptr<RRSIGImpl> impl_;
std::unique_ptr<RRSIGImpl> impl_;
};
class SOA : public Rdata {
@ -494,9 +496,9 @@ public:
static const uint16_t GSS_API_MODE;
private:
boost::shared_ptr<TKEYImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
std::unique_ptr<TKEYImpl> constructFromLexer(MasterLexer& lexer, const Name* origin);
boost::shared_ptr<TKEYImpl> impl_;
std::unique_ptr<TKEYImpl> impl_;
};
class TXT : public Rdata {
@ -517,7 +519,7 @@ public:
private:
typedef isc::dns::rdata::generic::detail::TXTLikeImpl<TXT, 16> TXTImpl;
boost::shared_ptr<TXTImpl> impl_;
std::unique_ptr<TXTImpl> impl_;
};
} // namespace generic

View File

@ -213,7 +213,90 @@ RRParamRegistry::RRParamRegistry() : impl_(new RRParamRegistryImpl()) {
add("OPT", 41, RdataFactoryPtr(new RdataFactory<generic::OPT>()));
add("RRSIG", 46, RdataFactoryPtr(new RdataFactory<generic::RRSIG>()));
add("TKEY", 249, RdataFactoryPtr(new RdataFactory<generic::TKEY>()));
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);