1 .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 .\" PERFORMANCE OF THIS SOFTWARE.
16 .\" $Id: lwres_resutil.3,v 1.14.2.2 2004/03/15 04:45:05 marka Exp $
18 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" ""
20 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
22 \fB#include <lwres/lwres.h>
26 lwres_string_parse(lwres_buffer_t *b, char **c, lwres_uint16_t *len);
31 lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
36 lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);
41 lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, lwres_uint16_t addrlen, const unsigned char *addr, lwres_gnbaresponse_t **structp);
46 \fBlwres_string_parse()\fR retrieves a DNS-encoded
47 string starting the current pointer of lightweight resolver buffer
48 \fIb\fR: i.e. b->current.
49 When the function returns, the address of the first byte of the
50 encoded string is returned via \fI*c\fR and the
51 length of that string is given by \fI*len\fR. The
52 buffer's current pointer is advanced to point at the character
53 following the string length, the encoded string, and the trailing
56 \fBlwres_addr_parse()\fR extracts an address from the
57 buffer \fIb\fR. The buffer's current pointer
58 b->current is presumed to point at an encoded
59 address: the address preceded by a 32-bit protocol family identifier
60 and a 16-bit length field. The encoded address is copied to
62 addr->length indicates the size in bytes of
63 the address that was copied. b->current is
64 advanced to point at the next byte of available data in the buffer
65 following the encoded address.
67 \fBlwres_getaddrsbyname()\fR
69 \fBlwres_getnamebyaddr()\fR
71 \fBlwres_gnbaresponse_t\fR
72 structure defined below:
77 lwres_uint16_t naliases;
78 lwres_uint16_t naddrs;
81 lwres_uint16_t realnamelen;
82 lwres_uint16_t *aliaslen;
83 lwres_addrlist_t addrs;
86 } lwres_gabnresponse_t;
89 The contents of this structure are not manipulated directly but
90 they are controlled through the
94 The lightweight resolver uses
95 \fBlwres_getaddrsbyname()\fR to perform foward lookups.
96 Hostname \fIname\fR is looked up using the resolver
97 context \fIctx\fR for memory allocation.
98 \fIaddrtypes\fR is a bitmask indicating which type of
99 addresses are to be looked up. Current values for this bitmask are
100 \fBLWRES_ADDRTYPE_V4\fR for IPv4 addresses and
101 \fBLWRES_ADDRTYPE_V6\fR for IPv6 addresses. Results of the
102 lookup are returned in \fI*structp\fR.
104 \fBlwres_getnamebyaddr()\fR performs reverse lookups.
105 Resolver context \fIctx\fR is used for memory
106 allocation. The address type is indicated by
107 \fIaddrtype\fR: \fBLWRES_ADDRTYPE_V4\fR or
108 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given
109 by \fIaddr\fR and its length is
110 \fIaddrlen\fR bytes. The result of the function call
111 is made available through \fI*structp\fR.
115 \fBlwres_string_parse()\fR
117 \fBlwres_addr_parse()\fR
120 Both functions return
122 if the buffer is corrupt or
123 LWRES_R_UNEXPECTEDEND
124 if the buffer has less space than expected for the components of the
125 encoded string or address.
127 \fBlwres_getaddrsbyname()\fR
130 on success and it returns
137 is returned by a successful call to
138 \fBlwres_getnamebyaddr()\fR.
141 \fBlwres_getaddrsbyname()\fR
143 \fBlwres_getnamebyaddr()\fR
146 when memory allocation requests fail and
147 LWRES_R_UNEXPECTEDEND
148 if the buffers used for sending queries and receiving replies are too
152 \fBlwres_buffer\fR(3),