]> git.ipfire.org Git - people/ms/strongswan.git/blob - lib/liblwres/man/lwres_resutil.docbook
- import of strongswan-2.7.0
[people/ms/strongswan.git] / lib / liblwres / man / lwres_resutil.docbook
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
2 <!--
3 - Copyright (C) 2001 Internet Software Consortium.
4 -
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.
8 -
9 - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
10 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
13 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 -->
18
19 <!-- $Id: lwres_resutil.docbook,v 1.1 2004/03/15 20:35:25 as Exp $ -->
20
21 <refentry>
22
23 <refentryinfo>
24 <date>Jun 30, 2000</date>
25 </refentryinfo>
26
27 <refmeta>
28 <refentrytitle>lwres_resutil</refentrytitle>
29 <manvolnum>3</manvolnum>
30 <refmiscinfo>BIND9</refmiscinfo>
31 </refmeta>
32
33 <refnamediv>
34 <refname>lwres_string_parse</refname>
35 <refname>lwres_addr_parse</refname>
36 <refname>lwres_getaddrsbyname</refname>
37 <refname>lwres_getnamebyaddr</refname>
38 <refpurpose>lightweight resolver utility functions</refpurpose>
39 </refnamediv>
40 <refsynopsisdiv>
41 <funcsynopsis>
42 <funcsynopsisinfo>#include &lt;lwres/lwres.h&gt;</funcsynopsisinfo>
43 <funcprototype>
44 <funcdef>
45 lwres_result_t
46 <function>lwres_string_parse</function></funcdef>
47 <paramdef>lwres_buffer_t *b</paramdef>
48 <paramdef>char **c</paramdef>
49 <paramdef>lwres_uint16_t *len</paramdef>
50 </funcprototype>
51 <funcprototype>
52 <funcdef>
53 lwres_result_t
54 <function>lwres_addr_parse</function></funcdef>
55 <paramdef>lwres_buffer_t *b</paramdef>
56 <paramdef>lwres_addr_t *addr</paramdef>
57 </funcprototype>
58 <funcprototype>
59 <funcdef>
60 lwres_result_t
61 <function>lwres_getaddrsbyname</function></funcdef>
62 <paramdef>lwres_context_t *ctx</paramdef>
63 <paramdef>const char *name</paramdef>
64 <paramdef>lwres_uint32_t addrtypes</paramdef>
65 <paramdef>lwres_gabnresponse_t **structp</paramdef>
66 </funcprototype>
67 <funcprototype>
68 <funcdef>
69 lwres_result_t
70 <function>lwres_getnamebyaddr</function></funcdef>
71 <paramdef>lwres_context_t *ctx</paramdef>
72 <paramdef>lwres_uint32_t addrtype</paramdef>
73 <paramdef>lwres_uint16_t addrlen</paramdef>
74 <paramdef>const unsigned char *addr</paramdef>
75 <paramdef>lwres_gnbaresponse_t **structp</paramdef>
76 </funcprototype>
77 </funcsynopsis>
78 </refsynopsisdiv>
79
80 <refsect1>
81 <title>DESCRIPTION</title>
82
83 <para>
84 <function>lwres_string_parse()</function> retrieves a DNS-encoded
85 string starting the current pointer of lightweight resolver buffer
86 <parameter>b</parameter>: i.e. <constant>b-&gt;current</constant>.
87 When the function returns, the address of the first byte of the
88 encoded string is returned via <parameter>*c</parameter> and the
89 length of that string is given by <parameter>*len</parameter>. The
90 buffer's current pointer is advanced to point at the character
91 following the string length, the encoded string, and the trailing
92 <type>NULL</type> character.
93 </para>
94
95 <para>
96 <function>lwres_addr_parse()</function> extracts an address from the
97 buffer <parameter>b</parameter>. The buffer's current pointer
98 <constant>b-&gt;current</constant> is presumed to point at an encoded
99 address: the address preceded by a 32-bit protocol family identifier
100 and a 16-bit length field. The encoded address is copied to
101 <constant>addr-&gt;address</constant> and
102 <constant>addr-&gt;length</constant> indicates the size in bytes of
103 the address that was copied. <constant>b-&gt;current</constant> is
104 advanced to point at the next byte of available data in the buffer
105 following the encoded address.
106 </para>
107
108 <para>
109 <function>lwres_getaddrsbyname()</function>
110 and
111 <function>lwres_getnamebyaddr()</function>
112 use the
113 <type>lwres_gnbaresponse_t</type>
114 structure defined below:
115 <programlisting>
116 typedef struct {
117 lwres_uint32_t flags;
118 lwres_uint16_t naliases;
119 lwres_uint16_t naddrs;
120 char *realname;
121 char **aliases;
122 lwres_uint16_t realnamelen;
123 lwres_uint16_t *aliaslen;
124 lwres_addrlist_t addrs;
125 void *base;
126 size_t baselen;
127 } lwres_gabnresponse_t;
128 </programlisting>
129 The contents of this structure are not manipulated directly but
130 they are controlled through the
131 <citerefentry>
132 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3
133 </manvolnum>
134 </citerefentry>
135 functions.
136 </para>
137
138 <para>
139 The lightweight resolver uses
140 <function>lwres_getaddrsbyname()</function> to perform foward lookups.
141 Hostname <parameter>name</parameter> is looked up using the resolver
142 context <parameter>ctx</parameter> for memory allocation.
143 <parameter>addrtypes</parameter> is a bitmask indicating which type of
144 addresses are to be looked up. Current values for this bitmask are
145 <type>LWRES_ADDRTYPE_V4</type> for IPv4 addresses and
146 <type>LWRES_ADDRTYPE_V6</type> for IPv6 addresses. Results of the
147 lookup are returned in <parameter>*structp</parameter>.
148 </para>
149
150 <para>
151 <function>lwres_getnamebyaddr()</function> performs reverse lookups.
152 Resolver context <parameter>ctx</parameter> is used for memory
153 allocation. The address type is indicated by
154 <parameter>addrtype</parameter>: <type>LWRES_ADDRTYPE_V4</type> or
155 <type>LWRES_ADDRTYPE_V6</type>. The address to be looked up is given
156 by <parameter>addr</parameter> and its length is
157 <parameter>addrlen</parameter> bytes. The result of the function call
158 is made available through <parameter>*structp</parameter>.
159 </para>
160 </refsect1>
161
162 <refsect1>
163 <title>RETURN VALUES</title>
164 <para>
165 Successful calls to
166 <function>lwres_string_parse()</function>
167 and
168 <function>lwres_addr_parse()</function>
169 return
170 <errorcode>LWRES_R_SUCCESS.</errorcode>
171 Both functions return
172 <errorcode>LWRES_R_FAILURE</errorcode>
173 if the buffer is corrupt or
174 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
175 if the buffer has less space than expected for the components of the
176 encoded string or address.
177 </para>
178 <para>
179 <function>lwres_getaddrsbyname()</function>
180 returns
181 <errorcode>LWRES_R_SUCCESS</errorcode>
182 on success and it returns
183 <errorcode>LWRES_R_NOTFOUND</errorcode>
184 if the hostname
185 <parameter>name</parameter>
186 could not be found.
187 </para>
188 <para>
189 <errorcode>LWRES_R_SUCCESS</errorcode>
190 is returned by a successful call to
191 <function>lwres_getnamebyaddr()</function>.
192 </para>
193
194 <para>
195 Both
196 <function>lwres_getaddrsbyname()</function>
197 and
198 <function>lwres_getnamebyaddr()</function>
199 return
200 <errorcode>LWRES_R_NOMEMORY</errorcode>
201 when memory allocation requests fail and
202 <errorcode>LWRES_R_UNEXPECTEDEND</errorcode>
203 if the buffers used for sending queries and receiving replies are too
204 small.
205 </para>
206
207 </refsect1>
208 <refsect1>
209 <title>SEE ALSO</title>
210 <para>
211 <citerefentry>
212 <refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
213 </citerefentry>,
214
215 <citerefentry>
216 <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
217 </citerefentry>.
218 </para>
219
220 </refsect1>
221 </refentry>