* 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>
'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;
isc_buffer_t buffer;
unsigned int len;
+ REQUIRE(address != NULL);
+
/*
* The caller must be holding the byaddr's lock.
*/
* 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.",
(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];
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
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;
* 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
* *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 */