bind - Removed version tag from contrib directory and updated README.DRAGONFLY.
[dragonfly.git] / contrib / bind / lib / lwres / man / lwres_resutil.3
1 .\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
3 .\" 
4 .\" Permission to use, copy, modify, and/or 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.28.214.1 2009/07/11 01:43:30 tbox Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\"     Title: lwres_resutil
21 .\"    Author: 
22 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
23 .\"      Date: Jun 30, 2000
24 .\"    Manual: BIND9
25 .\"    Source: BIND9
26 .\"
27 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
29 .nh
30 .\" disable justification (adjust text to left margin only)
31 .ad l
32 .SH "NAME"
33 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
34 .SH "SYNOPSIS"
35 .nf
36 #include <lwres/lwres.h>
37 .fi
38 .HP 34
39 .BI "lwres_result_t lwres_string_parse(lwres_buffer_t\ *" "b" ", char\ **" "c" ", lwres_uint16_t\ *" "len" ");"
40 .HP 32
41 .BI "lwres_result_t lwres_addr_parse(lwres_buffer_t\ *" "b" ", lwres_addr_t\ *" "addr" ");"
42 .HP 36
43 .BI "lwres_result_t lwres_getaddrsbyname(lwres_context_t\ *" "ctx" ", const\ char\ *" "name" ", lwres_uint32_t\ " "addrtypes" ", lwres_gabnresponse_t\ **" "structp" ");"
44 .HP 35
45 .BI "lwres_result_t lwres_getnamebyaddr(lwres_context_t\ *" "ctx" ", lwres_uint32_t\ " "addrtype" ", lwres_uint16_t\ " "addrlen" ", const\ unsigned\ char\ *" "addr" ", lwres_gnbaresponse_t\ **" "structp" ");"
46 .SH "DESCRIPTION"
47 .PP
48 \fBlwres_string_parse()\fR
49 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
50 \fIb\fR: i.e.
51 \fBb\->current\fR. When the function returns, the address of the first byte of the encoded string is returned via
52 \fI*c\fR
53 and the length of that string is given by
54 \fI*len\fR. The buffer's current pointer is advanced to point at the character following the string length, the encoded string, and the trailing
55 \fBNULL\fR
56 character.
57 .PP
58 \fBlwres_addr_parse()\fR
59 extracts an address from the buffer
60 \fIb\fR. The buffer's current pointer
61 \fBb\->current\fR
62 is presumed to point at an encoded address: the address preceded by a 32\-bit protocol family identifier and a 16\-bit length field. The encoded address is copied to
63 \fBaddr\->address\fR
64 and
65 \fBaddr\->length\fR
66 indicates the size in bytes of the address that was copied.
67 \fBb\->current\fR
68 is advanced to point at the next byte of available data in the buffer following the encoded address.
69 .PP
70 \fBlwres_getaddrsbyname()\fR
71 and
72 \fBlwres_getnamebyaddr()\fR
73 use the
74 \fBlwres_gnbaresponse_t\fR
75 structure defined below:
76 .PP
77 .RS 4
78 .nf
79 typedef struct {
80         lwres_uint32_t          flags;
81         lwres_uint16_t          naliases;
82         lwres_uint16_t          naddrs;
83         char                   *realname;
84         char                  **aliases;
85         lwres_uint16_t          realnamelen;
86         lwres_uint16_t         *aliaslen;
87         lwres_addrlist_t        addrs;
88         void                   *base;
89         size_t                  baselen;
90 } lwres_gabnresponse_t;
91 .fi
92 .RE
93 .PP
94 The contents of this structure are not manipulated directly but they are controlled through the
95 \fBlwres_gabn\fR(3)
96 functions.
97 .PP
98 The lightweight resolver uses
99 \fBlwres_getaddrsbyname()\fR
100 to perform foward lookups. Hostname
101 \fIname\fR
102 is looked up using the resolver context
103 \fIctx\fR
104 for memory allocation.
105 \fIaddrtypes\fR
106 is a bitmask indicating which type of addresses are to be looked up. Current values for this bitmask are
107 \fBLWRES_ADDRTYPE_V4\fR
108 for IPv4 addresses and
109 \fBLWRES_ADDRTYPE_V6\fR
110 for IPv6 addresses. Results of the lookup are returned in
111 \fI*structp\fR.
112 .PP
113 \fBlwres_getnamebyaddr()\fR
114 performs reverse lookups. Resolver context
115 \fIctx\fR
116 is used for memory allocation. The address type is indicated by
117 \fIaddrtype\fR:
118 \fBLWRES_ADDRTYPE_V4\fR
119 or
120 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given by
121 \fIaddr\fR
122 and its length is
123 \fIaddrlen\fR
124 bytes. The result of the function call is made available through
125 \fI*structp\fR.
126 .SH "RETURN VALUES"
127 .PP
128 Successful calls to
129 \fBlwres_string_parse()\fR
130 and
131 \fBlwres_addr_parse()\fR
132 return
133 \fBLWRES_R_SUCCESS.\fR
134 Both functions return
135 \fBLWRES_R_FAILURE\fR
136 if the buffer is corrupt or
137 \fBLWRES_R_UNEXPECTEDEND\fR
138 if the buffer has less space than expected for the components of the encoded string or address.
139 .PP
140 \fBlwres_getaddrsbyname()\fR
141 returns
142 \fBLWRES_R_SUCCESS\fR
143 on success and it returns
144 \fBLWRES_R_NOTFOUND\fR
145 if the hostname
146 \fIname\fR
147 could not be found.
148 .PP
149 \fBLWRES_R_SUCCESS\fR
150 is returned by a successful call to
151 \fBlwres_getnamebyaddr()\fR.
152 .PP
153 Both
154 \fBlwres_getaddrsbyname()\fR
155 and
156 \fBlwres_getnamebyaddr()\fR
157 return
158 \fBLWRES_R_NOMEMORY\fR
159 when memory allocation requests fail and
160 \fBLWRES_R_UNEXPECTEDEND\fR
161 if the buffers used for sending queries and receiving replies are too small.
162 .SH "SEE ALSO"
163 .PP
164 \fBlwres_buffer\fR(3),
165 \fBlwres_gabn\fR(3).
166 .SH "COPYRIGHT"
167 Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
168 .br
169 Copyright \(co 2000, 2001 Internet Software Consortium.
170 .br