[svn] commit: r813 - in /branches/each-ds/src/lib: auth/cpp/data_source.cc auth/cpp/query.h dns/cpp/rrclass-placeholder.h dns/cpp/rrtype-placeholder.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Feb 13 19:54:12 UTC 2010
Author: each
Date: Sat Feb 13 19:54:12 2010
New Revision: 813
Log:
- add meta-RRTypes (ANY, IXFR, AXFR)
- continued query logic cleanup
Modified:
branches/each-ds/src/lib/auth/cpp/data_source.cc
branches/each-ds/src/lib/auth/cpp/query.h
branches/each-ds/src/lib/dns/cpp/rrclass-placeholder.h
branches/each-ds/src/lib/dns/cpp/rrtype-placeholder.h
Modified: branches/each-ds/src/lib/auth/cpp/data_source.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source.cc Sat Feb 13 19:54:12 2010
@@ -29,22 +29,20 @@
// if they match the qname/qtype that we've already answered.
if (nsname != q.qname() || q.qtype() != RRType::A()) {
QueryTask t(nsname, q.qclass(), RRType::A(),
- Section::ADDITIONAL());
- t.state = QueryTask::GETADDITIONAL;
+ Section::ADDITIONAL(), QueryTask::GETADDITIONAL);
q.tasks().push(t);
}
if (nsname != q.qname() || q.qtype() != RRType::AAAA()) {
QueryTask t(nsname, q.qclass(), RRType::AAAA(),
- Section::ADDITIONAL());
- t.state = QueryTask::GETADDITIONAL;
+ Section::ADDITIONAL(), QueryTask::GETADDITIONAL);
q.tasks().push(t);
}
} else if (rrset->getType() == RRType::MX()) {
const rdata::generic::MX& mx =
dynamic_cast<const rdata::generic::MX&>(rd);
- QueryTask t(mx.getMXName(), q.qclass(), RRType::A(),
- Section::ADDITIONAL(), QueryTask::ADDR_QUERY);
- t.state = QueryTask::GETADDITIONAL;
+ QueryTask t(mx.getMXName(), q.qclass(), RRType::ANY(),
+ Section::ADDITIONAL(), QueryTask::ADDR_QUERY,
+ QueryTask::GETADDITIONAL);
q.tasks().push(t);
}
}
@@ -156,8 +154,7 @@
dynamic_cast<const rdata::generic::CNAME&>(rd);
const Name& target(cname.getCname());
QueryTask t(target, task.qclass, task.qtype,
- Section::ANSWER());
- t.state = QueryTask::FOLLOWCNAME;
+ Section::ANSWER(), QueryTask::FOLLOWCNAME);
q.tasks().push(t);
break;
}
Modified: branches/each-ds/src/lib/auth/cpp/query.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/query.h (original)
+++ branches/each-ds/src/lib/auth/cpp/query.h Sat Feb 13 19:54:12 2010
@@ -31,15 +31,6 @@
namespace isc {
namespace auth {
-///
-/// \brief exception to throw if a DNS Message is malformed
-///
-class MalformedMessage : public Exception {
-public:
- MalformedMessage(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
-};
-
// An individual task to be carried out by the query logic
class QueryTask {
public:
@@ -56,37 +47,55 @@
// written after it has been fetched from the data source.
const Section& section;
- // This indicates the operation to be carried out:
- // - STD_QUERY: look for an authoritative match for
- // qname/qclass/qtype, or for qname/qclass/CNAME,
- // or for a zone cut/referral.
+ // The op field indicates the operation to be carried out by
+ // this query task:
+ //
// - SIMPLE_QUERY: look for a match for qname/qclass/qtype
- // in local data, regardless of authority
+ // in local data (regardless of whether it is above or below
+ // a zone cut).
+ //
+ // - AUTH_QUERY: look for a match for qname/qclass/qtype, or
+ // for qname/qclass/CNAME, or for a referral.
+ //
// - ADDR_QUERY: look for matches with qname/qclass/A
// OR qname/class/AAAA in local data, regardless of
- // authority (this can be implemented with two successive
- // SIMPLE_QUERY lookups or as a single lookup, depending
- // on the Data Source implementation.
+ // authority, for use in glue. (This can be implemented
+ // as two successive SIMPLE_QUERY tasks, but might be
+ // optimized by the concrete data source implementation
+ // by turning it into a single database lookup.)
+ //
+ // - REF_QUERY: look for matches for qname/qclass/NS,
+ // qname/qclass/DS, and qname/qclass/DNAME. Used
+ // to search for a zone cut.
const enum Op {
- STD_QUERY,
SIMPLE_QUERY,
- ADDR_QUERY
+ AUTH_QUERY,
+ ADDR_QUERY,
+ REF_QUERY
} op;
- // This indicates the state of the query as of the time when
- // this answer should be processed.
- // - GETANSWER: We are looking for the answer to a query.
+ // The state field indicates the state of the query; it controls
+ // the next step after processing each query task.
+ //
+ // - GETANSWER: We are looking for the answer to a primary query.
+ // (The qname of the task should exactly match the qname of the
+ // query.) If we have no match, the query has failed.
+ //
// - FOLLOWCNAME: We are looking for the target of a CNAME RR that
- // was found via a GETANSWER query task.
+ // was found via a previous GETANSWER query task. If we have no
+ // match, the query is still successful.
+ //
// - GETAUTHORITY: We are looking for the authority information.
// If a complete answer was previously found, this might be a
// query for NS records. If no complete answer has been found,
// this might be a query for an SOA, NSEC or NSEC3 records.
+ //
// - GETADDITIONAL: We are filling in additional data, either
// as a result of finding NS or MX records via a GETANSWER
// query task, or as a result of finding NS records via a
// GETAUTHORITY query task.
+
enum State {
GETANSWER,
GETADDITIONAL,
@@ -94,10 +103,11 @@
FOLLOWCNAME
} state;
+ // Constructors
QueryTask(const Name& n, const RRClass& c,
const RRType& t, const Section& sect) :
qname(n), qclass(c), qtype(t),
- section(sect), op(SIMPLE_QUERY), state(GETANSWER) {}
+ section(sect), op(AUTH_QUERY), state(GETANSWER) {}
QueryTask(const Name& n, const RRClass& c,
const RRType& t, const Section& sect, const Op o) :
qname(n), qclass(c), qtype(t),
@@ -105,12 +115,13 @@
QueryTask(const Name& n, const RRClass& c,
const RRType& t, const Section& sect, const State st) :
qname(n), qclass(c), qtype(t),
- section(sect), op(SIMPLE_QUERY), state(st) {}
+ section(sect), op(AUTH_QUERY), state(st) {}
QueryTask(const Name& n, const RRClass& c,
const RRType& t, const Section& sect,
const Op o, const State st) :
qname(n), qclass(c), qtype(t),
section(sect), op(o), state(st) {}
+
virtual ~QueryTask() {}
};
@@ -122,12 +133,15 @@
// Data Source query
class Query {
public:
+ // The state of a query: running, succeeded, or failed.
+ // (XXX: Not sure this is needed.)
enum Status {
RUNNING,
SUCCESS,
FAILURE
};
+ // Query constructor
Query(Message& m, bool dnssec) {
message_ = &m;
want_additional = true;
@@ -135,10 +149,12 @@
status_ = RUNNING;
// Check message formatting
+ // (XXX: The Message API should have a method for getting
+ // section counts without having to use an iterator)
QuestionIterator qid = message_->beginQuestion();
qid++;
if (qid != message_->endQuestion())
- dns_throw(MalformedMessage, "too many questions");
+ dns_throw(Unexpected, "malformed message: too many questions");
// Populate the query task queue with the initial question
QuestionPtr query = *message_->beginQuestion();
Modified: branches/each-ds/src/lib/dns/cpp/rrclass-placeholder.h
==============================================================================
--- branches/each-ds/src/lib/dns/cpp/rrclass-placeholder.h (original)
+++ branches/each-ds/src/lib/dns/cpp/rrclass-placeholder.h Sat Feb 13 19:54:12 2010
@@ -238,16 +238,16 @@
// BEGIN_WELL_KNOWN_CLASS_DECLARATIONS
// END_WELL_KNOWN_CLASS_DECLARATIONS
+ static const RRClass& NONE();
+ static const RRClass& ANY();
+
+private:
// \brief Meta-classes
enum {
RRCLASS_RESERVED0 = 0,
RRCLASS_NONE = 254,
RRCLASS_ANY = 255
};
- static const RRClass& NONE();
- static const RRClass& ANY();
-
-private:
uint16_t classcode_;
};
Modified: branches/each-ds/src/lib/dns/cpp/rrtype-placeholder.h
==============================================================================
--- branches/each-ds/src/lib/dns/cpp/rrtype-placeholder.h (original)
+++ branches/each-ds/src/lib/dns/cpp/rrtype-placeholder.h Sat Feb 13 19:54:12 2010
@@ -251,12 +251,44 @@
// BEGIN_WELL_KNOWN_TYPE_DECLARATIONS
// END_WELL_KNOWN_TYPE_DECLARATIONS
+ static const RRType& IXFR();
+ static const RRType& AXFR();
+ static const RRType& ANY();
+
private:
+ // \brief Meta-classes
+ enum {
+ RRTYPE_IXFR = 251,
+ RRTYPE_AXFR = 252,
+ RRTYPE_ANY = 255
+ };
+
uint16_t typecode_;
};
// BEGIN_WELL_KNOWN_TYPE_DEFINITIONS
// END_WELL_KNOWN_TYPE_DEFINITIONS
+
+inline const RRType&
+RRType::IXFR()
+{
+ static RRType rrtype(RRTYPE_IXFR);
+ return (rrtype);
+}
+
+inline const RRType&
+RRType::AXFR()
+{
+ static RRType rrtype(RRTYPE_AXFR);
+ return (rrtype);
+}
+
+inline const RRType&
+RRType::ANY()
+{
+ static RRType rrtype(RRTYPE_ANY);
+ return (rrtype);
+}
///
/// \brief Insert the \c RRType as a string into stream.
More information about the bind10-changes
mailing list