BIND 10 trac1483, updated. 8e93f114a93671c4eda46f420c81e1101fc16e05 [1483] Port the ANY logic in memory datasource
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 9 20:28:25 UTC 2011
The branch, trac1483 has been updated
via 8e93f114a93671c4eda46f420c81e1101fc16e05 (commit)
via 118d0d9c047879133c412390d67dda70004da589 (commit)
via cbddeb5ad8ecb4d3ef403943e588fa2c858b0d3b (commit)
from a677ae91c9d7a5bd2ef8574f84e9f33f90c45e44 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8e93f114a93671c4eda46f420c81e1101fc16e05
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 9 21:26:31 2011 +0100
[1483] Port the ANY logic in memory datasource
To the new interface. The tests were reintroduced.
commit 118d0d9c047879133c412390d67dda70004da589
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 9 19:32:28 2011 +0100
[1483] Defined the findAll method interface
commit cbddeb5ad8ecb4d3ef403943e588fa2c858b0d3b
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 9 19:18:20 2011 +0100
[1438] Strip the datasources of target parameter
Is is being deprecated by a separate method in this branch, so get rid
of it.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.cc | 11 ++-
src/lib/datasrc/database.h | 16 ++-
src/lib/datasrc/memory_datasrc.cc | 19 ++-
src/lib/datasrc/memory_datasrc.h | 14 ++-
src/lib/datasrc/tests/database_unittest.cc | 35 +++---
src/lib/datasrc/tests/memory_datasrc_unittest.cc | 138 +++++++++++----------
src/lib/datasrc/zone.h | 21 +++-
7 files changed, 146 insertions(+), 108 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index 45ce0c2..25dc66e 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -391,9 +391,16 @@ DatabaseClient::Finder::findNSECCover(const Name& name) {
}
ZoneFinder::FindResult
+DatabaseClient::Finder::findAll(const isc::dns::Name&,
+ std::vector<isc::dns::ConstRRsetPtr>&,
+ const FindOptions)
+{
+ isc_throw(isc::NotImplemented, "Not implemented");
+}
+
+ZoneFinder::FindResult
DatabaseClient::Finder::find(const isc::dns::Name& name,
const isc::dns::RRType& type,
- isc::dns::RRsetList*,
const FindOptions options)
{
// This variable is used to determine the difference between
@@ -729,7 +736,7 @@ public:
// Find the SOA of the zone (may or may not succeed). Note that
// this must be done before starting the iteration context.
soa_ = DatabaseClient::Finder(accessor_, zone.second, zone_name).
- find(zone_name, RRType::SOA(), NULL).rrset;
+ find(zone_name, RRType::SOA()).rrset;
// Request the context
context_ = accessor_->getAllRecords(zone.second);
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index 81e6241..f0c4575 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -753,10 +753,6 @@ public:
* (this implementation is not complete, and currently only
* does full matches, CNAMES, and the signatures for matches and
* CNAMEs)
- * \note target was used in the original design to handle ANY
- * queries. This is not implemented yet, and may use
- * target again for that, but it might also use something
- * different. It is left in for compatibility at the moment.
* \note options are ignored at this moment
*
* \note Maybe counter intuitively, this method is not a const member
@@ -780,14 +776,22 @@ public:
*
* \param name The name to find
* \param type The RRType to find
- * \param target Unused at this moment
* \param options Options about how to search.
* See ZoneFinder::FindOptions.
*/
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type,
- isc::dns::RRsetList* target = NULL,
const FindOptions options = FIND_DEFAULT);
+ /**
+ * \brief Implementation of the ZoneFinder::findAll method.
+ *
+ * In short, it is mostly the same thing as find, but it returns all
+ * RRsets in the named node through the target parameter in successful
+ * case. It acts the same in the unsuccessful one.
+ */
+ virtual FindResult findAll(const isc::dns::Name& name,
+ std::vector<isc::dns::ConstRRsetPtr>& target,
+ const FindOptions options = FIND_DEFAULT);
/**
* \brief Implementation of ZoneFinder::findPreviousName method.
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index a79ee5b..d09eb6d 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -422,7 +422,8 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
// Implementation of InMemoryZoneFinder::find
FindResult find(const Name& name, RRType type,
- RRsetList* target, const FindOptions options) const
+ std::vector<ConstRRsetPtr> *target,
+ const FindOptions options) const
{
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_FIND).arg(name).
arg(type);
@@ -572,9 +573,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
for (found = node->getData()->begin();
found != node->getData()->end(); ++found)
{
- target->addRRset(
- boost::const_pointer_cast<RRset>(prepareRRset(name,
- found->second, rename)));
+ target->push_back(prepareRRset(name, found->second, rename));
}
LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_ANY_SUCCESS).
arg(name);
@@ -629,9 +628,17 @@ InMemoryZoneFinder::getClass() const {
ZoneFinder::FindResult
InMemoryZoneFinder::find(const Name& name, const RRType& type,
- RRsetList* target, const FindOptions options)
+ const FindOptions options)
+{
+ return (impl_->find(name, type, NULL, options));
+}
+
+ZoneFinder::FindResult
+InMemoryZoneFinder::findAll(const Name& name,
+ std::vector<ConstRRsetPtr>& target,
+ const FindOptions options)
{
- return (impl_->find(name, type, target, options));
+ return (impl_->find(name, RRType::ANY(), &target, options));
}
result::Result
diff --git a/src/lib/datasrc/memory_datasrc.h b/src/lib/datasrc/memory_datasrc.h
index b852eb3..32cf518 100644
--- a/src/lib/datasrc/memory_datasrc.h
+++ b/src/lib/datasrc/memory_datasrc.h
@@ -69,14 +69,20 @@ public:
///
/// See documentation in \c Zone.
///
- /// It returns NULL pointer in case of NXDOMAIN and NXRRSET,
- /// and also SUCCESS if target is not NULL(TYPE_ANY query).
- /// (the base class documentation does not seem to require that).
+ /// It returns NULL pointer in case of NXDOMAIN and NXRRSET.
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type,
- isc::dns::RRsetList* target = NULL,
const FindOptions options = FIND_DEFAULT);
+ /// \brief Version of find that returns all types at once
+ ///
+ /// It acts the same as find, just that when the correct node is found,
+ /// all the RRsets are filled into the target parameter instead of being
+ /// returned by the result.
+ virtual FindResult findAll(const isc::dns::Name& name,
+ std::vector<isc::dns::ConstRRsetPtr>& target,
+ const FindOptions options = FIND_DEFAULT);
+
/// \brief Imelementation of the ZoneFinder::findPreviousName method
///
/// This one throws NotImplemented exception, as InMemory doesn't
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 920c9a2..8491b7a 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -1419,8 +1419,7 @@ doFindTest(ZoneFinder& finder,
const ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT)
{
SCOPED_TRACE("doFindTest " + name.toText() + " " + type.toText());
- const ZoneFinder::FindResult result = finder.find(name, type, NULL,
- options);
+ const ZoneFinder::FindResult result = finder.find(name, type, options);
ASSERT_EQ(expected_result, result.code) << name << " " << type;
if (!expected_rdatas.empty() && result.rrset) {
checkRRset(result.rrset, expected_name != Name(".") ? expected_name :
@@ -1670,58 +1669,58 @@ TYPED_TEST(DatabaseClientTest, find) {
EXPECT_THROW(finder->find(isc::dns::Name("badcname1.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badcname2.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badcname3.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badrdata.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badtype.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badttl.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("badsig.example.org."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
// Trigger the hardcoded exceptions and see if find() has cleaned up
if (this->is_mock_) {
EXPECT_THROW(finder->find(isc::dns::Name("dsexception.in.search."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("iscexception.in.search."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
isc::Exception);
EXPECT_THROW(finder->find(isc::dns::Name("basicexception.in.search."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
std::exception);
EXPECT_THROW(finder->find(isc::dns::Name("dsexception.in.getnext."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("iscexception.in.getnext."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
isc::Exception);
EXPECT_THROW(finder->find(isc::dns::Name("basicexception.in.getnext."),
this->qtype_,
- NULL, ZoneFinder::FIND_DEFAULT),
+ ZoneFinder::FIND_DEFAULT),
std::exception);
}
@@ -1840,17 +1839,17 @@ TYPED_TEST(DatabaseClientTest, findDelegation) {
// This is broken dname, it contains two targets
EXPECT_THROW(finder->find(isc::dns::Name("below.baddname.example.org."),
- this->qtype_, NULL,
+ this->qtype_,
ZoneFinder::FIND_DEFAULT),
DataSourceError);
// Broken NS - it lives together with something else
EXPECT_THROW(finder->find(isc::dns::Name("brokenns1.example.org."),
- this->qtype_, NULL,
+ this->qtype_,
ZoneFinder::FIND_DEFAULT),
DataSourceError);
EXPECT_THROW(finder->find(isc::dns::Name("brokenns2.example.org."),
- this->qtype_, NULL,
+ this->qtype_,
ZoneFinder::FIND_DEFAULT),
DataSourceError);
}
diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
index a1bd94e..0ca4bde 100644
--- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc
+++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
@@ -16,6 +16,7 @@
#include <vector>
#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
#include <exceptions/exceptions.h>
@@ -389,7 +390,6 @@ public:
ZoneFinder::Result result,
bool check_answer = true,
const ConstRRsetPtr& answer = ConstRRsetPtr(),
- RRsetList* target = NULL,
InMemoryZoneFinder* zone_finder = NULL,
ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT,
bool check_wild_answer = false)
@@ -402,7 +402,7 @@ public:
EXPECT_NO_THROW({
ZoneFinder::FindResult find_result(zone_finder->find(
name, rrtype,
- target, options));
+ options));
// Check it returns correct answers
EXPECT_EQ(result, find_result.code);
if (check_answer) {
@@ -438,6 +438,32 @@ public:
}
});
}
+ /**
+ * \brief Calls the findAll on the finder and checks the result.
+ */
+ std::vector<ConstRRsetPtr> findAllTest(const Name& name,
+ ZoneFinder::Result result,
+ size_t expected_size,
+ InMemoryZoneFinder* finder = NULL,
+ const ConstRRsetPtr &rrset_result =
+ ConstRRsetPtr(),
+ ZoneFinder::FindOptions options =
+ ZoneFinder::FIND_DEFAULT)
+ {
+ if (finder == NULL) {
+ finder = &zone_finder_;
+ }
+ std::vector<ConstRRsetPtr> target;
+ ZoneFinder::FindResult findResult(finder->findAll(name, target,
+ options));
+ EXPECT_EQ(result, findResult.code);
+ EXPECT_EQ(rrset_result, findResult.rrset);
+ BOOST_FOREACH(const ConstRRsetPtr& rrset, target) {
+ EXPECT_EQ(name, rrset->getName());
+ }
+ EXPECT_EQ(expected_size, target.size());
+ return (target);
+ }
// Internal part of the cancelWildcard test that is multiple times
void doCancelWildcardTest();
};
@@ -522,7 +548,7 @@ TEST_F(InMemoryZoneFinderTest, findCNAMEUnderZoneCut) {
RRTTL(300)));
EXPECT_EQ(SUCCESS, zone_finder_.add(rr_cname_under_cut_));
findTest(Name("cname.child.example.org"), RRType::AAAA(),
- ZoneFinder::CNAME, true, rr_cname_under_cut_, NULL, NULL,
+ ZoneFinder::CNAME, true, rr_cname_under_cut_, NULL,
ZoneFinder::FIND_GLUE_OK);
}
@@ -598,7 +624,7 @@ TEST_F(InMemoryZoneFinderTest, DNAMEUnderNS) {
findTest(lowName, RRType::A(), ZoneFinder::DELEGATION, true, rr_child_ns_);
findTest(lowName, RRType::A(), ZoneFinder::DNAME, true, rr_child_dname_,
- NULL, NULL, ZoneFinder::FIND_GLUE_OK);
+ NULL, ZoneFinder::FIND_GLUE_OK);
}
// Test adding child zones and zone cut handling
@@ -636,25 +662,19 @@ TEST_F(InMemoryZoneFinderTest, findAny) {
EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_finder_.add(rr_child_glue_)));
// origin
- RRsetList origin_rrsets;
- findTest(origin_, RRType::ANY(), ZoneFinder::SUCCESS, true,
- ConstRRsetPtr(), &origin_rrsets);
- EXPECT_EQ(2, origin_rrsets.size());
- EXPECT_EQ(rr_a_, origin_rrsets.findRRset(RRType::A(), RRClass::IN()));
- EXPECT_EQ(rr_ns_, origin_rrsets.findRRset(RRType::NS(), RRClass::IN()));
+ std::vector<ConstRRsetPtr> rrsets(findAllTest(origin_, ZoneFinder::SUCCESS,
+ 2));
+ EXPECT_FALSE(rrsets.end() == std::find(rrsets.begin(), rrsets.end(),
+ rr_a_));
+ EXPECT_FALSE(rrsets.end() == std::find(rrsets.begin(), rrsets.end(),
+ rr_ns_));
// out zone name
- RRsetList out_rrsets;
- findTest(Name("example.com"), RRType::ANY(), ZoneFinder::NXDOMAIN, true,
- ConstRRsetPtr(), &out_rrsets);
- EXPECT_EQ(0, out_rrsets.size());
-
- RRsetList glue_child_rrsets;
- findTest(rr_child_glue_->getName(), RRType::ANY(), ZoneFinder::SUCCESS,
- true, ConstRRsetPtr(), &glue_child_rrsets);
- EXPECT_EQ(rr_child_glue_, glue_child_rrsets.findRRset(RRType::A(),
- RRClass::IN()));
- EXPECT_EQ(1, glue_child_rrsets.size());
+ findAllTest(Name("example.com"), ZoneFinder::NXDOMAIN, 0);
+
+ rrsets = findAllTest(rr_child_glue_->getName(), ZoneFinder::SUCCESS, 1);
+ EXPECT_FALSE(rrsets.end() == std::find(rrsets.begin(), rrsets.end(),
+ rr_child_glue_));
// TODO: test NXRRSET case after rbtree non-terminal logic has
// been implemented
@@ -663,16 +683,12 @@ TEST_F(InMemoryZoneFinderTest, findAny) {
EXPECT_NO_THROW(EXPECT_EQ(SUCCESS, zone_finder_.add(rr_child_ns_)));
// zone cut
- RRsetList child_rrsets;
- findTest(rr_child_ns_->getName(), RRType::ANY(), ZoneFinder::DELEGATION,
- true, rr_child_ns_, &child_rrsets);
- EXPECT_EQ(0, child_rrsets.size());
+ findAllTest(rr_child_ns_->getName(), ZoneFinder::DELEGATION, 0, NULL,
+ rr_child_ns_);
// glue for this zone cut
- RRsetList new_glue_child_rrsets;
- findTest(rr_child_glue_->getName(), RRType::ANY(), ZoneFinder::DELEGATION,
- true, rr_child_ns_, &new_glue_child_rrsets);
- EXPECT_EQ(0, new_glue_child_rrsets.size());
+ findAllTest(rr_child_glue_->getName(),ZoneFinder::DELEGATION, 0, NULL,
+ rr_child_ns_);
}
TEST_F(InMemoryZoneFinderTest, glue) {
@@ -693,26 +709,26 @@ TEST_F(InMemoryZoneFinderTest, glue) {
// If we do it in the "glue OK" mode, we should find the exact match.
findTest(rr_child_glue_->getName(), RRType::A(), ZoneFinder::SUCCESS, true,
- rr_child_glue_, NULL, NULL, ZoneFinder::FIND_GLUE_OK);
+ rr_child_glue_, NULL, ZoneFinder::FIND_GLUE_OK);
// glue OK + NXRRSET case
findTest(rr_child_glue_->getName(), RRType::AAAA(), ZoneFinder::NXRRSET,
- true, ConstRRsetPtr(), NULL, NULL, ZoneFinder::FIND_GLUE_OK);
+ true, ConstRRsetPtr(), NULL, ZoneFinder::FIND_GLUE_OK);
// glue OK + NXDOMAIN case
findTest(Name("www.child.example.org"), RRType::A(),
- ZoneFinder::DELEGATION, true, rr_child_ns_, NULL, NULL,
+ ZoneFinder::DELEGATION, true, rr_child_ns_, NULL,
ZoneFinder::FIND_GLUE_OK);
// nested cut case. The glue should be found.
findTest(rr_grandchild_glue_->getName(), RRType::AAAA(),
ZoneFinder::SUCCESS,
- true, rr_grandchild_glue_, NULL, NULL, ZoneFinder::FIND_GLUE_OK);
+ true, rr_grandchild_glue_, NULL, ZoneFinder::FIND_GLUE_OK);
// A non-existent name in nested cut. This should result in delegation
// at the highest zone cut.
findTest(Name("www.grand.child.example.org"), RRType::TXT(),
- ZoneFinder::DELEGATION, true, rr_child_ns_, NULL, NULL,
+ ZoneFinder::DELEGATION, true, rr_child_ns_, NULL,
ZoneFinder::FIND_GLUE_OK);
}
@@ -801,14 +817,14 @@ TEST_F(InMemoryZoneFinderTest, load) {
// Now see there are some rrsets (we don't look inside, though)
findTest(Name("."), RRType::SOA(), ZoneFinder::SUCCESS, false,
- ConstRRsetPtr(), NULL, &rootzone);
+ ConstRRsetPtr(), &rootzone);
findTest(Name("."), RRType::NS(), ZoneFinder::SUCCESS, false,
- ConstRRsetPtr(), NULL, &rootzone);
+ ConstRRsetPtr(), &rootzone);
findTest(Name("a.root-servers.net."), RRType::A(), ZoneFinder::SUCCESS,
- false, ConstRRsetPtr(), NULL, &rootzone);
+ false, ConstRRsetPtr(), &rootzone);
// But this should no longer be here
findTest(rr_ns_a_->getName(), RRType::AAAA(), ZoneFinder::NXDOMAIN, true,
- ConstRRsetPtr(), NULL, &rootzone);
+ ConstRRsetPtr(), &rootzone);
// Try loading zone that is wrong in a different way
EXPECT_THROW(zone_finder_.load(TEST_DATA_DIR "/duplicate_rrset.zone"),
@@ -846,14 +862,14 @@ TEST_F(InMemoryZoneFinderTest, wildcard) {
{
SCOPED_TRACE("Search at created child");
findTest(Name("a.wild.example.org"), RRType::A(), ZoneFinder::SUCCESS,
- false, rr_wild_, NULL, NULL, ZoneFinder::FIND_DEFAULT, true);
+ false, rr_wild_, NULL, ZoneFinder::FIND_DEFAULT, true);
}
// Search another created name, this time little bit lower
{
SCOPED_TRACE("Search at created grand-child");
findTest(Name("a.b.wild.example.org"), RRType::A(),
- ZoneFinder::SUCCESS, false, rr_wild_, NULL, NULL,
+ ZoneFinder::SUCCESS, false, rr_wild_, NULL,
ZoneFinder::FIND_DEFAULT, true);
}
@@ -885,7 +901,7 @@ TEST_F(InMemoryZoneFinderTest, delegatedWildcard) {
{
SCOPED_TRACE("Looking under delegation point in GLUE_OK mode");
findTest(Name("a.child.example.org"), RRType::A(),
- ZoneFinder::DELEGATION, true, rr_child_ns_, NULL, NULL,
+ ZoneFinder::DELEGATION, true, rr_child_ns_, NULL,
ZoneFinder::FIND_GLUE_OK);
}
}
@@ -897,9 +913,9 @@ TEST_F(InMemoryZoneFinderTest, anyWildcard) {
// First try directly the name (normal match)
{
SCOPED_TRACE("Asking direcly for *");
- RRsetList target;
- findTest(Name("*.wild.example.org"), RRType::ANY(),
- ZoneFinder::SUCCESS, true, ConstRRsetPtr(), &target);
+ const std::vector<ConstRRsetPtr>
+ target(findAllTest(Name("*.wild.example.org"), ZoneFinder::SUCCESS,
+ 1));
ASSERT_EQ(1, target.size());
EXPECT_EQ(RRType::A(), (*target.begin())->getType());
EXPECT_EQ(Name("*.wild.example.org"), (*target.begin())->getName());
@@ -908,10 +924,9 @@ TEST_F(InMemoryZoneFinderTest, anyWildcard) {
// Then a wildcard match
{
SCOPED_TRACE("Asking in the wild way");
- RRsetList target;
- findTest(Name("a.wild.example.org"), RRType::ANY(),
- ZoneFinder::SUCCESS, true, ConstRRsetPtr(), &target);
- ASSERT_EQ(1, target.size());
+ const std::vector<ConstRRsetPtr>
+ target(findAllTest(Name("a.wild.example.org"), ZoneFinder::SUCCESS,
+ 1));
EXPECT_EQ(RRType::A(), (*target.begin())->getType());
EXPECT_EQ(Name("a.wild.example.org"), (*target.begin())->getName());
}
@@ -943,15 +958,9 @@ TEST_F(InMemoryZoneFinderTest, emptyWildcard) {
{
SCOPED_TRACE("Asking for ANY record");
- RRsetList normalTarget;
- findTest(Name("*.foo.example.org"), RRType::ANY(), ZoneFinder::NXRRSET,
- true, ConstRRsetPtr(), &normalTarget);
- EXPECT_EQ(0, normalTarget.size());
-
- RRsetList wildTarget;
- findTest(Name("a.foo.example.org"), RRType::ANY(),
- ZoneFinder::NXRRSET, true, ConstRRsetPtr(), &wildTarget);
- EXPECT_EQ(0, wildTarget.size());
+ findAllTest(Name("*.foo.example.org"), ZoneFinder::NXRRSET, 0);
+
+ findAllTest(Name("a.foo.example.org"), ZoneFinder::NXRRSET, 0);
}
{
@@ -1011,10 +1020,7 @@ TEST_F(InMemoryZoneFinderTest, nestedEmptyWildcard) {
for (const char** name(names); *name != NULL; ++ name) {
SCOPED_TRACE(string("Node ") + *name);
- RRsetList target;
- findTest(Name(*name), RRType::ANY(), ZoneFinder::NXRRSET, true,
- ConstRRsetPtr(), &target);
- EXPECT_EQ(0, target.size());
+ findAllTest(Name(*name), ZoneFinder::NXRRSET, 0);
}
}
}
@@ -1054,7 +1060,7 @@ InMemoryZoneFinderTest::doCancelWildcardTest() {
SCOPED_TRACE(string("Node ") + *name);
findTest(Name(*name), RRType::A(), ZoneFinder::SUCCESS, false,
- rr_wild_, NULL, NULL, ZoneFinder::FIND_DEFAULT, true);
+ rr_wild_, NULL, ZoneFinder::FIND_DEFAULT, true);
}
}
@@ -1125,13 +1131,13 @@ TEST_F(InMemoryZoneFinderTest, swap) {
EXPECT_EQ(RRClass::IN(), finder2.getClass());
// make sure the zone data is swapped, too
findTest(origin_, RRType::NS(), ZoneFinder::NXDOMAIN, false,
- ConstRRsetPtr(), NULL, &finder1);
+ ConstRRsetPtr(), &finder1);
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
- ConstRRsetPtr(), NULL, &finder1);
+ ConstRRsetPtr(), &finder1);
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
- ConstRRsetPtr(), NULL, &finder2);
+ ConstRRsetPtr(), &finder2);
findTest(other_origin, RRType::TXT(), ZoneFinder::NXDOMAIN, false,
- ConstRRsetPtr(), NULL, &finder2);
+ ConstRRsetPtr(), &finder2);
}
TEST_F(InMemoryZoneFinderTest, getFileName) {
diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h
index 9fcd289..34aba82 100644
--- a/src/lib/datasrc/zone.h
+++ b/src/lib/datasrc/zone.h
@@ -237,9 +237,6 @@ public:
/// a successful match, and the code of \c SUCCESS will be returned.
/// - If the search name matches a delegation point of DNAME, it returns
/// the code of \c DNAME and that DNAME RR.
- /// - If the target isn't NULL, all RRsets under the domain are inserted
- /// there and SUCCESS (or NXDOMAIN, in case of empty domain) is returned
- /// instead of normall processing. This is intended to handle ANY query.
///
/// \note This behavior is controversial as we discussed in
/// https://lists.isc.org/pipermail/bind10-dev/2011-January/001918.html
@@ -273,16 +270,28 @@ public:
///
/// \param name The domain name to be searched for.
/// \param type The RR type to be searched for.
- /// \param target If target is not NULL, insert all RRs under the domain
- /// into it.
/// \param options The search options.
/// \return A \c FindResult object enclosing the search result (see above).
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type,
- isc::dns::RRsetList* target = NULL,
const FindOptions options
= FIND_DEFAULT) = 0;
+ ///
+ /// \brief Finds all RRsets in the given name.
+ ///
+ /// This function works almost exactly in the same way as the find one. The
+ /// only difference is, when the lookup is successful (eg. the code is
+ /// SUCCESS or WILDCARD), all the RRsets residing in the named node are
+ /// copied into the \c target parameter and the rrset member of the result
+ /// is NULL. All the other (unsuccessful) cases are handled the same,
+ /// including returning delegations, NSEC/NSEC3 proofs, etc. The options
+ /// parameter works the same way and it should comfort to the same exception
+ /// restrictions.
+ virtual FindResult findAll(const isc::dns::Name& name,
+ std::vector<isc::dns::ConstRRsetPtr> &target,
+ const FindOptions options = FIND_DEFAULT) = 0;
+
/// \brief Get previous name in the zone
///
/// Gets the previous name in the DNSSEC order. This can be used
More information about the bind10-changes
mailing list