diff --git a/CHANGES b/CHANGES index ba22b9be65..c57c3adf46 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +1368. [func] remove support for bitstring labels. + 1367. [func] Use response times to select forwarders. 1365. [func] "localhost" and "localnet" acls now include IPv6 diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index d06b74fee1..d94c09e2eb 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.221.2.19.2.4 2003/08/15 02:00:33 marka Exp $ */ +/* $Id: dighost.c,v 1.221.2.19.2.5 2003/08/20 05:33:11 marka Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -234,7 +234,7 @@ get_reverse(char *reverse, char *value, isc_boolean_t ip6_int, /* 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; diff --git a/bin/named/lwdgnba.c b/bin/named/lwdgnba.c index c079c648bf..020d9356f6 100644 --- a/bin/named/lwdgnba.c +++ b/bin/named/lwdgnba.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwdgnba.c,v 1.13.2.1 2003/07/25 04:36:45 marka Exp $ */ +/* $Id: lwdgnba.c,v 1.13.2.1.2.1 2003/08/20 05:33:12 marka Exp $ */ #include @@ -67,7 +67,7 @@ byaddr_done(isc_task_t *task, isc_event_t *event) { bevent = NULL; if (client->na.family != AF_INET6 || - (client->options & DNS_BYADDROPT_IPV6NIBBLE) == 0) { + (client->options & DNS_BYADDROPT_IPV6INT) != 0) { if (result == DNS_R_NCACHENXDOMAIN || result == DNS_R_NCACHENXRRSET || result == DNS_R_NXDOMAIN || @@ -80,12 +80,9 @@ byaddr_done(isc_task_t *task, isc_event_t *event) { } /* - * Fall back to IP6.INT nibble then IP6.ARPA bitstring. + * Fall back to IP6.INT reverse. */ - if ((client->options & DNS_BYADDROPT_IPV6INT) == 0) - client->options |= DNS_BYADDROPT_IPV6INT; - else - client->options &= ~DNS_BYADDROPT_IPV6NIBBLE; + client->options |= DNS_BYADDROPT_IPV6INT; start_byaddr(client); return; @@ -224,9 +221,9 @@ ns_lwdclient_processgnba(ns_lwdclient_t *client, lwres_buffer_t *b) { goto out; /* - * Start with IP6.ARPA NIBBLE lookups. + * Start with IP6.ARPA lookups. */ - client->options = DNS_BYADDROPT_IPV6NIBBLE; + client->options = 0; if (req->addr.family == LWRES_ADDRTYPE_V4) { client->na.family = AF_INET; if (req->addr.length != 4) diff --git a/bin/named/query.c b/bin/named/query.c index 0143518c52..17156e3c46 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.198.2.13.4.9 2003/08/20 03:29:44 marka Exp $ */ +/* $Id: query.c,v 1.198.2.13.4.10 2003/08/20 05:33:12 marka Exp $ */ #include @@ -101,6 +101,18 @@ static dns_name_t ip6int_name = { {NULL, NULL} }; +static unsigned char ip6arpa_ndata[] = "\003ip6\004arpa"; +static unsigned char ip6arpa_offsets[] = { 0, 4, 9 }; + +static dns_name_t ip6arpa_name = { + DNS_NAME_MAGIC, + ip6arpa_ndata, 10, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + ip6arpa_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + static isc_result_t query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type, isc_stdtime_t now, @@ -140,6 +152,9 @@ synth_rev_byaddrdone_int(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); + /* * Increment query statistics counters. */ @@ -3638,8 +3653,13 @@ ns_query_start(ns_client_t *client) { } else { INSIST(qtype == dns_rdatatype_ptr); /* Must be 32 nibbles + "ip6" + "int" + root */ - if (dns_name_countlabels(client->query.qname) == 32 + 3 && - dns_name_issubdomain(client->query.qname, &ip6int_name)) { + if (dns_name_countlabels(client->query.qname) == 35 && + (dns_name_issubdomain(client->query.qname, + &ip6int_name) || + dns_name_issubdomain(client->query.qname, + &ip6arpa_name)) && + nibbles2netaddr(client->query.qname, + &client->query.synth.na) == ISC_R_SUCCESS) { qclient = NULL; ns_client_attach(client, &qclient); synth_rev_start(qclient); @@ -3953,22 +3973,14 @@ synth_rev_start(ns_client_t *client) { ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY, ISC_LOG_DEBUG(5), "generating synthetic PTR response"); - result = nibbles2netaddr(client->query.qname, &client->query.synth.na); - if (result != ISC_R_SUCCESS) { - result = DNS_R_NXDOMAIN; - goto cleanup; - } - /* Try IP6.ARPA first. */ result = dns_byaddr_create(client->mctx, &client->query.synth.na, - client->view, - 0, client->task, + client->view, 0, client->task, synth_rev_byaddrdone_arpa, client, &byaddr_dummy); if (result == ISC_R_SUCCESS) return; /* Wait for completion event. */ - cleanup: synth_finish(client, result); } @@ -3989,7 +4001,7 @@ synth_rev_byaddrdone_arpa(isc_task_t *task, isc_event_t *event) { result = dns_byaddr_create(client->mctx, &client->query.synth.na, client->view, - DNS_BYADDROPT_IPV6NIBBLE, + DNS_BYADDROPT_IPV6INT, client->task, synth_rev_byaddrdone_int, client, &byaddr_dummy); @@ -4005,28 +4017,16 @@ synth_rev_byaddrdone_int(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 diff --git a/bin/tests/byaddr_test.c b/bin/tests/byaddr_test.c index d08fcf1e1b..8a3e05bfa1 100644 --- a/bin/tests/byaddr_test.c +++ b/bin/tests/byaddr_test.c @@ -15,7 +15,7 @@ * 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.22.22.1 2003/08/20 05:33:12 marka Exp $ */ /* * Principal Author: Bob Halley @@ -101,7 +101,9 @@ main(int argc, char *argv[]) { 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; diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c index 5d0997b038..2f8e87e809 100644 --- a/bin/tests/names/t_names.c +++ b/bin/tests/names/t_names.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_names.c,v 1.32.2.2 2002/08/05 06:57:06 marka Exp $ */ +/* $Id: t_names.c,v 1.32.2.2.8.1 2003/08/20 05:33:13 marka Exp $ */ #include @@ -36,10 +36,6 @@ #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]; /* @@ -356,167 +352,6 @@ dname_from_tname(char *name, dns_name_t *dns_name) { 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 @@ -2468,8 +2303,6 @@ t_dns_name_concatenate(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" }, diff --git a/bin/tests/system/lwresd/lwtest.c b/bin/tests/system/lwresd/lwtest.c index 35c2c294ad..d1572047db 100644 --- a/bin/tests/system/lwresd/lwtest.c +++ b/bin/tests/system/lwresd/lwtest.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwtest.c,v 1.22.2.4 2003/07/22 04:03:38 marka Exp $ */ +/* $Id: lwtest.c,v 1.22.2.4.2.1 2003/08/20 05:33:13 marka Exp $ */ #include @@ -695,11 +695,11 @@ main(void) { 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); @@ -728,16 +728,16 @@ main(void) { 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"); @@ -751,9 +751,9 @@ main(void) { 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"); diff --git a/bin/tests/system/lwresd/ns1/example1.db b/bin/tests/system/lwresd/ns1/example1.db index 84e1f1a9f3..a8d986a728 100644 --- a/bin/tests/system/lwresd/ns1/example1.db +++ b/bin/tests/system/lwresd/ns1/example1.db @@ -13,11 +13,11 @@ ; 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.10.22.1 2003/08/20 05:33:14 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) @@ -32,8 +32,8 @@ a3 CNAME nowhere 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 ) diff --git a/bin/tests/system/lwresd/ns1/ip6.arpa.db b/bin/tests/system/lwresd/ns1/ip6.arpa.db index bd87bace15..4546afe6b5 100644 --- a/bin/tests/system/lwresd/ns1/ip6.arpa.db +++ b/bin/tests/system/lwresd/ns1/ip6.arpa.db @@ -13,11 +13,11 @@ ; 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.7.22.1 2003/08/20 05:33:15 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) @@ -26,5 +26,5 @@ $TTL 300 ; 5 minutes 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. diff --git a/bin/tests/system/lwresd/ns1/ip6.int.db b/bin/tests/system/lwresd/ns1/ip6.int.db index c58e702aa9..dd54326334 100644 --- a/bin/tests/system/lwresd/ns1/ip6.int.db +++ b/bin/tests/system/lwresd/ns1/ip6.int.db @@ -13,11 +13,11 @@ ; 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.7.22.1 2003/08/20 05:33:15 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) @@ -26,4 +26,4 @@ $TTL 300 ; 5 minutes 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. diff --git a/bin/tests/system/v6synth/ns2/ip6.arpa.db b/bin/tests/system/v6synth/ns2/ip6.arpa.db index 1476b1c531..7afa4f4364 100644 --- a/bin/tests/system/v6synth/ns2/ip6.arpa.db +++ b/bin/tests/system/v6synth/ns2/ip6.arpa.db @@ -13,7 +13,7 @@ ; 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.1.22.1 2003/08/20 05:33:15 marka Exp $ $TTL 86400 @ IN SOA ns2 hostmaster ( @@ -21,8 +21,4 @@ $TTL 86400 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. diff --git a/lib/dns/byaddr.c b/lib/dns/byaddr.c index d185a35275..b84041bc65 100644 --- a/lib/dns/byaddr.c +++ b/lib/dns/byaddr.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: byaddr.c,v 1.29.2.1 2003/07/25 04:36:45 marka Exp $ */ +/* $Id: byaddr.c,v 1.29.2.1.2.1 2003/08/20 05:33:15 marka Exp $ */ #include @@ -68,12 +68,13 @@ isc_result_t dns_byaddr_createptrname(isc_netaddr_t *address, isc_boolean_t nibble, dns_name_t *name) { - unsigned int options = DNS_BYADDROPT_IPV6INT; + /* + * We dropped bitstring labels, so all lookups will use nibbles. + */ + UNUSED(nibble); - if (nibble) - options |= DNS_BYADDROPT_IPV6NIBBLE; - - return (dns_byaddr_createptrname2(address, options, name)); + return (dns_byaddr_createptrname2(address, + DNS_BYADDROPT_IPV6INT, name)); } isc_result_t @@ -103,31 +104,17 @@ dns_byaddr_createptrname2(isc_netaddr_t *address, unsigned int options, (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); diff --git a/lib/dns/include/dns/byaddr.h b/lib/dns/include/dns/byaddr.h index 25ca85e8ab..9440ec055b 100644 --- a/lib/dns/include/dns/byaddr.h +++ b/lib/dns/include/dns/byaddr.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: byaddr.h,v 1.12.2.1 2003/07/25 04:36:46 marka Exp $ */ +/* $Id: byaddr.h,v 1.12.2.1.2.1 2003/08/20 05:33:17 marka Exp $ */ #ifndef DNS_BYADDR_H #define DNS_BYADDR_H 1 @@ -68,8 +68,11 @@ typedef struct dns_byaddrevent { 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 /* Use IP6.INT nibble lookups */ + */ +#define DNS_BYADDROPT_IPV6INT 0x0002 isc_result_t dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view, @@ -80,7 +83,8 @@ dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view, * * Notes: * - * There is a reverse lookup format for IPv6 addresses, 'nibble' + * The is a reverse lookup format for IPv6 addresses is 'nibble' + * IP6.ARPA. The (now) expermental 'bitstring' is no-longer supported. * * The 'nibble' format for that address is * @@ -151,8 +155,9 @@ dns_byaddr_createptrname2(isc_netaddr_t *address, unsigned int options, /* * 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: * diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 597408e946..d6ecec780a 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: name.h,v 1.95.2.3.2.2 2003/08/19 04:11:24 marka Exp $ */ +/* $Id: name.h,v 1.95.2.3.2.3 2003/08/20 05:33:17 marka Exp $ */ #ifndef DNS_NAME_H #define DNS_NAME_H 1 @@ -87,86 +87,16 @@ ISC_LANG_BEGINDECLS ***** 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. *****/ /*** @@ -445,9 +375,8 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, * * *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 @@ -600,8 +529,7 @@ dns_name_depth(const dns_name_t *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, 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. * @@ -622,9 +550,7 @@ dns_name_countlabels(const dns_name_t *name); * 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 @@ -775,9 +701,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, * 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. * @@ -856,8 +779,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, * 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. * @@ -869,8 +790,8 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, * 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 @@ -1015,8 +936,6 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, * 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: @@ -1035,34 +954,25 @@ dns_name_split(dns_name_t *name, * * 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. * @@ -1072,28 +982,22 @@ dns_name_split(dns_name_t *name, * * '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 @@ -1115,11 +1019,11 @@ dns_name_splitatdepth(dns_name_t *name, unsigned int depth, * * 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 diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index 305c6b3903..04ce491b12 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.h,v 1.81.2.7.2.4 2003/08/19 07:26:09 marka Exp $ */ +/* $Id: result.h,v 1.81.2.7.2.5 2003/08/20 05:33:18 marka Exp $ */ #ifndef DNS_RESULT_H #define DNS_RESULT_H 1 @@ -38,8 +38,13 @@ */ #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) diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index d0273c6c1a..82310817c7 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: types.h,v 1.103.12.2 2003/08/14 02:34:17 marka Exp $ */ +/* $Id: types.h,v 1.103.12.3 2003/08/20 05:33:18 marka Exp $ */ #ifndef DNS_TYPES_H #define DNS_TYPES_H 1 @@ -111,22 +111,12 @@ typedef ISC_LIST(dns_zone_t) dns_zonelist_t; 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, diff --git a/lib/dns/name.c b/lib/dns/name.c index 8ecc5d4347..c8948fdda2 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: name.c,v 1.127.2.7.2.1 2003/08/14 03:22:37 marka Exp $ */ +/* $Id: name.c,v 1.127.2.7.2.2 2003/08/20 05:33:16 marka Exp $ */ #include @@ -41,16 +41,6 @@ typedef enum { 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; @@ -58,7 +48,6 @@ typedef enum { fw_start = 0, fw_ordinary, fw_copy, - fw_bitstring, fw_newcurrent } fw_state; @@ -81,11 +70,6 @@ static char digitvalue[256] = { -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, @@ -199,100 +183,6 @@ static void 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) { /* @@ -390,35 +280,17 @@ dns_name_iswildcard(const dns_name_t *name) { 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); } unsigned int @@ -481,8 +353,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, 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; @@ -515,7 +386,6 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, SETUP_OFFSETS(name2, offsets2, odata2); nlabels = 0; - nbits = 0; l1 = name1->labels; l2 = name2->labels; ldiff = (int)l1 - (int)l2; @@ -532,124 +402,35 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, 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; - 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; + count--; + label1++; + label2++; } + if (cdiff != 0) { + *orderp = cdiff; + goto done; + } + nlabels++; } *orderp = ldiff; @@ -662,7 +443,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, done: *nlabelsp = nlabels; - *nbitsp = nbits; + *nbitsp = 0; if (nlabels > 0 && namereln == dns_namereln_none) namereln = dns_namereln_commonancestor; @@ -728,30 +509,14 @@ dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { 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); - } } } @@ -786,43 +551,21 @@ dns_name_rdatacompare(const dns_name_t *name1, const dns_name_t *name2) { 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); } } @@ -885,7 +628,7 @@ dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) { unsigned int dns_name_depth(const dns_name_t *name) { - unsigned int depth, count, nrem, n; + unsigned int depth, count, nrem; unsigned char *ndata; /* @@ -902,23 +645,13 @@ dns_name_depth(const dns_name_t *name) { 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; @@ -1109,8 +842,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, 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; @@ -1172,7 +904,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, nused = 0; labels = 0; done = ISC_FALSE; - saw_bitstring = ISC_FALSE; state = ft_init; while (nrem > 0 && tlen > 0 && !done) { @@ -1180,7 +911,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, tlen--; tused++; - no_read: switch (state) { case ft_init: /* @@ -1249,15 +979,11 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, 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; @@ -1300,309 +1026,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, 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); @@ -1614,8 +1037,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, 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); @@ -1632,33 +1054,16 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, 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) { @@ -1676,9 +1081,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, name->labels = labels; name->length = nused; - if (saw_bitstring) - compact(name, offsets); - isc_buffer_forward(source, tused); isc_buffer_add(target, name->length); @@ -1694,11 +1096,8 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, 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 @@ -1809,47 +1208,6 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, } 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 <= 4U); - 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 { FATAL_ERROR(__FILE__, __LINE__, "Unexpected label type %02x", count); @@ -1888,10 +1246,7 @@ dns_name_tofilenametext(dns_name_t *name, isc_boolean_t omit_final_dot, 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 @@ -1963,47 +1318,6 @@ dns_name_tofilenametext(dns_name_t *name, isc_boolean_t omit_final_dot, } 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 <= 4U); - 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); @@ -2036,7 +1350,7 @@ dns_name_tofilenametext(dns_name_t *name, isc_boolean_t omit_final_dot, 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; /* @@ -2083,24 +1397,6 @@ dns_name_downcase(dns_name_t *source, dns_name_t *name, isc_buffer_t *target) { 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); @@ -2128,7 +1424,7 @@ static void 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; @@ -2142,26 +1438,13 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, 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) { @@ -2178,150 +1461,6 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, 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, @@ -2331,7 +1470,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, 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; @@ -2372,7 +1511,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, */ labels = 0; hops = 0; - saw_bitstring = ISC_FALSE; done = ISC_FALSE; ndata = isc_buffer_used(target); @@ -2435,15 +1573,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, 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; @@ -2457,19 +1586,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, 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; @@ -2502,9 +1618,6 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, 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); @@ -2606,10 +1719,9 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, 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; @@ -2644,25 +1756,6 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, 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. */ @@ -2694,35 +1787,6 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, 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); @@ -2747,11 +1811,9 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, 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); @@ -2765,17 +1827,15 @@ dns_name_split(dns_name_t *name, 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) && @@ -2786,17 +1846,6 @@ dns_name_split(dns_name_t *name, 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; @@ -2808,243 +1857,21 @@ dns_name_split(dns_name_t *name, */ 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))); + if (prefix != NULL) + dns_name_getlabelsequence(name, 0, splitlabel, prefix); - mod = nbits % 8; + if (suffix != NULL) + dns_name_getlabelsequence(name, splitlabel, + suffixlabels, suffix); - if (prefix != NULL) { - if (nbits > 0) { - isc_buffer_clear(prefix->buffer); - - /* - * '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++; - - 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; @@ -3059,38 +1886,14 @@ dns_name_splitatdepth(dns_name_t *name, unsigned int depth, 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); /* @@ -3105,7 +1908,7 @@ dns_name_splitatdepth(dns_name_t *name, unsigned int depth, INSIST(0); } - return (dns_name_split(name, suffixlabels, nbits, prefix, suffix)); + return (dns_name_split(name, suffixlabels, 0, prefix, suffix)); } isc_result_t diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 088e729eed..d39cfe1f93 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbt.c,v 1.115.2.2.2.1 2003/08/11 05:28:16 marka Exp $ */ +/* $Id: rbt.c,v 1.115.2.2.2.2 2003/08/20 05:33:16 marka Exp $ */ /* Principal Authors: DCL */ @@ -373,7 +373,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) { 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)); @@ -382,8 +382,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) { /* * 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); @@ -422,6 +421,11 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) { 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; @@ -562,89 +566,6 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) { 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, @@ -677,8 +598,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, dns_name_t *name, dns_rbtnode_t **nodep) { 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 @@ -814,7 +734,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname, else { /* * Appease GCC about variables it incorrectly thinks are - * possibly used unitialized. + * possibly used uninitialized. */ compared = dns_namereln_none; last_compared = NULL; @@ -827,8 +747,10 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname, * search_name is the name segment being sought in each tree level. * 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); @@ -858,20 +780,22 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname, 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); @@ -927,40 +851,17 @@ dns_rbt_findnode(dns_rbt_t *rbt, dns_name_t *name, dns_name_t *foundname, } } - /* - * 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 */ /* diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index f084f19701..140bf2117a 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.218.2.18.4.8 2003/08/20 04:52:46 marka Exp $ */ +/* $Id: resolver.c,v 1.218.2.18.4.9 2003/08/20 05:33:16 marka Exp $ */ #include @@ -2222,10 +2222,7 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, 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; diff --git a/lib/dns/result.c b/lib/dns/result.c index 207d1c541d..e2bff5418a 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.c,v 1.90.2.9.2.4 2003/08/19 07:26:09 marka Exp $ */ +/* $Id: result.c,v 1.90.2.9.2.5 2003/08/20 05:33:16 marka Exp $ */ #include @@ -28,6 +28,10 @@ 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 */ @@ -226,14 +230,14 @@ dns_result_torcode(isc_result_t result) { 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: diff --git a/lib/tests/t_api.c b/lib/tests/t_api.c index cb5f4826e2..a9935d7092 100644 --- a/lib/tests/t_api.c +++ b/lib/tests/t_api.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_api.c,v 1.48.2.1 2003/07/23 06:57:57 marka Exp $ */ +/* $Id: t_api.c,v 1.48.2.1.2.1 2003/08/20 05:33:18 marka Exp $ */ #include @@ -588,8 +588,8 @@ struct dns_errormap { { 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" },