Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
b0f941a5
Commit
b0f941a5
authored
Aug 14, 2000
by
Brian Wellington
Browse files
387. [func] Add dns_byaddr_createptrname(), which converts
an address into the name used by a PTR query.
parent
ffa24a38
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
b0f941a5
387. [func] Add dns_byaddr_createptrname(), which converts
an address into the name used by a PTR query.
386. [bug] Missing strdup() of ACL name caused random
ACL matching failures [RT #228].
...
...
lib/dns/byaddr.c
View file @
b0f941a5
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: byaddr.c,v 1.1
8
2000/08/
01 01:22:11 tale
Exp $ */
/* $Id: byaddr.c,v 1.1
9
2000/08/
14 19:09:55 bwelling
Exp $ */
#include <config.h>
...
...
@@ -68,8 +68,10 @@ 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,9 +79,7 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) {
isc_buffer_t
buffer
;
unsigned
int
len
;
/*
* The caller must be holding the byaddr's lock.
*/
REQUIRE
(
address
!=
NULL
);
/*
* We create the text representation and then convert to a
...
...
@@ -87,7 +87,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 +95,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 +123,23 @@ 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
address_to_ptr_name
(
dns_byaddr_t
*
byaddr
,
isc_netaddr_t
*
address
)
{
isc_boolean_t
nibble
;
/*
* The caller must be holding the byaddr's lock.
*/
dns_fixedname_init
(
&
byaddr
->
name
);
nibble
=
ISC_TF
(
byaddr
->
options
&
DNS_BYADDROPT_IPV6NIBBLE
);
return
(
dns_byaddr_createptrname
(
address
,
nibble
,
dns_fixedname_name
(
&
byaddr
->
name
)));
}
static
inline
isc_result_t
...
...
lib/dns/include/dns/byaddr.h
View file @
b0f941a5
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: byaddr.h,v 1.1
0
2000/08/
01 01:23:41 tale
Exp $ */
/* $Id: byaddr.h,v 1.1
1
2000/08/
14 19:09:56 bwelling
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 */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment