1 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
2 "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
3 [<!ENTITY mdash "—">]>
5 - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
6 - Copyright (C) 2000, 2001 Internet Software Consortium.
8 - Permission to use, copy, modify, and distribute this software for any
9 - purpose with or without fee is hereby granted, provided that the above
10 - copyright notice and this permission notice appear in all copies.
12 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
13 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 - PERFORMANCE OF THIS SOFTWARE.
21 <!-- $Id: lwres_resutil.docbook,v 1.5.206.3 2005/05/12 21:36:16 sra Exp $ -->
26 <date>Jun 30, 2000</date>
30 <refentrytitle>lwres_resutil</refentrytitle>
31 <manvolnum>3</manvolnum>
32 <refmiscinfo>BIND9</refmiscinfo>
39 <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
44 <holder>Internet Software Consortium.</holder>
49 <refname>lwres_string_parse</refname>
50 <refname>lwres_addr_parse</refname>
51 <refname>lwres_getaddrsbyname</refname>
52 <refname>lwres_getnamebyaddr</refname>
53 <refpurpose>lightweight resolver utility functions</refpurpose>
57 <funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
61 <function>lwres_string_parse</function></funcdef>
62 <paramdef>lwres_buffer_t *b</paramdef>
63 <paramdef>char **c</paramdef>
64 <paramdef>lwres_uint16_t *len</paramdef>
69 <function>lwres_addr_parse</function></funcdef>
70 <paramdef>lwres_buffer_t *b</paramdef>
71 <paramdef>lwres_addr_t *addr</paramdef>
76 <function>lwres_getaddrsbyname</function></funcdef>
77 <paramdef>lwres_context_t *ctx</paramdef>
78 <paramdef>const char *name</paramdef>
79 <paramdef>lwres_uint32_t addrtypes</paramdef>
80 <paramdef>lwres_gabnresponse_t **structp</paramdef>
85 <function>lwres_getnamebyaddr</function></funcdef>
86 <paramdef>lwres_context_t *ctx</paramdef>
87 <paramdef>lwres_uint32_t addrtype</paramdef>
88 <paramdef>lwres_uint16_t addrlen</paramdef>
89 <paramdef>const unsigned char *addr</paramdef>
90 <paramdef>lwres_gnbaresponse_t **structp</paramdef>
96 <title>DESCRIPTION</title>
99 <function>lwres_string_parse()</function> retrieves a DNS-encoded
100 string starting the current pointer of lightweight resolver buffer
101 <parameter>b</parameter>: i.e. <constant>b->current</constant>.
102 When the function returns, the address of the first byte of the
103 encoded string is returned via <parameter>*c</parameter> and the
104 length of that string is given by <parameter>*len</parameter>. The
105 buffer's current pointer is advanced to point at the character
106 following the string length, the encoded string, and the trailing
107 <type>NULL</type> character.
111 <function>lwres_addr_parse()</function> extracts an address from the
112 buffer <parameter>b</parameter>. The buffer's current pointer
113 <constant>b->current</constant> is presumed to point at an encoded
114 address: the address preceded by a 32-bit protocol family identifier
115 and a 16-bit length field. The encoded address is copied to
116 <constant>addr->address</constant> and
117 <constant>addr->length</constant> indicates the size in bytes of
118 the address that was copied. <constant>b->current</constant> is
119 advanced to point at the next byte of available data in the buffer
120 following the encoded address.
124 <function>lwres_getaddrsbyname()</function>
126 <function>lwres_getnamebyaddr()</function>
128 <type>lwres_gnbaresponse_t</type>
129 structure defined below:
132 lwres_uint32_t flags;
133 lwres_uint16_t naliases;
134 lwres_uint16_t naddrs;
137 lwres_uint16_t realnamelen;
138 lwres_uint16_t *aliaslen;
139 lwres_addrlist_t addrs;
142 } lwres_gabnresponse_t;
144 The contents of this structure are not manipulated directly but
145 they are controlled through the
147 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3
154 The lightweight resolver uses
155 <function>lwres_getaddrsbyname()</function> to perform foward lookups.
156 Hostname <parameter>name</parameter> is looked up using the resolver
157 context <parameter>ctx</parameter> for memory allocation.
158 <parameter>addrtypes</parameter> is a bitmask indicating which type of
159 addresses are to be looked up. Current values for this bitmask are
160 <type>LWRES_ADDRTYPE_V4</type> for IPv4 addresses and
161 <type>LWRES_ADDRTYPE_V6</type> for IPv6 addresses. Results of the
162 lookup are returned in <parameter>*structp</parameter>.
166 <function>lwres_getnamebyaddr()</function> performs reverse lookups.
167 Resolver context <parameter>ctx</parameter> is used for memory
168 allocation. The address type is indicated by
169 <parameter>addrtype</parameter>: <type>LWRES_ADDRTYPE_V4</type> or
170 <type>LWRES_ADDRTYPE_V6</type>. The address to be looked up is given
171 by <parameter>addr</parameter> and its length is
172 <parameter>addrlen</parameter> bytes. The result of the function call
173 is made available through <parameter>*structp</parameter>.
178 <title>RETURN VALUES</title>
181 <function>lwres_string_parse()</function>
183 <function>lwres_addr_parse()</function>
185 <errorcode>LWRES_R_SUCCESS.</errorcode>
186 Both functions return
187 <errorcode>LWRES_R_FAILURE</errorcode>
188 if the buffer is corrupt or
189 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
190 if the buffer has less space than expected for the components of the
191 encoded string or address.
194 <function>lwres_getaddrsbyname()</function>
196 <errorcode>LWRES_R_SUCCESS</errorcode>
197 on success and it returns
198 <errorcode>LWRES_R_NOTFOUND</errorcode>
200 <parameter>name</parameter>
204 <errorcode>LWRES_R_SUCCESS</errorcode>
205 is returned by a successful call to
206 <function>lwres_getnamebyaddr()</function>.
211 <function>lwres_getaddrsbyname()</function>
213 <function>lwres_getnamebyaddr()</function>
215 <errorcode>LWRES_R_NOMEMORY</errorcode>
216 when memory allocation requests fail and
217 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
218 if the buffers used for sending queries and receiving replies are too
224 <title>SEE ALSO</title>
227 <refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
231 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>