2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 15:05:23 +00:00

1528. [cleanup] Simplify some dns_name_ functions based on the

deprecation of bitstring labels.
This commit is contained in:
Tatuya JINMEI 神明達哉
2003-10-25 00:31:12 +00:00
parent 6da7c87a77
commit e407562a75
13 changed files with 115 additions and 365 deletions

View File

@@ -1,4 +1,5 @@
1528. [placeholder] 1528. [cleanup] Simplify some dns_name_ functions based on the
deprecation of bitstring labels.
1527. [cleanup] Reduce the number of gettimeofday() calls without 1527. [cleanup] Reduce the number of gettimeofday() calls without
losing necessary timer granularity. losing necessary timer granularity.

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: query.c,v 1.247 2003/09/30 05:56:01 marka Exp $ */ /* $Id: query.c,v 1.248 2003/10/25 00:31:06 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -1829,7 +1829,7 @@ query_addwildcardproof(ns_client_t *client, dns_db_t *db,
dns_name_t *tname; dns_name_t *tname;
dns_dbnode_t *node; dns_dbnode_t *node;
unsigned int options; unsigned int options;
unsigned int odepth, ndepth, i; unsigned int olabels, nlabels, i;
isc_boolean_t done; isc_boolean_t done;
isc_result_t result; isc_result_t result;
@@ -1870,11 +1870,11 @@ query_addwildcardproof(ns_client_t *client, dns_db_t *db,
query_releasename(client, &fname); query_releasename(client, &fname);
} }
odepth = dns_name_depth(dns_db_origin(db)); olabels = dns_name_countlabels(dns_db_origin(db));
ndepth = dns_name_depth(name); nlabels = dns_name_countlabels(name);
done = ISC_FALSE; done = ISC_FALSE;
for (i = ndepth - 1; i >= odepth && !done; i--) { for (i = nlabels - 1; i >= olabels && !done; i--) {
/* /*
* We'll need some resources... * We'll need some resources...
*/ */
@@ -1889,9 +1889,7 @@ query_addwildcardproof(ns_client_t *client, dns_db_t *db,
dns_fixedname_init(&tfixed); dns_fixedname_init(&tfixed);
tname = dns_fixedname_name(&tfixed); tname = dns_fixedname_name(&tfixed);
result = dns_name_splitatdepth(name, i, NULL, tname); dns_name_split(name, i, NULL, tname);
if (result != ISC_R_SUCCESS)
continue;
result = dns_name_concatenate(dns_wildcardname, tname, tname, result = dns_name_concatenate(dns_wildcardname, tname, tname,
NULL); NULL);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
@@ -1983,8 +1981,7 @@ query_addnxrrsetnsec(ns_client_t *client, dns_db_t *db, dns_name_t **namep,
fname = query_newname(client, dbuf, &b); fname = query_newname(client, dbuf, &b);
if (fname == NULL) if (fname == NULL)
return; return;
RUNTIME_CHECK(dns_name_splitatdepth(name, sig.labels + 1, NULL, dns_name_split(name, sig.labels + 1, NULL, fname);
fname) == ISC_R_SUCCESS);
/* This will succeed, since we've stripped labels. */ /* This will succeed, since we've stripped labels. */
RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, fname, fname, RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, fname, fname,
NULL) == ISC_R_SUCCESS); NULL) == ISC_R_SUCCESS);
@@ -2265,7 +2262,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdatasetiter_t *rdsiter; dns_rdatasetiter_t *rdsiter;
isc_boolean_t want_restart, authoritative, is_zone, need_wildcardproof; isc_boolean_t want_restart, authoritative, is_zone, need_wildcardproof;
unsigned int n, nlabels, nbits; unsigned int n, nlabels;
dns_namereln_t namereln; dns_namereln_t namereln;
int order; int order;
isc_buffer_t *dbuf; isc_buffer_t *dbuf;
@@ -2901,7 +2898,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
* we're going to have to split qname later on. * we're going to have to split qname later on.
*/ */
namereln = dns_name_fullcompare(client->query.qname, fname, namereln = dns_name_fullcompare(client->query.qname, fname,
&order, &nlabels, &nbits); &order, &nlabels);
INSIST(namereln == dns_namereln_subdomain); INSIST(namereln == dns_namereln_subdomain);
/* /*
* Keep a copy of the rdataset. We have to do this because * Keep a copy of the rdataset. We have to do this because
@@ -2958,12 +2955,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
*/ */
dns_fixedname_init(&fixed); dns_fixedname_init(&fixed);
prefix = dns_fixedname_name(&fixed); prefix = dns_fixedname_name(&fixed);
result = dns_name_split(client->query.qname, nlabels, nbits, dns_name_split(client->query.qname, nlabels, prefix, NULL);
prefix, NULL);
if (result != ISC_R_SUCCESS) {
dns_message_puttempname(client->message, &tname);
goto cleanup;
}
INSIST(fname == NULL); INSIST(fname == NULL);
dbuf = query_getnamebuf(client); dbuf = query_getnamebuf(client);
if (dbuf == NULL) { if (dbuf == NULL) {

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: name_test.c,v 1.34 2001/11/27 01:55:19 gson Exp $ */ /* $Id: name_test.c,v 1.35 2003/10/25 00:31:07 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -83,7 +83,7 @@ main(int argc, char *argv[]) {
isc_boolean_t test_downcase = ISC_FALSE; isc_boolean_t test_downcase = ISC_FALSE;
isc_boolean_t inplace = ISC_FALSE; isc_boolean_t inplace = ISC_FALSE;
isc_boolean_t want_split = ISC_FALSE; isc_boolean_t want_split = ISC_FALSE;
unsigned int depth, split_depth = 0; unsigned int labels, split_label = 0;
dns_fixedname_t fprefix, fsuffix; dns_fixedname_t fprefix, fsuffix;
dns_name_t *prefix, *suffix; dns_name_t *prefix, *suffix;
int ch; int ch;
@@ -107,7 +107,7 @@ main(int argc, char *argv[]) {
break; break;
case 's': case 's':
want_split = ISC_TRUE; want_split = ISC_TRUE;
split_depth = atoi(isc_commandline_argument); split_label = atoi(isc_commandline_argument);
break; break;
case 'w': case 'w':
check_wildcard = ISC_TRUE; check_wildcard = ISC_TRUE;
@@ -292,11 +292,11 @@ main(int argc, char *argv[]) {
if (comp != NULL && dns_name_countlabels(name) > 0) { if (comp != NULL && dns_name_countlabels(name) > 0) {
int order; int order;
unsigned int nlabels, nbits; unsigned int nlabels;
dns_namereln_t namereln; dns_namereln_t namereln;
namereln = dns_name_fullcompare(name, comp, &order, namereln = dns_name_fullcompare(name, comp, &order,
&nlabels, &nbits); &nlabels);
if (!quiet) { if (!quiet) {
if (order < 0) if (order < 0)
printf("<"); printf("<");
@@ -327,24 +327,18 @@ main(int argc, char *argv[]) {
dns_name_equal(name, comp) ? "TRUE" : "FALSE"); dns_name_equal(name, comp) ? "TRUE" : "FALSE");
} }
depth = dns_name_depth(name); labels = dns_name_countlabels(name);
if (want_split && split_depth < depth) { if (want_split && split_label < labels) {
dns_fixedname_init(&fprefix); dns_fixedname_init(&fprefix);
prefix = dns_fixedname_name(&fprefix); prefix = dns_fixedname_name(&fprefix);
dns_fixedname_init(&fsuffix); dns_fixedname_init(&fsuffix);
suffix = dns_fixedname_name(&fsuffix); suffix = dns_fixedname_name(&fsuffix);
printf("splitting at depth %u: ", split_depth); printf("splitting at label %u: ", split_label);
result = dns_name_splitatdepth(name, split_depth, dns_name_split(name, split_label, prefix, suffix);
prefix, suffix);
if (result == ISC_R_SUCCESS) {
printf("\n prefix = "); printf("\n prefix = ");
print_name(prefix); print_name(prefix);
printf(" suffix = "); printf(" suffix = ");
print_name(suffix); print_name(suffix);
} else {
printf("failed: %s\n",
isc_result_totext(result));
}
} }
if (concatenate) { if (concatenate) {

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: t_names.c,v 1.34 2002/08/27 04:53:39 marka Exp $ */ /* $Id: t_names.c,v 1.35 2003/10/25 00:31:08 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -710,7 +710,7 @@ t_dns_name_hash(void) {
} }
static const char *a10 = static const char *a10 =
"dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) " "dns_name_fullcompare(name1, name2, orderp, nlabelsp) "
"returns the DNSSEC ordering relationship between name1 and " "returns the DNSSEC ordering relationship between name1 and "
"name2, sets orderp to -1 if name1 < name2, to 0 if " "name2, sets orderp to -1 if name1 < name2, to 0 if "
"name1 == name2, or to 1 if name1 > name2, sets nlabelsp " "name1 == name2, or to 1 if name1 > name2, sets nlabelsp "
@@ -744,13 +744,12 @@ dns_namereln_to_text(dns_namereln_t reln) {
static int static int
test_dns_name_fullcompare(char *name1, char *name2, test_dns_name_fullcompare(char *name1, char *name2,
dns_namereln_t exp_dns_reln, dns_namereln_t exp_dns_reln,
int exp_order, int exp_nlabels, int exp_nbits) int exp_order, int exp_nlabels)
{ {
int result; int result;
int nfails; int nfails;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
dns_name_t dns_name1; dns_name_t dns_name1;
dns_name_t dns_name2; dns_name_t dns_name2;
isc_result_t dns_result; isc_result_t dns_result;
@@ -768,7 +767,7 @@ test_dns_name_fullcompare(char *name1, char *name2,
dns_result = dname_from_tname(name2, &dns_name2); dns_result = dname_from_tname(name2, &dns_name2);
if (dns_result == ISC_R_SUCCESS) { if (dns_result == ISC_R_SUCCESS) {
dns_reln = dns_name_fullcompare(&dns_name1, &dns_name2, dns_reln = dns_name_fullcompare(&dns_name1, &dns_name2,
&order, &nlabels, &nbits); &order, &nlabels);
if (dns_reln != exp_dns_reln) { if (dns_reln != exp_dns_reln) {
++nfails; ++nfails;
@@ -794,12 +793,6 @@ test_dns_name_fullcompare(char *name1, char *name2,
t_info("expecting %d labels, got %d\n", t_info("expecting %d labels, got %d\n",
exp_nlabels, nlabels); exp_nlabels, nlabels);
} }
if ((exp_nbits >= 0) &&
(nbits != (unsigned int)exp_nbits)) {
++nfails;
t_info("expecting %d bits, got %d\n",
exp_nbits, nbits);
}
if (nfails == 0) if (nfails == 0)
result = T_PASS; result = T_PASS;
else else
@@ -845,7 +838,7 @@ t_dns_name_fullcompare(void) {
if (cnt == 6) { if (cnt == 6) {
/* /*
* name1, name2, exp_reln, exp_order, * name1, name2, exp_reln, exp_order,
* exp_nlabels, exp_nbits * exp_nlabels
*/ */
if (!strcmp(Tokens[2], "none")) if (!strcmp(Tokens[2], "none"))
reln = dns_namereln_none; reln = dns_namereln_none;
@@ -867,8 +860,7 @@ t_dns_name_fullcompare(void) {
Tokens[1], Tokens[1],
reln, reln,
atoi(Tokens[3]), atoi(Tokens[3]),
atoi(Tokens[4]), atoi(Tokens[4]));
atoi(Tokens[5]));
} else { } else {
t_info("bad format at line %d\n", line); t_info("bad format at line %d\n", line);
} }
@@ -1509,7 +1501,6 @@ test_dns_name_fromregion(char *test_name) {
int result; int result;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
isc_result_t dns_result; isc_result_t dns_result;
dns_name_t dns_name1; dns_name_t dns_name1;
dns_name_t dns_name2; dns_name_t dns_name2;
@@ -1528,7 +1519,7 @@ test_dns_name_fromregion(char *test_name) {
dns_name_init(&dns_name2, NULL); dns_name_init(&dns_name2, NULL);
dns_name_fromregion(&dns_name2, &region); dns_name_fromregion(&dns_name2, &region);
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2,
&order, &nlabels, &nbits); &order, &nlabels);
if (dns_namereln == dns_namereln_equal) if (dns_namereln == dns_namereln_equal)
result = T_PASS; result = T_PASS;
else else
@@ -1647,7 +1638,6 @@ test_dns_name_fromtext(char *test_name1, char *test_name2, char *test_origin,
int result; int result;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
unsigned char junk1[BUFLEN]; unsigned char junk1[BUFLEN];
unsigned char junk2[BUFLEN]; unsigned char junk2[BUFLEN];
unsigned char junk3[BUFLEN]; unsigned char junk3[BUFLEN];
@@ -1711,7 +1701,7 @@ test_dns_name_fromtext(char *test_name1, char *test_name2, char *test_origin,
} }
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, &order, dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, &order,
&nlabels, &nbits); &nlabels);
if (dns_namereln == dns_namereln_equal) if (dns_namereln == dns_namereln_equal)
result = T_PASS; result = T_PASS;
@@ -1787,7 +1777,6 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) {
int len; int len;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
unsigned char junk1[BUFLEN]; unsigned char junk1[BUFLEN];
unsigned char junk2[BUFLEN]; unsigned char junk2[BUFLEN];
unsigned char junk3[BUFLEN]; unsigned char junk3[BUFLEN];
@@ -1847,7 +1836,7 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) {
} }
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2,
&order, &nlabels, &nbits); &order, &nlabels);
if (dns_namereln == dns_namereln_equal) if (dns_namereln == dns_namereln_equal)
result = T_PASS; result = T_PASS;
else { else {
@@ -1960,7 +1949,6 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase,
int result; int result;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
int len; int len;
unsigned char buf1[BIGBUFLEN]; unsigned char buf1[BIGBUFLEN];
char buf2[BUFLEN]; char buf2[BUFLEN];
@@ -1994,8 +1982,7 @@ test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase,
if (dns_result == ISC_R_SUCCESS) { if (dns_result == ISC_R_SUCCESS) {
dns_namereln = dns_name_fullcompare(&dns_name1, dns_namereln = dns_name_fullcompare(&dns_name1,
&dns_name2, &dns_name2,
&order, &nlabels, &order, &nlabels);
&nbits);
if (dns_namereln != dns_namereln_equal) { if (dns_namereln != dns_namereln_equal) {
t_info("dns_name_fullcompare returned %s\n", t_info("dns_name_fullcompare returned %s\n",
dns_namereln_to_text(dns_namereln)); dns_namereln_to_text(dns_namereln));

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: t_rbt.c,v 1.23 2001/01/09 21:42:11 bwelling Exp $ */ /* $Id: t_rbt.c,v 1.24 2003/10/25 00:31:08 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -581,7 +581,6 @@ t9_walkchain(dns_rbtnodechain_t *chain, dns_rbt_t *rbt) {
int cnt; int cnt;
int order; int order;
unsigned int nlabels; unsigned int nlabels;
unsigned int nbits;
int nprobs; int nprobs;
isc_result_t dns_result; isc_result_t dns_result;
@@ -668,7 +667,7 @@ t9_walkchain(dns_rbtnodechain_t *chain, dns_rbt_t *rbt) {
(void)dns_name_fullcompare( (void)dns_name_fullcompare(
dns_fixedname_name(&fullname1), dns_fixedname_name(&fullname1),
dns_fixedname_name(&fullname2), dns_fixedname_name(&fullname2),
&order, &nlabels, &nbits); &order, &nlabels);
if (order >= 0) { if (order >= 0) {
t_info("unexpected order %s %s %s\n", t_info("unexpected order %s %s %s\n",

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: adb.c,v 1.210 2003/10/17 03:46:43 marka Exp $ */ /* $Id: adb.c,v 1.211 2003/10/25 00:31:08 jinmei Exp $ */
/* /*
* Implementation notes * Implementation notes
@@ -958,7 +958,7 @@ set_target(dns_adb_t *adb, dns_name_t *name, dns_name_t *fname,
{ {
isc_result_t result; isc_result_t result;
dns_namereln_t namereln; dns_namereln_t namereln;
unsigned int nlabels, nbits; unsigned int nlabels;
int order; int order;
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
dns_fixedname_t fixed1, fixed2; dns_fixedname_t fixed1, fixed2;
@@ -987,8 +987,7 @@ set_target(dns_adb_t *adb, dns_name_t *name, dns_name_t *fname,
dns_rdata_dname_t dname; dns_rdata_dname_t dname;
INSIST(rdataset->type == dns_rdatatype_dname); INSIST(rdataset->type == dns_rdatatype_dname);
namereln = dns_name_fullcompare(name, fname, &order, namereln = dns_name_fullcompare(name, fname, &order, &nlabels);
&nlabels, &nbits);
INSIST(namereln == dns_namereln_subdomain); INSIST(namereln == dns_namereln_subdomain);
/* /*
* Get the target name of the DNAME. * Get the target name of the DNAME.
@@ -1007,13 +1006,7 @@ set_target(dns_adb_t *adb, dns_name_t *name, dns_name_t *fname,
prefix = dns_fixedname_name(&fixed1); prefix = dns_fixedname_name(&fixed1);
dns_fixedname_init(&fixed2); dns_fixedname_init(&fixed2);
new_target = dns_fixedname_name(&fixed2); new_target = dns_fixedname_name(&fixed2);
result = dns_name_split(name, nlabels, nbits, prefix, NULL); dns_name_split(name, nlabels, prefix, NULL);
if (result != ISC_R_SUCCESS) {
dns_rdata_freestruct(&dname);
return (result);
}
result = dns_name_concatenate(prefix, &dname.dname, new_target,
NULL);
dns_rdata_freestruct(&dname); dns_rdata_freestruct(&dname);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);

View File

@@ -16,7 +16,7 @@
*/ */
/* /*
* $Id: dnssec.c,v 1.77 2003/09/30 05:56:10 marka Exp $ * $Id: dnssec.c,v 1.78 2003/10/25 00:31:09 jinmei Exp $
*/ */
@@ -182,7 +182,7 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
dns_fixedname_t fnewname; dns_fixedname_t fnewname;
REQUIRE(name != NULL); REQUIRE(name != NULL);
REQUIRE(dns_name_depth(name) <= 255); REQUIRE(dns_name_countlabels(name) <= 255);
REQUIRE(set != NULL); REQUIRE(set != NULL);
REQUIRE(key != NULL); REQUIRE(key != NULL);
REQUIRE(inception != NULL); REQUIRE(inception != NULL);
@@ -212,7 +212,7 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
sig.covered = set->type; sig.covered = set->type;
sig.algorithm = dst_key_alg(key); sig.algorithm = dst_key_alg(key);
sig.labels = dns_name_depth(name) - 1; sig.labels = dns_name_countlabels(name) - 1;
if (dns_name_iswildcard(name)) if (dns_name_iswildcard(name))
sig.labels--; sig.labels--;
sig.originalttl = set->ttl; sig.originalttl = set->ttl;
@@ -403,11 +403,10 @@ dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
* If the name is an expanded wildcard, use the wildcard name. * If the name is an expanded wildcard, use the wildcard name.
*/ */
dns_fixedname_init(&fnewname); dns_fixedname_init(&fnewname);
labels = dns_name_depth(name) - 1; labels = dns_name_countlabels(name) - 1;
if (labels - sig.labels > 0) { if (labels - sig.labels > 0) {
RUNTIME_CHECK(dns_name_splitatdepth(name, sig.labels + 1, NULL, dns_name_split(name, sig.labels + 1, NULL,
dns_fixedname_name(&fnewname)) dns_fixedname_name(&fnewname));
== ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_downcase(dns_fixedname_name(&fnewname), RUNTIME_CHECK(dns_name_downcase(dns_fixedname_name(&fnewname),
dns_fixedname_name(&fnewname), dns_fixedname_name(&fnewname),
NULL) NULL)

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: name.h,v 1.103 2003/07/25 02:22:25 marka Exp $ */ /* $Id: name.h,v 1.104 2003/10/25 00:31:12 jinmei Exp $ */
#ifndef DNS_NAME_H #ifndef DNS_NAME_H
#define DNS_NAME_H 1 #define DNS_NAME_H 1
@@ -291,21 +291,6 @@ dns_name_iswildcard(const dns_name_t *name);
* FALSE The least significant label of 'name' is not '*'. * FALSE The least significant label of 'name' is not '*'.
*/ */
isc_boolean_t
dns_name_requiresedns(const dns_name_t *name);
/*
* Does 'name' require EDNS for transmission?
*
* Requires:
* 'name' is a valid name
*
* dns_name_countlabels(name) > 0
*
* Returns:
* TRUE The name requires EDNS to be transmitted.
* FALSE The name does not require EDNS to be transmitted.
*/
unsigned int unsigned int
dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive); dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive);
/* /*
@@ -359,8 +344,7 @@ dns_name_hashbylabel(dns_name_t *name, isc_boolean_t case_sensitive);
dns_namereln_t dns_namereln_t
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
int *orderp, int *orderp, unsigned int *nlabelsp);
unsigned int *nlabelsp, unsigned int *nbitsp);
/* /*
* Determine the relative ordering under the DNSSEC order relation of * Determine the relative ordering under the DNSSEC order relation of
* 'name1' and 'name2', and also determine the hierarchical * 'name1' and 'name2', and also determine the hierarchical
@@ -380,7 +364,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
* *
* dns_name_countlabels(name2) > 0 * dns_name_countlabels(name2) > 0
* *
* orderp, nlabelsp, and nbitsp are valid pointers. * orderp and nlabelsp are valid pointers.
* *
* Either name1 is absolute and name2 is absolute, or neither is. * Either name1 is absolute and name2 is absolute, or neither is.
* *
@@ -391,9 +375,6 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
* *
* *nlabelsp is the number of common significant labels. * *nlabelsp is the number of common significant labels.
* *
* Since we dropped the support of bitstring labels, *nbitsp is always
* set to 0.
*
* Returns: * Returns:
* dns_namereln_none There's no hierarchical relationship * dns_namereln_none There's no hierarchical relationship
* between name1 and name2. * between name1 and name2.
@@ -537,25 +518,6 @@ dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname);
* FALSE 'name' does not match the wildcard specified in 'wname' * FALSE 'name' does not match the wildcard specified in 'wname'
*/ */
unsigned int
dns_name_depth(const dns_name_t *name);
/*
* The depth of 'name'.
*
* Notes:
* The "depth" of a name represents how far down the DNS tree of trees
* the name is. For each wire-encoding label in name, the depth is
* increased by 1 for an ordinary label.
*
* Depth is used when creating or validating DNSSEC signatures.
*
* Requires:
* 'name' is a valid name
*
* Returns:
* The depth of 'name'.
*/
/*** /***
*** Labels *** Labels
***/ ***/
@@ -960,18 +922,16 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix,
* DNS_R_NAMETOOLONG * DNS_R_NAMETOOLONG
*/ */
isc_result_t void
dns_name_split(dns_name_t *name, dns_name_split(dns_name_t *name, unsigned int suffixlabels,
unsigned int suffixlabels, unsigned int nbits,
dns_name_t *prefix, dns_name_t *suffix); dns_name_t *prefix, dns_name_t *suffix);
/* /*
* *
* Split 'name' into two pieces on a label or bitlabel boundary. * Split 'name' into two pieces on a label boundary.
* *
* Notes: * Notes:
* 'name' is split such that 'suffix' holds the most significant * 'name' is split such that 'suffix' holds the most significant
* 'suffixlabels' labels. All other labels and bits are stored * 'suffixlabels' labels. All other labels are stored in 'prefix'.
* in 'prefix'.
* *
* Copying name data is avoided as much as possible, so 'prefix' * Copying name data is avoided as much as possible, so 'prefix'
* and 'suffix' will end up pointing at the data for 'name'. * and 'suffix' will end up pointing at the data for 'name'.
@@ -988,8 +948,6 @@ dns_name_split(dns_name_t *name,
* *
* 'suffixlabels' cannot exceed the number of labels in 'name'. * 'suffixlabels' cannot exceed the number of labels in 'name'.
* *
* 'nbits' must be 0, since we dropped the support of bitstring labels.
*
* 'prefix' is a valid name or NULL, and cannot be read-only. * 'prefix' is a valid name or NULL, and cannot be read-only.
* *
* 'suffix' is a valid name or NULL, and cannot be read-only. * 'suffix' is a valid name or NULL, and cannot be read-only.
@@ -1016,39 +974,6 @@ dns_name_split(dns_name_t *name,
* ISC_R_SUCCESS No worries. (This function should always success). * ISC_R_SUCCESS No worries. (This function should always success).
*/ */
isc_result_t
dns_name_splitatdepth(dns_name_t *name, unsigned int depth,
dns_name_t *prefix, dns_name_t *suffix);
/*
* Split 'name' into two pieces at a certain depth.
*
* Requires:
* 'name' is a valid non-empty name.
*
* depth > 0
*
* depth <= dns_name_depth(name)
*
* The preconditions of dns_name_split() apply to 'prefix' and 'suffix'.
*
* Ensures:
*
* On success:
* If 'prefix' is not NULL it will contain the least significant
* labels.
*
* If 'suffix' is not NULL it will contain the most significant
* labels. dns_name_countlabels(suffix) will be equal to
* suffixlabels.
*
* On failure:
* Either 'prefix' or 'suffix' is invalidated (depending
* on which one the problem was encountered with).
*
* Returns:
* The possible result codes are the same as those of dns_name_split().
*/
isc_result_t isc_result_t
dns_name_dup(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target); dns_name_dup(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target);
/* /*
@@ -1264,6 +1189,13 @@ do { \
(r)->length = (n)->length; \ (r)->length = (n)->length; \
} while (0); } while (0);
#define DNS_NAME_SPLIT(n, l, p, s) \
do { \
if ((p) != NULL) \
dns_name_getlabelsequence((n), 0, (n)->labels - (l), (p)); \
if ((s) != NULL) \
dns_name_getlabelsequence((n), (n)->labels - (l), (l), (s)); \
} while (0);
#ifdef DNS_NAME_USEINLINE #ifdef DNS_NAME_USEINLINE
@@ -1273,6 +1205,7 @@ do { \
#define dns_name_countlabels(n) DNS_NAME_COUNTLABELS(n) #define dns_name_countlabels(n) DNS_NAME_COUNTLABELS(n)
#define dns_name_isabsolute(n) DNS_NAME_ISABSOLUTE(n) #define dns_name_isabsolute(n) DNS_NAME_ISABSOLUTE(n)
#define dns_name_toregion(n, r) DNS_NAME_TOREGION(n, r) #define dns_name_toregion(n, r) DNS_NAME_TOREGION(n, r)
#define dns_name_split(n, l, p, s) DNS_NAME_SPLIT(n, l, p, s)
#endif /* DNS_NAME_USEINLINE */ #endif /* DNS_NAME_USEINLINE */

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: lookup.c,v 1.11 2003/09/30 05:56:10 marka Exp $ */ /* $Id: lookup.c,v 1.12 2003/10/25 00:31:09 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -188,7 +188,7 @@ lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
dns_name_t *name, *fname, *prefix; dns_name_t *name, *fname, *prefix;
dns_fixedname_t foundname, fixed; dns_fixedname_t foundname, fixed;
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
unsigned int nlabels, nbits; unsigned int nlabels;
int order; int order;
dns_namereln_t namereln; dns_namereln_t namereln;
dns_rdata_cname_t cname; dns_rdata_cname_t cname;
@@ -276,7 +276,7 @@ lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
break; break;
case DNS_R_DNAME: case DNS_R_DNAME:
namereln = dns_name_fullcompare(name, fname, &order, namereln = dns_name_fullcompare(name, fname, &order,
&nlabels, &nbits); &nlabels);
INSIST(namereln == dns_namereln_subdomain); INSIST(namereln == dns_namereln_subdomain);
/* /*
* Get the target name of the DNAME. * Get the target name of the DNAME.
@@ -294,12 +294,7 @@ lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
*/ */
dns_fixedname_init(&fixed); dns_fixedname_init(&fixed);
prefix = dns_fixedname_name(&fixed); prefix = dns_fixedname_name(&fixed);
result = dns_name_split(name, nlabels, nbits, prefix, dns_name_split(name, nlabels, prefix, NULL);
NULL);
if (result != ISC_R_SUCCESS) {
dns_rdata_freestruct(&dname);
break;
}
result = dns_name_concatenate(prefix, &dname.dname, result = dns_name_concatenate(prefix, &dname.dname,
name, NULL); name, NULL);
dns_rdata_freestruct(&dname); dns_rdata_freestruct(&dname);

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: name.c,v 1.141 2003/10/17 03:46:43 marka Exp $ */ /* $Id: name.c,v 1.142 2003/10/25 00:31:10 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -278,21 +278,6 @@ dns_name_iswildcard(const dns_name_t *name) {
return (ISC_FALSE); return (ISC_FALSE);
} }
isc_boolean_t
dns_name_requiresedns(const dns_name_t *name) {
/*
* Does 'name' require EDNS for transmission?
* Since we dropped the support of bitstring labels, this function
* currently returns a constant value; ISC_FALSE.
*/
REQUIRE(VALID_NAME(name));
REQUIRE(name->labels > 0);
UNUSED(name);
return (ISC_FALSE);
}
static inline unsigned int static inline unsigned int
name_hash(dns_name_t *name, isc_boolean_t case_sensitive) { name_hash(dns_name_t *name, isc_boolean_t case_sensitive) {
unsigned int length; unsigned int length;
@@ -390,8 +375,7 @@ dns_name_hashbylabel(dns_name_t *name, isc_boolean_t case_sensitive) {
dns_namereln_t dns_namereln_t
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
int *orderp, int *orderp, unsigned int *nlabelsp)
unsigned int *nlabelsp, unsigned int *nbitsp)
{ {
unsigned int l1, l2, l, count1, count2, count, nlabels; unsigned int l1, l2, l, count1, count2, count, nlabels;
int cdiff, ldiff, chdiff; int cdiff, ldiff, chdiff;
@@ -415,7 +399,6 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
REQUIRE(VALID_NAME(name2)); REQUIRE(VALID_NAME(name2));
REQUIRE(orderp != NULL); REQUIRE(orderp != NULL);
REQUIRE(nlabelsp != NULL); REQUIRE(nlabelsp != NULL);
REQUIRE(nbitsp != NULL);
/* /*
* Either name1 is absolute and name2 is absolute, or neither is. * Either name1 is absolute and name2 is absolute, or neither is.
*/ */
@@ -483,7 +466,6 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
done: done:
*nlabelsp = nlabels; *nlabelsp = nlabels;
*nbitsp = 0;
if (nlabels > 0 && namereln == dns_namereln_none) if (nlabels > 0 && namereln == dns_namereln_none)
namereln = dns_namereln_commonancestor; namereln = dns_namereln_commonancestor;
@@ -494,7 +476,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
int int
dns_name_compare(const dns_name_t *name1, const dns_name_t *name2) { dns_name_compare(const dns_name_t *name1, const dns_name_t *name2) {
int order; int order;
unsigned int nlabels, nbits; unsigned int nlabels;
/* /*
* Determine the relative ordering under the DNSSEC order relation of * Determine the relative ordering under the DNSSEC order relation of
@@ -506,7 +488,7 @@ dns_name_compare(const dns_name_t *name1, const dns_name_t *name2) {
* same domain. * same domain.
*/ */
(void)dns_name_fullcompare(name1, name2, &order, &nlabels, &nbits); (void)dns_name_fullcompare(name1, name2, &order, &nlabels);
return (order); return (order);
} }
@@ -624,7 +606,7 @@ dns_name_rdatacompare(const dns_name_t *name1, const dns_name_t *name2) {
isc_boolean_t isc_boolean_t
dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) { dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) {
int order; int order;
unsigned int nlabels, nbits; unsigned int nlabels;
dns_namereln_t namereln; dns_namereln_t namereln;
/* /*
@@ -636,8 +618,7 @@ dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) {
* same domain. * same domain.
*/ */
namereln = dns_name_fullcompare(name1, name2, &order, &nlabels, namereln = dns_name_fullcompare(name1, name2, &order, &nlabels);
&nbits);
if (namereln == dns_namereln_subdomain || if (namereln == dns_namereln_subdomain ||
namereln == dns_namereln_equal) namereln == dns_namereln_equal)
return (ISC_TRUE); return (ISC_TRUE);
@@ -648,7 +629,7 @@ dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) {
isc_boolean_t isc_boolean_t
dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) { dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) {
int order; int order;
unsigned int nlabels, nbits, labels; unsigned int nlabels, labels;
dns_name_t tname; dns_name_t tname;
REQUIRE(VALID_NAME(name)); REQUIRE(VALID_NAME(name));
@@ -660,46 +641,12 @@ dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) {
DNS_NAME_INIT(&tname, NULL); DNS_NAME_INIT(&tname, NULL);
dns_name_getlabelsequence(wname, 1, labels - 1, &tname); dns_name_getlabelsequence(wname, 1, labels - 1, &tname);
if (dns_name_fullcompare(name, &tname, &order, &nlabels, &nbits) == if (dns_name_fullcompare(name, &tname, &order, &nlabels) ==
dns_namereln_subdomain) dns_namereln_subdomain)
return (ISC_TRUE); return (ISC_TRUE);
return (ISC_FALSE); return (ISC_FALSE);
} }
unsigned int
dns_name_depth(const dns_name_t *name) {
unsigned int depth, count, nrem;
unsigned char *ndata;
/*
* The depth of 'name'.
*/
REQUIRE(VALID_NAME(name));
if (name->labels == 0)
return (0);
depth = 0;
ndata = name->ndata;
nrem = name->length;
while (nrem > 0) {
count = *ndata++;
INSIST(count <= 63); /* no bitstring support */
nrem--;
depth++;
if (count == 0)
break;
INSIST(nrem >= count);
nrem -= count;
ndata += count;
}
return (depth);
}
unsigned int unsigned int
dns_name_countlabels(const dns_name_t *name) { dns_name_countlabels(const dns_name_t *name) {
/* /*
@@ -1863,17 +1810,13 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name,
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
isc_result_t void
dns_name_split(dns_name_t *name, dns_name_split(dns_name_t *name, unsigned int suffixlabels,
unsigned int suffixlabels, unsigned int nbits,
dns_name_t *prefix, dns_name_t *suffix) dns_name_t *prefix, dns_name_t *suffix)
{ {
dns_offsets_t name_odata;
unsigned char *offsets;
unsigned int splitlabel; unsigned int splitlabel;
REQUIRE(nbits == 0); /* no bitstring support */
REQUIRE(VALID_NAME(name)); REQUIRE(VALID_NAME(name));
REQUIRE(suffixlabels > 0); REQUIRE(suffixlabels > 0);
REQUIRE(suffixlabels < name->labels); REQUIRE(suffixlabels < name->labels);
@@ -1887,8 +1830,6 @@ dns_name_split(dns_name_t *name,
suffix->buffer != NULL && suffix->buffer != NULL &&
BINDABLE(suffix))); BINDABLE(suffix)));
SETUP_OFFSETS(name, offsets, name_odata);
splitlabel = name->labels - suffixlabels; splitlabel = name->labels - suffixlabels;
if (prefix != NULL) if (prefix != NULL)
@@ -1898,51 +1839,7 @@ dns_name_split(dns_name_t *name,
dns_name_getlabelsequence(name, splitlabel, dns_name_getlabelsequence(name, splitlabel,
suffixlabels, suffix); suffixlabels, suffix);
return (ISC_R_SUCCESS); return;
}
isc_result_t
dns_name_splitatdepth(dns_name_t *name, unsigned int depth,
dns_name_t *prefix, dns_name_t *suffix)
{
unsigned int suffixlabels, label, count;
unsigned char *offsets, *ndata;
dns_offsets_t odata;
/*
* Split 'name' into two pieces at a certain depth.
*/
REQUIRE(VALID_NAME(name));
REQUIRE(name->labels > 0);
REQUIRE(depth > 0);
SETUP_OFFSETS(name, offsets, odata);
suffixlabels = 0;
label = name->labels;
do {
label--;
ndata = &name->ndata[offsets[label]];
count = *ndata++;
INSIST(count <= 63); /* no bitstring support */
suffixlabels++;
depth--;
} while (depth != 0 && label != 0);
/*
* If depth is not zero, then the caller violated the requirement
* that depth <= dns_name_depth(name).
*/
if (depth != 0) {
REQUIRE(depth <= dns_name_depth(name));
/*
* We should never get here!
*/
INSIST(0);
}
return (dns_name_split(name, suffixlabels, 0, prefix, suffix));
} }
isc_result_t isc_result_t

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: rbt.c,v 1.124 2003/05/08 04:03:25 marka Exp $ */ /* $Id: rbt.c,v 1.125 2003/10/25 00:31:10 jinmei Exp $ */
/* Principal Authors: DCL */ /* Principal Authors: DCL */
@@ -352,7 +352,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
dns_namereln_t compared; dns_namereln_t compared;
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
dns_rbtnodechain_t chain; dns_rbtnodechain_t chain;
unsigned int common_labels, common_bits; unsigned int common_labels;
int order; int order;
REQUIRE(VALID_RBT(rbt)); REQUIRE(VALID_RBT(rbt));
@@ -398,13 +398,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
NODENAME(current, &current_name); NODENAME(current, &current_name);
compared = dns_name_fullcompare(add_name, &current_name, compared = dns_name_fullcompare(add_name, &current_name,
&order, &order, &common_labels);
&common_labels, &common_bits);
/*
* since we dropped the support of bitstring labels,
* common_bits should always be set to 0.
*/
INSIST(common_bits == 0);
if (compared == dns_namereln_equal) { if (compared == dns_namereln_equal) {
*nodep = current; *nodep = current;
@@ -445,14 +439,9 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
* not-in-common part to be searched for * not-in-common part to be searched for
* in the next level. * in the next level.
*/ */
result = dns_name_split(add_name, dns_name_split(add_name, common_labels,
common_labels,
common_bits,
add_name, NULL); add_name, NULL);
if (result != ISC_R_SUCCESS)
break;
/* /*
* Follow the down pointer (possibly NULL). * Follow the down pointer (possibly NULL).
*/ */
@@ -505,12 +494,8 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
* two names and a suffix that is the common * two names and a suffix that is the common
* parts of them. * parts of them.
*/ */
result = dns_name_split(&current_name, dns_name_split(&current_name, common_labels,
common_labels,
common_bits,
prefix, suffix); prefix, suffix);
if (result == ISC_R_SUCCESS)
result = create_node(rbt->mctx, suffix, result = create_node(rbt->mctx, suffix,
&new_current); &new_current);
@@ -602,12 +587,8 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) {
* result != ISC_R_SUCCESS, which * result != ISC_R_SUCCESS, which
* is tested after the loop ends). * is tested after the loop ends).
*/ */
result = dns_name_split(add_name, dns_name_split(add_name, common_labels,
common_labels, add_name, NULL);
common_bits,
add_name,
NULL);
break; break;
} }
@@ -687,7 +668,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
dns_fixedname_t fixedcallbackname, fixedsearchname; dns_fixedname_t fixedcallbackname, fixedsearchname;
dns_namereln_t compared; dns_namereln_t compared;
isc_result_t result, saved_result; isc_result_t result, saved_result;
unsigned int common_labels, common_bits; unsigned int common_labels;
int order; int order;
REQUIRE(VALID_RBT(rbt)); REQUIRE(VALID_RBT(rbt));
@@ -725,9 +706,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
/* /*
* search_name is the name segment being sought in each tree level. * search_name is the name segment being sought in each tree level.
* By using a fixedname, the search_name will definitely have offsets * By using a fixedname, the search_name will definitely have offsets
* and a buffer for use by any splitting that happens in the middle * for use by any splitting.
* of a bitstring label. (XXXJT: this can be skipped since we dropped
* bitstring labels).
* By using dns_name_clone, no name data should be copied thanks to * By using dns_name_clone, no name data should be copied thanks to
* the lack of bitstring labels. * the lack of bitstring labels.
*/ */
@@ -744,8 +723,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
while (current != NULL) { while (current != NULL) {
NODENAME(current, &current_name); NODENAME(current, &current_name);
compared = dns_name_fullcompare(search_name, &current_name, compared = dns_name_fullcompare(search_name, &current_name,
&order, &order, &common_labels);
&common_labels, &common_bits);
last_compared = current; last_compared = current;
if (compared == dns_namereln_equal) if (compared == dns_namereln_equal)
@@ -825,7 +803,6 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
break; break;
} else { } else {
common_labels = tlabels; common_labels = tlabels;
common_bits = 0;
compared = dns_namereln_subdomain; compared = dns_namereln_subdomain;
goto subdomain; goto subdomain;
} }
@@ -866,15 +843,8 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
* Whack off the current node's common parts * Whack off the current node's common parts
* for the name to search in the next level. * for the name to search in the next level.
*/ */
result = dns_name_split(search_name, dns_name_split(search_name, common_labels,
common_labels,
common_bits,
search_name, NULL); search_name, NULL);
if (result != ISC_R_SUCCESS) {
dns_rbtnodechain_reset(chain);
return (result);
}
/* /*
* This might be the closest enclosing name. * This might be the closest enclosing name.
*/ */
@@ -1086,8 +1056,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname,
search_name, search_name,
&current_name, &current_name,
&order, &order,
&common_labels, &common_labels);
&common_bits);
last_compared = current; last_compared = current;

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: resolver.c,v 1.270 2003/10/17 03:46:44 marka Exp $ */ /* $Id: resolver.c,v 1.271 2003/10/25 00:31:11 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -2773,11 +2773,11 @@ is_lame(fetchctx_t *fctx) {
rdataset = ISC_LIST_NEXT(rdataset, link)) { rdataset = ISC_LIST_NEXT(rdataset, link)) {
dns_namereln_t namereln; dns_namereln_t namereln;
int order; int order;
unsigned int labels, bits; unsigned int labels;
if (rdataset->type != dns_rdatatype_ns) if (rdataset->type != dns_rdatatype_ns)
continue; continue;
namereln = dns_name_fullcompare(name, &fctx->domain, namereln = dns_name_fullcompare(name, &fctx->domain,
&order, &labels, &bits); &order, &labels);
if (namereln == dns_namereln_equal && if (namereln == dns_namereln_equal &&
(message->flags & DNS_MESSAGEFLAG_AA) != 0) (message->flags & DNS_MESSAGEFLAG_AA) != 0)
return (ISC_FALSE); return (ISC_FALSE);
@@ -3841,7 +3841,7 @@ dname_target(dns_rdataset_t *rdataset, dns_name_t *qname, dns_name_t *oname,
{ {
isc_result_t result; isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
unsigned int nlabels, nbits; unsigned int nlabels;
int order; int order;
dns_namereln_t namereln; dns_namereln_t namereln;
dns_rdata_dname_t dname; dns_rdata_dname_t dname;
@@ -3862,19 +3862,13 @@ dname_target(dns_rdataset_t *rdataset, dns_name_t *qname, dns_name_t *oname,
/* /*
* Get the prefix of qname. * Get the prefix of qname.
*/ */
namereln = dns_name_fullcompare(qname, oname, &order, &nlabels, namereln = dns_name_fullcompare(qname, oname, &order, &nlabels);
&nbits);
if (namereln != dns_namereln_subdomain) { if (namereln != dns_namereln_subdomain) {
dns_rdata_freestruct(&dname); dns_rdata_freestruct(&dname);
return (DNS_R_FORMERR); return (DNS_R_FORMERR);
} }
dns_fixedname_init(&prefix); dns_fixedname_init(&prefix);
result = dns_name_split(qname, nlabels, nbits, dns_name_split(qname, nlabels, dns_fixedname_name(&prefix), NULL);
dns_fixedname_name(&prefix), NULL);
if (result != ISC_R_SUCCESS) {
dns_rdata_freestruct(&dname);
return (result);
}
dns_fixedname_init(fixeddname); dns_fixedname_init(fixeddname);
result = dns_name_concatenate(dns_fixedname_name(&prefix), result = dns_name_concatenate(dns_fixedname_name(&prefix),
&dname.dname, &dname.dname,

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: validator.c,v 1.113 2003/09/30 05:56:14 marka Exp $ */ /* $Id: validator.c,v 1.114 2003/10/25 00:31:11 jinmei Exp $ */
#include <config.h> #include <config.h>
@@ -441,7 +441,7 @@ nsecprovesnonexistence(dns_validator_t *val, dns_name_t *nsecname,
isc_boolean_t isnxdomain; isc_boolean_t isnxdomain;
isc_result_t result; isc_result_t result;
dns_namereln_t relation; dns_namereln_t relation;
unsigned int olabels, nlabels, labels, bits; unsigned int olabels, nlabels, labels;
INSIST(DNS_MESSAGE_VALID(val->event->message)); INSIST(DNS_MESSAGE_VALID(val->event->message));
@@ -460,7 +460,7 @@ nsecprovesnonexistence(dns_validator_t *val, dns_name_t *nsecname,
validator_log(val, ISC_LOG_DEBUG(3), "looking for relevant nsec"); validator_log(val, ISC_LOG_DEBUG(3), "looking for relevant nsec");
relation = dns_name_fullcompare(val->event->name, nsecname, relation = dns_name_fullcompare(val->event->name, nsecname,
&order, &olabels, &bits); &order, &olabels);
if (order == 0) { if (order == 0) {
/* /*
* The names are the same. Look for the type present bit. * The names are the same. Look for the type present bit.
@@ -496,8 +496,7 @@ nsecprovesnonexistence(dns_validator_t *val, dns_name_t *nsecname,
RUNTIME_CHECK(result == ISC_R_SUCCESS); RUNTIME_CHECK(result == ISC_R_SUCCESS);
relation = dns_name_fullcompare(&nsec.next, relation = dns_name_fullcompare(&nsec.next,
val->event->name, val->event->name,
&order, &nlabels, &order, &nlabels);
&bits);
if (order > 0 && relation == dns_namereln_subdomain) { if (order > 0 && relation == dns_namereln_subdomain) {
dns_rdata_freestruct(&nsec); dns_rdata_freestruct(&nsec);
validator_log(val, ISC_LOG_DEBUG(3), validator_log(val, ISC_LOG_DEBUG(3),
@@ -548,7 +547,7 @@ nsecprovesnonexistence(dns_validator_t *val, dns_name_t *nsecname,
return (ISC_FALSE); return (ISC_FALSE);
dns_rdata_reset(&rdata); dns_rdata_reset(&rdata);
relation = dns_name_fullcompare(&nsec.next, val->event->name, relation = dns_name_fullcompare(&nsec.next, val->event->name,
&order, &nlabels, &bits); &order, &nlabels);
if (order <= 0) { if (order <= 0) {
/* /*
* The NSEC next name is less than the nonexistent * The NSEC next name is less than the nonexistent
@@ -820,7 +819,7 @@ get_dst_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo,
static isc_result_t static isc_result_t
get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) { get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) {
isc_result_t result; isc_result_t result;
unsigned int nbits, nlabels; unsigned int nlabels;
int order; int order;
dns_namereln_t namereln; dns_namereln_t namereln;
@@ -831,7 +830,7 @@ get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) {
* or closer to the the DNS root. * or closer to the the DNS root.
*/ */
namereln = dns_name_fullcompare(val->event->name, &siginfo->signer, namereln = dns_name_fullcompare(val->event->name, &siginfo->signer,
&order, &nlabels, &nbits); &order, &nlabels);
if (namereln != dns_namereln_subdomain && if (namereln != dns_namereln_subdomain &&
namereln != dns_namereln_equal) namereln != dns_namereln_equal)
return (DNS_R_CONTINUE); return (DNS_R_CONTINUE);
@@ -1548,29 +1547,27 @@ proveunsecure(dns_validator_t *val, isc_boolean_t resume) {
else if (result != ISC_R_SUCCESS) else if (result != ISC_R_SUCCESS)
return (result); return (result);
if (!resume) if (!resume) {
val->labels = dns_name_depth(dns_fixedname_name(&secroot)) + 1; val->labels =
else { dns_name_countlabels(dns_fixedname_name(&secroot)) + 1;
} else {
validator_log(val, ISC_LOG_DEBUG(3), "resuming proveunsecure"); validator_log(val, ISC_LOG_DEBUG(3), "resuming proveunsecure");
val->labels++; val->labels++;
} }
for (; for (;
val->labels <= dns_name_depth(val->event->name); val->labels <= dns_name_countlabels(val->event->name);
val->labels++) val->labels++)
{ {
char namebuf[DNS_NAME_FORMATSIZE]; char namebuf[DNS_NAME_FORMATSIZE];
if (val->labels == dns_name_depth(val->event->name)) { if (val->labels == dns_name_countlabels(val->event->name)) {
tname = val->event->name; tname = val->event->name;
} else { } else {
dns_fixedname_init(&val->fname); dns_fixedname_init(&val->fname);
tname = dns_fixedname_name(&val->fname); tname = dns_fixedname_name(&val->fname);
result = dns_name_splitatdepth(val->event->name, dns_name_split(val->event->name, val->labels,
val->labels,
NULL, tname); NULL, tname);
if (result != ISC_R_SUCCESS)
return (result);
} }
dns_name_format(tname, namebuf, sizeof(namebuf)); dns_name_format(tname, namebuf, sizeof(namebuf));