#include <dns/rdataclass.h>
#include <datasrc/client.h>
+#include <datasrc/client_list.h>
#include <auth/query.h>
// the qname consists of a single label, which also means it's the root name),
// we should search the deepest zone we have (which should be the root zone;
// otherwise it's a query error).
-DataSourceClient::FindResult
-findZone(const DataSourceClient& client, const Name& qname, RRType qtype) {
+ClientList::FindResult
+findZone(const ClientList& list, const Name& qname, RRType qtype) {
if (qtype != RRType::DS() || qname.getLabelCount() == 1) {
- return (client.findZone(qname));
+ return (list.find(qname));
}
- return (client.findZone(qname.split(1)));
+ return (list.find(qname.split(1)));
}
}
void
-Query::process(datasrc::DataSourceClient& datasrc_client,
+Query::process(datasrc::ClientList& client_list,
const isc::dns::Name& qname, const isc::dns::RRType& qtype,
isc::dns::Message& response, bool dnssec)
{
QueryCleaner cleaner(*this);
// Set up query parameters for the rest of the (internal) methods
- initialize(datasrc_client, qname, qtype, response, dnssec);
+ initialize(client_list, qname, qtype, response, dnssec);
// Found a zone which is the nearest ancestor to QNAME
- const DataSourceClient::FindResult result = findZone(*datasrc_client_,
- *qname_, *qtype_);
+ const ClientList::FindResult result = findZone(*client_list_, *qname_,
+ *qtype_);
// If we have no matching authoritative zone for the query name, return
// REFUSED. In short, this is to be compatible with BIND 9, but the
// background discussion is not that simple. See the relevant topic
// at the BIND 10 developers's ML:
// https://lists.isc.org/mailman/htdig/bind10-dev/2010-December/001633.html
- if (result.code != result::SUCCESS &&
- result.code != result::PARTIALMATCH) {
+ if (result.dsrc_client_ != NULL) {
// If we tried to find a "parent zone" for a DS query and failed,
// we may still have authority at the child side. If we do, the query
// has to be handled there.
response_->setRcode(Rcode::REFUSED());
return;
}
- ZoneFinder& zfinder = *result.zone_finder;
+ ZoneFinder& zfinder = *result.finder_;
// We have authority for a zone that contain the query name (possibly
// indirectly via delegation). Look into the zone.
// If the answer is a result of wildcard substitution,
// add a proof that there's no closer name.
if (dnssec_ && db_context->isWildcard()) {
- addWildcardProof(*result.zone_finder, *db_context);
+ addWildcardProof(*result.finder_, *db_context);
}
break;
case ZoneFinder::SUCCESS:
// section.
// Checking the findZone() is a lightweight check to see if
// qname is the zone origin.
- if (result.code != result::SUCCESS ||
+ if (result.exact_match_ ||
db_context->code != ZoneFinder::SUCCESS ||
(*qtype_ != RRType::NS() && !qtype_is_any))
{
- addAuthAdditional(*result.zone_finder, additionals_);
+ addAuthAdditional(*result.finder_, additionals_);
}
// If the answer is a result of wildcard substitution,
// add a proof that there's no closer name.
if (dnssec_ && db_context->isWildcard()) {
- addWildcardProof(*result.zone_finder, *db_context);
+ addWildcardProof(*result.finder_, *db_context);
}
break;
case ZoneFinder::DELEGATION:
// If DNSSEC is requested, see whether there is a DS
// record for this delegation.
if (dnssec_) {
- addDS(*result.zone_finder, db_context->rrset->getName());
+ addDS(*result.finder_, db_context->rrset->getName());
}
break;
case ZoneFinder::NXDOMAIN:
response_->setRcode(Rcode::NXDOMAIN());
- addSOA(*result.zone_finder);
+ addSOA(*result.finder_);
if (dnssec_) {
if (db_context->isNSECSigned() && db_context->rrset) {
addNXDOMAINProofByNSEC(zfinder, db_context->rrset);
}
break;
case ZoneFinder::NXRRSET:
- addSOA(*result.zone_finder);
+ addSOA(*result.finder_);
if (dnssec_) {
addNXRRsetProof(zfinder, *db_context);
}
}
void
-Query::initialize(datasrc::DataSourceClient& datasrc_client,
+Query::initialize(datasrc::ClientList& client_list,
const isc::dns::Name& qname, const isc::dns::RRType& qtype,
isc::dns::Message& response, bool dnssec)
{
- datasrc_client_ = &datasrc_client;
+ client_list_ = &client_list;
qname_ = &qname;
qtype_ = &qtype;
response_ = &response;
void
Query::reset() {
- datasrc_client_ = NULL;
+ client_list_ = NULL;
qname_ = NULL;
qtype_ = NULL;
response_ = NULL;
bool
Query::processDSAtChild() {
- const DataSourceClient::FindResult zresult =
- datasrc_client_->findZone(*qname_);
+ const ClientList::FindResult zresult =
+ client_list_->find(*qname_, true);
- if (zresult.code != result::SUCCESS) {
+ if (zresult.dsrc_client_) {
return (false);
}
// by seeing the SOA.
response_->setHeaderFlag(Message::HEADERFLAG_AA);
response_->setRcode(Rcode::NOERROR());
- addSOA(*zresult.zone_finder);
+ addSOA(*zresult.finder_);
ConstZoneFinderContextPtr ds_context =
- zresult.zone_finder->find(*qname_, RRType::DS(), dnssec_opt_);
+ zresult.finder_->find(*qname_, RRType::DS(), dnssec_opt_);
if (ds_context->code == ZoneFinder::NXRRSET) {
if (dnssec_) {
- addNXRRsetProof(*zresult.zone_finder, *ds_context);
+ addNXRRsetProof(*zresult.finder_, *ds_context);
}
}
}
namespace datasrc {
-class DataSourceClient;
+class ClientList;
}
namespace auth {
/// separate attribute setter.
/// - likewise, we'll eventually need to do per zone access control, for which
/// we need querier's information such as its IP address.
-/// - datasrc_client and response may better be parameters to process() instead
-/// of the constructor.
///
/// <b>Note:</b> The class name is intentionally the same as the one used in
/// the datasrc library. This is because the plan is to eventually merge
/// This is the first step of the process() method, and initializes
/// the member data
///
- /// \param datasrc_client The datasource wherein the answer to the query is
- /// to be found.
+ /// \param client_list The datasource list wherein the answer to the query
+ /// is to be found.
/// \param qname The query name
/// \param qtype The RR type of the query
/// \param response The response message to store the answer to the query.
/// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
/// possible.
- void initialize(datasrc::DataSourceClient& datasrc_client,
+ void initialize(datasrc::ClientList& client_list,
const isc::dns::Name& qname, const isc::dns::RRType& qtype,
isc::dns::Message& response, bool dnssec = false);
/// Query parameters will be set by the call to process()
///
Query() :
- datasrc_client_(NULL), qname_(NULL), qtype_(NULL),
+ client_list_(NULL), qname_(NULL), qtype_(NULL),
dnssec_(false), dnssec_opt_(isc::datasrc::ZoneFinder::FIND_DEFAULT),
response_(NULL)
{
/// shouldn't happen in real-life (as BadZone means wrong data, it should
/// have been rejected upon loading).
///
- /// \param datasrc_client The datasource wherein the answer to the query is
- /// to be found.
+ /// \param client_list The datasource list wherein the answer to the query
+ /// is to be found.
/// \param qname The query name
/// \param qtype The RR type of the query
/// \param response The response message to store the answer to the query.
/// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
/// possible.
- void process(datasrc::DataSourceClient& datasrc_client,
+ void process(datasrc::ClientList& client_list,
const isc::dns::Name& qname, const isc::dns::RRType& qtype,
isc::dns::Message& response, bool dnssec = false);
};
private:
- const isc::datasrc::DataSourceClient* datasrc_client_;
+ const isc::datasrc::ClientList* client_list_;
const isc::dns::Name* qname_;
const isc::dns::RRType* qtype_;
bool dnssec_;