From c5944292e9ebee4a39fe939b9a16fe5596808556 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 31 Jul 2000 23:27:25 +0000 Subject: [PATCH] 361. [func] When the RBT find or chain functions set the name and origin for a node that stores the root label the name is now set to an empty name, instead of ".", to simplify later use of the name and origin by dns_name_concatenate(), dns_name_totext() or dns_name_format(). 360. [func] dns_name_totext() and dns_name_format() now allow an empty name to be passed, which is formatted as "@". --- CHANGES | 10 ++++++++++ bin/tests/rbt_test.c | 14 ++++---------- lib/dns/include/dns/rbt.h | 24 ++++++++++-------------- lib/dns/rbt.c | 24 ++++++++++++------------ 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CHANGES b/CHANGES index c7ecb444ac..3b5243eabc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ + 361. [func] When the RBT find or chain functions set the name and + origin for a node that stores the root label + the name is now set to an empty name, instead of ".", + to simplify later use of the name and origin by + dns_name_concatenate(), dns_name_totext() or + dns_name_format(). + + 360. [func] dns_name_totext() and dns_name_format() now allow + an empty name to be passed, which is formatted as "@". + 359. [bug] dnssec-signzone occasionally signed glue records. 358. [cleanup] Rename the intermediate files used by the dnssec diff --git a/bin/tests/rbt_test.c b/bin/tests/rbt_test.c index 80aafeb310..f326d654f4 100644 --- a/bin/tests/rbt_test.c +++ b/bin/tests/rbt_test.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbt_test.c,v 1.37 2000/07/31 22:33:59 tale Exp $ */ +/* $Id: rbt_test.c,v 1.38 2000/07/31 23:27:22 tale Exp $ */ #include @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -88,7 +89,7 @@ static void delete_name(void *data, void *arg) { dns_name_t *name; - (void)arg; + UNUSED(arg); name = data; isc_mem_put(mctx, data, sizeof(dns_name_t) + DNSNAMELEN); } @@ -168,14 +169,7 @@ detail(dns_rbt_t *rbt, dns_name_t *name) { if (result == ISC_R_SUCCESS) { printf("\n name from dns_rbtnodechain_current: "); - /* - * If foundname is absolute, it includes the origin (which - * is intrinsically known here to be just "."). - */ - - result = dns_name_concatenate(foundname, - dns_name_isabsolute(foundname) ? - NULL : origin, + result = dns_name_concatenate(foundname, origin, fullname, NULL); if (result == ISC_R_SUCCESS) print_name(fullname); diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index 56b3ac6d41..a2f46042e2 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbt.h,v 1.44 2000/07/27 09:48:10 tale Exp $ */ +/* $Id: rbt.h,v 1.45 2000/07/31 23:27:25 tale Exp $ */ #ifndef DNS_RBT_H #define DNS_RBT_H 1 @@ -117,21 +117,17 @@ typedef isc_result_t (*dns_rbtfindcallback_t)(dns_rbtnode_t *node, * accomplished with a dns_fixedname_t. It is _not_ necessary to reinitialize * either 'name' or 'origin' between calls to the chain functions. * - * NOTE WELL: the above rule means that when a chain points to the root of the - * tree of trees and that root stores only the root label, ".", it means that - * BOTH 'name' *and* 'origin' will be ".". As a common operation on - * 'name' and 'origin' is to dns_name_concatenate them after they have been - * set, special care must be taken to not concatenate 'name' if it is - * dns_name_isabsolute(), which is only true in this special circumstance. - * The logic behind having both 'name' and 'origin' be "." had to do with - * zone file dumping. It is likely that dumping of "." will be handled - * differently in the future and that the chain API will be changed such that - * in the case of ".", only 'origin' will be "." and name will be set to - * have zero labels. + * NOTE WELL: even though the name data at the root of the tree of trees will + * be absolute (typically just "."), it will will be made into a relative name + * with an origin of "." -- an empty name when the node is ".". This is + * because a common on operation on 'name' and 'origin' is to use + * dns_name_concatenate() on them to generate the complete name. An empty name + * can be detected when dns_name_countlabels == 0, and is printed by + * dns_name_totext()/dns_name_format() as "@", consistent with RFC1035's + * definition of "@" as the current origin. * * dns_rbtnodechain_current is similar to the _first, _last, _prev and _next - * functions but additionally can provide the node to which the chain points. - */ + * functions but additionally can provide the node to which the chain points. */ /* * For use in allocating space for the chain of ancestor nodes. diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 0f04f6a0ce..270e5d8979 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbt.c,v 1.88 2000/07/31 22:34:01 tale Exp $ */ +/* $Id: rbt.c,v 1.89 2000/07/31 23:27:24 tale Exp $ */ /* Principal Authors: DCL */ @@ -1948,7 +1948,8 @@ dns_rbtnodechain_init(dns_rbtnodechain_t *chain, isc_mem_t *mctx) { isc_result_t dns_rbtnodechain_current(dns_rbtnodechain_t *chain, dns_name_t *name, - dns_name_t *origin, dns_rbtnode_t **node) { + dns_name_t *origin, dns_rbtnode_t **node) +{ isc_result_t result = ISC_R_SUCCESS; REQUIRE(VALID_CHAIN(chain)); @@ -1964,18 +1965,17 @@ dns_rbtnodechain_current(dns_rbtnodechain_t *chain, dns_name_t *name, if (chain->level_count == 0) { /* - * Eliminate the root name, except when name is ".". + * Names in the top level tree are all absolute. + * Always make 'name' relative. */ - if (dns_name_countlabels(name) > 1) { - INSIST(dns_name_isabsolute(name)); + INSIST(dns_name_isabsolute(name)); - /* - * XXX EVIL. But what _should_ I do? - */ - name->labels--; - name->length--; - name->attributes &= ~DNS_NAMEATTR_ABSOLUTE; - } + /* + * This is cheaper than dns_name_getlabelsequence(). + */ + name->labels--; + name->length--; + name->attributes &= ~DNS_NAMEATTR_ABSOLUTE; } }