1N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 1N/A - Permission to use, copy, modify, and distribute this software for any 1N/A - purpose with or without fee is hereby granted, provided that the above 1N/A - copyright notice and this permission notice appear in all copies. 1N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 1N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 1N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 1N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 1N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 1N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 1N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 1N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1N/A>lwres_context</
TITLE 1N/ACONTENT="Modular DocBook HTML Stylesheet Version 1.73 1N/A>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 1N/ACLASS="REFSYNOPSISDIV" 1N/ACLASS="FUNCSYNOPSISINFO" 1N/Alwres_context_create</
CODE 1N/A>(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, lwres_free_t free_function);</
CODE 1N/Alwres_context_destroy</
CODE 1N/A>(lwres_context_t **contextp);</
CODE 1N/Alwres_context_initserial</
CODE 1N/A>(lwres_context_t *ctx, lwres_uint32_t serial);</
CODE 1N/Alwres_context_nextserial</
CODE 1N/A>(lwres_context_t *ctx);</
CODE 1N/Alwres_context_freemem</
CODE 1N/A>(lwres_context_t *ctx, void *mem, size_t len);</
CODE 1N/Alwres_context_allocmem</
CODE 1N/A>(lwres_context_t *ctx, size_t len);</
CODE 1N/Alwres_context_sendrecv</
CODE 1N/A>(lwres_context_t *ctx, void *sendbase, int sendlen, void *recvbase, int recvlen, int *recvd_len);</
CODE 1N/A>lwres_context_create()</
TT 1N/A>lwres_context_t</
SPAN 1N/Astructure for use in lightweight resolver operations.
1N/AIt holds a socket and other data needed for communicating
1N/Awith a resolver daemon.
1N/A>lwres_context_t</
SPAN 1N/A>lwres_context_t</
SPAN 1N/A>lwres_context_t</
SPAN 1N/Apointer must initially be NULL, and is modified
1N/Ato point to the newly created
1N/A>lwres_context_t</
SPAN 1N/A>When the lightweight resolver needs to perform dynamic memory
1N/Aallocation, it will call
1N/Ato allocate memory and
1N/Aare NULL, memory is allocated using
1N/ACLASS="REFENTRYTITLE" 1N/AIt is not permitted to have a NULL
1N/Ais passed as the first parameter to the memory
1N/Aallocation functions.
1N/Ais unused and should be passed as NULL.</
P 1N/A>Once memory for the structure has been allocated,
1N/Ait is initialized using
1N/ACLASS="REFENTRYTITLE" 1N/A>lwres_conf_init</
SPAN 1N/A>lwres_context_destroy()</
TT 1N/A>lwres_context_t</
SPAN 1N/Ais a pointer to a pointer to the context that is to be destroyed.
1N/AThe pointer will be set to NULL when the context has been destroyed.</
P 1N/A>The context holds a serial number that is used to identify resolver
1N/Arequest packets and associate responses with the corresponding requests.
1N/AThis serial number is controlled using
1N/A>lwres_context_initserial()</
TT 1N/A>lwres_context_nextserial()</
TT 1N/A>lwres_context_initserial()</
TT 1N/Asets the serial number for context
1N/A>lwres_context_nextserial()</
TT 1N/Aincrements the serial number and returns the previous value.</
P 1N/A>Memory for a lightweight resolver context is allocated and freed using
1N/A>lwres_context_allocmem()</
TT 1N/A>lwres_context_freemem()</
TT 1N/AThese use whatever allocations were defined when the context was
1N/A>lwres_context_create()</
TT 1N/A>lwres_context_allocmem()</
TT 1N/Abytes of memory and if successful returns a pointer to the allocated
1N/A>lwres_context_freemem()</
TT 1N/Abytes of space starting at location
1N/A>lwres_context_sendrecv()</
TT 1N/Aperforms I/O for the context
1N/AData are read and written from the context's socket.
1N/A— typically a lightweight resolver query packet —
1N/Aand waits for a reply which is copied to the receive buffer at
1N/AThe number of bytes that were written to this receive buffer is
1N/A>lwres_context_create()</
TT 1N/A>LWRES_R_NOMEMORY</
SPAN 1N/A>struct lwres_context</
SPAN 1N/Acould not be allocated,
1N/A>LWRES_R_SUCCESS</
SPAN 1N/A>Successful calls to the memory allocator
1N/A>lwres_context_allocmem()</
TT return a pointer to the start of the allocated space.
It returns NULL if memory could not be allocated.</
P>lwres_context_sendrecv()</
TTis returned if an I/O error occurs and
>lwres_context_sendrecv()</
TTtimes out waiting for a response.</
P