[svn] commit: r496 - in /branches/jelte-datasource1/src: bin/parkinglot/Makefile.am bin/parkinglot/data_source_plot.cc bin/parkinglot/parkinglot.cc bin/parkinglot/zoneset.h lib/dns/name.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jan 21 13:28:40 UTC 2010
Author: jelte
Date: Thu Jan 21 13:28:40 2010
New Revision: 496
Log:
parkinglots zoneset now contains Names instead of strings,
made std:set an attribute instead of zoneset a subclass
Added a very temporary operator< to Name (this is the 'old' name), which was needed for zoneset.
Made the DS API interaction a bit smarter
parkinglot can now return NXDOMAIN if you ask for a subdomain of a known one (still returns SERVFAIL for unknown zones)
Modified:
branches/jelte-datasource1/src/bin/parkinglot/Makefile.am
branches/jelte-datasource1/src/bin/parkinglot/data_source_plot.cc
branches/jelte-datasource1/src/bin/parkinglot/parkinglot.cc
branches/jelte-datasource1/src/bin/parkinglot/zoneset.h
branches/jelte-datasource1/src/lib/dns/name.cc
Modified: branches/jelte-datasource1/src/bin/parkinglot/Makefile.am
==============================================================================
--- branches/jelte-datasource1/src/bin/parkinglot/Makefile.am (original)
+++ branches/jelte-datasource1/src/bin/parkinglot/Makefile.am Thu Jan 21 13:28:40 2010
@@ -1,7 +1,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/ext
bin_PROGRAMS = parkinglot
-parkinglot_SOURCES = common.cc common.h zoneset.h parkinglot.cc
+parkinglot_SOURCES = common.cc common.h zoneset.h zoneset.cc parkinglot.cc
parkinglot_SOURCES += parkinglot.h ccsession.cc ccsession.h main.cc
parkinglot_SOURCES += data_source_plot.h data_source_plot.cc
parkinglot_LDADD = $(top_srcdir)/src/lib/dns/libdns.a $(top_srcdir)/src/lib/cc/cpp/libcc.a
Modified: branches/jelte-datasource1/src/bin/parkinglot/data_source_plot.cc
==============================================================================
--- branches/jelte-datasource1/src/bin/parkinglot/data_source_plot.cc (original)
+++ branches/jelte-datasource1/src/bin/parkinglot/data_source_plot.cc Thu Jan 21 13:28:40 2010
@@ -60,13 +60,7 @@
bool
DataSourceParkingLot::hasZoneFor(const Name& name, Name &zone_name)
{
- if (zones.contains(name.toText(true))) {
- zone_name = Name(name);
- return true;
- } else {
- /* try 1 level higher? i.e. www.asdf.nl? */
- return false;
- }
+ return zones.findClosest(name, zone_name);
}
SearchResult
@@ -78,7 +72,6 @@
Name authors_name("authors.bind");
Name version_name("version.bind");
- std::cout << "findRRset()" << std::endl;
if (clas == RRClass::CH) {
if (type == RRType::TXT) {
if (name == authors_name) {
@@ -104,16 +97,13 @@
result.addRRset(rrset);
result.setStatus(SearchResult::success);
} else {
- std::cout << "ch txt but unknown name" << std::endl;
result.setStatus(SearchResult::name_not_found);
}
} else {
result.setStatus(SearchResult::name_not_found);
}
} else if (clas == RRClass::IN) {
- // make zoneset contain Name instead of string?
- std::cout << "Finding zone for " << name.toText() << std::endl;
- if (zones.contains(name.toText(true))) {
+ if (zones.contains(name)) {
RRsetPtr rrset = RRsetPtr(new RRset(name, clas, type, TTL(3600)));
result.setStatus(SearchResult::success);
if (type == RRType::A) {
@@ -133,11 +123,14 @@
}
result.addRRset(rrset);
} else {
- std::cout << "zone not in zoneset" << std::endl;
- result.setStatus(SearchResult::zone_not_found);
+ // we don't have the name itself. Do we have the zone?
+ if (zones.contains(zone_name)) {
+ result.setStatus(SearchResult::name_not_found);
+ } else {
+ result.setStatus(SearchResult::zone_not_found);
+ }
}
} else {
- std::cout << "not ch or in" << std::endl;
result.setStatus(SearchResult::zone_not_found);
}
return result;
Modified: branches/jelte-datasource1/src/bin/parkinglot/parkinglot.cc
==============================================================================
--- branches/jelte-datasource1/src/bin/parkinglot/parkinglot.cc (original)
+++ branches/jelte-datasource1/src/bin/parkinglot/parkinglot.cc Thu Jan 21 13:28:40 2010
@@ -110,6 +110,7 @@
status = data_source.addToMessage(msg, SECTION_ANSWER, zname, name, qclass, qtype);
// rcode is based on this result?
if (status == SearchResult::name_not_found) {
+ msg.setRcode(Message::RCODE_NXDOMAIN);
if (qtype != RRType::NS) {
status = data_source.addToMessage(msg, SECTION_AUTHORITY, zname, zname, qclass, RRType::SOA);
}
Modified: branches/jelte-datasource1/src/bin/parkinglot/zoneset.h
==============================================================================
--- branches/jelte-datasource1/src/bin/parkinglot/zoneset.h (original)
+++ branches/jelte-datasource1/src/bin/parkinglot/zoneset.h Thu Jan 21 13:28:40 2010
@@ -18,23 +18,43 @@
#define __ZONESET_H 1
#include <set>
+#include <dns/buffer.h>
+#include <dns/name.h>
-class ZoneSet : std::set<std::string> {
- public:
- void serve(std::string s) {
- std::cout << "now serving: " << s << std::endl;
- this->insert(s);
- }
- void forget(std::string s) {
- std::cout << "no longer serving: " << s << std::endl;
- this->erase(s);
- }
- void clear_zones() {
- this->clear();
- }
- bool contains(std::string s) {
- return (this->find(s) != this->end());
- }
+class ZoneSet {
+public:
+ void serve(const std::string& s) {
+ serve(isc::dns::Name(s));
+ }
+
+ void serve(const isc::dns::Name& n) {
+ elements.insert(n);
+ }
+
+ void forget(const std::string& s) {
+ forget(isc::dns::Name(s));
+ }
+
+ void forget(const isc::dns::Name& n) {
+ elements.erase(n);
+ }
+
+ void clear_zones() {
+ elements.clear();
+ }
+
+ bool contains(const std::string& s) {
+ return contains(isc::dns::Name(s));
+ }
+
+ bool contains(const isc::dns::Name& n) {
+ return (elements.find(n) != elements.end());
+ }
+
+ bool findClosest(const isc::dns::Name& n, isc::dns::Name& closest);
+
+private:
+ std::set<isc::dns::Name> elements;
};
#endif // __ZONESET_H
Modified: branches/jelte-datasource1/src/lib/dns/name.cc
==============================================================================
--- branches/jelte-datasource1/src/lib/dns/name.cc (original)
+++ branches/jelte-datasource1/src/lib/dns/name.cc Thu Jan 21 13:28:40 2010
@@ -550,3 +550,15 @@
os << name.toText();
return (os);
}
+
+// temp (bad) comparison, compare not merged yet; needed for zoneset
+// in parkinglot, real version is in trunk, but currently incompatible
+// with this branch
+bool
+Name::operator<(const Name&other) const
+{
+ std::string a = toText();
+ std::string b = other.toText();
+ return a.compare(b);
+}
+
More information about the bind10-changes
mailing list