2 - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 - Copyright (C) 2001, 2003 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_context.html,v 1.5.2.3 2004/03/15 04:45:01 marka Exp $ -->
26 CONTENT="Modular DocBook HTML Stylesheet Version 1.73
47 >lwres_context_create, lwres_context_destroy, lwres_context_nextserial, lwres_context_initserial, lwres_context_freemem, lwres_context_allocmem, lwres_context_sendrecv -- lightweight resolver context management</DIV
49 CLASS="REFSYNOPSISDIV"
63 CLASS="FUNCSYNOPSISINFO"
64 >#include <lwres/lwres.h></PRE
70 lwres_context_create</CODE
71 >(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, lwres_free_t free_function);</CODE
78 lwres_context_destroy</CODE
79 >(lwres_context_t **contextp);</CODE
86 lwres_context_initserial</CODE
87 >(lwres_context_t *ctx, lwres_uint32_t serial);</CODE
94 lwres_context_nextserial</CODE
95 >(lwres_context_t *ctx);</CODE
102 lwres_context_freemem</CODE
103 >(lwres_context_t *ctx, void *mem, size_t len);</CODE
110 lwres_context_allocmem</CODE
111 >(lwres_context_t *ctx, size_t len);</CODE
118 lwres_context_sendrecv</CODE
119 >(lwres_context_t *ctx, void *sendbase, int sendlen, void *recvbase, int recvlen, int *recvd_len);</CODE
135 >lwres_context_create()</TT
140 >lwres_context_t</SPAN
142 structure for use in lightweight resolver operations.
143 It holds a socket and other data needed for communicating
144 with a resolver daemon.
148 >lwres_context_t</SPAN
161 >lwres_context_t</SPAN
166 >lwres_context_t</SPAN
168 pointer must initially be NULL, and is modified
169 to point to the newly created
172 >lwres_context_t</SPAN
175 >When the lightweight resolver needs to perform dynamic memory
176 allocation, it will call
183 to allocate memory and
206 are NULL, memory is allocated using
212 CLASS="REFENTRYTITLE"
217 It is not permitted to have a NULL
238 is passed as the first parameter to the memory
239 allocation functions.
262 is unused and should be passed as NULL.</P
264 >Once memory for the structure has been allocated,
265 it is initialized using
269 CLASS="REFENTRYTITLE"
270 >lwres_conf_init</SPAN
284 >lwres_context_destroy()</TT
289 >lwres_context_t</SPAN
299 is a pointer to a pointer to the context that is to be destroyed.
300 The pointer will be set to NULL when the context has been destroyed.</P
302 >The context holds a serial number that is used to identify resolver
303 request packets and associate responses with the corresponding requests.
304 This serial number is controlled using
307 >lwres_context_initserial()</TT
312 >lwres_context_nextserial()</TT
316 >lwres_context_initserial()</TT
318 sets the serial number for context
335 >lwres_context_nextserial()</TT
337 increments the serial number and returns the previous value.</P
339 >Memory for a lightweight resolver context is allocated and freed using
342 >lwres_context_allocmem()</TT
347 >lwres_context_freemem()</TT
349 These use whatever allocations were defined when the context was
353 >lwres_context_create()</TT
357 >lwres_context_allocmem()</TT
366 bytes of memory and if successful returns a pointer to the allocated
370 >lwres_context_freemem()</TT
379 bytes of space starting at location
389 >lwres_context_sendrecv()</TT
391 performs I/O for the context
399 Data are read and written from the context's socket.
407 — typically a lightweight resolver query packet —
408 and waits for a reply which is copied to the receive buffer at
416 The number of bytes that were written to this receive buffer is
435 >lwres_context_create()</TT
440 >LWRES_R_NOMEMORY</SPAN
445 >struct lwres_context</SPAN
447 could not be allocated,
450 >LWRES_R_SUCCESS</SPAN
454 >Successful calls to the memory allocator
457 >lwres_context_allocmem()</TT
459 return a pointer to the start of the allocated space.
460 It returns NULL if memory could not be allocated.</P
464 >LWRES_R_SUCCESS</SPAN
469 >lwres_context_sendrecv()</TT
471 completes successfully.
474 >LWRES_R_IOERROR</SPAN
476 is returned if an I/O error occurs and
479 >LWRES_R_TIMEOUT</SPAN
484 >lwres_context_sendrecv()</TT
486 times out waiting for a response.</P
499 CLASS="REFENTRYTITLE"
500 >lwres_conf_init</SPAN
507 CLASS="REFENTRYTITLE"
515 CLASS="REFENTRYTITLE"