Merge from vendor branch SENDMAIL:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / lwres / man / lwres_resutil.3
1 .\" Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001  Internet Software Consortium.
3 .\"
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.
7 .\"
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.
15 .\"
16 .\" $Id: lwres_resutil.3,v 1.14.2.2 2004/03/15 04:45:05 marka Exp $
17 .\"
18 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" ""
19 .SH NAME
20 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
21 .SH SYNOPSIS
22 \fB#include <lwres/lwres.h>
23 .sp
24 .na
25 lwres_result_t
26 lwres_string_parse(lwres_buffer_t *b, char **c, lwres_uint16_t *len);
27 .ad
28 .sp
29 .na
30 lwres_result_t
31 lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
32 .ad
33 .sp
34 .na
35 lwres_result_t
36 lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);
37 .ad
38 .sp
39 .na
40 lwres_result_t
41 lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, lwres_uint16_t addrlen, const unsigned char *addr, lwres_gnbaresponse_t **structp);
42 .ad
43 \fR
44 .SH "DESCRIPTION"
45 .PP
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
54 \fBNULL\fR character.
55 .PP
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
61 addr->address and
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.
66 .PP
67 \fBlwres_getaddrsbyname()\fR
68 and
69 \fBlwres_getnamebyaddr()\fR
70 use the
71 \fBlwres_gnbaresponse_t\fR
72 structure defined below:
73 .sp
74 .nf
75 typedef struct {
76         lwres_uint32_t          flags;
77         lwres_uint16_t          naliases;
78         lwres_uint16_t          naddrs;
79         char                   *realname;
80         char                  **aliases;
81         lwres_uint16_t          realnamelen;
82         lwres_uint16_t         *aliaslen;
83         lwres_addrlist_t        addrs;
84         void                   *base;
85         size_t                  baselen;
86 } lwres_gabnresponse_t;
87 .sp
88 .fi
89 The contents of this structure are not manipulated directly but
90 they are controlled through the
91 \fBlwres_gabn\fR(3)
92 functions.
93 .PP
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.
103 .PP
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.
112 .SH "RETURN VALUES"
113 .PP
114 Successful calls to
115 \fBlwres_string_parse()\fR
116 and
117 \fBlwres_addr_parse()\fR
118 return
119 LWRES_R_SUCCESS.
120 Both functions return
121 LWRES_R_FAILURE
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.
126 .PP
127 \fBlwres_getaddrsbyname()\fR
128 returns
129 LWRES_R_SUCCESS
130 on success and it returns
131 LWRES_R_NOTFOUND
132 if the hostname
133 \fIname\fR
134 could not be found.
135 .PP
136 LWRES_R_SUCCESS
137 is returned by a successful call to
138 \fBlwres_getnamebyaddr()\fR.
139 .PP
140 Both
141 \fBlwres_getaddrsbyname()\fR
142 and
143 \fBlwres_getnamebyaddr()\fR
144 return
145 LWRES_R_NOMEMORY
146 when memory allocation requests fail and
147 LWRES_R_UNEXPECTEDEND
148 if the buffers used for sending queries and receiving replies are too
149 small.
150 .SH "SEE ALSO"
151 .PP
152 \fBlwres_buffer\fR(3),
153 \fBlwres_gabn\fR(3).