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 INTERNET SOFTWARE CONSORTIUM
9 .\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 .\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 .\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" ""
19 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
21 \fB#include <lwres/lwres.h>
25 lwres_string_parse(lwres_buffer_t *b, char **c, lwres_uint16_t *len);
30 lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
35 lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);
40 lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, lwres_uint16_t addrlen, const unsigned char *addr, lwres_gnbaresponse_t **structp);
44 \fBlwres_string_parse()\fR retrieves a DNS-encoded
45 string starting the current pointer of lightweight resolver buffer
46 \fIb\fR: i.e. b->current.
47 When the function returns, the address of the first byte of the
48 encoded string is returned via \fI*c\fR and the
49 length of that string is given by \fI*len\fR. The
50 buffer's current pointer is advanced to point at the character
51 following the string length, the encoded string, and the trailing
54 \fBlwres_addr_parse()\fR extracts an address from the
55 buffer \fIb\fR. The buffer's current pointer
56 b->current is presumed to point at an encoded
57 address: the address preceded by a 32-bit protocol family identifier
58 and a 16-bit length field. The encoded address is copied to
60 addr->length indicates the size in bytes of
61 the address that was copied. b->current is
62 advanced to point at the next byte of available data in the buffer
63 following the encoded address.
65 \fBlwres_getaddrsbyname()\fR
67 \fBlwres_getnamebyaddr()\fR
69 \fBlwres_gnbaresponse_t\fR
70 structure defined below:
75 lwres_uint16_t naliases;
76 lwres_uint16_t naddrs;
79 lwres_uint16_t realnamelen;
80 lwres_uint16_t *aliaslen;
81 lwres_addrlist_t addrs;
84 } lwres_gabnresponse_t;
87 The contents of this structure are not manipulated directly but
88 they are controlled through the
92 The lightweight resolver uses
93 \fBlwres_getaddrsbyname()\fR to perform foward lookups.
94 Hostname \fIname\fR is looked up using the resolver
95 context \fIctx\fR for memory allocation.
96 \fIaddrtypes\fR is a bitmask indicating which type of
97 addresses are to be looked up. Current values for this bitmask are
98 \fBLWRES_ADDRTYPE_V4\fR for IPv4 addresses and
99 \fBLWRES_ADDRTYPE_V6\fR for IPv6 addresses. Results of the
100 lookup are returned in \fI*structp\fR.
102 \fBlwres_getnamebyaddr()\fR performs reverse lookups.
103 Resolver context \fIctx\fR is used for memory
104 allocation. The address type is indicated by
105 \fIaddrtype\fR: \fBLWRES_ADDRTYPE_V4\fR or
106 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given
107 by \fIaddr\fR and its length is
108 \fIaddrlen\fR bytes. The result of the function call
109 is made available through \fI*structp\fR.
113 \fBlwres_string_parse()\fR
115 \fBlwres_addr_parse()\fR
118 Both functions return
120 if the buffer is corrupt or
121 LWRES_R_UNEXPECTEDEND
122 if the buffer has less space than expected for the components of the
123 encoded string or address.
125 \fBlwres_getaddrsbyname()\fR
128 on success and it returns
135 is returned by a successful call to
136 \fBlwres_getnamebyaddr()\fR.
139 \fBlwres_getaddrsbyname()\fR
141 \fBlwres_getnamebyaddr()\fR
144 when memory allocation requests fail and
145 LWRES_R_UNEXPECTEDEND
146 if the buffers used for sending queries and receiving replies are too
150 \fBlwres_buffer\fR(3),