Commit b2e7f7e4 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1607] supported type ANY query case.

parent de4b10ee
...@@ -403,7 +403,8 @@ DatabaseClient::Finder::findAll(const isc::dns::Name& name, ...@@ -403,7 +403,8 @@ DatabaseClient::Finder::findAll(const isc::dns::Name& name,
{ {
return (ZoneFinderContextPtr(new Context(*this, options, return (ZoneFinderContextPtr(new Context(*this, options,
findInternal(name, RRType::ANY(), findInternal(name, RRType::ANY(),
&target, options)))); &target, options),
target)));
} }
ZoneFinderContextPtr ZoneFinderContextPtr
......
...@@ -895,7 +895,8 @@ InMemoryZoneFinder::findAll(const Name& name, ...@@ -895,7 +895,8 @@ InMemoryZoneFinder::findAll(const Name& name,
{ {
return (ZoneFinderContextPtr( return (ZoneFinderContextPtr(
new Context(*this, options, impl_->find(name, RRType::ANY(), new Context(*this, options, impl_->find(name, RRType::ANY(),
&target, options)))); &target, options),
target)));
} }
ZoneFinder::FindNSEC3Result ZoneFinder::FindNSEC3Result
......
...@@ -281,4 +281,32 @@ TEST_P(ZoneFinderContextTest, getAdditionalNoOP) { ...@@ -281,4 +281,32 @@ TEST_P(ZoneFinderContextTest, getAdditionalNoOP) {
EXPECT_TRUE(result_sets_.empty()); EXPECT_TRUE(result_sets_.empty());
} }
TEST_P(ZoneFinderContextTest, getAdditionalForAny) {
// getAdditional() after successful type ANY query should return
// the additional records of all returned RRsets.
vector<ConstRRsetPtr> all_rrsets;
ZoneFinderContextPtr ctx = finder_->findAll(qzone_, all_rrsets);
EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
rrsetsCheck("ns1.example.org. 3600 IN A 192.0.2.1\n"
"ns1.example.org. 3600 IN AAAA 2001:db8::1\n"
"ns2.example.org. 3600 IN A 192.0.2.2\n"
"mx1.example.org. 3600 IN A 192.0.2.10\n"
"mx2.example.org. 3600 IN AAAA 2001:db8::10\n",
result_sets_.begin(), result_sets_.end());
// If the type ANY query results in DELEGATION, the result should be the
// same as normal query.
all_rrsets.clear();
result_sets_.clear();
ctx = finder_->findAll(Name("www.a.example.org"), all_rrsets);
EXPECT_EQ(ZoneFinder::DELEGATION, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
rrsetsCheck("ns1.a.example.org. 3600 IN A 192.0.2.5\n"
"ns2.a.example.org. 3600 IN A 192.0.2.6\n"
"ns2.a.example.org. 3600 IN AAAA 2001:db8::6\n",
result_sets_.begin(), result_sets_.end());
}
} }
...@@ -153,6 +153,15 @@ public: ...@@ -153,6 +153,15 @@ public:
code(result.code), rrset(result.rrset), code(result.code), rrset(result.rrset),
finder_(finder), flags_(result.flags), options_(options) finder_(finder), flags_(result.flags), options_(options)
{} {}
Context(ZoneFinder& finder, FindOptions options,
const ResultContext& result,
std::vector<isc::dns::ConstRRsetPtr> &all_set) :
code(result.code), rrset(result.rrset),
finder_(finder), flags_(result.flags), options_(options),
all_set_(all_set)
{}
const Result code; const Result code;
const isc::dns::ConstRRsetPtr rrset; const isc::dns::ConstRRsetPtr rrset;
...@@ -203,6 +212,7 @@ public: ...@@ -203,6 +212,7 @@ public:
ZoneFinder& finder_; ZoneFinder& finder_;
const FindResultFlags flags_; const FindResultFlags flags_;
const FindOptions options_; const FindOptions options_;
std::vector<isc::dns::ConstRRsetPtr> all_set_;
}; };
/// ///
......
...@@ -51,30 +51,52 @@ getAdditionalAddrs(ZoneFinder& finder, const Name& name, ...@@ -51,30 +51,52 @@ getAdditionalAddrs(ZoneFinder& finder, const Name& name,
} }
} }
} }
}
void void
ZoneFinder::Context::getAdditionalImpl(const vector<RRType>& requested_types, getAdditionalForRRset(ZoneFinder& finder, const AbstractRRset& rrset,
vector<ConstRRsetPtr>& result) const vector<RRType>& requested_types,
vector<ConstRRsetPtr>& result,
ZoneFinder::FindOptions orig_options)
{ {
RdataIteratorPtr rdata_iterator(rrset->getRdataIterator()); RdataIteratorPtr rdata_iterator(rrset.getRdataIterator());
ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT; ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT;
if ((orig_options & ZoneFinder::FIND_DNSSEC) != 0) {
options = options | ZoneFinder::FIND_DNSSEC;
}
for (; !rdata_iterator->isLast(); rdata_iterator->next()) { for (; !rdata_iterator->isLast(); rdata_iterator->next()) {
const Rdata& rdata(rdata_iterator->getCurrent()); const Rdata& rdata(rdata_iterator->getCurrent());
if (rrset->getType() == RRType::NS()) { if (rrset.getType() == RRType::NS()) {
// Need to perform the search in the "GLUE OK" mode. // Need to perform the search in the "GLUE OK" mode.
const generic::NS& ns = dynamic_cast<const generic::NS&>(rdata); const generic::NS& ns = dynamic_cast<const generic::NS&>(rdata);
getAdditionalAddrs(finder_, ns.getNSName(), requested_types, getAdditionalAddrs(finder, ns.getNSName(), requested_types,
result, options | ZoneFinder::FIND_GLUE_OK); result, options | ZoneFinder::FIND_GLUE_OK);
} else if (rrset->getType() == RRType::MX()) { } else if (rrset.getType() == RRType::MX()) {
const generic::MX& mx = dynamic_cast<const generic::MX&>(rdata); const generic::MX& mx = dynamic_cast<const generic::MX&>(rdata);
getAdditionalAddrs(finder_, mx.getMXName(), requested_types, getAdditionalAddrs(finder, mx.getMXName(), requested_types,
result, options); result, options);
} }
} }
} }
}
void
ZoneFinder::Context::getAdditionalImpl(const vector<RRType>& requested_types,
vector<ConstRRsetPtr>& result)
{
// If rrset is non NULL, it should have been SUCCESS/DELEGATION; otherwise
// we should have responded to type ANY query.
if (rrset) {
getAdditionalForRRset(finder_, *rrset, requested_types, result,
options_);
return;
}
BOOST_FOREACH(ConstRRsetPtr rrset_in_set, all_set_) {
getAdditionalForRRset(finder_, *rrset_in_set, requested_types, result,
options_);
}
}
} // namespace datasrc } // namespace datasrc
} // datasrc isc } // datasrc isc
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment