BIND 10 trac551, updated. de81dbd26e42616b7c56718ffe1ffc7c6861b9e9 [trac551] Rename rrsets from wildcard match
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Feb 10 14:42:45 UTC 2011
The branch, trac551 has been updated
via de81dbd26e42616b7c56718ffe1ffc7c6861b9e9 (commit)
via 406ff425ec228f5b99a61576d8a576fbc76b3122 (commit)
from 2db67df75178a2bc407417540dde75e895eb619b (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 de81dbd26e42616b7c56718ffe1ffc7c6861b9e9
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 15:39:29 2011 +0100
[trac551] Rename rrsets from wildcard match
Everything is passed trough the prepareRRset, for consistency. In most
cases, it does nothing, just passes it trough.
commit 406ff425ec228f5b99a61576d8a576fbc76b3122
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Feb 10 15:38:53 2011 +0100
[trac551] Method for changing name of rrset
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory_datasrc.cc | 47 +++++++++++++++++++++++++++++++-----
1 files changed, 40 insertions(+), 7 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 82c623f..63d8aa4 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -351,6 +351,31 @@ struct MemoryZone::MemoryZoneImpl {
return (false);
}
+ /*
+ * Prepares a rrset to be return as a result.
+ *
+ * If rename is false, it returns the one provided. If it is true, it
+ * creates a new rrset with the same data but with provided name.
+ * It is designed for wildcard case, where we create the rrsets
+ * dynamically.
+ */
+ static ConstRRsetPtr prepareRRset(const Name& name, const ConstRRsetPtr&
+ rrset, bool rename)
+ {
+ if (rename) {
+ // TODO What about signatures? If we change the name, it would be
+ // wrong anyway...
+ RRsetPtr result(new RRset(name, rrset->getClass(),
+ rrset->getType(), rrset->getTTL()));
+ for (RdataIteratorPtr i(rrset->getRdataIterator()); !i->isLast();
+ i->next()) {
+ result->addRdata(i->getCurrent());
+ }
+ return (result);
+ } else {
+ return (rrset);
+ }
+ }
// Implementation of MemoryZone::find
FindResult find(const Name& name, RRType type,
@@ -360,6 +385,7 @@ struct MemoryZone::MemoryZoneImpl {
DomainNode* node(NULL);
FindState state(options);
RBTreeNodeChain<Domain> node_path;
+ bool rename(false);
switch (domains_.find(name, &node, node_path, cutCallback, &state)) {
case DomainTree::PARTIALMATCH:
/*
@@ -383,10 +409,12 @@ struct MemoryZone::MemoryZoneImpl {
if (state.dname_node_ != NULL) {
// We were traversing a DNAME node (and wanted to go
// lower below it), so return the DNAME
- return (FindResult(DNAME, state.rrset_));
+ return (FindResult(DNAME, prepareRRset(name, state.rrset_,
+ rename)));
}
if (state.zonecut_node_ != NULL) {
- return (FindResult(DELEGATION, state.rrset_));
+ return (FindResult(DELEGATION, prepareRRset(name,
+ state.rrset_, rename)));
}
/*
* No redirection anywhere. Let's try if it is a wildcard.
@@ -404,8 +432,9 @@ struct MemoryZone::MemoryZoneImpl {
* We have the wildcard node now. Jump below the switch,
* where handling of the common (exact-match) case is.
*
- * TODO: Some synthesis of RRsets for the wildcard node.
+ * However, rename it to the searched name.
*/
+ rename = true;
break;
}
@@ -440,7 +469,8 @@ struct MemoryZone::MemoryZoneImpl {
if (node->getFlag(DomainNode::FLAG_CALLBACK) && node != origin_data_) {
found = node->getData()->find(RRType::NS());
if (found != node->getData()->end()) {
- return (FindResult(DELEGATION, found->second));
+ return (FindResult(DELEGATION, prepareRRset(name,
+ found->second, rename)));
}
}
@@ -451,7 +481,8 @@ struct MemoryZone::MemoryZoneImpl {
found != node->getData()->end(); found++)
{
target->addRRset(
- boost::const_pointer_cast<RRset>(found->second));
+ boost::const_pointer_cast<RRset>(prepareRRset(name,
+ found->second, rename)));
}
return (FindResult(SUCCESS, ConstRRsetPtr()));
}
@@ -459,12 +490,14 @@ struct MemoryZone::MemoryZoneImpl {
found = node->getData()->find(type);
if (found != node->getData()->end()) {
// Good, it is here
- return (FindResult(SUCCESS, found->second));
+ return (FindResult(SUCCESS, prepareRRset(name, found->second,
+ rename)));
} else {
// Next, try CNAME.
found = node->getData()->find(RRType::CNAME());
if (found != node->getData()->end()) {
- return (FindResult(CNAME, found->second));
+ return (FindResult(CNAME, prepareRRset(name, found->second,
+ rename)));
}
}
// No exact match or CNAME. Return NXRRSET.
More information about the bind10-changes
mailing list