1 .\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
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.
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.
16 .\" $Id: lwres_resutil.3,v 1.29 2009-07-11 01:12:46 tbox Exp $
20 .\" Title: lwres_resutil
22 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
23 .\" Date: Jun 30, 2000
27 .TH "LWRES_RESUTIL" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
30 .\" disable justification (adjust text to left margin only)
33 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
36 #include <lwres/lwres.h>
39 .BI "lwres_result_t lwres_string_parse(lwres_buffer_t\ *" "b" ", char\ **" "c" ", lwres_uint16_t\ *" "len" ");"
41 .BI "lwres_result_t lwres_addr_parse(lwres_buffer_t\ *" "b" ", lwres_addr_t\ *" "addr" ");"
43 .BI "lwres_result_t lwres_getaddrsbyname(lwres_context_t\ *" "ctx" ", const\ char\ *" "name" ", lwres_uint32_t\ " "addrtypes" ", lwres_gabnresponse_t\ **" "structp" ");"
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" ");"
48 \fBlwres_string_parse()\fR
49 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
51 \fBb\->current\fR. When the function returns, the address of the first byte of the encoded string is returned via
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
58 \fBlwres_addr_parse()\fR
59 extracts an address from the buffer
60 \fIb\fR. The buffer's current pointer
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
66 indicates the size in bytes of the address that was copied.
68 is advanced to point at the next byte of available data in the buffer following the encoded address.
70 \fBlwres_getaddrsbyname()\fR
72 \fBlwres_getnamebyaddr()\fR
74 \fBlwres_gnbaresponse_t\fR
75 structure defined below:
81 lwres_uint16_t naliases;
82 lwres_uint16_t naddrs;
85 lwres_uint16_t realnamelen;
86 lwres_uint16_t *aliaslen;
87 lwres_addrlist_t addrs;
90 } lwres_gabnresponse_t;
94 The contents of this structure are not manipulated directly but they are controlled through the
98 The lightweight resolver uses
99 \fBlwres_getaddrsbyname()\fR
100 to perform foward lookups. Hostname
102 is looked up using the resolver context
104 for memory allocation.
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
113 \fBlwres_getnamebyaddr()\fR
114 performs reverse lookups. Resolver context
116 is used for memory allocation. The address type is indicated by
118 \fBLWRES_ADDRTYPE_V4\fR
120 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given by
124 bytes. The result of the function call is made available through
129 \fBlwres_string_parse()\fR
131 \fBlwres_addr_parse()\fR
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.
140 \fBlwres_getaddrsbyname()\fR
142 \fBLWRES_R_SUCCESS\fR
143 on success and it returns
144 \fBLWRES_R_NOTFOUND\fR
149 \fBLWRES_R_SUCCESS\fR
150 is returned by a successful call to
151 \fBlwres_getnamebyaddr()\fR.
154 \fBlwres_getaddrsbyname()\fR
156 \fBlwres_getnamebyaddr()\fR
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.
164 \fBlwres_buffer\fR(3),
167 Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
169 Copyright \(co 2000, 2001 Internet Software Consortium.