BIND 10 trac1177, updated. 56f6a1ea6ef70f8dbed5083ae3b8f8e264e7c225 [1177] The findPreviousName
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 8 13:35:23 UTC 2011
The branch, trac1177 has been updated
via 56f6a1ea6ef70f8dbed5083ae3b8f8e264e7c225 (commit)
via 11d759dbbfb1eaf61b184caf2aba37eeca48c23d (commit)
from 91e77326e2f33dea91529a9157d46c27507f0a1a (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 56f6a1ea6ef70f8dbed5083ae3b8f8e264e7c225
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Sep 8 15:34:21 2011 +0200
[1177] The findPreviousName
But only if the underlying DB supports it. The SQLite3 one needs to be
still implemented.
commit 11d759dbbfb1eaf61b184caf2aba37eeca48c23d
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Sep 8 14:40:41 2011 +0200
[1177] Test for the previous name in DB
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.cc | 4 +-
src/lib/datasrc/database.h | 16 ++++++++++
src/lib/datasrc/sqlite3_accessor.cc | 5 +++
src/lib/datasrc/sqlite3_accessor.h | 4 ++
src/lib/datasrc/tests/database_unittest.cc | 45 ++++++++++++++++++++++++++++
src/lib/datasrc/zone.h | 4 +-
6 files changed, 74 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index bcd2a03..2c021c1 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -562,8 +562,8 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
}
Name
-DatabaseClient::Finder::findPreviousName(const Name&) const {
- return (Name::ROOT_NAME()); // TODO Implement
+DatabaseClient::Finder::findPreviousName(const Name& name) const {
+ return (Name(database_->findPreviousName(zone_id_, name.toText())));
}
Name
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index 75f8064..c6c435b 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -221,6 +221,22 @@ public:
* \return the name of the database
*/
virtual const std::string& getDBName() const = 0;
+
+ /**
+ * \brief It returns the previous name in DNSSEC/NSEC order.
+ *
+ * This is used in DatabaseClient::findPreviousName and does more
+ * or less the real work, except for working on strings.
+ *
+ * \param name The name to ask for previous of.
+ * \param zone_id The zone to look through.
+ * \return The previous name.
+ *
+ * \throw DataSourceError if there's a problem with the database.
+ * \throw NotImplemented if this database doesn't support DNSSEC.
+ */
+ virtual std::string findPreviousName(int zone_id,
+ const std::string& name) const = 0;
};
/**
diff --git a/src/lib/datasrc/sqlite3_accessor.cc b/src/lib/datasrc/sqlite3_accessor.cc
index 3cbaeab..023ba69 100644
--- a/src/lib/datasrc/sqlite3_accessor.cc
+++ b/src/lib/datasrc/sqlite3_accessor.cc
@@ -528,5 +528,10 @@ SQLite3Database::getAllRecords(int id) const {
return (IteratorContextPtr(new Context(shared_from_this(), id)));
}
+std::string
+SQLite3Database::findPreviousName(int , const std::string&) const {
+ return (std::string()); // TODO Test and implement
+}
+
}
}
diff --git a/src/lib/datasrc/sqlite3_accessor.h b/src/lib/datasrc/sqlite3_accessor.h
index bcbf358..59b3fbb 100644
--- a/src/lib/datasrc/sqlite3_accessor.h
+++ b/src/lib/datasrc/sqlite3_accessor.h
@@ -128,6 +128,10 @@ public:
/// "sqlite3_bind10.sqlite3".
virtual const std::string& getDBName() const { return (database_name_); }
+ /// \brief Concrete implementation of the pure virtual method
+ virtual std::string findPreviousName(int zone_id, const std::string& name)
+ const;
+
private:
/// \brief Private database data
boost::scoped_ptr<SQLite3Parameters> dbparameters_;
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 6bfaf11..6a8fac7 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -73,6 +73,11 @@ public:
isc_throw(isc::NotImplemented,
"This database datasource can't be iterated");
};
+
+ virtual std::string findPreviousName(int, const std::string&) const {
+ isc_throw(isc::NotImplemented,
+ "This data source doesn't support DNSSEC");
+ }
private:
const std::string database_name_;
@@ -273,6 +278,26 @@ public:
}
}
+ virtual std::string findPreviousName(int id, const std::string& name)
+ const
+ {
+ // Hardcoded for now, but we could compute it from the data
+ // Maybe do it when it is needed some time in future?
+ if (id == -1) {
+ isc_throw(isc::NotImplemented, "Test not implemented behaviour");
+ } else if (id == 42) {
+ if (name == "example.org.") {
+ return ("zzz.example.org.");
+ } else if (name == "www2.example.org.") {
+ return ("www.example.org.");
+ } else {
+ isc_throw(isc::Unexpected, "Unexpected name");
+ }
+ } else {
+ isc_throw(isc::Unexpected, "Unknown zone ID");
+ }
+ }
+
private:
typedef std::map<std::string, std::vector< std::vector<std::string> > >
Domains;
@@ -480,6 +505,9 @@ private:
addCurName("wild.*.foo.example.org.");
addRecord("A", "3600", "", "192.0.2.5");
addCurName("wild.*.foo.*.bar.example.org.");
+ // For finding previous, this one is the last in zone
+ addRecord("NSEC", "3600", "", "example.org NSEC");
+ addCurName("zzz.example.org");
}
};
@@ -1354,4 +1382,21 @@ TEST_F(DatabaseClientTest, getOrigin) {
EXPECT_EQ(isc::dns::Name("example.org"), finder->getOrigin());
}
+TEST_F(DatabaseClientTest, previous) {
+ shared_ptr<DatabaseClient::Finder> finder(getFinder());
+
+ EXPECT_EQ(Name("www.example.org."),
+ finder->findPreviousName(Name("www2.example.org.")));
+ // Check wrap around
+ EXPECT_EQ(Name("zzz.example.org."),
+ finder->findPreviousName(Name("example.org.")));
+ // Check it doesn't crash or anything if the underlying DB throws
+ DataSourceClient::FindResult
+ zone(client_->findZone(Name("bad.example.org")));
+ finder = dynamic_pointer_cast<DatabaseClient::Finder>(zone.zone_finder);
+
+ EXPECT_THROW(finder->findPreviousName(Name("bad.example.org")),
+ isc::NotImplemented);
+}
+
}
diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h
index 1c43aa9..722f23c 100644
--- a/src/lib/datasrc/zone.h
+++ b/src/lib/datasrc/zone.h
@@ -218,8 +218,8 @@ public:
/// \brief Get previous name in the zone
///
- /// Gets the previous name in the DNSSEC order. This can be used
- /// to find the correct NSEC or NSEC3 records for proving nonexistenc
+ /// Gets the previous name in the DNSSEC/NSEC order. This can be used
+ /// to find the correct NSEC records for proving nonexistenc
/// of domains.
///
/// The concrete implementation might throw anything it thinks appropriate,
More information about the bind10-changes
mailing list