BIND - Update BIND to 9.5.2
[dragonfly.git] / contrib / bind-9.5.2 / lib / lwres / man / lwres_context.3
1 .\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
3 .\" 
4 .\" Permission to use, copy, modify, and/or 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.
7 .\" 
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.
15 .\"
16 .\" $Id: lwres_context.3,v 1.28.214.1 2009/07/11 01:43:32 tbox Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\"     Title: lwres_context
21 .\"    Author: 
22 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
23 .\"      Date: Jun 30, 2000
24 .\"    Manual: BIND9
25 .\"    Source: BIND9
26 .\"
27 .TH "LWRES_CONTEXT" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
29 .nh
30 .\" disable justification (adjust text to left margin only)
31 .ad l
32 .SH "NAME"
33 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
34 .SH "SYNOPSIS"
35 .nf
36 #include <lwres/lwres.h>
37 .fi
38 .HP 36
39 .BI "lwres_result_t lwres_context_create(lwres_context_t\ **" "contextp" ", void\ *" "arg" ", lwres_malloc_t\ " "malloc_function" ", lwres_free_t\ " "free_function" ");"
40 .HP 37
41 .BI "lwres_result_t lwres_context_destroy(lwres_context_t\ **" "contextp" ");"
42 .HP 30
43 .BI "void lwres_context_initserial(lwres_context_t\ *" "ctx" ", lwres_uint32_t\ " "serial" ");"
44 .HP 40
45 .BI "lwres_uint32_t lwres_context_nextserial(lwres_context_t\ *" "ctx" ");"
46 .HP 27
47 .BI "void lwres_context_freemem(lwres_context_t\ *" "ctx" ", void\ *" "mem" ", size_t\ " "len" ");"
48 .HP 28
49 .BI "void lwres_context_allocmem(lwres_context_t\ *" "ctx" ", size_t\ " "len" ");"
50 .HP 30
51 .BI "void * lwres_context_sendrecv(lwres_context_t\ *" "ctx" ", void\ *" "sendbase" ", int\ " "sendlen" ", void\ *" "recvbase" ", int\ " "recvlen" ", int\ *" "recvd_len" ");"
52 .SH "DESCRIPTION"
53 .PP
54 \fBlwres_context_create()\fR
55 creates a
56 \fBlwres_context_t\fR
57 structure for use in lightweight resolver operations. It holds a socket and other data needed for communicating with a resolver daemon. The new
58 \fBlwres_context_t\fR
59 is returned through
60 \fIcontextp\fR, a pointer to a
61 \fBlwres_context_t\fR
62 pointer. This
63 \fBlwres_context_t\fR
64 pointer must initially be NULL, and is modified to point to the newly created
65 \fBlwres_context_t\fR.
66 .PP
67 When the lightweight resolver needs to perform dynamic memory allocation, it will call
68 \fImalloc_function\fR
69 to allocate memory and
70 \fIfree_function\fR
71 to free it. If
72 \fImalloc_function\fR
73 and
74 \fIfree_function\fR
75 are NULL, memory is allocated using
76 \fBmalloc\fR(3). and
77 \fBfree\fR(3). It is not permitted to have a NULL
78 \fImalloc_function\fR
79 and a non\-NULL
80 \fIfree_function\fR
81 or vice versa.
82 \fIarg\fR
83 is passed as the first parameter to the memory allocation functions. If
84 \fImalloc_function\fR
85 and
86 \fIfree_function\fR
87 are NULL,
88 \fIarg\fR
89 is unused and should be passed as NULL.
90 .PP
91 Once memory for the structure has been allocated, it is initialized using
92 \fBlwres_conf_init\fR(3)
93 and returned via
94 \fI*contextp\fR.
95 .PP
96 \fBlwres_context_destroy()\fR
97 destroys a
98 \fBlwres_context_t\fR, closing its socket.
99 \fIcontextp\fR
100 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.
101 .PP
102 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
103 \fBlwres_context_initserial()\fR
104 and
105 \fBlwres_context_nextserial()\fR.
106 \fBlwres_context_initserial()\fR
107 sets the serial number for context
108 \fI*ctx\fR
109 to
110 \fIserial\fR.
111 \fBlwres_context_nextserial()\fR
112 increments the serial number and returns the previous value.
113 .PP
114 Memory for a lightweight resolver context is allocated and freed using
115 \fBlwres_context_allocmem()\fR
116 and
117 \fBlwres_context_freemem()\fR. These use whatever allocations were defined when the context was created with
118 \fBlwres_context_create()\fR.
119 \fBlwres_context_allocmem()\fR
120 allocates
121 \fIlen\fR
122 bytes of memory and if successful returns a pointer to the allocated storage.
123 \fBlwres_context_freemem()\fR
124 frees
125 \fIlen\fR
126 bytes of space starting at location
127 \fImem\fR.
128 .PP
129 \fBlwres_context_sendrecv()\fR
130 performs I/O for the context
131 \fIctx\fR. Data are read and written from the context's socket. It writes data from
132 \fIsendbase\fR
133 \(em typically a lightweight resolver query packet \(em and waits for a reply which is copied to the receive buffer at
134 \fIrecvbase\fR. The number of bytes that were written to this receive buffer is returned in
135 \fI*recvd_len\fR.
136 .SH "RETURN VALUES"
137 .PP
138 \fBlwres_context_create()\fR
139 returns
140 \fBLWRES_R_NOMEMORY\fR
141 if memory for the
142 \fBstruct lwres_context\fR
143 could not be allocated,
144 \fBLWRES_R_SUCCESS\fR
145 otherwise.
146 .PP
147 Successful calls to the memory allocator
148 \fBlwres_context_allocmem()\fR
149 return a pointer to the start of the allocated space. It returns NULL if memory could not be allocated.
150 .PP
151 \fBLWRES_R_SUCCESS\fR
152 is returned when
153 \fBlwres_context_sendrecv()\fR
154 completes successfully.
155 \fBLWRES_R_IOERROR\fR
156 is returned if an I/O error occurs and
157 \fBLWRES_R_TIMEOUT\fR
158 is returned if
159 \fBlwres_context_sendrecv()\fR
160 times out waiting for a response.
161 .SH "SEE ALSO"
162 .PP
163 \fBlwres_conf_init\fR(3),
164 \fBmalloc\fR(3),
165 \fBfree\fR(3).
166 .SH "COPYRIGHT"
167 Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
168 .br
169 Copyright \(co 2000, 2001, 2003 Internet Software Consortium.
170 .br