|
@@ -31,14 +31,14 @@ namespace isc {
|
|
|
namespace auth {
|
|
|
|
|
|
void
|
|
|
-Query::getAdditional(const Zone& zone, const RRset& rrset) const {
|
|
|
+Query::getAdditional(const ZoneFinder& zone, const RRset& rrset) const {
|
|
|
RdataIteratorPtr rdata_iterator(rrset.getRdataIterator());
|
|
|
for (; !rdata_iterator->isLast(); rdata_iterator->next()) {
|
|
|
const Rdata& rdata(rdata_iterator->getCurrent());
|
|
|
if (rrset.getType() == RRType::NS()) {
|
|
|
// Need to perform the search in the "GLUE OK" mode.
|
|
|
const generic::NS& ns = dynamic_cast<const generic::NS&>(rdata);
|
|
|
- findAddrs(zone, ns.getNSName(), Zone::FIND_GLUE_OK);
|
|
|
+ findAddrs(zone, ns.getNSName(), ZoneFinder::FIND_GLUE_OK);
|
|
|
} else if (rrset.getType() == RRType::MX()) {
|
|
|
const generic::MX& mx(dynamic_cast<const generic::MX&>(rdata));
|
|
|
findAddrs(zone, mx.getMXName());
|
|
@@ -47,8 +47,8 @@ Query::getAdditional(const Zone& zone, const RRset& rrset) const {
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-Query::findAddrs(const Zone& zone, const Name& qname,
|
|
|
- const Zone::FindOptions options) const
|
|
|
+Query::findAddrs(const ZoneFinder& zone, const Name& qname,
|
|
|
+ const ZoneFinder::FindOptions options) const
|
|
|
{
|
|
|
// Out of zone name
|
|
|
NameComparisonResult result = zone.getOrigin().compare(qname);
|
|
@@ -66,9 +66,9 @@ Query::findAddrs(const Zone& zone, const Name& qname,
|
|
|
|
|
|
// Find A rrset
|
|
|
if (qname_ != qname || qtype_ != RRType::A()) {
|
|
|
- Zone::FindResult a_result = zone.find(qname, RRType::A(), NULL,
|
|
|
+ ZoneFinder::FindResult a_result = zone.find(qname, RRType::A(), NULL,
|
|
|
options);
|
|
|
- if (a_result.code == Zone::SUCCESS) {
|
|
|
+ if (a_result.code == ZoneFinder::SUCCESS) {
|
|
|
response_.addRRset(Message::SECTION_ADDITIONAL,
|
|
|
boost::const_pointer_cast<RRset>(a_result.rrset));
|
|
|
}
|
|
@@ -76,9 +76,9 @@ Query::findAddrs(const Zone& zone, const Name& qname,
|
|
|
|
|
|
// Find AAAA rrset
|
|
|
if (qname_ != qname || qtype_ != RRType::AAAA()) {
|
|
|
- Zone::FindResult aaaa_result =
|
|
|
+ ZoneFinder::FindResult aaaa_result =
|
|
|
zone.find(qname, RRType::AAAA(), NULL, options);
|
|
|
- if (aaaa_result.code == Zone::SUCCESS) {
|
|
|
+ if (aaaa_result.code == ZoneFinder::SUCCESS) {
|
|
|
response_.addRRset(Message::SECTION_ADDITIONAL,
|
|
|
boost::const_pointer_cast<RRset>(aaaa_result.rrset));
|
|
|
}
|
|
@@ -86,10 +86,10 @@ Query::findAddrs(const Zone& zone, const Name& qname,
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-Query::putSOA(const Zone& zone) const {
|
|
|
- Zone::FindResult soa_result(zone.find(zone.getOrigin(),
|
|
|
+Query::putSOA(const ZoneFinder& zone) const {
|
|
|
+ ZoneFinder::FindResult soa_result(zone.find(zone.getOrigin(),
|
|
|
RRType::SOA()));
|
|
|
- if (soa_result.code != Zone::SUCCESS) {
|
|
|
+ if (soa_result.code != ZoneFinder::SUCCESS) {
|
|
|
isc_throw(NoSOA, "There's no SOA record in zone " <<
|
|
|
zone.getOrigin().toText());
|
|
|
} else {
|
|
@@ -104,11 +104,12 @@ Query::putSOA(const Zone& zone) const {
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-Query::getAuthAdditional(const Zone& zone) const {
|
|
|
+Query::getAuthAdditional(const ZoneFinder& zone) const {
|
|
|
// Fill in authority and addtional sections.
|
|
|
- Zone::FindResult ns_result = zone.find(zone.getOrigin(), RRType::NS());
|
|
|
+ ZoneFinder::FindResult ns_result = zone.find(zone.getOrigin(),
|
|
|
+ RRType::NS());
|
|
|
// zone origin name should have NS records
|
|
|
- if (ns_result.code != Zone::SUCCESS) {
|
|
|
+ if (ns_result.code != ZoneFinder::SUCCESS) {
|
|
|
isc_throw(NoApexNS, "There's no apex NS records in zone " <<
|
|
|
zone.getOrigin().toText());
|
|
|
} else {
|
|
@@ -145,11 +146,10 @@ Query::process() const {
|
|
|
while (keep_doing) {
|
|
|
keep_doing = false;
|
|
|
std::auto_ptr<RRsetList> target(qtype_is_any ? new RRsetList : NULL);
|
|
|
- const Zone::FindResult db_result(result.zone->find(qname_, qtype_,
|
|
|
- target.get()));
|
|
|
-
|
|
|
+ const ZoneFinder::FindResult db_result(
|
|
|
+ result.zone_finder->find(qname_, qtype_, target.get()));
|
|
|
switch (db_result.code) {
|
|
|
- case Zone::DNAME: {
|
|
|
+ case ZoneFinder::DNAME: {
|
|
|
// First, put the dname into the answer
|
|
|
response_.addRRset(Message::SECTION_ANSWER,
|
|
|
boost::const_pointer_cast<RRset>(db_result.rrset));
|
|
@@ -191,7 +191,7 @@ Query::process() const {
|
|
|
response_.addRRset(Message::SECTION_ANSWER, cname);
|
|
|
break;
|
|
|
}
|
|
|
- case Zone::CNAME:
|
|
|
+ case ZoneFinder::CNAME:
|
|
|
/*
|
|
|
* We don't do chaining yet. Therefore handling a CNAME is
|
|
|
* mostly the same as handling SUCCESS, but we didn't get
|
|
@@ -204,46 +204,46 @@ Query::process() const {
|
|
|
response_.addRRset(Message::SECTION_ANSWER,
|
|
|
boost::const_pointer_cast<RRset>(db_result.rrset));
|
|
|
break;
|
|
|
- case Zone::SUCCESS:
|
|
|
+ case ZoneFinder::SUCCESS:
|
|
|
if (qtype_is_any) {
|
|
|
// If quety type is ANY, insert all RRs under the domain
|
|
|
// into answer section.
|
|
|
BOOST_FOREACH(RRsetPtr rrset, *target) {
|
|
|
response_.addRRset(Message::SECTION_ANSWER, rrset);
|
|
|
// Handle additional for answer section
|
|
|
- getAdditional(*result.zone, *rrset.get());
|
|
|
+ getAdditional(*result.zone_finder, *rrset.get());
|
|
|
}
|
|
|
} else {
|
|
|
response_.addRRset(Message::SECTION_ANSWER,
|
|
|
boost::const_pointer_cast<RRset>(db_result.rrset));
|
|
|
// Handle additional for answer section
|
|
|
- getAdditional(*result.zone, *db_result.rrset);
|
|
|
+ getAdditional(*result.zone_finder, *db_result.rrset);
|
|
|
}
|
|
|
// If apex NS records haven't been provided in the answer
|
|
|
// section, insert apex NS records into the authority section
|
|
|
// and AAAA/A RRS of each of the NS RDATA into the additional
|
|
|
// section.
|
|
|
- if (qname_ != result.zone->getOrigin() ||
|
|
|
- db_result.code != Zone::SUCCESS ||
|
|
|
+ if (qname_ != result.zone_finder->getOrigin() ||
|
|
|
+ db_result.code != ZoneFinder::SUCCESS ||
|
|
|
(qtype_ != RRType::NS() && !qtype_is_any))
|
|
|
{
|
|
|
- getAuthAdditional(*result.zone);
|
|
|
+ getAuthAdditional(*result.zone_finder);
|
|
|
}
|
|
|
break;
|
|
|
- case Zone::DELEGATION:
|
|
|
+ case ZoneFinder::DELEGATION:
|
|
|
response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
|
|
|
response_.addRRset(Message::SECTION_AUTHORITY,
|
|
|
boost::const_pointer_cast<RRset>(db_result.rrset));
|
|
|
- getAdditional(*result.zone, *db_result.rrset);
|
|
|
+ getAdditional(*result.zone_finder, *db_result.rrset);
|
|
|
break;
|
|
|
- case Zone::NXDOMAIN:
|
|
|
+ case ZoneFinder::NXDOMAIN:
|
|
|
// Just empty answer with SOA in authority section
|
|
|
response_.setRcode(Rcode::NXDOMAIN());
|
|
|
- putSOA(*result.zone);
|
|
|
+ putSOA(*result.zone_finder);
|
|
|
break;
|
|
|
- case Zone::NXRRSET:
|
|
|
+ case ZoneFinder::NXRRSET:
|
|
|
// Just empty answer with SOA in authority section
|
|
|
- putSOA(*result.zone);
|
|
|
+ putSOA(*result.zone_finder);
|
|
|
break;
|
|
|
}
|
|
|
}
|