summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/lwres/man/lwres_context.html
blob: 6f7fbecec2b479d8dfdbe6e61e773596f211a0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!--
 - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
 - Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
 - 
 - Permission to use, copy, modify, and distribute this software for any
 - purpose with or without fee is hereby granted, provided that the above
 - copyright notice and this permission notice appear in all copies.
 - 
 - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 - PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id: lwres_context.html,v 1.5.2.2.2.12 2006/06/29 13:02:31 marka Exp $ -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>lwres_context</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
<a name="id2482688"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>lwres_context_create, lwres_context_destroy, lwres_context_nextserial, lwres_context_initserial, lwres_context_freemem, lwres_context_allocmem, lwres_context_sendrecv &#8212; lightweight resolver context management</p>
</div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<div class="funcsynopsis">
<pre class="funcsynopsisinfo">#include &lt;lwres/lwres.h&gt;</pre>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_context_create</b>(</code></td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
lwres_result_t
<b class="fsfunc">lwres_context_destroy</b>(</code></td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_context_initserial</b>(</code></td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
lwres_uint32_t
<b class="fsfunc">lwres_context_nextserial</b>(</code></td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_context_freemem</b>(</code></td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
<tr>
<td><code class="funcdef">
void
<b class="fsfunc">lwres_context_allocmem</b>(</code></td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
<tr>
<td><code class="funcdef">
void *
<b class="fsfunc">lwres_context_sendrecv</b>(</code></td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>, </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<code>)</code>;</td>
</tr>
</table>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2549540"></a><h2>DESCRIPTION</h2>
<p>
<code class="function">lwres_context_create()</code>
creates a
<span class="type">lwres_context_t</span>
structure for use in lightweight resolver operations.
It holds a socket and other data needed for communicating
with a resolver daemon.
The new
<span class="type">lwres_context_t</span>
is returned through
<em class="parameter"><code>contextp</code></em>,

a pointer to a
<span class="type">lwres_context_t</span>
pointer.  This 
<span class="type">lwres_context_t</span>
pointer must initially be NULL, and is modified 
to point to the newly created
<span class="type">lwres_context_t</span>.

</p>
<p>
When the lightweight resolver needs to perform dynamic memory
allocation, it will call
<em class="parameter"><code>malloc_function</code></em>
to allocate memory and
<em class="parameter"><code>free_function</code></em>

to free it.  If 
<em class="parameter"><code>malloc_function</code></em>
and
<em class="parameter"><code>free_function</code></em>

are NULL, memory is allocated using
.Xr malloc 3
and
<span class="citerefentry"><span class="refentrytitle">free</span>(3)</span>.

It is not permitted to have a NULL
<em class="parameter"><code>malloc_function</code></em>
and a non-NULL
<em class="parameter"><code>free_function</code></em>
or vice versa.
<em class="parameter"><code>arg</code></em>
is passed as the first parameter to the memory
allocation functions.  
If
<em class="parameter"><code>malloc_function</code></em>
and
<em class="parameter"><code>free_function</code></em>
are NULL,
<em class="parameter"><code>arg</code></em>

is unused and should be passed as NULL.
</p>
<p>
Once memory for the structure has been allocated,
it is initialized using
<span class="citerefentry"><span class="refentrytitle">lwres_conf_init</span>(3)</span>

and returned via
<em class="parameter"><code>*contextp</code></em>.

</p>
<p>
<code class="function">lwres_context_destroy()</code>
destroys a 
<span class="type">lwres_context_t</span>,

closing its socket.
<em class="parameter"><code>contextp</code></em>
is a pointer to a pointer to the context that is to be destroyed.
The pointer will be set to NULL when the context has been destroyed.
</p>
<p>
The context holds a serial number that is used to identify resolver
request packets and associate responses with the corresponding requests.
This serial number is controlled using
<code class="function">lwres_context_initserial()</code>
and
<code class="function">lwres_context_nextserial()</code>.
<code class="function">lwres_context_initserial()</code>
sets the serial number for context
<em class="parameter"><code>*ctx</code></em>
to
<em class="parameter"><code>serial</code></em>.

<code class="function">lwres_context_nextserial()</code>
increments the serial number and returns the previous value.
</p>
<p>
Memory for a lightweight resolver context is allocated and freed using
<code class="function">lwres_context_allocmem()</code>
and
<code class="function">lwres_context_freemem()</code>.
These use whatever allocations were defined when the context was
created with
<code class="function">lwres_context_create()</code>.
<code class="function">lwres_context_allocmem()</code>
allocates
<em class="parameter"><code>len</code></em>
bytes of memory and if successful returns a pointer to the allocated
storage.
<code class="function">lwres_context_freemem()</code>
frees
<em class="parameter"><code>len</code></em>
bytes of space starting at location
<em class="parameter"><code>mem</code></em>.

</p>
<p>
<code class="function">lwres_context_sendrecv()</code>
performs I/O for the context
<em class="parameter"><code>ctx</code></em>.

Data are read and written from the context's socket.
It writes data from
<em class="parameter"><code>sendbase</code></em>
&#8212; typically a lightweight resolver query packet &#8212;
and waits for a reply which is copied to the receive buffer at
<em class="parameter"><code>recvbase</code></em>.

The number of bytes that were written to this receive buffer is
returned in
<em class="parameter"><code>*recvd_len</code></em>.

</p>
</div>
<div class="refsect1" lang="en">
<a name="id2549789"></a><h2>RETURN VALUES</h2>
<p>
<code class="function">lwres_context_create()</code>
returns
<span class="errorcode">LWRES_R_NOMEMORY</span>
if memory for the
<span class="type">struct lwres_context</span>
could not be allocated, 
<span class="errorcode">LWRES_R_SUCCESS</span>
otherwise.
</p>
<p>
Successful calls to the memory allocator
<code class="function">lwres_context_allocmem()</code>
return a pointer to the start of the allocated space.
It returns NULL if memory could not be allocated.
</p>
<p>
<span class="errorcode">LWRES_R_SUCCESS</span>
is returned when
<code class="function">lwres_context_sendrecv()</code>
completes successfully.
<span class="errorcode">LWRES_R_IOERROR</span>
is returned if an I/O error occurs and
<span class="errorcode">LWRES_R_TIMEOUT</span>
is returned if
<code class="function">lwres_context_sendrecv()</code>
times out waiting for a response.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2549841"></a><h2>SEE ALSO</h2>
<p>
<span class="citerefentry"><span class="refentrytitle">lwres_conf_init</span>(3)</span>,

<span class="citerefentry"><span class="refentrytitle">malloc</span>(3)</span>,

<span class="citerefentry"><span class="refentrytitle">free</span>(3
)</span>.
</p>
</div>
</div></body>
</html>
OpenPOWER on IntegriCloud