2000-01-12 20:05:15 +00:00
|
|
|
/*
|
2018-02-15 12:08:52 +11:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-01-12 20:05:15 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2000-01-12 20:05:15 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
2000-01-12 20:05:15 +00:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
2000-01-18 02:50:23 +00:00
|
|
|
* information regarding copyright ownership.
|
2000-01-12 20:05:15 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2000-01-18 19:07:39 +00:00
|
|
|
#include <isc/mem.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/netaddr.h>
|
2021-10-04 17:14:53 +02:00
|
|
|
#include <isc/result.h>
|
2022-04-11 15:53:34 +01:00
|
|
|
#include <isc/string.h>
|
2000-01-12 20:05:15 +00:00
|
|
|
#include <isc/util.h>
|
|
|
|
|
|
|
|
#include <dns/byaddr.h>
|
2000-01-15 02:20:49 +00:00
|
|
|
#include <dns/db.h>
|
|
|
|
#include <dns/rdata.h>
|
2000-01-15 00:48:49 +00:00
|
|
|
#include <dns/rdataset.h>
|
2000-10-07 00:09:28 +00:00
|
|
|
#include <dns/rdatastruct.h>
|
2000-01-12 20:05:15 +00:00
|
|
|
#include <dns/resolver.h>
|
|
|
|
#include <dns/view.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXXRTH We could use a static event...
|
|
|
|
*/
|
|
|
|
|
2000-01-18 02:50:23 +00:00
|
|
|
static char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
|
|
|
|
2000-08-14 19:09:56 +00:00
|
|
|
isc_result_t
|
2022-12-07 19:58:40 +00:00
|
|
|
dns_byaddr_createptrname(const isc_netaddr_t *address, dns_name_t *name) {
|
2000-01-18 02:50:23 +00:00
|
|
|
char textname[128];
|
2016-12-30 15:45:08 +11:00
|
|
|
const unsigned char *bytes;
|
2000-01-18 02:50:23 +00:00
|
|
|
int i;
|
|
|
|
char *cp;
|
|
|
|
isc_buffer_t buffer;
|
|
|
|
unsigned int len;
|
2000-01-15 02:20:49 +00:00
|
|
|
|
2000-08-14 19:09:56 +00:00
|
|
|
REQUIRE(address != NULL);
|
2000-01-15 02:20:49 +00:00
|
|
|
|
2000-01-18 02:50:23 +00:00
|
|
|
/*
|
|
|
|
* We create the text representation and then convert to a
|
|
|
|
* dns_name_t. This is not maximally efficient, but it keeps all
|
|
|
|
* of the knowledge of wire format in the dns_name_ routines.
|
|
|
|
*/
|
2000-01-15 02:20:49 +00:00
|
|
|
|
2016-12-30 15:45:08 +11:00
|
|
|
bytes = (const unsigned char *)(&address->type);
|
2000-01-18 02:50:23 +00:00
|
|
|
if (address->family == AF_INET) {
|
2003-04-11 07:25:31 +00:00
|
|
|
(void)snprintf(textname, sizeof(textname),
|
|
|
|
"%u.%u.%u.%u.in-addr.arpa.",
|
2019-03-14 19:46:10 +11:00
|
|
|
((unsigned int)bytes[3] & 0xffU),
|
|
|
|
((unsigned int)bytes[2] & 0xffU),
|
|
|
|
((unsigned int)bytes[1] & 0xffU),
|
|
|
|
((unsigned int)bytes[0] & 0xffU));
|
2000-01-18 02:50:23 +00:00
|
|
|
} else if (address->family == AF_INET6) {
|
2017-09-13 00:14:37 -07:00
|
|
|
size_t remaining;
|
|
|
|
|
2002-08-27 04:53:43 +00:00
|
|
|
cp = textname;
|
|
|
|
for (i = 15; i >= 0; i--) {
|
|
|
|
*cp++ = hex_digits[bytes[i] & 0x0f];
|
|
|
|
*cp++ = '.';
|
|
|
|
*cp++ = hex_digits[(bytes[i] >> 4) & 0x0f];
|
|
|
|
*cp++ = '.';
|
2000-01-18 02:50:23 +00:00
|
|
|
}
|
2017-09-13 00:14:37 -07:00
|
|
|
remaining = sizeof(textname) - (cp - textname);
|
2018-11-02 14:23:01 +00:00
|
|
|
strlcpy(cp, "ip6.arpa.", remaining);
|
2000-01-18 02:50:23 +00:00
|
|
|
} else {
|
2000-04-06 22:03:35 +00:00
|
|
|
return ISC_R_NOTIMPLEMENTED;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-01-18 02:50:23 +00:00
|
|
|
|
|
|
|
len = (unsigned int)strlen(textname);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&buffer, textname, len);
|
2000-01-18 02:50:23 +00:00
|
|
|
isc_buffer_add(&buffer, len);
|
2025-02-22 00:11:38 -08:00
|
|
|
return dns_name_fromtext(name, &buffer, dns_rootname, 0);
|
2000-08-14 19:09:56 +00:00
|
|
|
}
|