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