deprecation of bitstring labels.
-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
losing necessary timer granularity.
* 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>
dns_name_t *tname;
dns_dbnode_t *node;
unsigned int options;
- unsigned int odepth, ndepth, i;
+ unsigned int olabels, nlabels, i;
isc_boolean_t done;
isc_result_t result;
query_releasename(client, &fname);
}
- odepth = dns_name_depth(dns_db_origin(db));
- ndepth = dns_name_depth(name);
+ olabels = dns_name_countlabels(dns_db_origin(db));
+ nlabels = dns_name_countlabels(name);
done = ISC_FALSE;
- for (i = ndepth - 1; i >= odepth && !done; i--) {
+ for (i = nlabels - 1; i >= olabels && !done; i--) {
/*
* We'll need some resources...
*/
dns_fixedname_init(&tfixed);
tname = dns_fixedname_name(&tfixed);
- result = dns_name_splitatdepth(name, i, NULL, tname);
- if (result != ISC_R_SUCCESS)
- continue;
+ dns_name_split(name, i, NULL, tname);
result = dns_name_concatenate(dns_wildcardname, tname, tname,
NULL);
if (result != ISC_R_SUCCESS)
fname = query_newname(client, dbuf, &b);
if (fname == NULL)
return;
- RUNTIME_CHECK(dns_name_splitatdepth(name, sig.labels + 1, NULL,
- fname) == ISC_R_SUCCESS);
+ dns_name_split(name, sig.labels + 1, NULL, fname);
/* This will succeed, since we've stripped labels. */
RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, fname, fname,
NULL) == ISC_R_SUCCESS);
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdatasetiter_t *rdsiter;
isc_boolean_t want_restart, authoritative, is_zone, need_wildcardproof;
- unsigned int n, nlabels, nbits;
+ unsigned int n, nlabels;
dns_namereln_t namereln;
int order;
isc_buffer_t *dbuf;
* we're going to have to split qname later on.
*/
namereln = dns_name_fullcompare(client->query.qname, fname,
- &order, &nlabels, &nbits);
+ &order, &nlabels);
INSIST(namereln == dns_namereln_subdomain);
/*
* Keep a copy of the rdataset. We have to do this because
*/
dns_fixedname_init(&fixed);
prefix = dns_fixedname_name(&fixed);
- result = dns_name_split(client->query.qname, nlabels, nbits,
- prefix, NULL);
- if (result != ISC_R_SUCCESS) {
- dns_message_puttempname(client->message, &tname);
- goto cleanup;
- }
+ dns_name_split(client->query.qname, nlabels, prefix, NULL);
INSIST(fname == NULL);
dbuf = query_getnamebuf(client);
if (dbuf == NULL) {
* 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>
isc_boolean_t test_downcase = ISC_FALSE;
isc_boolean_t inplace = 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_name_t *prefix, *suffix;
int ch;
break;
case 's':
want_split = ISC_TRUE;
- split_depth = atoi(isc_commandline_argument);
+ split_label = atoi(isc_commandline_argument);
break;
case 'w':
check_wildcard = ISC_TRUE;
if (comp != NULL && dns_name_countlabels(name) > 0) {
int order;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
dns_namereln_t namereln;
namereln = dns_name_fullcompare(name, comp, &order,
- &nlabels, &nbits);
+ &nlabels);
if (!quiet) {
if (order < 0)
printf("<");
dns_name_equal(name, comp) ? "TRUE" : "FALSE");
}
- depth = dns_name_depth(name);
- if (want_split && split_depth < depth) {
+ labels = dns_name_countlabels(name);
+ if (want_split && split_label < labels) {
dns_fixedname_init(&fprefix);
prefix = dns_fixedname_name(&fprefix);
dns_fixedname_init(&fsuffix);
suffix = dns_fixedname_name(&fsuffix);
- printf("splitting at depth %u: ", split_depth);
- result = dns_name_splitatdepth(name, split_depth,
- prefix, suffix);
- if (result == ISC_R_SUCCESS) {
- printf("\n prefix = ");
- print_name(prefix);
- printf(" suffix = ");
- print_name(suffix);
- } else {
- printf("failed: %s\n",
- isc_result_totext(result));
- }
+ printf("splitting at label %u: ", split_label);
+ dns_name_split(name, split_label, prefix, suffix);
+ printf("\n prefix = ");
+ print_name(prefix);
+ printf(" suffix = ");
+ print_name(suffix);
}
if (concatenate) {
* 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>
}
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 "
"name2, sets orderp to -1 if name1 < name2, to 0 if "
"name1 == name2, or to 1 if name1 > name2, sets nlabelsp "
static int
test_dns_name_fullcompare(char *name1, char *name2,
dns_namereln_t exp_dns_reln,
- int exp_order, int exp_nlabels, int exp_nbits)
+ int exp_order, int exp_nlabels)
{
int result;
int nfails;
int order;
unsigned int nlabels;
- unsigned int nbits;
dns_name_t dns_name1;
dns_name_t dns_name2;
isc_result_t dns_result;
dns_result = dname_from_tname(name2, &dns_name2);
if (dns_result == ISC_R_SUCCESS) {
dns_reln = dns_name_fullcompare(&dns_name1, &dns_name2,
- &order, &nlabels, &nbits);
+ &order, &nlabels);
if (dns_reln != exp_dns_reln) {
++nfails;
t_info("expecting %d labels, got %d\n",
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)
result = T_PASS;
else
if (cnt == 6) {
/*
* name1, name2, exp_reln, exp_order,
- * exp_nlabels, exp_nbits
+ * exp_nlabels
*/
if (!strcmp(Tokens[2], "none"))
reln = dns_namereln_none;
Tokens[1],
reln,
atoi(Tokens[3]),
- atoi(Tokens[4]),
- atoi(Tokens[5]));
+ atoi(Tokens[4]));
} else {
t_info("bad format at line %d\n", line);
}
int result;
int order;
unsigned int nlabels;
- unsigned int nbits;
isc_result_t dns_result;
dns_name_t dns_name1;
dns_name_t dns_name2;
dns_name_init(&dns_name2, NULL);
dns_name_fromregion(&dns_name2, ®ion);
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2,
- &order, &nlabels, &nbits);
+ &order, &nlabels);
if (dns_namereln == dns_namereln_equal)
result = T_PASS;
else
int result;
int order;
unsigned int nlabels;
- unsigned int nbits;
unsigned char junk1[BUFLEN];
unsigned char junk2[BUFLEN];
unsigned char junk3[BUFLEN];
}
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, &order,
- &nlabels, &nbits);
+ &nlabels);
if (dns_namereln == dns_namereln_equal)
result = T_PASS;
int len;
int order;
unsigned int nlabels;
- unsigned int nbits;
unsigned char junk1[BUFLEN];
unsigned char junk2[BUFLEN];
unsigned char junk3[BUFLEN];
}
dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2,
- &order, &nlabels, &nbits);
+ &order, &nlabels);
if (dns_namereln == dns_namereln_equal)
result = T_PASS;
else {
int result;
int order;
unsigned int nlabels;
- unsigned int nbits;
int len;
unsigned char buf1[BIGBUFLEN];
char buf2[BUFLEN];
if (dns_result == ISC_R_SUCCESS) {
dns_namereln = dns_name_fullcompare(&dns_name1,
&dns_name2,
- &order, &nlabels,
- &nbits);
+ &order, &nlabels);
if (dns_namereln != dns_namereln_equal) {
t_info("dns_name_fullcompare returned %s\n",
dns_namereln_to_text(dns_namereln));
* 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>
int cnt;
int order;
unsigned int nlabels;
- unsigned int nbits;
int nprobs;
isc_result_t dns_result;
(void)dns_name_fullcompare(
dns_fixedname_name(&fullname1),
dns_fixedname_name(&fullname2),
- &order, &nlabels, &nbits);
+ &order, &nlabels);
if (order >= 0) {
t_info("unexpected order %s %s %s\n",
* 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
{
isc_result_t result;
dns_namereln_t namereln;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
int order;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_fixedname_t fixed1, fixed2;
dns_rdata_dname_t dname;
INSIST(rdataset->type == dns_rdatatype_dname);
- namereln = dns_name_fullcompare(name, fname, &order,
- &nlabels, &nbits);
+ namereln = dns_name_fullcompare(name, fname, &order, &nlabels);
INSIST(namereln == dns_namereln_subdomain);
/*
* Get the target name of the DNAME.
prefix = dns_fixedname_name(&fixed1);
dns_fixedname_init(&fixed2);
new_target = dns_fixedname_name(&fixed2);
- result = dns_name_split(name, nlabels, nbits, prefix, NULL);
- if (result != ISC_R_SUCCESS) {
- dns_rdata_freestruct(&dname);
- return (result);
- }
- result = dns_name_concatenate(prefix, &dname.dname, new_target,
- NULL);
+ dns_name_split(name, nlabels, prefix, NULL);
dns_rdata_freestruct(&dname);
if (result != ISC_R_SUCCESS)
return (result);
*/
/*
- * $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 $
*/
dns_fixedname_t fnewname;
REQUIRE(name != NULL);
- REQUIRE(dns_name_depth(name) <= 255);
+ REQUIRE(dns_name_countlabels(name) <= 255);
REQUIRE(set != NULL);
REQUIRE(key != NULL);
REQUIRE(inception != NULL);
sig.covered = set->type;
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))
sig.labels--;
sig.originalttl = set->ttl;
* If the name is an expanded wildcard, use the wildcard name.
*/
dns_fixedname_init(&fnewname);
- labels = dns_name_depth(name) - 1;
+ labels = dns_name_countlabels(name) - 1;
if (labels - sig.labels > 0) {
- RUNTIME_CHECK(dns_name_splitatdepth(name, sig.labels + 1, NULL,
- dns_fixedname_name(&fnewname))
- == ISC_R_SUCCESS);
+ dns_name_split(name, sig.labels + 1, NULL,
+ dns_fixedname_name(&fnewname));
RUNTIME_CHECK(dns_name_downcase(dns_fixedname_name(&fnewname),
dns_fixedname_name(&fnewname),
NULL)
* 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
#define DNS_NAME_H 1
* 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
dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive);
/*
dns_namereln_t
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
- int *orderp,
- unsigned int *nlabelsp, unsigned int *nbitsp);
+ int *orderp, unsigned int *nlabelsp);
/*
* Determine the relative ordering under the DNSSEC order relation of
* 'name1' and 'name2', and also determine the hierarchical
*
* 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.
*
*
* *nlabelsp is the number of common significant labels.
*
- * Since we dropped the support of bitstring labels, *nbitsp is always
- * set to 0.
- *
* Returns:
* dns_namereln_none There's no hierarchical relationship
* between name1 and name2.
* 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
***/
* DNS_R_NAMETOOLONG
*/
-isc_result_t
-dns_name_split(dns_name_t *name,
- unsigned int suffixlabels, unsigned int nbits,
+void
+dns_name_split(dns_name_t *name, unsigned int suffixlabels,
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:
* 'name' is split such that 'suffix' holds the most significant
- * 'suffixlabels' labels. All other labels and bits are stored
- * in 'prefix'.
+ * 'suffixlabels' labels. All other labels are stored in 'prefix'.
*
* Copying name data is avoided as much as possible, so 'prefix'
* and 'suffix' will end up pointing at the data for '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.
*
* 'suffix' is a valid name or NULL, and cannot be read-only.
* 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
dns_name_dup(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target);
/*
(r)->length = (n)->length; \
} 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
#define dns_name_countlabels(n) DNS_NAME_COUNTLABELS(n)
#define dns_name_isabsolute(n) DNS_NAME_ISABSOLUTE(n)
#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 */
* 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>
dns_name_t *name, *fname, *prefix;
dns_fixedname_t foundname, fixed;
dns_rdata_t rdata = DNS_RDATA_INIT;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
int order;
dns_namereln_t namereln;
dns_rdata_cname_t cname;
break;
case DNS_R_DNAME:
namereln = dns_name_fullcompare(name, fname, &order,
- &nlabels, &nbits);
+ &nlabels);
INSIST(namereln == dns_namereln_subdomain);
/*
* Get the target name of the DNAME.
*/
dns_fixedname_init(&fixed);
prefix = dns_fixedname_name(&fixed);
- result = dns_name_split(name, nlabels, nbits, prefix,
- NULL);
- if (result != ISC_R_SUCCESS) {
- dns_rdata_freestruct(&dname);
- break;
- }
+ dns_name_split(name, nlabels, prefix, NULL);
result = dns_name_concatenate(prefix, &dname.dname,
name, NULL);
dns_rdata_freestruct(&dname);
* 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>
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
name_hash(dns_name_t *name, isc_boolean_t case_sensitive) {
unsigned int length;
dns_namereln_t
dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2,
- int *orderp,
- unsigned int *nlabelsp, unsigned int *nbitsp)
+ int *orderp, unsigned int *nlabelsp)
{
unsigned int l1, l2, l, count1, count2, count, nlabels;
int cdiff, ldiff, chdiff;
REQUIRE(VALID_NAME(name2));
REQUIRE(orderp != NULL);
REQUIRE(nlabelsp != NULL);
- REQUIRE(nbitsp != NULL);
/*
* Either name1 is absolute and name2 is absolute, or neither is.
*/
done:
*nlabelsp = nlabels;
- *nbitsp = 0;
if (nlabels > 0 && namereln == dns_namereln_none)
namereln = dns_namereln_commonancestor;
int
dns_name_compare(const dns_name_t *name1, const dns_name_t *name2) {
int order;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
/*
* Determine the relative ordering under the DNSSEC order relation of
* same domain.
*/
- (void)dns_name_fullcompare(name1, name2, &order, &nlabels, &nbits);
+ (void)dns_name_fullcompare(name1, name2, &order, &nlabels);
return (order);
}
isc_boolean_t
dns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) {
int order;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
dns_namereln_t namereln;
/*
* same domain.
*/
- namereln = dns_name_fullcompare(name1, name2, &order, &nlabels,
- &nbits);
+ namereln = dns_name_fullcompare(name1, name2, &order, &nlabels);
if (namereln == dns_namereln_subdomain ||
namereln == dns_namereln_equal)
return (ISC_TRUE);
isc_boolean_t
dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) {
int order;
- unsigned int nlabels, nbits, labels;
+ unsigned int nlabels, labels;
dns_name_t tname;
REQUIRE(VALID_NAME(name));
DNS_NAME_INIT(&tname, NULL);
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)
return (ISC_TRUE);
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
dns_name_countlabels(const dns_name_t *name) {
/*
return (ISC_R_SUCCESS);
}
-isc_result_t
-dns_name_split(dns_name_t *name,
- unsigned int suffixlabels, unsigned int nbits,
+void
+dns_name_split(dns_name_t *name, unsigned int suffixlabels,
dns_name_t *prefix, dns_name_t *suffix)
{
- dns_offsets_t name_odata;
- unsigned char *offsets;
unsigned int splitlabel;
- REQUIRE(nbits == 0); /* no bitstring support */
REQUIRE(VALID_NAME(name));
REQUIRE(suffixlabels > 0);
REQUIRE(suffixlabels < name->labels);
suffix->buffer != NULL &&
BINDABLE(suffix)));
- SETUP_OFFSETS(name, offsets, name_odata);
-
splitlabel = name->labels - suffixlabels;
if (prefix != NULL)
dns_name_getlabelsequence(name, splitlabel,
suffixlabels, suffix);
- return (ISC_R_SUCCESS);
-}
-
-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));
+ return;
}
isc_result_t
* 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 */
dns_namereln_t compared;
isc_result_t result = ISC_R_SUCCESS;
dns_rbtnodechain_t chain;
- unsigned int common_labels, common_bits;
+ unsigned int common_labels;
int order;
REQUIRE(VALID_RBT(rbt));
NODENAME(current, ¤t_name);
compared = dns_name_fullcompare(add_name, ¤t_name,
- &order,
- &common_labels, &common_bits);
- /*
- * since we dropped the support of bitstring labels,
- * common_bits should always be set to 0.
- */
- INSIST(common_bits == 0);
+ &order, &common_labels);
if (compared == dns_namereln_equal) {
*nodep = current;
* not-in-common part to be searched for
* in the next level.
*/
- result = dns_name_split(add_name,
- common_labels,
- common_bits,
- add_name, NULL);
-
- if (result != ISC_R_SUCCESS)
- break;
+ dns_name_split(add_name, common_labels,
+ add_name, NULL);
/*
* Follow the down pointer (possibly NULL).
* two names and a suffix that is the common
* parts of them.
*/
- result = dns_name_split(¤t_name,
- common_labels,
- common_bits,
- prefix, suffix);
-
- if (result == ISC_R_SUCCESS)
- result = create_node(rbt->mctx, suffix,
- &new_current);
+ dns_name_split(¤t_name, common_labels,
+ prefix, suffix);
+ result = create_node(rbt->mctx, suffix,
+ &new_current);
if (result != ISC_R_SUCCESS)
break;
* result != ISC_R_SUCCESS, which
* is tested after the loop ends).
*/
- result = dns_name_split(add_name,
- common_labels,
- common_bits,
- add_name,
- NULL);
-
+ dns_name_split(add_name, common_labels,
+ add_name, NULL);
break;
}
dns_fixedname_t fixedcallbackname, fixedsearchname;
dns_namereln_t compared;
isc_result_t result, saved_result;
- unsigned int common_labels, common_bits;
+ unsigned int common_labels;
int order;
REQUIRE(VALID_RBT(rbt));
/*
* search_name is the name segment being sought in each tree level.
* By using a fixedname, the search_name will definitely have offsets
- * and a buffer for use by any splitting that happens in the middle
- * of a bitstring label. (XXXJT: this can be skipped since we dropped
- * bitstring labels).
+ * for use by any splitting.
* By using dns_name_clone, no name data should be copied thanks to
* the lack of bitstring labels.
*/
while (current != NULL) {
NODENAME(current, ¤t_name);
compared = dns_name_fullcompare(search_name, ¤t_name,
- &order,
- &common_labels, &common_bits);
+ &order, &common_labels);
last_compared = current;
if (compared == dns_namereln_equal)
break;
} else {
common_labels = tlabels;
- common_bits = 0;
compared = dns_namereln_subdomain;
goto subdomain;
}
* Whack off the current node's common parts
* for the name to search in the next level.
*/
- result = dns_name_split(search_name,
- common_labels,
- common_bits,
- search_name, NULL);
- if (result != ISC_R_SUCCESS) {
- dns_rbtnodechain_reset(chain);
- return (result);
- }
-
+ dns_name_split(search_name, common_labels,
+ search_name, NULL);
/*
* This might be the closest enclosing name.
*/
search_name,
¤t_name,
&order,
- &common_labels,
- &common_bits);
+ &common_labels);
last_compared = current;
* 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>
rdataset = ISC_LIST_NEXT(rdataset, link)) {
dns_namereln_t namereln;
int order;
- unsigned int labels, bits;
+ unsigned int labels;
if (rdataset->type != dns_rdatatype_ns)
continue;
namereln = dns_name_fullcompare(name, &fctx->domain,
- &order, &labels, &bits);
+ &order, &labels);
if (namereln == dns_namereln_equal &&
(message->flags & DNS_MESSAGEFLAG_AA) != 0)
return (ISC_FALSE);
{
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
- unsigned int nlabels, nbits;
+ unsigned int nlabels;
int order;
dns_namereln_t namereln;
dns_rdata_dname_t dname;
/*
* Get the prefix of qname.
*/
- namereln = dns_name_fullcompare(qname, oname, &order, &nlabels,
- &nbits);
+ namereln = dns_name_fullcompare(qname, oname, &order, &nlabels);
if (namereln != dns_namereln_subdomain) {
dns_rdata_freestruct(&dname);
return (DNS_R_FORMERR);
}
dns_fixedname_init(&prefix);
- result = dns_name_split(qname, nlabels, nbits,
- dns_fixedname_name(&prefix), NULL);
- if (result != ISC_R_SUCCESS) {
- dns_rdata_freestruct(&dname);
- return (result);
- }
+ dns_name_split(qname, nlabels, dns_fixedname_name(&prefix), NULL);
dns_fixedname_init(fixeddname);
result = dns_name_concatenate(dns_fixedname_name(&prefix),
&dname.dname,
* 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>
isc_boolean_t isnxdomain;
isc_result_t result;
dns_namereln_t relation;
- unsigned int olabels, nlabels, labels, bits;
+ unsigned int olabels, nlabels, labels;
INSIST(DNS_MESSAGE_VALID(val->event->message));
validator_log(val, ISC_LOG_DEBUG(3), "looking for relevant nsec");
relation = dns_name_fullcompare(val->event->name, nsecname,
- &order, &olabels, &bits);
+ &order, &olabels);
if (order == 0) {
/*
* The names are the same. Look for the type present bit.
RUNTIME_CHECK(result == ISC_R_SUCCESS);
relation = dns_name_fullcompare(&nsec.next,
val->event->name,
- &order, &nlabels,
- &bits);
+ &order, &nlabels);
if (order > 0 && relation == dns_namereln_subdomain) {
dns_rdata_freestruct(&nsec);
validator_log(val, ISC_LOG_DEBUG(3),
return (ISC_FALSE);
dns_rdata_reset(&rdata);
relation = dns_name_fullcompare(&nsec.next, val->event->name,
- &order, &nlabels, &bits);
+ &order, &nlabels);
if (order <= 0) {
/*
* The NSEC next name is less than the nonexistent
static isc_result_t
get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) {
isc_result_t result;
- unsigned int nbits, nlabels;
+ unsigned int nlabels;
int order;
dns_namereln_t namereln;
* or closer to the the DNS root.
*/
namereln = dns_name_fullcompare(val->event->name, &siginfo->signer,
- &order, &nlabels, &nbits);
+ &order, &nlabels);
if (namereln != dns_namereln_subdomain &&
namereln != dns_namereln_equal)
return (DNS_R_CONTINUE);
else if (result != ISC_R_SUCCESS)
return (result);
- if (!resume)
- val->labels = dns_name_depth(dns_fixedname_name(&secroot)) + 1;
- else {
+ if (!resume) {
+ val->labels =
+ dns_name_countlabels(dns_fixedname_name(&secroot)) + 1;
+ } else {
validator_log(val, ISC_LOG_DEBUG(3), "resuming proveunsecure");
val->labels++;
}
for (;
- val->labels <= dns_name_depth(val->event->name);
+ val->labels <= dns_name_countlabels(val->event->name);
val->labels++)
{
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;
} else {
dns_fixedname_init(&val->fname);
tname = dns_fixedname_name(&val->fname);
- result = dns_name_splitatdepth(val->event->name,
- val->labels,
- NULL, tname);
- if (result != ISC_R_SUCCESS)
- return (result);
+ dns_name_split(val->event->name, val->labels,
+ NULL, tname);
}
dns_name_format(tname, namebuf, sizeof(namebuf));