2 - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2001 Internet Software Consortium.
5 - Permission to use, copy, modify, and distribute this software for any
6 - purpose with or without fee is hereby granted, provided that the above
7 - copyright notice and this permission notice appear in all copies.
9 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 - PERFORMANCE OF THIS SOFTWARE.
18 <!-- $Id: lwres_resutil.html,v 1.8.2.2 2004/03/15 04:45:05 marka Exp $ -->
26 CONTENT="Modular DocBook HTML Stylesheet Version 1.73
47 >lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr -- lightweight resolver utility functions</DIV
49 CLASS="REFSYNOPSISDIV"
63 CLASS="FUNCSYNOPSISINFO"
64 >#include <lwres/lwres.h></PRE
70 lwres_string_parse</CODE
71 >(lwres_buffer_t *b, char **c, lwres_uint16_t *len);</CODE
78 lwres_addr_parse</CODE
79 >(lwres_buffer_t *b, lwres_addr_t *addr);</CODE
86 lwres_getaddrsbyname</CODE
87 >(lwres_context_t *ctx, const char *name, lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);</CODE
94 lwres_getnamebyaddr</CODE
95 >(lwres_context_t *ctx, lwres_uint32_t addrtype, lwres_uint16_t addrlen, const unsigned char *addr, lwres_gnbaresponse_t **structp);</CODE
111 >lwres_string_parse()</TT
112 > retrieves a DNS-encoded
113 string starting the current pointer of lightweight resolver buffer
123 When the function returns, the address of the first byte of the
124 encoded string is returned via <TT
130 length of that string is given by <TT
136 buffer's current pointer is advanced to point at the character
137 following the string length, the encoded string, and the trailing
145 >lwres_addr_parse()</TT
146 > extracts an address from the
152 >. The buffer's current pointer
156 > is presumed to point at an encoded
157 address: the address preceded by a 32-bit protocol family identifier
158 and a 16-bit length field. The encoded address is copied to
161 >addr->address</TT
166 > indicates the size in bytes of
167 the address that was copied. <TT
171 advanced to point at the next byte of available data in the buffer
172 following the encoded address.</P
176 >lwres_getaddrsbyname()</TT
181 >lwres_getnamebyaddr()</TT
186 >lwres_gnbaresponse_t</SPAN
188 structure defined below:
190 CLASS="PROGRAMLISTING"
192 lwres_uint32_t flags;
193 lwres_uint16_t naliases;
194 lwres_uint16_t naddrs;
197 lwres_uint16_t realnamelen;
198 lwres_uint16_t *aliaslen;
199 lwres_addrlist_t addrs;
202 } lwres_gabnresponse_t;</PRE
204 The contents of this structure are not manipulated directly but
205 they are controlled through the
209 CLASS="REFENTRYTITLE"
215 >The lightweight resolver uses
218 >lwres_getaddrsbyname()</TT
219 > to perform foward lookups.
225 > is looked up using the resolver
231 > for memory allocation.
237 > is a bitmask indicating which type of
238 addresses are to be looked up. Current values for this bitmask are
241 >LWRES_ADDRTYPE_V4</SPAN
242 > for IPv4 addresses and
245 >LWRES_ADDRTYPE_V6</SPAN
246 > for IPv6 addresses. Results of the
247 lookup are returned in <TT
256 >lwres_getnamebyaddr()</TT
257 > performs reverse lookups.
264 allocation. The address type is indicated by
272 >LWRES_ADDRTYPE_V4</SPAN
276 >LWRES_ADDRTYPE_V6</SPAN
277 >. The address to be looked up is given
289 > bytes. The result of the function call
290 is made available through <TT
308 >lwres_string_parse()</TT
313 >lwres_addr_parse()</TT
318 >LWRES_R_SUCCESS.</SPAN
320 Both functions return
323 >LWRES_R_FAILURE</SPAN
325 if the buffer is corrupt or
328 >LWRES_R_UNEXPECTEDEND</SPAN
330 if the buffer has less space than expected for the components of the
331 encoded string or address.</P
335 >lwres_getaddrsbyname()</TT
340 >LWRES_R_SUCCESS</SPAN
342 on success and it returns
345 >LWRES_R_NOTFOUND</SPAN
354 could not be found.</P
358 >LWRES_R_SUCCESS</SPAN
360 is returned by a successful call to
363 >lwres_getnamebyaddr()</TT
369 >lwres_getaddrsbyname()</TT
374 >lwres_getnamebyaddr()</TT
379 >LWRES_R_NOMEMORY</SPAN
381 when memory allocation requests fail and
384 >LWRES_R_UNEXPECTEDEND</SPAN
386 if the buffers used for sending queries and receiving replies are too
400 CLASS="REFENTRYTITLE"
408 CLASS="REFENTRYTITLE"