1 .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 .\" PERFORMANCE OF THIS SOFTWARE.
16 .\" $Id: lwres_context.3,v 1.13.2.3 2004/03/15 04:45:01 marka Exp $
18 .TH "LWRES_CONTEXT" "3" "Jun 30, 2000" "BIND9" ""
20 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
22 \fB#include <lwres/lwres.h>
26 lwres_context_create(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, lwres_free_t free_function);
31 lwres_context_destroy(lwres_context_t **contextp);
36 lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
41 lwres_context_nextserial(lwres_context_t *ctx);
46 lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
51 lwres_context_allocmem(lwres_context_t *ctx, size_t len);
56 lwres_context_sendrecv(lwres_context_t *ctx, void *sendbase, int sendlen, void *recvbase, int recvlen, int *recvd_len);
61 \fBlwres_context_create()\fR
64 structure for use in lightweight resolver operations.
65 It holds a socket and other data needed for communicating
66 with a resolver daemon.
75 pointer must initially be NULL, and is modified
76 to point to the newly created
77 \fBlwres_context_t\fR.
79 When the lightweight resolver needs to perform dynamic memory
80 allocation, it will call
82 to allocate memory and
88 are NULL, memory is allocated using
92 It is not permitted to have a NULL
98 is passed as the first parameter to the memory
101 \fImalloc_function\fR
106 is unused and should be passed as NULL.
108 Once memory for the structure has been allocated,
109 it is initialized using
110 \fBlwres_conf_init\fR(3)
114 \fBlwres_context_destroy()\fR
116 \fBlwres_context_t\fR,
119 is a pointer to a pointer to the context that is to be destroyed.
120 The pointer will be set to NULL when the context has been destroyed.
122 The context holds a serial number that is used to identify resolver
123 request packets and associate responses with the corresponding requests.
124 This serial number is controlled using
125 \fBlwres_context_initserial()\fR
127 \fBlwres_context_nextserial()\fR.
128 \fBlwres_context_initserial()\fR
129 sets the serial number for context
133 \fBlwres_context_nextserial()\fR
134 increments the serial number and returns the previous value.
136 Memory for a lightweight resolver context is allocated and freed using
137 \fBlwres_context_allocmem()\fR
139 \fBlwres_context_freemem()\fR.
140 These use whatever allocations were defined when the context was
142 \fBlwres_context_create()\fR.
143 \fBlwres_context_allocmem()\fR
146 bytes of memory and if successful returns a pointer to the allocated
148 \fBlwres_context_freemem()\fR
151 bytes of space starting at location
154 \fBlwres_context_sendrecv()\fR
155 performs I/O for the context
157 Data are read and written from the context's socket.
160 \(em typically a lightweight resolver query packet \(em
161 and waits for a reply which is copied to the receive buffer at
163 The number of bytes that were written to this receive buffer is
168 \fBlwres_context_create()\fR
172 \fBstruct lwres_context\fR
173 could not be allocated,
177 Successful calls to the memory allocator
178 \fBlwres_context_allocmem()\fR
179 return a pointer to the start of the allocated space.
180 It returns NULL if memory could not be allocated.
184 \fBlwres_context_sendrecv()\fR
185 completes successfully.
187 is returned if an I/O error occurs and
190 \fBlwres_context_sendrecv()\fR
191 times out waiting for a response.
194 \fBlwres_conf_init\fR(3),