1 .\" $NetBSD: lwres_context.3,v 1.5 2014/12/10 04:38:02 christos Exp $
3 .\" Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
4 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
6 .\" Permission to use, copy, modify, and/or distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 .\" PERFORMANCE OF THIS SOFTWARE.
22 .\" Title: lwres_context
24 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
25 .\" Date: June 18, 2007
29 .TH "LWRES_CONTEXT" "3" "June 18, 2007" "BIND9" "BIND9"
30 .\" disable hyphenation
32 .\" disable justification (adjust text to left margin only)
35 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
38 #include <lwres/lwres.h>
41 .BI "lwres_result_t lwres_context_create(lwres_context_t\ **" "contextp" ", void\ *" "arg" ", lwres_malloc_t\ " "malloc_function" ", lwres_free_t\ " "free_function" ");"
43 .BI "lwres_result_t lwres_context_destroy(lwres_context_t\ **" "contextp" ");"
45 .BI "void lwres_context_initserial(lwres_context_t\ *" "ctx" ", lwres_uint32_t\ " "serial" ");"
47 .BI "lwres_uint32_t lwres_context_nextserial(lwres_context_t\ *" "ctx" ");"
49 .BI "void lwres_context_freemem(lwres_context_t\ *" "ctx" ", void\ *" "mem" ", size_t\ " "len" ");"
51 .BI "void lwres_context_allocmem(lwres_context_t\ *" "ctx" ", size_t\ " "len" ");"
53 .BI "void * lwres_context_sendrecv(lwres_context_t\ *" "ctx" ", void\ *" "sendbase" ", int\ " "sendlen" ", void\ *" "recvbase" ", int\ " "recvlen" ", int\ *" "recvd_len" ");"
56 \fBlwres_context_create()\fR
59 structure for use in lightweight resolver operations. It holds a socket and other data needed for communicating with a resolver daemon. The new
62 \fIcontextp\fR, a pointer to a
66 pointer must initially be NULL, and is modified to point to the newly created
67 \fBlwres_context_t\fR.
69 When the lightweight resolver needs to perform dynamic memory allocation, it will call
71 to allocate memory and
77 are NULL, memory is allocated using
79 \fBfree\fR(3). It is not permitted to have a NULL
85 is passed as the first parameter to the memory allocation functions. If
91 is unused and should be passed as NULL.
93 Once memory for the structure has been allocated, it is initialized using
94 \fBlwres_conf_init\fR(3)
98 \fBlwres_context_destroy()\fR
100 \fBlwres_context_t\fR, closing its socket.
102 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.
104 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
105 \fBlwres_context_initserial()\fR
107 \fBlwres_context_nextserial()\fR.
108 \fBlwres_context_initserial()\fR
109 sets the serial number for context
113 \fBlwres_context_nextserial()\fR
114 increments the serial number and returns the previous value.
116 Memory for a lightweight resolver context is allocated and freed using
117 \fBlwres_context_allocmem()\fR
119 \fBlwres_context_freemem()\fR. These use whatever allocations were defined when the context was created with
120 \fBlwres_context_create()\fR.
121 \fBlwres_context_allocmem()\fR
124 bytes of memory and if successful returns a pointer to the allocated storage.
125 \fBlwres_context_freemem()\fR
128 bytes of space starting at location
131 \fBlwres_context_sendrecv()\fR
132 performs I/O for the context
133 \fIctx\fR. Data are read and written from the context's socket. It writes data from
135 \(em typically a lightweight resolver query packet \(em and waits for a reply which is copied to the receive buffer at
136 \fIrecvbase\fR. The number of bytes that were written to this receive buffer is returned in
140 \fBlwres_context_create()\fR
142 \fBLWRES_R_NOMEMORY\fR
144 \fBstruct lwres_context\fR
145 could not be allocated,
146 \fBLWRES_R_SUCCESS\fR
149 Successful calls to the memory allocator
150 \fBlwres_context_allocmem()\fR
151 return a pointer to the start of the allocated space. It returns NULL if memory could not be allocated.
153 \fBLWRES_R_SUCCESS\fR
155 \fBlwres_context_sendrecv()\fR
156 completes successfully.
157 \fBLWRES_R_IOERROR\fR
158 is returned if an I/O error occurs and
159 \fBLWRES_R_TIMEOUT\fR
161 \fBlwres_context_sendrecv()\fR
162 times out waiting for a response.
165 \fBlwres_conf_init\fR(3),
169 Copyright \(co 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
171 Copyright \(co 2000, 2001, 2003 Internet Software Consortium.