Import of bind-9.3.2-P1
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_resutil.3
1 .\" Copyright (C) 2004, 2005 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.1.8.5 2005/10/13 02:33:54 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\" ** You probably do not want to edit this file directly **
21 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
22 .\" Instead of manually editing it, you probably should edit the DocBook XML
23 .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
24 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" "BIND9"
25 .\" disable hyphenation
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .SH "NAME"
30 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/lwres.h>
34 .fi
35 .HP 34
36 \fBlwres_result_t\ \fBlwres_string_parse\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBchar\ **c\fR\fB, \fR\fBlwres_uint16_t\ *len\fR\fB);\fR
37 .HP 32
38 \fBlwres_result_t\ \fBlwres_addr_parse\fR\fR\fB(\fR\fBlwres_buffer_t\ *b\fR\fB, \fR\fBlwres_addr_t\ *addr\fR\fB);\fR
39 .HP 36
40 \fBlwres_result_t\ \fBlwres_getaddrsbyname\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBconst\ char\ *name\fR\fB, \fR\fBlwres_uint32_t\ addrtypes\fR\fB, \fR\fBlwres_gabnresponse_t\ **structp\fR\fB);\fR
41 .HP 35
42 \fBlwres_result_t\ \fBlwres_getnamebyaddr\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBlwres_uint32_t\ addrtype\fR\fB, \fR\fBlwres_uint16_t\ addrlen\fR\fB, \fR\fBconst\ unsigned\ char\ *addr\fR\fB, \fR\fBlwres_gnbaresponse_t\ **structp\fR\fB);\fR
43 .SH "DESCRIPTION"
44 .PP
45 \fBlwres_string_parse()\fR
46 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
47 \fIb\fR: i.e.
48 \fBb\->current\fR. When the function returns, the address of the first byte of the encoded string is returned via
49 \fI*c\fR
50 and the length of that string is given by
51 \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
52 \fBNULL\fR
53 character.
54 .PP
55 \fBlwres_addr_parse()\fR
56 extracts an address from the buffer
57 \fIb\fR. The buffer's current pointer
58 \fBb\->current\fR
59 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
60 \fBaddr\->address\fR
61 and
62 \fBaddr\->length\fR
63 indicates the size in bytes of the address that was copied.
64 \fBb\->current\fR
65 is advanced to point at the next byte of available data in the buffer 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 .fi
88 .sp
89 The contents of this structure are not manipulated directly but they are controlled through the
90 \fBlwres_gabn\fR(3 )
91 functions.
92 .PP
93 The lightweight resolver uses
94 \fBlwres_getaddrsbyname()\fR
95 to perform foward lookups. Hostname
96 \fIname\fR
97 is looked up using the resolver context
98 \fIctx\fR
99 for memory allocation.
100 \fIaddrtypes\fR
101 is a bitmask indicating which type of addresses are to be looked up. Current values for this bitmask are
102 \fBLWRES_ADDRTYPE_V4\fR
103 for IPv4 addresses and
104 \fBLWRES_ADDRTYPE_V6\fR
105 for IPv6 addresses. Results of the lookup are returned in
106 \fI*structp\fR.
107 .PP
108 \fBlwres_getnamebyaddr()\fR
109 performs reverse lookups. Resolver context
110 \fIctx\fR
111 is used for memory allocation. The address type is indicated by
112 \fIaddrtype\fR:
113 \fBLWRES_ADDRTYPE_V4\fR
114 or
115 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given by
116 \fIaddr\fR
117 and its length is
118 \fIaddrlen\fR
119 bytes. The result of the function call is made available through
120 \fI*structp\fR.
121 .SH "RETURN VALUES"
122 .PP
123 Successful calls to
124 \fBlwres_string_parse()\fR
125 and
126 \fBlwres_addr_parse()\fR
127 return
128 \fBLWRES_R_SUCCESS.\fR
129 Both functions return
130 \fBLWRES_R_FAILURE\fR
131 if the buffer is corrupt or
132 \fBLWRES_R_UNEXPECTEDEND\fR
133 if the buffer has less space than expected for the components of the encoded string or address.
134 .PP
135 \fBlwres_getaddrsbyname()\fR
136 returns
137 \fBLWRES_R_SUCCESS\fR
138 on success and it returns
139 \fBLWRES_R_NOTFOUND\fR
140 if the hostname
141 \fIname\fR
142 could not be found.
143 .PP
144 \fBLWRES_R_SUCCESS\fR
145 is returned by a successful call to
146 \fBlwres_getnamebyaddr()\fR.
147 .PP
148 Both
149 \fBlwres_getaddrsbyname()\fR
150 and
151 \fBlwres_getnamebyaddr()\fR
152 return
153 \fBLWRES_R_NOMEMORY\fR
154 when memory allocation requests fail and
155 \fBLWRES_R_UNEXPECTEDEND\fR
156 if the buffers used for sending queries and receiving replies are too small.
157 .SH "SEE ALSO"
158 .PP
159 \fBlwres_buffer\fR(3),
160 \fBlwres_gabn\fR(3).