From: Andreas Gustafsson Date: Thu, 21 Sep 2000 22:07:22 +0000 (+0000) Subject: pullup: X-Git-Tag: v9.0.0^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15df42d74d46846dbc9c24dc9c82ee5331f80bc1;p=thirdparty%2Fbind9.git pullup: 387. [func] Add dns_byaddr_createptrname(), which converts an address into the name used by a PTR query. (required by dig pullup) --- diff --git a/CHANGES b/CHANGES index 3690fafb5dd..aaed9b5cd19 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,9 @@ 471. [bug] nsupdate didn't compile on HP/UX 10.20 + 387. [func] Add dns_byaddr_createptrname(), which converts + an address into the name used by a PTR query. + --- 9.0.0 released --- 463. [bug] nsupdate sent malformed SOA queries to the second diff --git a/lib/dns/byaddr.c b/lib/dns/byaddr.c index 5614902d12d..1e8a8024d9b 100644 --- a/lib/dns/byaddr.c +++ b/lib/dns/byaddr.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: byaddr.c,v 1.16 2000/06/22 21:54:20 tale Exp $ */ +/* $Id: byaddr.c,v 1.16.2.1 2000/09/21 22:07:21 gson Exp $ */ #include @@ -68,8 +68,9 @@ static char hex_digits[] = { '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; -static inline isc_result_t -address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) { +isc_result_t +dns_byaddr_createptrname(isc_netaddr_t *address, isc_boolean_t nibble, + dns_name_t *name) { char textname[128]; unsigned char *bytes; int i; @@ -77,6 +78,8 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) { isc_buffer_t buffer; unsigned int len; + REQUIRE(address != NULL); + /* * The caller must be holding the byaddr's lock. */ @@ -87,7 +90,6 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) { * of the knowledge of wire format in the dns_name_ routines. */ - dns_fixedname_init(&byaddr->name); bytes = (unsigned char *)(&address->type); if (address->family == AF_INET) { (void)sprintf(textname, "%u.%u.%u.%u.in-addr.arpa.", @@ -96,7 +98,7 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) { (bytes[1] & 0xff), (bytes[0] & 0xff)); } else if (address->family == AF_INET6) { - if ((byaddr->options & DNS_BYADDROPT_IPV6NIBBLE) != 0) { + if (nibble) { cp = textname; for (i = 15; i >= 0; i--) { *cp++ = hex_digits[bytes[i] & 0x0f]; @@ -124,8 +126,8 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) { len = (unsigned int)strlen(textname); isc_buffer_init(&buffer, textname, len); isc_buffer_add(&buffer, len); - return (dns_name_fromtext(dns_fixedname_name(&byaddr->name), - &buffer, dns_rootname, ISC_FALSE, NULL)); + return (dns_name_fromtext(name, &buffer, dns_rootname, + ISC_FALSE, NULL)); } static inline isc_result_t @@ -409,7 +411,9 @@ dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view, if (result != ISC_R_SUCCESS) goto cleanup_event; - result = address_to_ptr_name(byaddr, address); + result = dns_byaddr_createptrname(address, + ISC_TF(byaddr->options & DNS_BYADDROPT_IPV6NIBBLE), + dns_fixedname_name(&byaddr->name)); if (result != ISC_R_SUCCESS) goto cleanup_lock; diff --git a/lib/dns/include/dns/byaddr.h b/lib/dns/include/dns/byaddr.h index 6cf3df8f982..efbd597e6a5 100644 --- a/lib/dns/include/dns/byaddr.h +++ b/lib/dns/include/dns/byaddr.h @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: byaddr.h,v 1.8 2000/06/22 21:55:10 tale Exp $ */ +/* $Id: byaddr.h,v 1.8.2.1 2000/09/21 22:07:22 gson Exp $ */ #ifndef DNS_BYADDR_H #define DNS_BYADDR_H 1 @@ -144,6 +144,20 @@ dns_byaddr_destroy(dns_byaddr_t **byaddrp); * *byaddrp == NULL. */ +isc_result_t +dns_byaddr_createptrname(isc_netaddr_t *address, isc_boolean_t nibble, + dns_name_t *name); +/* + * 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. + * + * Requires: + * + * 'address' is a valid address. + * 'name' is a valid name with a dedicated buffer. + */ + ISC_LANG_ENDDECLS #endif /* DNS_BYADDR_H */