2 .\" Copyright (C) 2000, 2001 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 INTERNET SOFTWARE CONSORTIUM
9 .\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 .\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 .\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .TH "LWRES_CONTEXT" "3" "Jun 30, 2000" "BIND9" ""
19 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
21 \fB#include <lwres/lwres.h>
25 lwres_context_create(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, lwres_free_t free_function);
30 lwres_context_destroy(lwres_context_t **contextp);
35 lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
40 lwres_context_nextserial(lwres_context_t *ctx);
45 lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
50 lwres_context_allocmem(lwres_context_t *ctx, size_t len);
55 lwres_context_sendrecv(lwres_context_t *ctx, void *sendbase, int sendlen, void *recvbase, int recvlen, int *recvd_len);
59 \fBlwres_context_create()\fR
62 structure for use in lightweight resolver operations.
63 It holds a socket and other data needed for communicating
64 with a resolver daemon.
73 pointer must initially be NULL, and is modified
74 to point to the newly created
75 \fBlwres_context_t\fR.
77 When the lightweight resolver needs to perform dynamic memory
78 allocation, it will call
80 to allocate memory and
86 are NULL, memory is allocated using
90 It is not permitted to have a NULL
96 is passed as the first parameter to the memory
104 is unused and should be passed as NULL.
106 Once memory for the structure has been allocated,
107 it is initialized using
108 \fBlwres_conf_init\fR(3)
112 \fBlwres_context_destroy()\fR
114 \fBlwres_context_t\fR,
117 is a pointer to a pointer to the context that is to be destroyed.
118 The pointer will be set to NULL when the context has been destroyed.
120 The context holds a serial number that is used to identify resolver
121 request packets and associate responses with the corresponding requests.
122 This serial number is controlled using
123 \fBlwres_context_initserial()\fR
125 \fBlwres_context_nextserial()\fR.
126 \fBlwres_context_initserial()\fR
127 sets the serial number for context
131 \fBlwres_context_nextserial()\fR
132 increments the serial number and returns the previous value.
134 Memory for a lightweight resolver context is allocated and freed using
135 \fBlwres_context_allocmem()\fR
137 \fBlwres_context_freemem()\fR.
138 These use whatever allocations were defined when the context was
140 \fBlwres_context_create()\fR.
141 \fBlwres_context_allocmem()\fR
144 bytes of memory and if successful returns a pointer to the allocated
146 \fBlwres_context_freemem()\fR
149 bytes of space starting at location
152 \fBlwres_context_sendrecv()\fR
153 performs I/O for the context
155 Data are read and written from the context's socket.
158 \(em typically a lightweight resolver query packet \(em
159 and waits for a reply which is copied to the receive buffer at
161 The number of bytes that were written to this receive buffer is
166 \fBlwres_context_create()\fR
170 \fBstruct lwres_context\fR
171 could not be allocated,
175 Successful calls to the memory allocator
176 \fBlwres_context_allocmem()\fR
177 return a pointer to the start of the allocated space.
178 It returns NULL if memory could not be allocated.
182 \fBlwres_context_sendrecv()\fR
183 completes successfully.
185 is returned if an I/O error occurs and
188 \fBlwres_context_sendrecv()\fR
189 times out waiting for a response.
192 \fBlwres_conf_init\fR(3),