]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Thu, 21 Sep 2000 22:07:22 +0000 (22:07 +0000)
committerAndreas Gustafsson <source@isc.org>
Thu, 21 Sep 2000 22:07:22 +0000 (22:07 +0000)
 387.   [func]          Add dns_byaddr_createptrname(), which converts
                        an address into the name used by a PTR query.
(required by dig pullup)

CHANGES
lib/dns/byaddr.c
lib/dns/include/dns/byaddr.h

diff --git a/CHANGES b/CHANGES
index 3690fafb5dd5185d6bac40dc96d2d1dc49517988..aaed9b5cd19004e5e0edd8816dc2417b8b66396d 100644 (file)
--- 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
index 5614902d12d784a329e75657d602a270d543ae8e..1e8a8024d9be5af4da74256e1cc408f9ae3dfb93 100644 (file)
@@ -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 <config.h>
 
@@ -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;
 
index 6cf3df8f98284704683355e03e35167c696d95fa..efbd597e6a50d960497f0a68eaea8966fe1eb9e8 100644 (file)
@@ -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 */