2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[1483] Remove unused loop and control variable

Unrelated cleanup.
This commit is contained in:
Michal 'vorner' Vaner
2011-12-16 13:42:57 +01:00
parent 86b08bc45b
commit 30b1cc45e2

View File

@@ -230,7 +230,6 @@ Query::addAuthAdditional(ZoneFinder& finder) {
void void
Query::process() { Query::process() {
bool keep_doing = true;
const bool qtype_is_any = (qtype_ == RRType::ANY()); const bool qtype_is_any = (qtype_ == RRType::ANY());
response_.setHeaderFlag(Message::HEADERFLAG_AA, false); response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
@@ -252,154 +251,151 @@ Query::process() {
// Found a zone which is the nearest ancestor to QNAME, set the AA bit // Found a zone which is the nearest ancestor to QNAME, set the AA bit
response_.setHeaderFlag(Message::HEADERFLAG_AA); response_.setHeaderFlag(Message::HEADERFLAG_AA);
response_.setRcode(Rcode::NOERROR()); response_.setRcode(Rcode::NOERROR());
while (keep_doing) { std::vector<ConstRRsetPtr> target;
keep_doing = false; boost::function0<ZoneFinder::FindResult> find;
std::vector<ConstRRsetPtr> target; if (qtype_is_any) {
boost::function0<ZoneFinder::FindResult> find; find = boost::bind(&ZoneFinder::findAll, &zfinder, qname_,
if (qtype_is_any) { boost::ref(target), dnssec_opt_);
find = boost::bind(&ZoneFinder::findAll, &zfinder, qname_, } else {
boost::ref(target), dnssec_opt_); find = boost::bind(&ZoneFinder::find, &zfinder, qname_, qtype_,
} else { dnssec_opt_);
find = boost::bind(&ZoneFinder::find, &zfinder, qname_, qtype_, }
dnssec_opt_); ZoneFinder::FindResult db_result(find());
} switch (db_result.code) {
ZoneFinder::FindResult db_result(find()); case ZoneFinder::DNAME: {
switch (db_result.code) { // First, put the dname into the answer
case ZoneFinder::DNAME: { response_.addRRset(Message::SECTION_ANSWER,
// First, put the dname into the answer boost::const_pointer_cast<RRset>(db_result.rrset),
response_.addRRset(Message::SECTION_ANSWER, dnssec_);
boost::const_pointer_cast<RRset>(db_result.rrset), /*
dnssec_); * Empty DNAME should never get in, as it is impossible to
* create one in master file.
*
* FIXME: Other way to prevent this should be done
*/
assert(db_result.rrset->getRdataCount() > 0);
// Get the data of DNAME
const rdata::generic::DNAME& dname(
dynamic_cast<const rdata::generic::DNAME&>(
db_result.rrset->getRdataIterator()->getCurrent()));
// The yet unmatched prefix dname
const Name prefix(qname_.split(0, qname_.getLabelCount() -
db_result.rrset->getName().getLabelCount()));
// If we put it together, will it be too long?
// (The prefix contains trailing ., which will be removed
if (prefix.getLength() - Name::ROOT_NAME().getLength() +
dname.getDname().getLength() > Name::MAX_WIRE) {
/* /*
* Empty DNAME should never get in, as it is impossible to * In case the synthesized name is too long, section 4.1
* create one in master file. * of RFC 2672 mandates we return YXDOMAIN.
*
* FIXME: Other way to prevent this should be done
*/ */
assert(db_result.rrset->getRdataCount() > 0); response_.setRcode(Rcode::YXDOMAIN());
// Get the data of DNAME return;
const rdata::generic::DNAME& dname(
dynamic_cast<const rdata::generic::DNAME&>(
db_result.rrset->getRdataIterator()->getCurrent()));
// The yet unmatched prefix dname
const Name prefix(qname_.split(0, qname_.getLabelCount() -
db_result.rrset->getName().getLabelCount()));
// If we put it together, will it be too long?
// (The prefix contains trailing ., which will be removed
if (prefix.getLength() - Name::ROOT_NAME().getLength() +
dname.getDname().getLength() > Name::MAX_WIRE) {
/*
* In case the synthesized name is too long, section 4.1
* of RFC 2672 mandates we return YXDOMAIN.
*/
response_.setRcode(Rcode::YXDOMAIN());
return;
}
// The new CNAME we are creating (it will be unsigned even
// with DNSSEC, the DNAME is signed and it can be validated
// by that)
RRsetPtr cname(new RRset(qname_, db_result.rrset->getClass(),
RRType::CNAME(), db_result.rrset->getTTL()));
// Construct the new target by replacing the end
cname->addRdata(rdata::generic::CNAME(qname_.split(0,
qname_.getLabelCount() -
db_result.rrset->getName().getLabelCount()).
concatenate(dname.getDname())));
response_.addRRset(Message::SECTION_ANSWER, cname, dnssec_);
break;
} }
case ZoneFinder::CNAME: // The new CNAME we are creating (it will be unsigned even
case ZoneFinder::WILDCARD_CNAME: // with DNSSEC, the DNAME is signed and it can be validated
/* // by that)
* We don't do chaining yet. Therefore handling a CNAME is RRsetPtr cname(new RRset(qname_, db_result.rrset->getClass(),
* mostly the same as handling SUCCESS, but we didn't get RRType::CNAME(), db_result.rrset->getTTL()));
* what we expected. It means no exceptions in ANY or NS // Construct the new target by replacing the end
* on the origin (though CNAME in origin is probably cname->addRdata(rdata::generic::CNAME(qname_.split(0,
* forbidden anyway). qname_.getLabelCount() -
* db_result.rrset->getName().getLabelCount()).
* So, just put it there. concatenate(dname.getDname())));
*/ response_.addRRset(Message::SECTION_ANSWER, cname, dnssec_);
break;
}
case ZoneFinder::CNAME:
case ZoneFinder::WILDCARD_CNAME:
/*
* We don't do chaining yet. Therefore handling a CNAME is
* mostly the same as handling SUCCESS, but we didn't get
* what we expected. It means no exceptions in ANY or NS
* on the origin (though CNAME in origin is probably
* forbidden anyway).
*
* So, just put it there.
*/
response_.addRRset(Message::SECTION_ANSWER,
boost::const_pointer_cast<RRset>(db_result.rrset),
dnssec_);
// If the answer is a result of wildcard substitution,
// add a proof that there's no closer name.
if (dnssec_ && db_result.code == ZoneFinder::WILDCARD_CNAME) {
addWildcardProof(*result.zone_finder);
}
break;
case ZoneFinder::SUCCESS:
case ZoneFinder::WILDCARD:
if (qtype_is_any) {
// If quety type is ANY, insert all RRs under the domain
// into answer section.
BOOST_FOREACH(ConstRRsetPtr rrset, target) {
response_.addRRset(Message::SECTION_ANSWER,
boost::const_pointer_cast<RRset>(rrset), dnssec_);
// Handle additional for answer section
addAdditional(*result.zone_finder, *rrset.get());
}
} else {
response_.addRRset(Message::SECTION_ANSWER, response_.addRRset(Message::SECTION_ANSWER,
boost::const_pointer_cast<RRset>(db_result.rrset), boost::const_pointer_cast<RRset>(db_result.rrset),
dnssec_); dnssec_);
// Handle additional for answer section
// If the answer is a result of wildcard substitution,
// add a proof that there's no closer name.
if (dnssec_ && db_result.code == ZoneFinder::WILDCARD_CNAME) {
addWildcardProof(*result.zone_finder);
}
break;
case ZoneFinder::SUCCESS:
case ZoneFinder::WILDCARD:
if (qtype_is_any) {
// If quety type is ANY, insert all RRs under the domain
// into answer section.
BOOST_FOREACH(ConstRRsetPtr rrset, target) {
response_.addRRset(Message::SECTION_ANSWER,
boost::const_pointer_cast<RRset>(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),
dnssec_);
// Handle additional for answer section
addAdditional(*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_finder->getOrigin() ||
db_result.code != ZoneFinder::SUCCESS ||
(qtype_ != RRType::NS() && !qtype_is_any))
{
addAuthAdditional(*result.zone_finder);
}
// If the answer is a result of wildcard substitution,
// add a proof that there's no closer name.
if (dnssec_ && db_result.code == ZoneFinder::WILDCARD) {
addWildcardProof(*result.zone_finder);
}
break;
case ZoneFinder::DELEGATION:
response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
response_.addRRset(Message::SECTION_AUTHORITY,
boost::const_pointer_cast<RRset>(db_result.rrset),
dnssec_);
addAdditional(*result.zone_finder, *db_result.rrset); addAdditional(*result.zone_finder, *db_result.rrset);
break; }
case ZoneFinder::NXDOMAIN: // If apex NS records haven't been provided in the answer
response_.setRcode(Rcode::NXDOMAIN()); // section, insert apex NS records into the authority section
addSOA(*result.zone_finder); // and AAAA/A RRS of each of the NS RDATA into the additional
if (dnssec_ && db_result.rrset) { // section.
addNXDOMAINProof(zfinder, db_result.rrset); if (qname_ != result.zone_finder->getOrigin() ||
} db_result.code != ZoneFinder::SUCCESS ||
break; (qtype_ != RRType::NS() && !qtype_is_any))
case ZoneFinder::NXRRSET: {
addSOA(*result.zone_finder); addAuthAdditional(*result.zone_finder);
if (dnssec_ && db_result.rrset) { }
response_.addRRset(Message::SECTION_AUTHORITY,
boost::const_pointer_cast<RRset>( // If the answer is a result of wildcard substitution,
db_result.rrset), // add a proof that there's no closer name.
dnssec_); if (dnssec_ && db_result.code == ZoneFinder::WILDCARD) {
} addWildcardProof(*result.zone_finder);
break; }
case ZoneFinder::WILDCARD_NXRRSET: break;
addSOA(*result.zone_finder); case ZoneFinder::DELEGATION:
if (dnssec_ && db_result.rrset) { response_.setHeaderFlag(Message::HEADERFLAG_AA, false);
addWildcardNXRRSETProof(zfinder, db_result.rrset); response_.addRRset(Message::SECTION_AUTHORITY,
} boost::const_pointer_cast<RRset>(db_result.rrset),
break; dnssec_);
default: addAdditional(*result.zone_finder, *db_result.rrset);
// This is basically a bug of the data source implementation, break;
// but could also happen in the middle of development where case ZoneFinder::NXDOMAIN:
// we try to add a new result code. response_.setRcode(Rcode::NXDOMAIN());
isc_throw(isc::NotImplemented, "Unknown result code"); addSOA(*result.zone_finder);
break; if (dnssec_ && db_result.rrset) {
} addNXDOMAINProof(zfinder, db_result.rrset);
}
break;
case ZoneFinder::NXRRSET:
addSOA(*result.zone_finder);
if (dnssec_ && db_result.rrset) {
response_.addRRset(Message::SECTION_AUTHORITY,
boost::const_pointer_cast<RRset>(
db_result.rrset),
dnssec_);
}
break;
case ZoneFinder::WILDCARD_NXRRSET:
addSOA(*result.zone_finder);
if (dnssec_ && db_result.rrset) {
addWildcardNXRRSETProof(zfinder, db_result.rrset);
}
break;
default:
// This is basically a bug of the data source implementation,
// but could also happen in the middle of development where
// we try to add a new result code.
isc_throw(isc::NotImplemented, "Unknown result code");
break;
} }
} }