+1368. [func] remove support for bitstring labels.
+
1367. [func] Use response times to select forwarders.
1366. [contrib] queryperf usage was incomplete. Add '-h' for help.
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.250 2002/08/12 19:57:13 mayer Exp $ */
+/* $Id: dighost.c,v 1.251 2002/08/27 04:53:38 marka Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
/* This is a valid IPv6 address. */
dns_fixedname_t fname;
dns_name_t *name;
- unsigned int options = DNS_BYADDROPT_IPV6NIBBLE;
-
+ unsigned int options = 0;
+
if (ip6_int)
options |= DNS_BYADDROPT_IPV6INT;
dns_fixedname_init(&fname);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwdgnba.c,v 1.14 2001/11/27 00:55:35 gson Exp $ */
+/* $Id: lwdgnba.c,v 1.15 2002/08/27 04:53:38 marka Exp $ */
#include <config.h>
isc_event_free(&event);
bevent = NULL;
- if ((client->options & DNS_BYADDROPT_IPV6NIBBLE) != 0) {
+ if (client->na.family != AF_INET6 ||
+ (client->options & DNS_BYADDROPT_IPV6INT) != 0) {
if (result == DNS_R_NCACHENXDOMAIN ||
result == DNS_R_NCACHENXRRSET ||
result == DNS_R_NXDOMAIN ||
}
/*
- * Fall back to nibble reverse if the default of bitstrings
+ * Fall back to ip6.int reverse if the default ip6.arpa
* fails.
*/
- client->options |= DNS_BYADDROPT_IPV6NIBBLE;
+ client->options |= DNS_BYADDROPT_IPV6INT;
start_byaddr(client);
return;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: query.c,v 1.233 2002/08/19 21:32:56 marka Exp $ */
+/* $Id: query.c,v 1.234 2002/08/27 04:53:38 marka Exp $ */
#include <config.h>
static void
synth_rev_byaddrdone_int(isc_task_t *task, isc_event_t *event);
-static void
-synth_rev_byaddrdone_bitstring(isc_task_t *task, isc_event_t *event);
-
static void
synth_rev_respond(ns_client_t *client, dns_byaddrevent_t *bevent);
static isc_result_t
nibbles2netaddr(dns_name_t *name, isc_netaddr_t *na);
-static isc_result_t
-bitstring2netaddr(dns_name_t *name, isc_netaddr_t *na);
-
/*
* Increment query statistics counters.
*/
&ip6arpa_name)) &&
nibbles2netaddr(client->query.qname,
&client->query.synth.na) == ISC_R_SUCCESS) {
- qclient= NULL;
- ns_client_attach(client, &qclient);
- synth_rev_start(qclient);
- return;
- }
- /* bitstring label + "ip6" + "arpa" + root */
- if (dns_name_countlabels(client->query.qname) == 4 &&
- dns_name_issubdomain(client->query.qname,
- &ip6arpa_name) &&
- bitstring2netaddr(client->query.qname,
- &client->query.synth.na) == ISC_R_SUCCESS) {
- qclient= NULL;
+ qclient = NULL;
ns_client_attach(client, &qclient);
synth_rev_start(qclient);
return;
return (ISC_R_SUCCESS);
}
-static isc_result_t
-bitstring2netaddr(dns_name_t *name, isc_netaddr_t *na) {
- struct in6_addr ina6;
- isc_region_t label;
-
- dns_name_getlabel(name, 0, &label);
- if (label.length != 18 ||
- label.base[0] != DNS_LABELTYPE_BITSTRING ||
- label.base[1] != 128)
- return (ISC_R_FAILURE);
- memcpy(ina6.s6_addr, &label.base[2], 16);
- isc_netaddr_fromin6(na, &ina6);
- return (ISC_R_NOTIMPLEMENTED);
-}
-
/*
* Generate a synthetic IPv6 reverse mapping response for the current
* query of 'client'.
ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
ISC_LOG_DEBUG(5), "generating synthetic PTR response");
- /* Try IP6.ARPA nibble style first. */
+ /* Try IP6.ARPA first. */
result = dns_byaddr_create(client->mctx,
&client->query.synth.na,
- client->view,
- DNS_BYADDROPT_IPV6NIBBLE, client->task,
+ client->view, 0, client->task,
synth_rev_byaddrdone_arpa,
client, &byaddr_dummy);
if (result == ISC_R_SUCCESS)
if (bevent->result == ISC_R_SUCCESS) {
synth_rev_respond(client, bevent);
} else {
- /* Try IP6.INT nibble next. */
+ /* Try IP6.INT next. */
result = dns_byaddr_create(client->mctx,
&client->query.synth.na,
client->view,
- DNS_BYADDROPT_IPV6NIBBLE|
DNS_BYADDROPT_IPV6INT,
client->task,
synth_rev_byaddrdone_int,
static void
synth_rev_byaddrdone_int(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
dns_byaddrevent_t *bevent = (dns_byaddrevent_t *)event;
ns_client_t *client = event->ev_arg;
dns_byaddr_t *byaddr = event->ev_sender;
- dns_byaddr_t *byaddr_dummy = NULL;
-
- UNUSED(task);
-
- if (bevent->result == ISC_R_SUCCESS) {
- synth_rev_respond(client, bevent);
- } else {
- /* Try IP6.ARPA bitstring next. */
- result = dns_byaddr_create(client->mctx,
- &client->query.synth.na,
- client->view, 0, client->task,
- synth_rev_byaddrdone_bitstring,
- client, &byaddr_dummy);
- if (result != ISC_R_SUCCESS)
- synth_finish(client, result);
- }
- dns_byaddr_destroy(&byaddr);
- isc_event_free(&event);
-}
-static void
-synth_rev_byaddrdone_bitstring(isc_task_t *task, isc_event_t *event) {
- dns_byaddrevent_t *bevent = (dns_byaddrevent_t *)event;
- ns_client_t *client = event->ev_arg;
- dns_byaddr_t *byaddr = event->ev_sender;
-
UNUSED(task);
- if (bevent->result == ISC_R_SUCCESS) {
+ if (bevent->result == ISC_R_SUCCESS)
synth_rev_respond(client, bevent);
- } else if (bevent->result == DNS_R_NCACHENXDOMAIN ||
- bevent->result == DNS_R_NCACHENXRRSET ||
- bevent->result == DNS_R_NXDOMAIN ||
- bevent->result == DNS_R_NXRRSET) {
- /*
- * We could give a NOERROR/NODATA response instead
- * in some cases, but since there may be any combination
- * of NXDOMAIN and NXRRSET results from the IP6.INT
- * and IP6.ARPA lookups, it could still be wrong with
- * respect to one or the other.
- */
- synth_finish(client, DNS_R_NXDOMAIN);
- } else {
+ else
synth_finish(client, bevent->result);
- }
+
+ dns_byaddr_destroy(&byaddr);
isc_event_free(&event);
- dns_byaddr_destroy(&byaddr);
}
static void
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: byaddr_test.c,v 1.22 2001/01/09 21:40:54 bwelling Exp $ */
+/* $Id: byaddr_test.c,v 1.23 2002/08/27 04:53:39 marka Exp $ */
/*
* Principal Author: Bob Halley
while ((ch = isc_commandline_parse(argc, argv, "nvw:")) != -1) {
switch (ch) {
case 'n':
- options |= DNS_BYADDROPT_IPV6NIBBLE;
+ /*
+ * We only try nibbles, so do nothing for this option.
+ */
break;
case 'v':
verbose = ISC_TRUE;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: t_names.c,v 1.33 2002/05/23 04:32:22 marka Exp $ */
+/* $Id: t_names.c,v 1.34 2002/08/27 04:53:39 marka Exp $ */
#include <config.h>
#define BUFLEN 256
#define BIGBUFLEN 4096
-static const char *a1 =
- "dns_label_countbits returns the number of "
- "bits in a bitstring label";
-
static char *Tokens[MAXTOKS + 1];
/*
return (result);
}
-static int
-test_dns_label_countbits(char *test_name, int pos, int expected_bits) {
- dns_label_t label;
- dns_name_t dns_name;
- int bits;
- int rval;
- isc_result_t result;
-
- rval = T_UNRESOLVED;
- t_info("testing name %s, label %d\n", test_name, pos);
-
- result = dname_from_tname(test_name, &dns_name);
- if (result == ISC_R_SUCCESS) {
- dns_name_getlabel(&dns_name, pos, &label);
- bits = dns_label_countbits(&label);
- if (bits == expected_bits)
- rval = T_PASS;
- else {
- t_info("got %d, expected %d\n", bits, expected_bits);
- rval = T_FAIL;
- }
- } else {
- t_info("dname_from_tname %s failed, result = %s\n",
- test_name, dns_result_totext(result));
- rval = T_UNRESOLVED;
- }
- return (rval);
-}
-
-static void
-t_dns_label_countbits(void) {
- FILE *fp;
- char *p;
- int line;
- int cnt;
- int result;
-
- result = T_UNRESOLVED;
- t_assert("dns_label_countbits", 1, T_REQUIRED, a1);
-
- fp = fopen("dns_label_countbits_data", "r");
- if (fp != NULL) {
- line = 0;
- while ((p = t_fgetbs(fp)) != NULL) {
-
- ++line;
-
- /*
- * Skip comment lines.
- */
- if ((isspace((unsigned char)*p)) || (*p == '#'))
- continue;
-
- /*
- * testname, labelpos, bitpos, expected val.
- */
- cnt = bustline(p, Tokens);
- if (cnt == 3) {
- result = test_dns_label_countbits(Tokens[0],
- atoi(Tokens[1]),
- atoi(Tokens[2]));
- } else {
- t_info("bad datafile format at line %d\n",
- line);
- }
-
- (void)free(p);
- t_result(result);
- }
- (void)fclose(fp);
- } else {
- t_info("Missing datafile dns_label_countbits_data\n");
- t_result(result);
- }
-}
-
-static const char *a2 = "dns_label_getbit returns the n'th most significant "
- "bit of a bitstring label";
-
-static int
-test_dns_label_getbit(char *test_name, int label_pos, int bit_pos,
- int expected_bitval)
-{
- dns_label_t label;
- dns_name_t dns_name;
- int bitval;
- int rval;
- isc_result_t result;
-
- rval = T_UNRESOLVED;
-
- t_info("testing name %s, label %d, bit %d\n",
- test_name, label_pos, bit_pos);
-
- result = dname_from_tname(test_name, &dns_name);
- if (result == ISC_R_SUCCESS) {
- dns_name_getlabel(&dns_name, label_pos, &label);
- bitval = dns_label_getbit(&label, bit_pos);
- if (bitval == expected_bitval)
- rval = T_PASS;
- else {
- t_info("got %d, expected %d\n", bitval,
- expected_bitval);
- rval = T_FAIL;
- }
- } else {
- t_info("dname_from_tname %s failed, result = %s\n",
- test_name, dns_result_totext(result));
- rval = T_UNRESOLVED;
- }
- return (rval);
-}
-
-static void
-t_dns_label_getbit(void) {
- int line;
- int cnt;
- int result;
- char *p;
- FILE *fp;
-
- t_assert("dns_label_getbit", 1, T_REQUIRED, a2);
-
- result = T_UNRESOLVED;
- fp = fopen("dns_label_getbit_data", "r");
- if (fp != NULL) {
- line = 0;
- while ((p = t_fgetbs(fp)) != NULL) {
-
- ++line;
-
- /*
- * Skip comment lines.
- */
- if ((isspace((unsigned char)*p)) || (*p == '#'))
- continue;
-
- cnt = bustline(p, Tokens);
- if (cnt == 4) {
- /*
- * label, bitpos, expected value.
- */
- result = test_dns_label_getbit(Tokens[0],
- atoi(Tokens[1]),
- atoi(Tokens[2]),
- atoi(Tokens[3]));
- } else {
- t_info("bad datafile format at line %d\n",
- line);
- }
-
- (void)free(p);
- t_result(result);
- }
- (void)fclose(fp);
- } else {
- t_info("Missing datafile dns_label_getbit_data\n");
- t_result(result);
- }
-}
-
static const char *a3 = "dns_name_init initializes 'name' to the empty name";
static void
#endif
testspec_t T_testlist[] = {
- { t_dns_label_countbits, "dns_label_countbits" },
- { t_dns_label_getbit, "dns_label_getbit" },
{ t_dns_name_init, "dns_name_init" },
{ t_dns_name_invalidate, "dns_name_invalidate" },
{ t_dns_name_setbuffer, "dns_name_setbuffer" },
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwtest.c,v 1.23 2002/05/23 04:32:24 marka Exp $ */
+/* $Id: lwtest.c,v 1.24 2002/08/27 04:53:39 marka Exp $ */
#include <config.h>
test_gnba("10.10.10.17", LWRES_ADDRTYPE_V4, LWRES_R_NOTFOUND,
NULL);
test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
- LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "nibble.example");
+ LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "ip6.int.example");
test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cde0",
LWRES_ADDRTYPE_V6, LWRES_R_NOTFOUND, NULL);
test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
- LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "bitstring.example");
+ LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "ip6.arpa.example");
test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cde0",
LWRES_ADDRTYPE_V6, LWRES_R_NOTFOUND, NULL);
test_gethostbyaddr("10.10.10.1", AF_INET, "ipv4.example");
test_gethostbyaddr("10.10.10.17", AF_INET, NULL);
test_gethostbyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "nibble.example");
+ AF_INET6, "ip6.int.example");
test_gethostbyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "bitstring.example");
+ AF_INET6, "ip6.arpa.example");
test_getipnodebyaddr("10.10.10.1", AF_INET, "ipv4.example");
test_getipnodebyaddr("10.10.10.17", AF_INET, NULL);
test_getipnodebyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "nibble.example");
+ AF_INET6, "ip6.int.example");
test_getipnodebyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "bitstring.example");
+ AF_INET6, "ip6.arpa.example");
test_getaddrinfo("a.example1.", AF_INET, 1, 1, "10.0.1.1");
test_getaddrinfo("a.example1.", AF_INET, 1, 0, "10.0.1.1");
test_getnameinfo("10.10.10.1", AF_INET, "ipv4.example");
test_getnameinfo("10.10.10.17", AF_INET, NULL);
test_getnameinfo("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "nibble.example");
+ AF_INET6, "ip6.int.example");
test_getnameinfo("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
- AF_INET6, "bitstring.example");
+ AF_INET6, "ip6.arpa.example");
test_getnameinfo("1122:3344:5566:7788:99aa:bbcc:ddee:ff00",
AF_INET6, "dname.example1");
; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
; WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-; $Id: example1.db,v 1.10 2001/01/09 21:43:41 bwelling Exp $
+; $Id: example1.db,v 1.11 2002/08/27 04:53:39 marka Exp $
$TTL 300 ; 5 minutes
@ IN SOA mname1. . (
- 2000062101 ; serial
+ 2002082210 ; serial
20 ; refresh (20 seconds)
20 ; retry (20 seconds)
1814400 ; expire (3 weeks)
b A6 64 ::ffff:ffff:ffff:ffff c
c A6 0 eeee:eeee:eeee:eeee::
d A6 64 ::ffff:ffff:ffff:ffff e
-\[x7788/16] DNAME net
-\[x99aabbccddeeff00/64].net PTR dname
+8.8.7.7 DNAME net
+0.0.f.f.e.e.d.d.c.c.b.b.a.a.9.9.net PTR dname
e A 10.0.1.1
SIG A 1 1 300 20001202003412 (
20001102003412 1 example. abcd )
; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
; WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-; $Id: ip6.arpa.db,v 1.7 2001/01/09 21:43:43 bwelling Exp $
+; $Id: ip6.arpa.db,v 1.8 2002/08/27 04:53:40 marka Exp $
$TTL 300 ; 5 minutes
@ IN SOA mname1. . (
- 2000062101 ; serial
+ 2002082300 ; serial
20 ; refresh (20 seconds)
20 ; retry (20 seconds)
1814400 ; expire (3 weeks)
NS ns
ns A 10.53.0.1
-\[x1123456789abcdef0123456789abcdef/128] PTR bitstring.example.
-\[x112233445566/48] DNAME example1.
+f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.1 PTR ip6.arpa.example.
+6.6.5.5.4.4.3.3.2.2.1.1 DNAME example1.
; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
; WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-; $Id: ip6.int.db,v 1.7 2001/01/09 21:43:44 bwelling Exp $
+; $Id: ip6.int.db,v 1.8 2002/08/27 04:53:40 marka Exp $
$TTL 300 ; 5 minutes
@ IN SOA mname1. . (
- 2000062001 ; serial
+ 2002082300 ; serial
20 ; refresh (20 seconds)
20 ; retry (20 seconds)
1814400 ; expire (3 weeks)
NS ns
ns A 10.53.0.1
-f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0 PTR nibble.example.
+f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0 PTR ip6.int.example.
; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
; WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-; $Id: ip6.arpa.db,v 1.1 2001/01/10 01:18:28 gson Exp $
+; $Id: ip6.arpa.db,v 1.2 2002/08/27 04:53:42 marka Exp $
$TTL 86400
@ IN SOA ns2 hostmaster (
NS ns2.example.
ns2.example. A 10.53.0.2
-\[x123456000000000000000000000001ff] PTR foo.
-
-
-
-
+f.f.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.5.4.3.2.1 PTR foo.
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: byaddr.c,v 1.31 2002/07/24 06:42:32 marka Exp $ */
+/* $Id: byaddr.c,v 1.32 2002/08/27 04:53:42 marka Exp $ */
#include <config.h>
dns_byaddr_createptrname(isc_netaddr_t *address, isc_boolean_t nibble,
dns_name_t *name)
{
- unsigned int options;
+ /*
+ * We dropped bitstring labels, so all lookups will use nibbles.
+ */
+ UNUSED(nibble);
- options = nibble ? (DNS_BYADDROPT_IPV6NIBBLE|DNS_BYADDROPT_IPV6INT) : 0;
- return (dns_byaddr_createptrname2(address, options, name));
+ return (dns_byaddr_createptrname2(address,
+ DNS_BYADDROPT_IPV6INT, name));
}
isc_result_t
(bytes[1] & 0xff),
(bytes[0] & 0xff));
} else if (address->family == AF_INET6) {
- if ((options & DNS_BYADDROPT_IPV6NIBBLE) != 0) {
- cp = textname;
- for (i = 15; i >= 0; i--) {
- *cp++ = hex_digits[bytes[i] & 0x0f];
- *cp++ = '.';
- *cp++ = hex_digits[(bytes[i] >> 4) & 0x0f];
- *cp++ = '.';
- }
- if ((options & DNS_BYADDROPT_IPV6INT) != 0)
- strcpy(cp, "ip6.int.");
- else
- strcpy(cp, "ip6.arpa.");
- } else {
- cp = textname;
- *cp++ = '\\';
- *cp++ = '[';
- *cp++ = 'x';
- for (i = 0; i < 16; i += 2) {
- *cp++ = hex_digits[(bytes[i] >> 4) & 0x0f];
- *cp++ = hex_digits[bytes[i] & 0x0f];
- *cp++ = hex_digits[(bytes[i+1] >> 4) & 0x0f];
- *cp++ = hex_digits[bytes[i+1] & 0x0f];
- }
- strcpy(cp, "].ip6.arpa.");
+ cp = textname;
+ for (i = 15; i >= 0; i--) {
+ *cp++ = hex_digits[bytes[i] & 0x0f];
+ *cp++ = '.';
+ *cp++ = hex_digits[(bytes[i] >> 4) & 0x0f];
+ *cp++ = '.';
}
+ if ((options & DNS_BYADDROPT_IPV6INT) != 0)
+ strcpy(cp, "ip6.int.");
+ else
+ strcpy(cp, "ip6.arpa.");
} else
return (ISC_R_NOTIMPLEMENTED);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: byaddr.h,v 1.13 2002/07/24 06:42:32 marka Exp $ */
+/* $Id: byaddr.h,v 1.14 2002/08/27 04:53:43 marka Exp $ */
#ifndef DNS_BYADDR_H
#define DNS_BYADDR_H 1
dns_namelist_t names;
} dns_byaddrevent_t;
+/*
+ * This option is deprecated since we now only consider nibbles.
#define DNS_BYADDROPT_IPV6NIBBLE 0x0001
+ */
#define DNS_BYADDROPT_IPV6INT 0x0002
isc_result_t
*
* Notes:
*
- * There are two reverse lookup formats for IPv6 addresses, 'bitstring'
- * and 'nibble'. The newer 'bitstring' format for the address fe80::1 is
- *
- * \[xfe800000000000000000000000000001].ip6.int.
+ * There is a reverse lookup format for IPv6 addresses, 'nibble'
*
* The 'nibble' format for that address is
*
* 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa.
*
- * The 'bitstring' format will be used unless the DNS_BYADDROPT_IPV6NIBBLE
- * option has been set.
- * DNS_BYADDROPT_IPV6INT can be combined with DNS_BYADDROPT_IPV6NIBBLE
- * to get nibble lookups under ip6.int.
+ * DNS_BYADDROPT_IPV6INT can be used to get nibble lookups under ip6.int.
*
* Requires:
*
/*
* Creates a name that would be used in a PTR query for this address. The
* nibble flag indicates that the 'nibble' format is to be used if an IPv6
- * address is provided, instead of the 'bitstring' format. 'options' are
- * the same as for dns_byaddr_create().
+ * address is provided, instead of the 'bitstring' format. Since we dropped
+ * the support of the bitstring labels, it is expected that the flag is always
+ * set. 'options' are the same as for dns_byaddr_create().
*
* Requires:
*
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: name.h,v 1.101 2002/08/06 01:50:28 marka Exp $ */
+/* $Id: name.h,v 1.102 2002/08/27 04:53:43 marka Exp $ */
#ifndef DNS_NAME_H
#define DNS_NAME_H 1
***** Labels
*****
***** A 'label' is basically a region. It contains one DNS wire format
- ***** label of either type 00 (ordinary) or type 01000001 (bitstring).
+ ***** label of type 00 (ordinary).
*****/
-/***
- *** Extended Label Types
- ***/
-
-#define DNS_LABELTYPE_BITSTRING 0x41
-
-/***
- *** Properties
- ***/
-
-dns_labeltype_t
-dns_label_type(dns_label_t *label);
-/*
- * Get the type of 'label'.
- *
- * Requires:
- * 'label' is a valid label (i.e. not NULL, points to a
- * struct dns_label)
- * 'label' is a type 00 or type 01000001 label (i.e. not compressed).
- *
- * Returns:
- * dns_labeltype_ordinary type 00 label
- * dns_labeltype_bitstring type 01000001 label
- */
-
-/***
- *** Bitstring Labels
- ***/
-
-unsigned int
-dns_label_countbits(dns_label_t *label);
-/*
- * The number of bits in a bitstring label.
- *
- * Requires:
- * 'label' is a valid label
- *
- * dns_label_type(label) == dns_labeltype_bitstring
- *
- * Ensures:
- * Result is <= 256.
- *
- * Returns:
- * The number of bits in the bitstring label.
- */
-
-dns_bitlabel_t
-dns_label_getbit(dns_label_t *label, unsigned int n);
-/*
- * The 'n'th most significant bit of 'label'.
- *
- * Notes:
- * Numbering starts at 0.
- *
- * Require:
- * n < dns_label_countbits(label)
- *
- * Returns:
- * dns_bitlabel_0 The bit was 0.
- * dns_bitlabel_1 The bit was 1.
- */
-
-/***
- *** Note
- ***
- *** Some provision still needs to be made for splitting bitstring labels.
- ***/
-
-
-
/*****
***** Names
*****
***** A 'name' is a handle to a binary region. It contains a sequence of one
- ***** or more DNS wire format labels of either type 00 (ordinary) or type
- ***** 01000001 (bitstring). Note that all names are not required to end
- ***** with the root label, as they are in the actual DNS wire protocol.
+ ***** or more DNS wire format labels of type 00 (ordinary).
+ ***** Note that all names are not required to end with the root label,
+ ***** as they are in the actual DNS wire protocol.
*****/
/***
*
* *nlabelsp is the number of common significant labels.
*
- * If *nbitsp is non-zero, then the least-signficant of the
- * common significant labels is a bitstring label, and the
- * two names have *nbitsp significant bits in common.
+ * Since we dropped the support of bitstring labels, *nbitsp is always
+ * set to 0.
*
* Returns:
* dns_namereln_none There's no hierarchical relationship
* 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, and by the number of bits in
- * a bitstring label.
+ * increased by 1 for an ordinary label.
*
* Depth is used when creating or validating DNSSEC signatures.
*
* How many labels does 'name' have?
*
* Notes:
- * In this case, as in other places, a 'label' is an ordinary label
- * or a bitstring label. The term is not meant to refer to individual
- * bit labels. For that purpose, use dns_name_depth().
+ * In this case, as in other places, a 'label' is an ordinary label.
*
* Requires:
* 'name' is a valid name
* Uppercase letters are downcased in the copy iff. 'downcase' is
* true.
*
- * Any bitstring labels in source are canonicalized.
- * (i.e. maximally packed and any padding bits zeroed.)
- *
* The current location in source is advanced, and the used space
* in target is updated.
*
* If result is success:
* If 'target' is not NULL, 'name' is attached to it.
*
- * Any bitstring labels in source are canonicalized.
- *
* Uppercase letters are downcased in the copy iff. 'downcase' is
* true.
*
* DNS_R_EMPTYLABEL
* DNS_R_LABELTOOLONG
* DNS_R_BADESCAPE
- * DNS_R_BADBITSTRING
- * DNS_R_BITSTRINGTOOLONG
+ * (DNS_R_BADBITSTRING: should not be returned)
+ * (DNS_R_BITSTRINGTOOLONG: should not be returned)
* DNS_R_BADDOTTEDQUAD
* ISC_R_NOSPACE
* ISC_R_UNEXPECTEDEND
* If 'target' is not NULL and 'name' is not NULL, then 'name'
* is attached to it.
*
- * Any bitstring labels are in canonical form.
- *
* The used space in target is updated.
*
* Returns:
*
* Notes:
* 'name' is split such that 'suffix' holds the most significant
- * 'suffixlabels' labels, except that if the least significant
- * suffix label is a bitstring label, then only the 'nbits' most
- * significant bits of that label are included in 'suffix'. All
- * other labels and bits are stored in 'prefix'.
+ * 'suffixlabels' labels. All other labels and bits are stored
+ * in 'prefix'.
*
* Copying name data is avoided as much as possible, so 'prefix'
- * and 'suffix' will usually end up pointing at the data for 'name',
- * except when 'nbits' > 0. The name data is copied to the
- * the dedicated buffers when splitting on bitlabel boundaries
- * because of the bit fiddling that must be done.
+ * and 'suffix' will end up pointing at the data for 'name'.
*
* It is legitimate to pass a 'prefix' or 'suffix' that has
* its name data stored someplace other than the dedicated buffer.
* This is useful to avoid name copying in the calling function.
*
* It is also legitimate to pass a 'prefix' or 'suffix' that is
- * the same dns_name_t as 'name', but note well the requirement
- * below if splitting on a bitlabel boundary.
+ * the same dns_name_t as 'name'.
*
* Requires:
* 'name' is a valid name.
*
* 'suffixlabels' cannot exceed the number of labels in 'name'.
*
- * 'nbits' can be greater than zero only when the least significant
- * label of 'suffix' is a bitstring label.
- *
- * 'nbits' cannot exceed the number of bits in the bitstring label.
+ * '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' and 'suffix' cannot point to the same buffer.
*
- * If 'nbits' > 0 and 'prefix' and 'suffix' are both non-NULL,
- * the buffer for 'prefix' cannot be storing the labels for 'name'.
- *
* Ensures:
*
* On success:
* If 'prefix' is not NULL it will contain the least significant
- * labels and bits.
+ * labels.
*
* If 'suffix' is not NULL it will contain the most significant
- * labels and bits. dns_name_countlabels(suffix) will be
- * equal to suffixlabels.
+ * 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:
- * ISC_R_SUCCESS No worries.
- * ISC_R_NOSPACE An attempt was made to split a name on a bitlabel
- * boundary but either 'prefix' or 'suffix' did not
- * have enough room to receive the split name.
+ * ISC_R_SUCCESS No worries. (This function should always success).
*/
isc_result_t
*
* On success:
* If 'prefix' is not NULL it will contain the least significant
- * labels and bits.
+ * labels.
*
* If 'suffix' is not NULL it will contain the most significant
- * labels and bits. dns_name_countlabels(suffix) will be
- * equal to suffixlabels.
+ * labels. dns_name_countlabels(suffix) will be equal to
+ * suffixlabels.
*
* On failure:
* Either 'prefix' or 'suffix' is invalidated (depending
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: result.h,v 1.93 2002/08/09 06:12:50 marka Exp $ */
+/* $Id: result.h,v 1.94 2002/08/27 04:53:43 marka Exp $ */
#ifndef DNS_RESULT_H
#define DNS_RESULT_H 1
*/
#define DNS_R_LABELTOOLONG (ISC_RESULTCLASS_DNS + 0)
#define DNS_R_BADESCAPE (ISC_RESULTCLASS_DNS + 1)
+/*
+ * Since we dropped the support of bitstring labels, deprecate the related
+ * result codes too.
+
#define DNS_R_BADBITSTRING (ISC_RESULTCLASS_DNS + 2)
#define DNS_R_BITSTRINGTOOLONG (ISC_RESULTCLASS_DNS + 3)
+*/
#define DNS_R_EMPTYLABEL (ISC_RESULTCLASS_DNS + 4)
#define DNS_R_BADDOTTEDQUAD (ISC_RESULTCLASS_DNS + 5)
#define DNS_R_INVALIDNS (ISC_RESULTCLASS_DNS + 6)
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: types.h,v 1.105 2002/03/07 07:48:48 bwelling Exp $ */
+/* $Id: types.h,v 1.106 2002/08/27 04:53:43 marka Exp $ */
#ifndef DNS_TYPES_H
#define DNS_TYPES_H 1
typedef struct dns_zonemgr dns_zonemgr_t;
typedef struct dns_zt dns_zt_t;
-typedef enum {
- dns_bitlabel_0 = 0,
- dns_bitlabel_1 = 1
-} dns_bitlabel_t;
-
typedef enum {
dns_fwdpolicy_none = 0,
dns_fwdpolicy_first = 1,
dns_fwdpolicy_only = 2
} dns_fwdpolicy_t;
-typedef enum {
- dns_labeltype_ordinary = 0,
- dns_labeltype_bitstring = 1
-} dns_labeltype_t;
-
typedef enum {
dns_namereln_none = 0,
dns_namereln_contains = 1,
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: name.c,v 1.136 2002/08/02 00:25:15 marka Exp $ */
+/* $Id: name.c,v 1.137 2002/08/27 04:53:42 marka Exp $ */
#include <config.h>
ft_initialescape,
ft_escape,
ft_escdecimal,
- ft_bitstring,
- ft_binary,
- ft_octal,
- ft_hex,
- ft_dottedquad,
- ft_dqdecimal,
- ft_maybeslash,
- ft_finishbitstring,
- ft_bitlength,
- ft_eatdot,
ft_at
} ft_state;
fw_start = 0,
fw_ordinary,
fw_copy,
- fw_bitstring,
fw_newcurrent
} fw_state;
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/
};
-static char hexdigits[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
-};
-
static unsigned char maptolower[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
set_offsets(const dns_name_t *name, unsigned char *offsets,
dns_name_t *set_name);
-static void
-compact(dns_name_t *name, unsigned char *offsets);
-
-/*
- * Yes, get_bit and set_bit are lame. We define them here so they can
- * be inlined by smart compilers.
- */
-
-static inline unsigned int
-get_bit(unsigned char *array, unsigned int idx) {
- unsigned int byte, shift;
-
- byte = array[idx / 8];
- shift = 7 - (idx % 8);
-
- return ((byte >> shift) & 0x01);
-}
-
-static inline void
-set_bit(unsigned char *array, unsigned int idx, unsigned int bit) {
- unsigned int shift, mask;
-
- shift = 7 - (idx % 8);
- mask = 1 << shift;
-
- if (bit != 0)
- array[idx / 8] |= mask;
- else
- array[idx / 8] &= (~mask & 0xFF);
-}
-
-dns_labeltype_t
-dns_label_type(dns_label_t *label) {
- /*
- * Get the type of 'label'.
- */
-
- REQUIRE(label != NULL);
- REQUIRE(label->length > 0);
- REQUIRE(label->base[0] <= 63 ||
- label->base[0] == DNS_LABELTYPE_BITSTRING);
-
- if (label->base[0] <= 63)
- return (dns_labeltype_ordinary);
- else
- return (dns_labeltype_bitstring);
-}
-
-unsigned int
-dns_label_countbits(dns_label_t *label) {
- unsigned int count;
-
- /*
- * The number of bits in a bitstring label.
- */
-
- REQUIRE(label != NULL);
- REQUIRE(label->length > 2);
- REQUIRE(label->base[0] == DNS_LABELTYPE_BITSTRING);
-
- count = label->base[1];
- if (count == 0)
- count = 256;
-
- return (count);
-}
-
-dns_bitlabel_t
-dns_label_getbit(dns_label_t *label, unsigned int n) {
- unsigned int count, bit;
-
- /*
- * The 'n'th most significant bit of 'label'.
- *
- * Notes:
- * Numbering starts at 0.
- */
-
- REQUIRE(label != NULL);
- REQUIRE(label->length > 2);
- REQUIRE(label->base[0] == DNS_LABELTYPE_BITSTRING);
-
- count = label->base[1];
- if (count == 0)
- count = 256;
-
- REQUIRE(n < count);
-
- bit = get_bit(&label->base[2], n);
- if (bit == 0)
- return (dns_bitlabel_0);
- return (dns_bitlabel_1);
-}
-
void
dns_name_init(dns_name_t *name, unsigned char *offsets) {
/*
isc_boolean_t
dns_name_requiresedns(const dns_name_t *name) {
- unsigned int count, nrem;
- unsigned char *ndata;
- isc_boolean_t requiresedns = ISC_FALSE;
-
/*
* 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);
- ndata = name->ndata;
- nrem = name->length;
- while (nrem > 0) {
- count = *ndata++;
- nrem--;
- if (count == 0)
- break;
- if (count > 63) {
- INSIST(count == DNS_LABELTYPE_BITSTRING);
- requiresedns = ISC_TRUE;
- break;
- }
- INSIST(nrem >= count);
- nrem -= count;
- ndata += count;
- }
-
- return (requiresedns);
+ return (ISC_FALSE);
}
static inline unsigned int
int *orderp,
unsigned int *nlabelsp, unsigned int *nbitsp)
{
- unsigned int l1, l2, l, count1, count2, count;
- unsigned int b1, b2, n, nlabels, nbits;
+ unsigned int l1, l2, l, count1, count2, count, nlabels;
int cdiff, ldiff, chdiff;
unsigned char *label1, *label2;
unsigned char *offsets1, *offsets2;
SETUP_OFFSETS(name2, offsets2, odata2);
nlabels = 0;
- nbits = 0;
l1 = name1->labels;
l2 = name2->labels;
ldiff = (int)l1 - (int)l2;
label2 = &name2->ndata[offsets2[l2]];
count1 = *label1++;
count2 = *label2++;
- if (count1 <= 63 && count2 <= 63) {
- cdiff = (int)count1 - (int)count2;
- if (cdiff < 0)
- count = count1;
- else
- count = count2;
- while (count > 0) {
- chdiff = (int)maptolower[*label1] -
- (int)maptolower[*label2];
- if (chdiff != 0) {
- *orderp = chdiff;
- goto done;
- }
- count--;
- label1++;
- label2++;
- }
- if (cdiff != 0) {
- *orderp = cdiff;
+ /*
+ * We dropped bitstring labels, and we don't support any
+ * other extended label types.
+ */
+ INSIST(count1 <= 63 && count2 <= 63);
+
+ cdiff = (int)count1 - (int)count2;
+ if (cdiff < 0)
+ count = count1;
+ else
+ count = count2;
+
+ while (count > 0) {
+ chdiff = (int)maptolower[*label1] -
+ (int)maptolower[*label2];
+ if (chdiff != 0) {
+ *orderp = chdiff;
goto done;
}
- nlabels++;
- } else if (count1 == DNS_LABELTYPE_BITSTRING && count2 <= 63) {
- if (count2 == 0)
- *orderp = 1;
- else
- *orderp = -1;
- goto done;
- } else if (count2 == DNS_LABELTYPE_BITSTRING && count1 <= 63) {
- if (count1 == 0)
- *orderp = -1;
- else
- *orderp = 1;
+ count--;
+ label1++;
+ label2++;
+ }
+ if (cdiff != 0) {
+ *orderp = cdiff;
goto done;
- } else {
- INSIST(count1 == DNS_LABELTYPE_BITSTRING &&
- count2 == DNS_LABELTYPE_BITSTRING);
- count1 = *label1++;
- if (count1 == 0)
- count1 = 256;
- count2 = *label2++;
- if (count2 == 0)
- count2 = 256;
- if (count1 < count2) {
- cdiff = -1;
- count = count1;
- } else {
- count = count2;
- if (count1 > count2)
- cdiff = 1;
- else
- cdiff = 0;
- }
- /* Yes, this loop is really slow! */
- for (n = 0; n < count; n++) {
- b1 = get_bit(label1, n);
- b2 = get_bit(label2, n);
- if (b1 < b2) {
- *orderp = -1;
- goto done;
- } else if (b1 > b2) {
- *orderp = 1;
- goto done;
- }
- if (nbits == 0)
- nlabels++;
- nbits++;
- }
- if (cdiff != 0) {
- /*
- * If we're here, then we have two bitstrings
- * of differing length.
- *
- * If the name with the shorter bitstring
- * has any labels, then it must be greater
- * than the longer bitstring. This is a bit
- * counterintuitive. If the name with the
- * shorter bitstring has any more labels, then
- * the next label must be an ordinary label.
- * It can't be a bitstring label because if it
- * were, then there would be room for it in
- * the current bitstring label (since all
- * bitstrings are canonicalized). Since
- * there's at least one more bit in the
- * name with the longer bitstring, and since
- * a bitlabel sorts before any ordinary label,
- * the name with the longer bitstring must
- * be lexically before the one with the shorter
- * bitstring.
- *
- * On the other hand, if there are no more
- * labels in the name with the shorter
- * bitstring, then that name contains the
- * other name.
- */
- namereln = dns_namereln_commonancestor;
- if (cdiff < 0) {
- if (l1 > 0)
- *orderp = 1;
- else {
- *orderp = -1;
- namereln =
- dns_namereln_contains;
- }
- } else {
- if (l2 > 0)
- *orderp = -1;
- else {
- *orderp = 1;
- namereln =
- dns_namereln_subdomain;
- }
- }
- goto done;
- }
- nbits = 0;
}
+ nlabels++;
}
*orderp = ldiff;
done:
*nlabelsp = nlabels;
- *nbitsp = nbits;
+ *nbitsp = 0;
if (nlabels > 0 && namereln == dns_namereln_none)
namereln = dns_namereln_commonancestor;
count = *label1++;
if (count != *label2++)
return (ISC_FALSE);
- if (count <= 63) {
- while (count > 0) {
- count--;
- c = maptolower[*label1++];
- if (c != maptolower[*label2++])
- return (ISC_FALSE);
- }
- } else {
- INSIST(count == DNS_LABELTYPE_BITSTRING);
- count = *label1++;
- if (count != *label2++)
+
+ INSIST(count <= 63); /* no bitstring support */
+
+ while (count > 0) {
+ count--;
+ c = maptolower[*label1++];
+ if (c != maptolower[*label2++])
return (ISC_FALSE);
- if (count == 0)
- count = 256;
- /*
- * Number of bytes.
- */
- count = (count + 7) / 8;
- while (count > 0) {
- count--;
- c = *label1++;
- if (c != *label2++)
- return (ISC_FALSE);
- }
}
}
l--;
count1 = *label1++;
count2 = *label2++;
- if (count1 <= 63 && count2 <= 63) {
- if (count1 != count2)
- return ((count1 < count2) ? -1 : 1);
- count = count1;
- while (count > 0) {
- count--;
- c1 = maptolower[*label1++];
- c2 = maptolower[*label2++];
- if (c1 < c2)
- return (-1);
- else if (c1 > c2)
- return (1);
- }
- } else if (count1 == DNS_LABELTYPE_BITSTRING && count2 <= 63) {
- return (1);
- } else if (count2 == DNS_LABELTYPE_BITSTRING && count1 <= 63) {
- return (-1);
- } else {
- INSIST(count1 == DNS_LABELTYPE_BITSTRING &&
- count2 == DNS_LABELTYPE_BITSTRING);
- count2 = *label2++;
- count1 = *label1++;
- if (count1 != count2)
- return ((count1 < count2) ? -1 : 1);
- if (count1 == 0)
- count1 = 256;
- if (count2 == 0)
- count2 = 256;
- /* number of bytes */
- count = (count1 + 7) / 8;
- while (count > 0) {
- count--;
- c1 = *label1++;
- c2 = *label2++;
- if (c1 != c2)
- return ((c1 < c2) ? -1 : 1);
- }
+
+ /* no bitstring support */
+ INSIST(count1 <= 63 && count2 <= 63);
+
+ if (count1 != count2)
+ return ((count1 < count2) ? -1 : 1);
+ count = count1;
+ while (count > 0) {
+ count--;
+ c1 = maptolower[*label1++];
+ c2 = maptolower[*label2++];
+ if (c1 < c2)
+ return (-1);
+ else if (c1 > c2)
+ return (1);
}
}
unsigned int
dns_name_depth(const dns_name_t *name) {
- unsigned int depth, count, nrem, n;
+ unsigned int depth, count, nrem;
unsigned char *ndata;
/*
nrem = name->length;
while (nrem > 0) {
count = *ndata++;
+ INSIST(count <= 63); /* no bitstring support */
+
nrem--;
- if (count > 63) {
- INSIST(count == DNS_LABELTYPE_BITSTRING);
- INSIST(nrem != 0);
- n = *ndata++;
- nrem--;
- if (n == 0)
- n = 256;
- depth += n;
- count = n / 8;
- if (n % 8 != 0)
- count++;
- } else {
- depth++;
- if (count == 0)
- break;
- }
+ depth++;
+ if (count == 0)
+ break;
+
INSIST(nrem >= count);
nrem -= count;
ndata += count;
ft_state state, kind;
unsigned int value, count, tbcount, bitlength, maxlength;
unsigned int n1, n2, vlen, tlen, nrem, nused, digits, labels, tused;
- isc_boolean_t done, saw_bitstring;
- unsigned char dqchars[4];
+ isc_boolean_t done;
unsigned char *offsets;
dns_offsets_t odata;
nused = 0;
labels = 0;
done = ISC_FALSE;
- saw_bitstring = ISC_FALSE;
state = ft_init;
while (nrem > 0 && tlen > 0 && !done) {
tlen--;
tused++;
- no_read:
switch (state) {
case ft_init:
/*
break;
case ft_initialescape:
if (c == '[') {
- saw_bitstring = ISC_TRUE;
- kind = ft_bitstring;
- state = ft_bitstring;
- *label = DNS_LABELTYPE_BITSTRING;
- label = ndata;
- ndata++;
- nrem--;
- nused++;
- break;
+ /*
+ * This looks like a bitstring label, which
+ * was deprecated. Intentionally drop it.
+ */
+ return (DNS_R_BADLABELTYPE);
}
kind = ft_ordinary;
state = ft_escape;
state = ft_ordinary;
}
break;
- case ft_bitstring:
- /* count is zero */
- tbcount = 0;
- value = 0;
- if (c == 'b') {
- vlen = 8;
- maxlength = 256;
- kind = ft_binary;
- state = ft_binary;
- } else if (c == 'o') {
- vlen = 8;
- maxlength = 256;
- kind = ft_octal;
- state = ft_octal;
- } else if (c == 'x') {
- vlen = 8;
- maxlength = 256;
- kind = ft_hex;
- state = ft_hex;
- } else if (isdigit(c & 0xff)) {
- vlen = 32;
- maxlength = 32;
- n1 = 0;
- n2 = 0;
- digits = 0;
- kind = ft_dottedquad;
- state = ft_dqdecimal;
- goto no_read;
- } else
- return (DNS_R_BADBITSTRING);
- break;
- case ft_binary:
- if (c != '0' && c != '1') {
- state = ft_maybeslash;
- goto no_read;
- }
- value <<= 1;
- if (c == '1')
- value |= 1;
- count++;
- tbcount++;
- if (tbcount > 256)
- return (DNS_R_BITSTRINGTOOLONG);
- if (count == 8) {
- *ndata++ = value;
- nrem--;
- nused++;
- count = 0;
- }
- break;
- case ft_octal:
- if (!isdigit(c & 0xff) || c == '9' || c == '8') {
- state = ft_maybeslash;
- goto no_read;
- }
- value <<= 3;
- value += digitvalue[(int)c];
- count += 3;
- tbcount += 3;
- /*
- * The total bit count is tested against 258 instead
- * of 256 because of the possibility that the bitstring
- * label is exactly 256 bits long; on the last octal
- * digit (which must be 4) tbcount is incremented
- * from 255 to 258. This case is adequately handled
- * later.
- */
- if (tbcount > 258)
- return (DNS_R_BITSTRINGTOOLONG);
- if (count == 8) {
- *ndata++ = value;
- nrem--;
- nused++;
- count = 0;
- } else if (count == 9) {
- *ndata++ = (value >> 1);
- nrem--;
- nused++;
- value &= 1;
- count = 1;
- } else if (count == 10) {
- *ndata++ = (value >> 2);
- nrem--;
- nused++;
- value &= 3;
- count = 2;
- }
- break;
- case ft_hex:
- if (!isxdigit(c & 0xff)) {
- state = ft_maybeslash;
- goto no_read;
- }
- value <<= 4;
- value += digitvalue[(int)c];
- count += 4;
- tbcount += 4;
- if (tbcount > 256)
- return (DNS_R_BITSTRINGTOOLONG);
- if (count == 8) {
- *ndata++ = value;
- nrem--;
- nused++;
- count = 0;
- }
- break;
- case ft_dottedquad:
- if (c != '.' && n1 < 3)
- return (DNS_R_BADDOTTEDQUAD);
- dqchars[n1] = value;
- n2 *= 256;
- n2 += value;
- n1++;
- if (n1 == 4) {
- tbcount = 32;
- value = n2;
- state = ft_maybeslash;
- goto no_read;
- }
- value = 0;
- digits = 0;
- state = ft_dqdecimal;
- break;
- case ft_dqdecimal:
- if (!isdigit(c & 0xff)) {
- if (digits == 0 || value > 255)
- return (DNS_R_BADDOTTEDQUAD);
- state = ft_dottedquad;
- goto no_read;
- }
- digits++;
- if (digits > 3)
- return (DNS_R_BADDOTTEDQUAD);
- value *= 10;
- value += digitvalue[(int)c];
- break;
- case ft_maybeslash:
- bitlength = 0;
- if (c == '/') {
- state = ft_bitlength;
- break;
- }
- /* FALLTHROUGH */
- case ft_finishbitstring:
- if (c == ']') {
- if (tbcount == 0)
- return (DNS_R_BADBITSTRING);
-
- if (count > 0) {
- n1 = count % 8;
- if (n1 != 0)
- value <<= (8 - n1);
- }
-
- if (bitlength != 0) {
- if (bitlength > tbcount)
- return (DNS_R_BADBITSTRING);
- if (kind == ft_binary &&
- bitlength != tbcount) {
- return (DNS_R_BADBITSTRING);
- } else if (kind == ft_octal) {
- /*
- * Figure out correct number
- * of octal digits for the
- * bitlength, and compare to
- * what was given.
- */
- n1 = bitlength / 3;
- if (bitlength % 3 != 0)
- n1++;
- n2 = tbcount / 3;
- /* tbcount % 3 == 0 */
- if (n1 != n2)
- return (DNS_R_BADBITSTRING);
-
- /*
- * Check that no bits extend
- * past the end of the last
- * byte that is included in
- * the bitlength. Example:
- * \[o036/8] == \[b00001111],
- * which fits into just one
- * byte, but the three octal
- * digits actually specified
- * two bytes worth of data,
- * 9 bits, before the bitlength
- * limited it back to one byte.
- *
- * n1 is the number of bytes
- * necessary for the bitlength.
- * n2 is the number of bytes
- * encompassed by the octal
- * digits. If they are not
- * equal, then "value" holds
- * the excess bits, which
- * must be zero. If the bits
- * are zero, then "count" is
- * zero'ed to prevent the
- * addition of another byte
- * below.
- */
- n1 = (bitlength - 1) / 8;
- n2 = (tbcount - 1) / 8;
- if (n1 != n2) {
- if (value != 0)
- return
- (DNS_R_BADBITSTRING);
- else
- count = 0;
- }
- } else if (kind == ft_hex) {
- /*
- * Figure out correct number
- * of hex digits for the
- * bitlength, and compare to
- * what was given.
- */
- n1 = bitlength / 4;
- if (bitlength % 4 != 0)
- n1++;
- n2 = tbcount / 4;
- /* tbcount % 4 == 0 */
- if (n1 != n2)
- return (DNS_R_BADBITSTRING);
- }
- n1 = bitlength % vlen;
- if (n1 != 0) {
- /*
- * Are the pad bits in the
- * last 'vlen' bits zero?
- */
- if ((value &
- ~((~0) << (vlen-n1))) != 0)
- return (DNS_R_BADBITSTRING);
- }
- } else if (kind == ft_dottedquad)
- bitlength = 32;
- else if (tbcount > 256)
- /*
- * This can happen when an octal
- * bitstring label of 86 octal digits
- * is specified; tbcount will be 258.
- * This is not trapped above because
- * the bitstring label might be limited
- * by a "/256" modifier.
- */
- return (DNS_R_BADBITSTRING);
- else
- bitlength = tbcount;
-
- if (count > 0) {
- *ndata++ = value;
- nrem--;
- nused++;
- }
-
- if (kind == ft_dottedquad) {
- n1 = bitlength / 8;
- if (bitlength % 8 != 0)
- n1++;
- if (nrem < n1)
- return (ISC_R_NOSPACE);
- for (n2 = 0; n2 < n1; n2++) {
- *ndata++ = dqchars[n2];
- nrem--;
- nused++;
- }
- }
- if (bitlength == 256)
- *label = 0;
- else
- *label = bitlength;
- labels++;
- INSIST(labels <= 127);
- offsets[labels] = nused;
- } else
- return (DNS_R_BADBITSTRING);
- state = ft_eatdot;
- break;
- case ft_bitlength:
- if (!isdigit(c & 0xff)) {
- if (bitlength == 0)
- return (DNS_R_BADBITSTRING);
- state = ft_finishbitstring;
- goto no_read;
- }
- bitlength *= 10;
- bitlength += digitvalue[(int)c];
- if (bitlength > maxlength)
- return (DNS_R_BADBITSTRING);
- break;
- case ft_eatdot:
- if (c != '.')
- return (DNS_R_BADBITSTRING);
- if (tlen == 0) {
- labels++;
- *ndata++ = 0;
- nrem--;
- nused++;
- done = ISC_TRUE;
- }
- state = ft_start;
- break;
default:
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected state %d", state);
if (nrem == 0)
return (ISC_R_NOSPACE);
INSIST(tlen == 0);
- if (state != ft_ordinary && state != ft_eatdot &&
- state != ft_at)
+ if (state != ft_ordinary && state != ft_at)
return (ISC_R_UNEXPECTEDEND);
if (state == ft_ordinary) {
INSIST(count != 0);
nrem -= n1;
while (n1 > 0) {
n2 = *label++;
- if (n2 <= 63) {
- *ndata++ = n2;
- n1 -= n2 + 1;
- nused += n2 + 1;
- while (n2 > 0) {
- c = *label++;
- if (downcase)
- c = maptolower[(int)c];
- *ndata++ = c;
- n2--;
- }
- } else {
- INSIST(n2 == DNS_LABELTYPE_BITSTRING);
- *ndata++ = n2;
- bitlength = *label++;
- *ndata++ = bitlength;
- if (bitlength == 0)
- bitlength = 256;
- n2 = bitlength / 8;
- if (bitlength % 8 != 0)
- n2++;
- n1 -= n2 + 2;
- nused += n2 + 2;
- while (n2 > 0) {
- *ndata++ = *label++;
- n2--;
- }
+ INSIST(n2 <= 63); /* no bitstring support */
+ *ndata++ = n2;
+ n1 -= n2 + 1;
+ nused += n2 + 1;
+ while (n2 > 0) {
+ c = *label++;
+ if (downcase)
+ c = maptolower[(int)c];
+ *ndata++ = c;
+ n2--;
}
labels++;
if (n1 > 0) {
name->labels = labels;
name->length = nused;
- if (saw_bitstring)
- compact(name, offsets);
-
isc_buffer_forward(source, tused);
isc_buffer_add(target, name->length);
unsigned int nlen, tlen;
unsigned char c;
unsigned int trem, count;
- unsigned int bytes, nibbles;
- size_t i, len;
unsigned int labels;
isc_boolean_t saw_root = ISC_FALSE;
- char num[4];
/*
* This function assumes the name is in proper uncompressed
}
count--;
}
- } else if (count == DNS_LABELTYPE_BITSTRING) {
- if (trem < 3)
- return (ISC_R_NOSPACE);
- *tdata++ = '\\';
- *tdata++ = '[';
- *tdata++ = 'x';
- trem -= 3;
- INSIST(nlen > 0);
- count = *ndata++;
- if (count == 0)
- count = 256;
- nlen--;
- len = sprintf(num, "%u", count); /* XXX */
- INSIST(len <= 4);
- bytes = count / 8;
- if (count % 8 != 0)
- bytes++;
- INSIST(nlen >= bytes);
- nibbles = count / 4;
- if (count % 4 != 0)
- nibbles++;
- if (trem < nibbles)
- return (ISC_R_NOSPACE);
- trem -= nibbles;
- nlen -= bytes;
- while (nibbles > 0) {
- c = *ndata++;
- *tdata++ = hexdigits[(c >> 4)];
- nibbles--;
- if (nibbles != 0) {
- *tdata++ = hexdigits[c & 0xf];
- nibbles--;
- }
- }
- if (trem < 2 + len)
- return (ISC_R_NOSPACE);
- *tdata++ = '/';
- for (i = 0; i < len; i++)
- *tdata++ = num[i];
- *tdata++ = ']';
- trem -= 2 + len;
- } else {
+ } else {
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected label type %02x", count);
/* NOTREACHED */
unsigned int nlen, tlen;
unsigned char c;
unsigned int trem, count;
- unsigned int bytes, nibbles;
- size_t i, len;
unsigned int labels;
- char num[4];
/*
* This function assumes the name is in proper uncompressed
}
count--;
}
- } else if (count == DNS_LABELTYPE_BITSTRING) {
- if (trem < 3)
- return (ISC_R_NOSPACE);
- *tdata++ = '%';
- *tdata++ = 'x';
- trem -= 2;
- INSIST(nlen > 0);
- count = *ndata++;
- if (count == 0)
- count = 256;
- nlen--;
- len = sprintf(num, "%u", count); /* XXX */
- INSIST(len <= 4);
- bytes = count / 8;
- if (count % 8 != 0)
- bytes++;
- INSIST(nlen >= bytes);
- nibbles = count / 4;
- if (count % 4 != 0)
- nibbles++;
- if (trem < nibbles)
- return (ISC_R_NOSPACE);
- trem -= nibbles;
- nlen -= bytes;
- while (nibbles > 0) {
- c = *ndata++;
- *tdata++ = hexdigits[(c >> 4)];
- nibbles--;
- if (nibbles != 0) {
- *tdata++ = hexdigits[c & 0xf];
- i++;
- nibbles--;
- }
- }
- if (trem < 2 + len)
- return (ISC_R_NOSPACE);
- *tdata++ = '%';
- for (i = 0; i < len; i++)
- *tdata++ = num[i];
- *tdata++ = '%';
- trem -= 2 + len;
} else {
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected label type %02x", count);
isc_result_t
dns_name_downcase(dns_name_t *source, dns_name_t *name, isc_buffer_t *target) {
unsigned char *sndata, *ndata;
- unsigned int nlen, count, bytes, labels;
+ unsigned int nlen, count, labels;
isc_buffer_t buffer;
/*
nlen--;
count--;
}
- } else if (count == DNS_LABELTYPE_BITSTRING) {
- INSIST(nlen > 0);
- count = *sndata++;
- *ndata++ = count;
- if (count == 0)
- count = 256;
- nlen--;
-
- bytes = count / 8;
- if (count % 8 != 0)
- bytes++;
-
- INSIST(nlen >= bytes);
- nlen -= bytes;
- while (bytes > 0) {
- *ndata++ = *sndata++;
- bytes--;
- }
} else {
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected label type %02x", count);
set_offsets(const dns_name_t *name, unsigned char *offsets,
dns_name_t *set_name)
{
- unsigned int offset, count, length, nlabels, n;
+ unsigned int offset, count, length, nlabels;
unsigned char *ndata;
isc_boolean_t absolute;
offsets[nlabels++] = offset;
count = *ndata++;
offset++;
- if (count <= 63) {
- offset += count;
- ndata += count;
- INSIST(offset <= length);
- if (count == 0) {
- absolute = ISC_TRUE;
- break;
- }
- } else {
- INSIST(count == DNS_LABELTYPE_BITSTRING);
- n = *ndata++;
- offset++;
- if (n == 0)
- n = 256;
- count = n / 8;
- if (n % 8 != 0)
- count++;
- offset += count;
- ndata += count;
- INSIST(offset <= length);
+ INSIST(count <= 63);
+ offset += count;
+ ndata += count;
+ INSIST(offset <= length);
+ if (count == 0) {
+ absolute = ISC_TRUE;
+ break;
}
}
if (set_name != NULL) {
INSIST(offset == name->length);
}
-static void
-compact(dns_name_t *name, unsigned char *offsets) {
- unsigned char *head, *curr, *last;
- unsigned int count, n, bit;
- unsigned int headbits, currbits, tailbits, newbits;
- unsigned int headrem, newrem;
- unsigned int headindex, currindex, tailindex, newindex;
- unsigned char tail[32];
-
- /*
- * The caller MUST ensure that all bitstrings are correctly formatted
- * and that the offsets table is valid.
- */
-
- again:
- memset(tail, 0, sizeof(tail));
- INSIST(name->labels != 0);
- n = name->labels - 1;
-
- while (n > 0) {
- head = &name->ndata[offsets[n]];
- if (head[0] == DNS_LABELTYPE_BITSTRING && head[1] != 0) {
- if (n != 0) {
- n--;
- curr = &name->ndata[offsets[n]];
- if (curr[0] != DNS_LABELTYPE_BITSTRING)
- continue;
- /*
- * We have consecutive bitstrings labels, and
- * the more significant label ('head') has
- * space.
- */
- currbits = curr[1];
- if (currbits == 0)
- currbits = 256;
- currindex = 0;
- headbits = head[1];
- if (headbits == 0)
- headbits = 256;
- headindex = headbits;
- count = 256 - headbits;
- if (count > currbits)
- count = currbits;
- headrem = headbits % 8;
- if (headrem != 0)
- headrem = 8 - headrem;
- if (headrem != 0) {
- if (headrem > count)
- headrem = count;
- do {
- bit = get_bit(&curr[2],
- currindex);
- set_bit(&head[2], headindex,
- bit);
- currindex++;
- headindex++;
- headbits++;
- count--;
- headrem--;
- } while (headrem != 0);
- }
- tailindex = 0;
- tailbits = 0;
- while (count > 0) {
- bit = get_bit(&curr[2], currindex);
- set_bit(tail, tailindex, bit);
- currindex++;
- tailindex++;
- tailbits++;
- count--;
- }
- newbits = 0;
- newindex = 0;
- if (currindex < currbits) {
- while (currindex < currbits) {
- bit = get_bit(&curr[2],
- currindex);
- set_bit(&curr[2], newindex,
- bit);
- currindex++;
- newindex++;
- newbits++;
- }
- INSIST(newbits < 256);
- curr[1] = newbits;
- count = newbits / 8;
- newrem = newbits % 8;
- /* Zero remaining pad bits, if any. */
- if (newrem != 0) {
- count++;
- newrem = 8 - newrem;
- while (newrem > 0) {
- set_bit(&curr[2],
- newindex,
- 0);
- newrem--;
- newindex++;
- }
- }
- curr += count + 2;
- } else {
- /* We got rid of curr. */
- name->labels--;
- }
- /* copy head, then tail, then rest to curr. */
- count = headbits + tailbits;
- INSIST(count <= 256);
- curr[0] = DNS_LABELTYPE_BITSTRING;
- if (count == 256)
- curr[1] = 0;
- else
- curr[1] = count;
- curr += 2;
- head += 2;
- count = headbits / 8;
- if (headbits % 8 != 0)
- count++;
- while (count > 0) {
- *curr++ = *head++;
- count--;
- }
- count = tailbits / 8;
- if (tailbits % 8 != 0)
- count++;
- last = tail;
- while (count > 0) {
- *curr++ = *last++;
- count--;
- }
- last = name->ndata + name->length;
- while (head != last)
- *curr++ = *head++;
- name->length = (curr - name->ndata);
- /*
- * The offsets table may now be invalid.
- */
- set_offsets(name, offsets, NULL);
- goto again;
- }
- }
- n--;
- }
-}
-
isc_result_t
dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
dns_decompress_t *dctx, isc_boolean_t downcase,
unsigned int cused; /* Bytes of compressed name data used */
unsigned int hops, nused, labels, n, nmax;
unsigned int current, new_current, biggest_pointer;
- isc_boolean_t saw_bitstring, done;
+ isc_boolean_t done;
fw_state state = fw_start;
unsigned int c;
unsigned char *offsets;
*/
labels = 0;
hops = 0;
- saw_bitstring = ISC_FALSE;
done = ISC_FALSE;
ndata = isc_buffer_used(target);
new_current = c & 0x3F;
n = 1;
state = fw_newcurrent;
- } else if (c == DNS_LABELTYPE_BITSTRING) {
- offsets[labels] = nused;
- labels++;
- if (nused == nmax)
- goto full;
- nused++;
- *ndata++ = c;
- saw_bitstring = ISC_TRUE;
- state = fw_bitstring;
} else
return (DNS_R_BADLABELTYPE);
break;
if (n == 0)
state = fw_start;
break;
- case fw_bitstring:
- if (c == 0)
- n = 256 / 8;
- else
- n = c / 8;
- if ((c % 8) != 0)
- n++;
- if (nused + n + 1 > nmax)
- goto full;
- nused += n + 1;
- *ndata++ = c;
- state = fw_copy;
- break;
case fw_newcurrent:
new_current *= 256;
new_current += c;
name->length = nused;
name->attributes |= DNS_NAMEATTR_ABSOLUTE;
- if (saw_bitstring)
- compact(name, offsets);
-
isc_buffer_forward(source, cused);
isc_buffer_add(target, name->length);
isc_buffer_t *target)
{
unsigned char *ndata, *offsets;
- unsigned int nrem, labels, prefix_length, length, offset;
+ unsigned int nrem, labels, prefix_length, length;
isc_boolean_t copy_prefix = ISC_TRUE;
isc_boolean_t copy_suffix = ISC_TRUE;
- isc_boolean_t saw_bitstring = ISC_FALSE;
isc_boolean_t absolute = ISC_FALSE;
dns_name_t tmp_name;
dns_offsets_t odata;
REQUIRE(BINDABLE(name));
- /*
- * XXX IMPORTANT NOTE
- *
- * If the most-signficant label in prefix is a bitstring,
- * and the least-signficant label in suffix is a bitstring,
- * it's possible that compaction could convert them into
- * one label. If this happens, then the final size will
- * be three bytes less than nrem.
- *
- * We do not check for this special case, and handling it is
- * a little messy; we can't just concatenate and compact,
- * because we may only have 255 bytes but might need 258 bytes
- * temporarily. There are ways to do this with only 255 bytes,
- * which will be implemented later.
- *
- * For now, we simply reject these few cases as being too
- * long.
- */
-
/*
* Set up.
*/
if (copy_suffix) {
if ((suffix->attributes & DNS_NAMEATTR_ABSOLUTE) != 0)
absolute = ISC_TRUE;
- if (copy_prefix &&
- suffix->ndata[0] == DNS_LABELTYPE_BITSTRING) {
- /*
- * We only need to call compact() if both the
- * least-significant label of the suffix and the
- * most-significant label of the prefix are both
- * bitstrings.
- *
- * A further possible optimization, which we don't do,
- * is to not compact() if the suffix bitstring is
- * full. It will usually not be full, so I don't
- * think this is worth it.
- */
- if (prefix->offsets != NULL) {
- offset = prefix->offsets[prefix->labels - 1];
- if (prefix->ndata[offset] ==
- DNS_LABELTYPE_BITSTRING)
- saw_bitstring = ISC_TRUE;
- } else {
- /*
- * We don't have an offsets table for prefix,
- * and rather than spend the effort to make it
- * we'll just compact(), which doesn't cost
- * more than computing the offsets table if
- * there is no bitstring in prefix.
- */
- saw_bitstring = ISC_TRUE;
- }
- }
if (suffix == name && suffix->buffer == target)
memmove(ndata + prefix_length, suffix->ndata,
suffix->length);
else
name->attributes = 0;
- if (name->labels > 0 && (name->offsets != NULL || saw_bitstring)) {
+ if (name->labels > 0 && name->offsets != NULL) {
INIT_OFFSETS(name, offsets, odata);
set_offsets(name, offsets, NULL);
- if (saw_bitstring)
- compact(name, offsets);
}
isc_buffer_add(target, name->length);
dns_name_t *prefix, dns_name_t *suffix)
{
- dns_offsets_t name_odata, prefix_odata, suffix_odata;
- unsigned char *offsets, *prefix_offsets = NULL, *suffix_offsets;
- isc_result_t result = ISC_R_SUCCESS;
- unsigned int splitlabel, bitbytes, mod, len;
- unsigned char *p, *src, *dst;
- isc_boolean_t maybe_compact_prefix = ISC_FALSE;
+ dns_offsets_t name_odata;
+ unsigned char *offsets;
+ unsigned int splitlabel;
+ unsigned char *p;
+ REQUIRE(nbits == 0); /* no bitstring support */
REQUIRE(VALID_NAME(name));
REQUIRE(suffixlabels > 0);
- REQUIRE((nbits == 0 && suffixlabels < name->labels) ||
- (nbits != 0 && suffixlabels <= name->labels));
+ REQUIRE(suffixlabels < name->labels);
REQUIRE(prefix != NULL || suffix != NULL);
REQUIRE(prefix == NULL ||
(VALID_NAME(prefix) &&
suffix->buffer != NULL &&
BINDABLE(suffix)));
- /*
- * When splitting bitstring labels, if prefix and suffix have the same
- * buffer, suffix will overwrite the ndata of prefix, corrupting it.
- * If prefix has the ndata of name, then it modifies the bitstring
- * label and suffix doesn't have the original available. This latter
- * problem could be worked around if it is ever deemed desirable.
- */
- REQUIRE(nbits == 0 || prefix == NULL || suffix == NULL ||
- (prefix->buffer->base != suffix->buffer->base &&
- prefix->buffer->base != name->ndata));
-
SETUP_OFFSETS(name, offsets, name_odata);
splitlabel = name->labels - suffixlabels;
*/
p = &name->ndata[offsets[splitlabel] + 1];
- /*
- * When a bit count is specified, ensure that the label is a bitstring
- * label and it has more bits than the requested slice.
- */
- REQUIRE(nbits == 0 ||
- (*(p - 1) == DNS_LABELTYPE_BITSTRING && nbits < 256 &&
- (*p == 0 || *p > nbits)));
-
- mod = nbits % 8;
-
- if (prefix != NULL) {
- if (nbits > 0) {
- isc_buffer_clear(prefix->buffer);
+ if (prefix != NULL)
+ dns_name_getlabelsequence(name, 0, splitlabel, prefix);
- /*
- * '2' is for the DNS_LABELTYPE_BITSTRING id
- * plus the existing number of bits byte.
- */
- len = offsets[splitlabel] + 2;
- src = name->ndata;
- dst = prefix->buffer->base;
-
- if (src != dst) {
- /*
- * If these are overlapping names ...
- * wow. How bizarre could that be?
- */
- INSIST(! (src <= dst && src + len > dst) ||
- (dst <= src && dst + len > src));
-
- memcpy(dst, src, len);
-
- p = dst + len - 1;
- }
-
- /*
- * Set the new bit count. Also, when a bitstring
- * label being split is maximal length, compaction
- * might be necessary on the prefix.
- */
- if (*p == 0) {
- maybe_compact_prefix = ISC_TRUE;
- *p = 256 - nbits;
- } else
- *p = *p - nbits;
-
- /*
- * Calculate the number of bytes necessary to hold
- * all of the bits left in the prefix.
- */
- bitbytes = (*p - 1) / 8 + 1;
-
- prefix->length = len + bitbytes;
-
- if (prefix->length > prefix->buffer->length ) {
- dns_name_invalidate(prefix);
- return (ISC_R_NOSPACE);
- }
-
- /*
- * All of the bits now need to be shifted to the left
- * to fill in the space taken by the removed bits.
- * This is wonderfully easy when the number of removed
- * bits is an integral multiple of 8, but of course
- * life isn't always that easy.
- */
- src += len + nbits / 8;
- dst = p + 1;
- len = bitbytes;
-
- if (mod == 0) {
- memmove(dst, src, len);
- } else {
- /*
- * p is adjusted to point to the last byte of
- * the starting bitstring label to make it
- * cheap to determine when bits from the next
- * byte should be shifted into the low order
- * bits of the current byte.
- */
- p = src + (mod + *p - 1) / 8;
-
- while (len--) {
- *dst = *src++ << mod;
- /*
- * The 0xff subexpression guards
- * against arithmetic sign extension
- * by the right shift.
- */
- if (src <= p)
- *dst++ |=
- (*src >> (8 - mod)) &
- ~(0xFF << mod);
- }
-
- /*
- * Et voila, the very last byte has
- * automatically already had its padding
- * fixed by the left shift.
- */
- }
-
- prefix->buffer->used = prefix->length;
- prefix->ndata = prefix->buffer->base;
-
- /*
- * Yes, = is meant here, not ==. The intent is
- * to have it set only when INSISTs are turned on,
- * to doublecheck the result of set_offsets.
- */
- INSIST(len = prefix->length);
-
- INIT_OFFSETS(prefix, prefix_offsets, prefix_odata);
- set_offsets(prefix, prefix_offsets, prefix);
-
- INSIST(prefix->labels == splitlabel + 1 &&
- prefix->length == len);
-
- } else
- dns_name_getlabelsequence(name, 0, splitlabel,
- prefix);
-
- }
-
- if (suffix != NULL && result == ISC_R_SUCCESS) {
- if (nbits > 0) {
- bitbytes = (nbits - 1) / 8 + 1;
-
- isc_buffer_clear(suffix->buffer);
-
- /*
- * The existing bitcount is in src.
- * Set len to the number of bytes to be removed,
- * and the suffix length to the number of bytes in
- * the new name.
- */
- src = &name->ndata[offsets[splitlabel] + 1];
- len = ((*src == 0 ? 256 : *src) - 1) / 8;
- len -= (bitbytes - 1);
- src++;
+ if (suffix != NULL)
+ dns_name_getlabelsequence(name, splitlabel,
+ suffixlabels, suffix);
- suffix->length = name->length -
- offsets[splitlabel] - len;
-
- INSIST(suffix->length > 0);
- if (suffix->length > suffix->buffer->length) {
- dns_name_invalidate(suffix);
- return (ISC_R_NOSPACE);
- }
-
- /*
- * First set up the bitstring label.
- */
- dst = suffix->buffer->base;
- *dst++ = DNS_LABELTYPE_BITSTRING;
- *dst++ = nbits;
-
- if (len > 0) {
- /*
- * Remember where the next label starts.
- */
- p = src + bitbytes + len;
-
- /*
- * Some bytes are being removed from the
- * middle of the name because of the truncation
- * of bits in the bitstring label. Copy
- * the bytes (whether full with 8 bits or not)
- * that are being kept.
- */
- for (len = bitbytes; len > 0; len--)
- *dst++ = *src++;
-
- /*
- * Now just copy the rest of the labels of
- * the name by adjusting src to point to
- * the next label.
- *
- * 2 == label type byte + bitcount byte.
- */
- len = suffix->length - bitbytes - 2;
- src = p;
- } else
- len = suffix->length - 2;
-
- if (len > 0)
- memmove(dst, src, len);
-
- suffix->buffer->used = suffix->length;
- suffix->ndata = suffix->buffer->base;
-
- /*
- * The byte that contains the end of the
- * bitstring has its pad bits (if any) masked
- * to zero.
- */
- if (mod != 0)
- suffix->ndata[bitbytes + 1] &=
- 0xFF << (8 - mod);
-
- /*
- * Yes, = is meant here, not ==. The intent is
- * to have it set only when INSISTs are turned on,
- * to doublecheck the result of set_offsets.
- */
- INSIST(len = suffix->length);
-
- INIT_OFFSETS(suffix, suffix_offsets, suffix_odata);
- set_offsets(suffix, suffix_offsets, suffix);
-
- INSIST(suffix->labels == suffixlabels &&
- suffix->length == len);
-
- } else
- dns_name_getlabelsequence(name, splitlabel,
- suffixlabels, suffix);
-
- }
-
- /*
- * Compacting the prefix can't be done until after the suffix is
- * set, because it would screw up the offsets table of 'name'
- * when 'name' == 'prefix'.
- */
- if (maybe_compact_prefix && splitlabel > 0 &&
- prefix->ndata[prefix_offsets[splitlabel - 1]] ==
- DNS_LABELTYPE_BITSTRING)
- compact(prefix, prefix_offsets);
-
- return (result);
+ 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, nbits, label, count, n;
+ unsigned int suffixlabels, label, count;
unsigned char *offsets, *ndata;
dns_offsets_t odata;
SETUP_OFFSETS(name, offsets, odata);
suffixlabels = 0;
- nbits = 0;
label = name->labels;
do {
label--;
ndata = &name->ndata[offsets[label]];
count = *ndata++;
- if (count > 63) {
- INSIST(count == DNS_LABELTYPE_BITSTRING);
- /*
- * Get the number of bits in the bitstring label.
- */
- n = *ndata++;
- if (n == 0)
- n = 256;
- suffixlabels++;
- if (n <= depth) {
- /*
- * This entire bitstring is in the suffix.
- */
- depth -= n;
- } else {
- /*
- * Only the first 'depth' bits of this
- * bitstring are in the suffix.
- */
- nbits = depth;
- depth = 0;
- }
- } else {
- suffixlabels++;
- depth--;
- }
+ INSIST(count <= 63); /* no bitstring support */
+ suffixlabels++;
+ depth--;
} while (depth != 0 && label != 0);
/*
INSIST(0);
}
- return (dns_name_split(name, suffixlabels, nbits, prefix, suffix));
+ return (dns_name_split(name, suffixlabels, 0, prefix, suffix));
}
isc_result_t
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rbt.c,v 1.122 2001/12/04 01:32:43 bwelling Exp $ */
+/* $Id: rbt.c,v 1.123 2002/08/27 04:53:42 marka 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, add_bits;
+ unsigned int common_labels, common_bits;
int order;
REQUIRE(VALID_RBT(rbt));
/*
* Create a copy of the name so the original name structure is
- * not modified. The name data needs to be modifiable when
- * a node is split on a bitstring label.
+ * not modified.
*/
dns_fixedname_init(&fixedcopy);
add_name = dns_fixedname_name(&fixedcopy);
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);
if (compared == dns_namereln_equal) {
*nodep = current;
if (*root == current)
*root = new_current;
- /*
- * Now make the new root of the subtree
- * as the not-in-common labels of the current
- * node, keeping the same memory location so
- * as not to break any external references to
- * the node. The down pointer and name data
- * are preserved, while left and right
- * pointers are nullified when the node is
- * established as the start of the next level.
- *
- * The name stored at the node is effectively
- * truncated in place by setting the shorter
- * name length, moving the offsets to the
- * end of the truncated name, and then
- * updating PADBYTES to reflect the truncation.
- *
- * When bitstring labels are involved, things
- * are just a tad more complicated (aren't
- * they always?) because the splitting
- * has shifted the bits that this name needs
- * from the end of the label they were in
- * to either the beginning of the label or
- * even to the previous (lesser significance)
- * label if the split was done in a maximally
- * sized bitstring label. The bit count has
- * been adjusted too, so there are convolutions
- * to deal with all the bit movement. Yay,
- * I *love* bit labels. Grumble grumble.
- */
- if (common_bits > 0) {
- unsigned char *p;
- unsigned int skip_width;
- unsigned int start_label =
- dns_name_countlabels(¤t_name)
- - common_labels;
-
- /*
- * If it is not the first label which
- * was split, also copy the label
- * before it -- which will essentially
- * be a NO-OP unless the preceding
- * label is a bitstring and the split
- * label was 256 bits. Testing for
- * that case is probably roughly
- * as expensive as just unconditionally
- * copying the preceding label.
- */
- if (start_label > 0)
- start_label--;
-
- skip_width =
- prefix->offsets[start_label];
-
- memcpy(NAME(current) + skip_width,
- prefix->ndata + skip_width,
- prefix->length - skip_width);
-
- /*
- * Now add_bits is set to the total
- * number of bits in the split label of
- * the name being added, and used later
- * to determine if the job was
- * completed by pushing the
- * not-in-common bits down one level.
- */
- start_label =
- dns_name_countlabels(add_name)
- - common_labels;
-
- p = add_name->ndata +
- add_name->offsets[start_label];
- INSIST(*p == DNS_LABELTYPE_BITSTRING);
-
- add_bits = *(p + 1);
-
- /*
- * A bitstring that was split would not
- * result in a part of maximal length.
- */
- INSIST(add_bits != 0);
- } else
- add_bits = 0;
-
NAMELEN(current) = prefix->length;
OFFSETLEN(current) = prefix->labels;
memcpy(OFFSETS(current), prefix->offsets,
break;
if (common_labels ==
- dns_name_countlabels(add_name) &&
- common_bits == add_bits) {
+ dns_name_countlabels(add_name)) {
/*
* The name has been added by pushing
* the not-in-common parts down to
else {
/*
* Appease GCC about variables it incorrectly thinks are
- * possibly used unitialized.
+ * possibly used uninitialized.
*/
compared = dns_namereln_none;
last_compared = NULL;
* 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. By using dns_name_clone, no name data is
- * copied unless a bitstring split occurs.
+ * 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
+ * the lack of bitstring labels.
*/
dns_fixedname_init(&fixedsearchname);
search_name = dns_fixedname_name(&fixedsearchname);
unsigned int nlabels;
unsigned int tlabels = 1;
unsigned int hash;
- isc_boolean_t has_bitstring = ISC_FALSE;
/*
* If there is no hash table, hashing can't be done.
- * Similarly, when current != current_root, that
- * means a left or right pointer was followed, which
+ */
+ if (rbt->hashtable == NULL)
+ goto nohash;
+
+ /*
+ * The case of current != current_root, that
+ * means a left or right pointer was followed,
* only happens when the algorithm fell through to
* the traditional binary search because of a
- * bitstring label, so that traditional search
- * should be continued.
+ * bitstring label. Since we dropped the bitstring
+ * support, this should not happen.
*/
- if (rbt->hashtable == NULL ||
- current != current_root)
- goto nohash;
+ INSIST(current == current_root);
nlabels = dns_name_countlabels(search_name);
}
}
- /*
- * XXXDCL Bitstring labels complicate things, as usual.
- * Checking for the situation could be done up by the
- * dns_name_getlabelsequence so that they could still
- * use the hashing code, but it would be messy to
- * repeatedly try various bitstring lengths. Instead
- * just notice when a bitstring label is involved and
- * then punt to the traditional binary search if no
- * hash node is found after all of the labels are
- * tried.
- */
- if (has_bitstring == ISC_FALSE &&
- hash_name.ndata[0] ==
- DNS_LABELTYPE_BITSTRING)
- has_bitstring = ISC_TRUE;
-
if (tlabels++ < nlabels)
goto hashagain;
/*
* All of the labels have been tried against the hash
- * table. If there wasn't a bitstring label involved,
- * the name isn't in the table. If there was, fall
- * through to the traditional search algorithm.
+ * table. Since we dropped the support of bitstring
+ * labels, the name isn't in the table.
*/
- if (! has_bitstring) {
- /*
- * Done with the search.
- */
- current = NULL;
- continue;
- }
+ current = NULL;
+ continue;
- /* FALLTHROUGH */
nohash:
#endif /* DNS_RBT_USEHASH */
/*
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: resolver.c,v 1.247 2002/08/23 00:27:10 marka Exp $ */
+/* $Id: resolver.c,v 1.248 2002/08/27 04:53:42 marka Exp $ */
#include <config.h>
fctx->pending = 0;
fctx->restarts = 0;
fctx->timeouts = 0;
- if (dns_name_requiresedns(name))
- fctx->attributes = FCTX_ATTR_NEEDEDNS0;
- else
- fctx->attributes = 0;
+ fctx->attributes = 0;
if (domain == NULL) {
dns_forwarders_t *forwarders = NULL;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: result.c,v 1.103 2002/08/09 06:12:50 marka Exp $ */
+/* $Id: result.c,v 1.104 2002/08/27 04:53:43 marka Exp $ */
#include <config.h>
static const char *text[DNS_R_NRESULTS] = {
"label too long", /* 0 DNS_R_LABELTOOLONG */
"bad escape", /* 1 DNS_R_BADESCAPE */
+ /*
+ * Note that DNS_R_BADBITSTRING and DNS_R_BITSTRINGTOOLONG are
+ * deprecated.
+ */
"bad bitstring", /* 2 DNS_R_BADBITSTRING */
"bitstring too long", /* 3 DNS_R_BITSTRINGTOOLONG */
"empty label", /* 4 DNS_R_EMPTYLABEL */
case ISC_R_RANGE:
case ISC_R_UNEXPECTEDEND:
case DNS_R_BADAAAA:
- case DNS_R_BADBITSTRING:
+ /* case DNS_R_BADBITSTRING: deprecated */
case DNS_R_BADCKSUM:
case DNS_R_BADCLASS:
case DNS_R_BADLABELTYPE:
case DNS_R_BADPOINTER:
case DNS_R_BADTTL:
case DNS_R_BADZONE:
- case DNS_R_BITSTRINGTOOLONG:
+ /* case DNS_R_BITSTRINGTOOLONG: deprecated */
case DNS_R_EXTRADATA:
case DNS_R_LABELTOOLONG:
case DNS_R_NOREDATA:
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: t_api.c,v 1.48 2001/07/11 18:51:22 bwelling Exp $ */
+/* $Id: t_api.c,v 1.49 2002/08/27 04:53:43 marka Exp $ */
#include <config.h>
{ ISC_R_RANGE, "ISC_R_RANGE" },
{ DNS_R_LABELTOOLONG, "DNS_R_LABELTOOLONG" },
{ DNS_R_BADESCAPE, "DNS_R_BADESCAPE" },
- { DNS_R_BADBITSTRING, "DNS_R_BADBITSTRING" },
- { DNS_R_BITSTRINGTOOLONG, "DNS_R_BITSTRINGTOOLONG"},
+ /* { DNS_R_BADBITSTRING, "DNS_R_BADBITSTRING" }, */
+ /* { DNS_R_BITSTRINGTOOLONG, "DNS_R_BITSTRINGTOOLONG"}, */
{ DNS_R_EMPTYLABEL, "DNS_R_EMPTYLABEL" },
{ DNS_R_BADDOTTEDQUAD, "DNS_R_BADDOTTEDQUAD" },
{ DNS_R_UNKNOWN, "DNS_R_UNKNOWN" },