]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/bind9/lib/lwres/man/lwres_resutil.3
MFC r363988:
[FreeBSD/stable/9.git] / contrib / bind9 / lib / lwres / man / lwres_resutil.3
1 .\" Copyright (C) 2004, 2005, 2007, 2014, 2015 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 .hy 0
17 .ad l
18 '\" t
19 .\"     Title: lwres_resutil
20 .\"    Author: 
21 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
22 .\"      Date: 2007-06-18
23 .\"    Manual: BIND9
24 .\"    Source: ISC
25 .\"  Language: English
26 .\"
27 .TH "LWRES_RESUTIL" "3" "2007\-06\-18" "ISC" "BIND9"
28 .\" -----------------------------------------------------------------
29 .\" * Define some portability stuff
30 .\" -----------------------------------------------------------------
31 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 .\" http://bugs.debian.org/507673
33 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
34 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 .ie \n(.g .ds Aq \(aq
36 .el       .ds Aq '
37 .\" -----------------------------------------------------------------
38 .\" * set default formatting
39 .\" -----------------------------------------------------------------
40 .\" disable hyphenation
41 .nh
42 .\" disable justification (adjust text to left margin only)
43 .ad l
44 .\" -----------------------------------------------------------------
45 .\" * MAIN CONTENT STARTS HERE *
46 .\" -----------------------------------------------------------------
47 .SH "NAME"
48 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
49 .SH "SYNOPSIS"
50 .sp
51 .ft B
52 .nf
53 #include <lwres/lwres\&.h>
54 .fi
55 .ft
56 .HP \w'lwres_result_t\ lwres_string_parse('u
57 .BI "lwres_result_t lwres_string_parse(lwres_buffer_t\ *" "b" ", char\ **" "c" ", lwres_uint16_t\ *" "len" ");"
58 .HP \w'lwres_result_t\ lwres_addr_parse('u
59 .BI "lwres_result_t lwres_addr_parse(lwres_buffer_t\ *" "b" ", lwres_addr_t\ *" "addr" ");"
60 .HP \w'lwres_result_t\ lwres_getaddrsbyname('u
61 .BI "lwres_result_t lwres_getaddrsbyname(lwres_context_t\ *" "ctx" ", const\ char\ *" "name" ", lwres_uint32_t\ " "addrtypes" ", lwres_gabnresponse_t\ **" "structp" ");"
62 .HP \w'lwres_result_t\ lwres_getnamebyaddr('u
63 .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" ");"
64 .SH "DESCRIPTION"
65 .PP
66 \fBlwres_string_parse()\fR
67 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
68 \fIb\fR: i\&.e\&.
69 \fBb\->current\fR\&. When the function returns, the address of the first byte of the encoded string is returned via
70 \fI*c\fR
71 and the length of that string is given by
72 \fI*len\fR\&. The buffer\*(Aqs current pointer is advanced to point at the character following the string length, the encoded string, and the trailing
73 \fBNULL\fR
74 character\&.
75 .PP
76 \fBlwres_addr_parse()\fR
77 extracts an address from the buffer
78 \fIb\fR\&. The buffer\*(Aqs current pointer
79 \fBb\->current\fR
80 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
81 \fBaddr\->address\fR
82 and
83 \fBaddr\->length\fR
84 indicates the size in bytes of the address that was copied\&.
85 \fBb\->current\fR
86 is advanced to point at the next byte of available data in the buffer following the encoded address\&.
87 .PP
88 \fBlwres_getaddrsbyname()\fR
89 and
90 \fBlwres_getnamebyaddr()\fR
91 use the
92 \fBlwres_gnbaresponse_t\fR
93 structure defined below:
94 .PP
95 .if n \{\
96 .RS 4
97 .\}
98 .nf
99 typedef struct {
100         lwres_uint32_t          flags;
101         lwres_uint16_t          naliases;
102         lwres_uint16_t          naddrs;
103         char                   *realname;
104         char                  **aliases;
105         lwres_uint16_t          realnamelen;
106         lwres_uint16_t         *aliaslen;
107         lwres_addrlist_t        addrs;
108         void                   *base;
109         size_t                  baselen;
110 } lwres_gabnresponse_t;
111 .fi
112 .if n \{\
113 .RE
114 .\}
115 .PP
116 The contents of this structure are not manipulated directly but they are controlled through the
117 \fBlwres_gabn\fR(3)
118 functions\&.
119 .PP
120 The lightweight resolver uses
121 \fBlwres_getaddrsbyname()\fR
122 to perform forward lookups\&. Hostname
123 \fIname\fR
124 is looked up using the resolver context
125 \fIctx\fR
126 for memory allocation\&.
127 \fIaddrtypes\fR
128 is a bitmask indicating which type of addresses are to be looked up\&. Current values for this bitmask are
129 \fBLWRES_ADDRTYPE_V4\fR
130 for IPv4 addresses and
131 \fBLWRES_ADDRTYPE_V6\fR
132 for IPv6 addresses\&. Results of the lookup are returned in
133 \fI*structp\fR\&.
134 .PP
135 \fBlwres_getnamebyaddr()\fR
136 performs reverse lookups\&. Resolver context
137 \fIctx\fR
138 is used for memory allocation\&. The address type is indicated by
139 \fIaddrtype\fR:
140 \fBLWRES_ADDRTYPE_V4\fR
141 or
142 \fBLWRES_ADDRTYPE_V6\fR\&. The address to be looked up is given by
143 \fIaddr\fR
144 and its length is
145 \fIaddrlen\fR
146 bytes\&. The result of the function call is made available through
147 \fI*structp\fR\&.
148 .SH "RETURN VALUES"
149 .PP
150 Successful calls to
151 \fBlwres_string_parse()\fR
152 and
153 \fBlwres_addr_parse()\fR
154 return
155 \fBLWRES_R_SUCCESS\&.\fR
156 Both functions return
157 \fBLWRES_R_FAILURE\fR
158 if the buffer is corrupt or
159 \fBLWRES_R_UNEXPECTEDEND\fR
160 if the buffer has less space than expected for the components of the encoded string or address\&.
161 .PP
162 \fBlwres_getaddrsbyname()\fR
163 returns
164 \fBLWRES_R_SUCCESS\fR
165 on success and it returns
166 \fBLWRES_R_NOTFOUND\fR
167 if the hostname
168 \fIname\fR
169 could not be found\&.
170 .PP
171 \fBLWRES_R_SUCCESS\fR
172 is returned by a successful call to
173 \fBlwres_getnamebyaddr()\fR\&.
174 .PP
175 Both
176 \fBlwres_getaddrsbyname()\fR
177 and
178 \fBlwres_getnamebyaddr()\fR
179 return
180 \fBLWRES_R_NOMEMORY\fR
181 when memory allocation requests fail and
182 \fBLWRES_R_UNEXPECTEDEND\fR
183 if the buffers used for sending queries and receiving replies are too small\&.
184 .SH "SEE ALSO"
185 .PP
186 \fBlwres_buffer\fR(3),
187 \fBlwres_gabn\fR(3)\&.
188 .SH "AUTHOR"
189 .PP
190 \fBInternet Systems Consortium, Inc\&.\fR
191 .SH "COPYRIGHT"
192 .br
193 Copyright \(co 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
194 .br
195 Copyright \(co 2000, 2001 Internet Software Consortium.
196 .br