namespace auth {
void
-Query::addAdditional(ZoneFinder& zone, const RRset& rrset) {
+Query::addAdditional(ZoneFinder& zone, const AbstractRRset& rrset) {
RdataIteratorPtr rdata_iterator(rrset.getRdataIterator());
for (; !rdata_iterator->isLast(); rdata_iterator->next()) {
const Rdata& rdata(rdata_iterator->getCurrent());
options | dnssec_opt_);
if (a_result.code == ZoneFinder::SUCCESS) {
response_.addRRset(Message::SECTION_ADDITIONAL,
- boost::const_pointer_cast<RRset>(a_result.rrset), dnssec_);
+ boost::const_pointer_cast<AbstractRRset>(a_result.rrset), dnssec_);
}
}
options | dnssec_opt_);
if (aaaa_result.code == ZoneFinder::SUCCESS) {
response_.addRRset(Message::SECTION_ADDITIONAL,
- boost::const_pointer_cast<RRset>(aaaa_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(aaaa_result.rrset),
dnssec_);
}
}
* to insist.
*/
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(soa_result.rrset), dnssec_);
+ boost::const_pointer_cast<AbstractRRset>(soa_result.rrset), dnssec_);
}
}
// Add the NSEC proving NXDOMAIN to the authority section.
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(nsec), dnssec_);
+ boost::const_pointer_cast<AbstractRRset>(nsec), dnssec_);
// Next, identify the best possible wildcard name that would match
// the query name. It's the longer common suffix with the qname
// for some optimized data source implementations.
if (nsec->getName() != fresult.rrset->getName()) {
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(fresult.rrset),
+ boost::const_pointer_cast<AbstractRRset>(fresult.rrset),
dnssec_);
}
}
isc_throw(BadNSEC, "Unexpected result for wildcard proof");
}
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(fresult.rrset),
+ boost::const_pointer_cast<AbstractRRset>(fresult.rrset),
dnssec_);
}
if (nsec->getName() != fresult.rrset->getName()) {
// one NSEC RR proves wildcard_nxrrset that no matched QNAME.
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(fresult.rrset),
+ boost::const_pointer_cast<AbstractRRset>(fresult.rrset),
dnssec_);
}
}
finder.find(dname, RRType::DS(), dnssec_opt_);
if (ds_result.code == ZoneFinder::SUCCESS) {
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(ds_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(ds_result.rrset),
dnssec_);
} else if (ds_result.code == ZoneFinder::NXRRSET) {
addNXRRsetProof(finder, ds_result);
{
if (db_result.isNSECSigned() && db_result.rrset) {
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(
+ boost::const_pointer_cast<AbstractRRset>(
db_result.rrset),
dnssec_);
if (db_result.isWildcard()) {
finder.getOrigin().toText());
} else {
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(ns_result.rrset), dnssec_);
+ boost::const_pointer_cast<AbstractRRset>(ns_result.rrset), dnssec_);
// Handle additional for authority section
addAdditional(finder, *ns_result.rrset);
}
case ZoneFinder::DNAME: {
// First, put the dname into the answer
response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(db_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(db_result.rrset),
dnssec_);
/*
* Empty DNAME should never get in, as it is impossible to
* So, just put it there.
*/
response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(db_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(db_result.rrset),
dnssec_);
// If the answer is a result of wildcard substitution,
// into answer section.
BOOST_FOREACH(ConstRRsetPtr rrset, target) {
response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(rrset), dnssec_);
+ boost::const_pointer_cast<AbstractRRset>(rrset), dnssec_);
// Handle additional for answer section
addAdditional(*result.zone_finder, *rrset.get());
}
} else {
response_.addRRset(Message::SECTION_ANSWER,
- boost::const_pointer_cast<RRset>(db_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(db_result.rrset),
dnssec_);
// Handle additional for answer section
addAdditional(*result.zone_finder, *db_result.rrset);
case ZoneFinder::DELEGATION:
response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
response_.addRRset(Message::SECTION_AUTHORITY,
- boost::const_pointer_cast<RRset>(db_result.rrset),
+ boost::const_pointer_cast<AbstractRRset>(db_result.rrset),
dnssec_);
// If DNSSEC is requested, see whether there is a DS
// record for this delegation.
/// \param rrset The RRset (i.e., NS or MX rrset) which require additional
/// processing.
void addAdditional(isc::datasrc::ZoneFinder& zone,
- const isc::dns::RRset& rrset);
+ const isc::dns::AbstractRRset& rrset);
/// \brief Find address records for a specified name.
///
// A helper function that generates a new RRset based on "wild_rrset",
// replacing its owner name with 'real_name'.
ConstRRsetPtr
-substituteWild(const RRset& wild_rrset, const Name& real_name) {
+substituteWild(const AbstractRRset& wild_rrset, const Name& real_name) {
RRsetPtr rrset(new RRset(real_name, wild_rrset.getClass(),
wild_rrset.getType(), wild_rrset.getTTL()));
// For simplicity we only consider the case with one RDATA (for now)
}
void
-LocalZoneData::update(const isc::dns::RRset& rrset) {
+LocalZoneData::update(const isc::dns::AbstractRRset& rrset) {
//TODO Do we really need to recreate the rrset again?
string key = genCacheEntryName(rrset.getName(), rrset.getType());
LOG_DEBUG(logger, DBG_TRACE_DATA, CACHE_LOCALZONE_UPDATE).arg(key);
/// Otherwise, the existed one will be overwritten.
///
/// \param rrset The rrset to update
- void update(const isc::dns::RRset& rrset);
+ void update(const isc::dns::AbstractRRset& rrset);
private:
std::map<std::string, isc::dns::RRsetPtr> rrsets_map_; // RRsets of the zone
}
RRsetEntryPtr
-RRsetCache::update(const isc::dns::RRset& rrset,
+RRsetCache::update(const isc::dns::AbstractRRset& rrset,
const RRsetTrustLevel& level)
{
LOG_DEBUG(logger, DBG_TRACE_DATA, CACHE_RRSET_UPDATE).arg(rrset.getName()).
/// \param level trustworthiness of the rrset.
/// \return return the rrset entry in the cache, it may be the
/// new added rrset entry or existed one if it is not replaced.
- RRsetEntryPtr update(const isc::dns::RRset& rrset,
+ RRsetEntryPtr update(const isc::dns::AbstractRRset& rrset,
const RRsetTrustLevel& level);
/// \short Protected memebers, so they can be accessed by tests.
namespace cache {
void
-rrsetCopy(const isc::dns::RRset& src, isc::dns::RRset& dst) {
+rrsetCopy(const isc::dns::AbstractRRset& src, isc::dns::AbstractRRset& dst) {
RdataIteratorPtr rdata_itor = src.getRdataIterator();
rdata_itor->first();
while(!rdata_itor->isLast()){
/// we have to do the copy.
void
-rrsetCopy(const isc::dns::RRset& src, isc::dns::RRset& dst);
+rrsetCopy(const isc::dns::AbstractRRset& src, isc::dns::AbstractRRset& dst);
} // namespace cache
} // namespace isc
namespace isc {
namespace cache {
-RRsetEntry::RRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& level):
+RRsetEntry::RRsetEntry(const isc::dns::AbstractRRset& rrset,
+ const RRsetTrustLevel& level):
entry_name_(genCacheEntryName(rrset.getName(), rrset.getType())),
expire_time_(time(NULL) + rrset.getTTL().getValue()),
trust_level_(level),
/// \brief Constructor
/// \param rrset The RRset used to initialize the RRset entry.
/// \param level trustworthiness of the RRset.
- RRsetEntry(const isc::dns::RRset& rrset, const RRsetTrustLevel& level);
+ RRsetEntry(const isc::dns::AbstractRRset& rrset,
+ const RRsetTrustLevel& level);
/// The destructor.
~RRsetEntry() {}
virtual ZoneFinder& getFinder() { return (*finder_); }
- virtual void addRRset(const RRset& rrset);
- virtual void deleteRRset(const RRset& rrset);
+ virtual void addRRset(const AbstractRRset& rrset);
+ virtual void deleteRRset(const AbstractRRset& rrset);
virtual void commit();
private:
// This is a set of validation checks commonly used for addRRset() and
// deleteRRset to minimize duplicate code logic and to make the main
// code concise.
- void validateAddOrDelete(const char* const op_str, const RRset& rrset,
+ void validateAddOrDelete(const char* const op_str,
+ const AbstractRRset& rrset,
DiffPhase prev_phase,
DiffPhase current_phase) const;
};
void
DatabaseUpdater::validateAddOrDelete(const char* const op_str,
- const RRset& rrset,
+ const AbstractRRset& rrset,
DiffPhase prev_phase,
DiffPhase current_phase) const
{
}
void
-DatabaseUpdater::addRRset(const RRset& rrset) {
+DatabaseUpdater::addRRset(const AbstractRRset& rrset) {
validateAddOrDelete("add", rrset, DELETE, ADD);
// It's guaranteed rrset has at least one RDATA at this point.
}
void
-DatabaseUpdater::deleteRRset(const RRset& rrset) {
+DatabaseUpdater::deleteRRset(const AbstractRRset& rrset) {
// If this is the first operation, pretend we are starting a new delete
// sequence after adds. This will simplify the validation below.
if (diff_phase_ == NOT_STARTED) {
// Note: there's a slight chance of getting an exception.
// As noted in add(), we give up strong exception guarantee in such
// cases.
- boost::const_pointer_cast<RRset>(it->second)->addRRsig(sig_rrset);
+ boost::const_pointer_cast<AbstractRRset>(it->second)->addRRsig(sig_rrset);
return (result::SUCCESS);
}
/// \exception std::bad_alloc Resource allocation failure
///
/// \param rrset The RRset to be added
- virtual void addRRset(const isc::dns::RRset& rrset) = 0;
+ virtual void addRRset(const isc::dns::AbstractRRset& rrset) = 0;
/// Delete an RRset from a zone via the updater
///
/// \exception std::bad_alloc Resource allocation failure
///
/// \param rrset The RRset to be deleted
- virtual void deleteRRset(const isc::dns::RRset& rrset) = 0;
+ virtual void deleteRRset(const isc::dns::AbstractRRset& rrset) = 0;
/// Commit the updates made in the updater to the zone
///
};
typedef SectionInserter<ConstQuestionPtr, Question> QuestionInserter;
-typedef SectionInserter<ConstRRsetPtr, RRset> RRsetInserter;
+typedef SectionInserter<ConstRRsetPtr, AbstractRRset> RRsetInserter;
// TODO use direct iterators for these? (or simply lists for now?)
PyObject*
};
PyObject*
-createRRsetObject(const RRset& source) {
+createRRsetObject(const AbstractRRset& source) {
// RRsets are noncopyable, so as a workaround we recreate a new one
// and copy over all content
return (PyObject_TypeCheck(obj, &rrset_type));
}
-RRset&
+AbstractRRset&
PyRRset_ToRRset(PyObject* rrset_obj) {
s_RRset* rrset = static_cast<s_RRset*>(rrset_obj);
return (*rrset->cppobj);
/// returns a NULL pointer).
/// This function is expected to be called within a try block
/// followed by necessary setup for python exception.
-PyObject* createRRsetObject(const RRset& source);
+PyObject* createRRsetObject(const AbstractRRset& source);
/// \brief Checks if the given python object is a RRset object
///
/// may be destroyed, the caller must copy it itself.
///
/// \param rrset_obj The rrset object to convert
-RRset& PyRRset_ToRRset(PyObject* rrset_obj);
+AbstractRRset& PyRRset_ToRRset(PyObject* rrset_obj);
/// \brief Returns the shared_ptr of the RRset object contained within the
/// given Python object.
///
/// This type is commonly used as an argument of various functions defined
/// in this library in order to handle RRsets in a polymorphic manner.
-typedef boost::shared_ptr<RRset> RRsetPtr;
+typedef boost::shared_ptr<AbstractRRset> RRsetPtr;
/// \brief A pointer-like type pointing to an (immutable) \c RRset
/// object.
///
/// This type is commonly used as an argument of various functions defined
/// in this library in order to handle RRsets in a polymorphic manner.
-typedef boost::shared_ptr<const RRset> ConstRRsetPtr;
+typedef boost::shared_ptr<const AbstractRRset> ConstRRsetPtr;
/// \brief A pointer-like type point to an \c RdataIterator object.
typedef boost::shared_ptr<RdataIterator> RdataIteratorPtr;
/// object.
virtual RdataIteratorPtr getRdataIterator() const = 0;
//@}
+
+ ///
+ /// \name Associated RRSIG methods
+ ///
+ /// These methods access an "associated" RRset, that containing the DNSSEC
+ /// signatures for this RRset. It can be argued that this is not a
+ /// fundamental part of the RRset abstraction, since RFC 2181 defined an
+ /// RRset as a group of records with the same label, class and type but
+ /// different data. However, BIND 10 has to deal with DNSSEC and in
+ /// practice, including the information at the AbstractRRset level makes
+ /// implementation easier. (If a class is ever needed that must be
+ /// ignorant of the idea of an associated RRSIG RRset - e.g. a specialised
+ /// RRSIG RRset class - these methods can just throw a "NotImplemented"
+ /// exception.)
+ //@{
+ /// \brief Return pointer to this RRset's RRSIG RRset
+ ///
+ /// \return Pointer to the associated RRSIG RRset or null if there is none.
+ virtual RRsetPtr getRRsig() const = 0;
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Adds the (assumed) RRSIG rdata the RRSIG RRset associated with this
+ /// RRset. If one does not exist, it is created using the data given.
+ ///
+ /// \param rdata Pointer to RRSIG rdata to be added.
+ virtual void addRRsig(const rdata::ConstRdataPtr rdata) = 0;
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Adds the (assumed) RRSIG rdata the RRSIG RRset associated with this
+ /// RRset. If one does not exist, it is created using the data given.
+ ///
+ /// (This overload is for an older version of boost that doesn't support
+ /// conversion from shared_ptr<X> to shared_ptr<const X>.)
+ ///
+ /// \param rdata Pointer to RRSIG rdata to be added.
+ virtual void addRRsig(const rdata::RdataPtr rdata) = 0;
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Adds the signatures in the given (assumed) RRSIG RRset to the RRSIG
+ /// RRset associated with this RRset. If one does not exist, it is created
+ /// using the data given.
+ ///
+ /// \param sigs RRSIG RRset containing signatures to be added to the
+ /// RRSIG RRset associated with this class.
+ virtual void addRRsig(const AbstractRRset& sigs) = 0;
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Adds the signatures in the given (assumed) RRSIG RRset to the RRSIG
+ /// RRset associated with this RRset. If one does not exist, it is created
+ /// using the data given.
+ ///
+ /// \param sigs Pointer to a RRSIG RRset containing signatures to be added
+ /// to the RRSIG RRset associated with this class.
+ virtual void addRRsig(ConstRRsetPtr sigs) = 0;
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Adds the signatures in the given (assumed) RRSIG RRset to the RRSIG
+ /// RRset associated with this RRset. If one does not exist, it is created
+ /// using the data given.
+ ///
+ /// (This overload is for an older version of boost that doesn't support
+ /// conversion from shared_ptr<X> to shared_ptr<const X>.)
+ ///
+ /// \param sigs Pointer to a RRSIG RRset containing signatures to be added
+ /// to the RRSIG RRset associated with this class.
+ virtual void addRRsig(RRsetPtr sigs) = 0;
+
+ /// \brief Clear the RRSIGs for this RRset
+ virtual void removeRRsig() = 0;
+
+ //@}
};
/// \brief The \c RdataIterator class is an abstract base class that
/// object for the \c BasicRRset class.
virtual RdataIteratorPtr getRdataIterator() const;
//@}
+
+ ///
+ /// \name Associated RRSIG methods
+ ///
+ /// The associated RRSIG RRset is not supported in BasicRRset, so these
+ /// methods throw a NotImplemented exception.
+ //@{
+ /// \brief Return pointer to this RRset's RRSIG RRset
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ ///
+ /// \return Never returns normally - always throws a NotImplemented
+ /// exception.
+ virtual RRsetPtr getRRsig() const {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the getRRsig() method");
+ }
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Not implemented in this class.
+ ///
+ /// \param rdata RRSIG rdata to be added to this RRset
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ virtual void addRRsig(const rdata::ConstRdataPtr) {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the addRRsig() method");
+ }
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Not implemented in this class.
+ /// (This overload is for an older version of boost that doesn't support
+ /// conversion from shared_ptr<X> to shared_ptr<const X>.)
+ ///
+ /// \param rdata RRSIG rdata to be added to this RRset
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ virtual void addRRsig(const rdata::RdataPtr) {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the addRRsig() method");
+ }
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Not implemented in this class.
+ ///
+ /// \param sigs RRSIG RRset containing signatures to be added to the
+ /// RRSIG RRset associated with this class.
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ virtual void addRRsig(const AbstractRRset&) {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the addRRsig() method");
+ }
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Not implemented in this class.
+ ///
+ /// \param sigs Pointer to a RRSIG RRset containing signatures to be added
+ /// to the RRSIG RRset associated with this class.
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ virtual void addRRsig(ConstRRsetPtr) {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the addRRsig() method");
+ }
+
+ /// \brief Adds RRSIG RRset RRs to the associated RRSIG RRset
+ ///
+ /// Not implemented in this class.
+ /// (This overload is for an older version of boost that doesn't support
+ /// conversion from shared_ptr<X> to shared_ptr<const X>.)
+ ///
+ /// \param sigs Pointer to a RRSIG RRset containing signatures to be added
+ /// to the RRSIG RRset associated with this class.
+ ///
+ /// \exception NotImplemented Always thrown. Associated RRSIG RRsets are
+ /// not supported in this class.
+ virtual void addRRsig(RRsetPtr) {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the addRRsig() method");
+ }
+
+ /// \brief Clear the RRSIGs for this RRset
+ virtual void removeRRsig() {
+ isc_throw(NotImplemented,
+ "BasicRRset does not implement the removeRRsig() method");
+ }
+ //@}
private:
BasicRRsetImpl* impl_;
};
// conversion from shared_ptr<X> to shared_ptr<const X>. Note: we should
// revisit the interface of managing RRset signatures, at which point this
// problem may go away.
- void addRRsig(const rdata::RdataPtr rdata) {
+ virtual void addRRsig(const rdata::RdataPtr rdata) {
addRRsig(static_cast<rdata::ConstRdataPtr>(rdata));
}
/// \brief Adds an RRSIG RRset to this RRset
- void addRRsig(const AbstractRRset& sigs) {
+ virtual void addRRsig(const AbstractRRset& sigs) {
RdataIteratorPtr it = sigs.getRdataIterator();
if (!rrsig_) {
}
}
- void addRRsig(ConstRRsetPtr sigs) { addRRsig(*sigs); }
+ virtual void addRRsig(ConstRRsetPtr sigs) { addRRsig(*sigs); }
// Another workaround for older boost (see above)
- void addRRsig(RRsetPtr sigs) { addRRsig(*sigs); }
+ virtual void addRRsig(RRsetPtr sigs) { addRRsig(*sigs); }
/// \brief Clear the RRSIGs for this RRset
- void removeRRsig() { rrsig_ = RRsetPtr(); }
+ virtual void removeRRsig() { rrsig_ = RRsetPtr(); }
/// \brief Return a pointer to this RRset's RRSIG RRset
RRsetPtr getRRsig() const { return (rrsig_); }
// for ns.example.com (the nameserver set for example.net in the class
// initialization). We'll set two addresses.
Name ns_example_com(ns_name);
- RRsetPtr ns_address = boost::shared_ptr<RRset>(new RRset(
+ isc::dns::RRsetPtr ns_address = boost::shared_ptr<RRset>(new RRset(
ns_example_com, RRClass::IN(), RRType::A(), RRTTL(300)));
BOOST_FOREACH(string addr, address) {
ns_address->addRdata(rdata::in::A(addr));