]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/lib/lwres/man/lwres_context.3
This commit was generated by cvs2svn to compensate for changes in r164219,
[FreeBSD/FreeBSD.git] / contrib / bind9 / lib / lwres / man / lwres_context.3
1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
3 .\" 
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.
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.13.2.2.2.6 2005/10/13 02:33:52 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\" ** You probably do not want to edit this file directly **
21 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
22 .\" Instead of manually editing it, you probably should edit the DocBook XML
23 .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
24 .TH "LWRES_CONTEXT" "3" "Jun 30, 2000" "BIND9" "BIND9"
25 .\" disable hyphenation
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .SH "NAME"
30 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
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/lwres.h>
34 .fi
35 .HP 36
36 \fBlwres_result_t\ \fBlwres_context_create\fR\fR\fB(\fR\fBlwres_context_t\ **contextp\fR\fB, \fR\fBvoid\ *arg\fR\fB, \fR\fBlwres_malloc_t\ malloc_function\fR\fB, \fR\fBlwres_free_t\ free_function\fR\fB);\fR
37 .HP 37
38 \fBlwres_result_t\ \fBlwres_context_destroy\fR\fR\fB(\fR\fBlwres_context_t\ **contextp\fR\fB);\fR
39 .HP 30
40 \fBvoid\ \fBlwres_context_initserial\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBlwres_uint32_t\ serial\fR\fB);\fR
41 .HP 40
42 \fBlwres_uint32_t\ \fBlwres_context_nextserial\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB);\fR
43 .HP 27
44 \fBvoid\ \fBlwres_context_freemem\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBvoid\ *mem\fR\fB, \fR\fBsize_t\ len\fR\fB);\fR
45 .HP 28
46 \fBvoid\ \fBlwres_context_allocmem\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBsize_t\ len\fR\fB);\fR
47 .HP 30
48 \fBvoid\ *\ \fBlwres_context_sendrecv\fR\fR\fB(\fR\fBlwres_context_t\ *ctx\fR\fB, \fR\fBvoid\ *sendbase\fR\fB, \fR\fBint\ sendlen\fR\fB, \fR\fBvoid\ *recvbase\fR\fB, \fR\fBint\ recvlen\fR\fB, \fR\fBint\ *recvd_len\fR\fB);\fR
49 .SH "DESCRIPTION"
50 .PP
51 \fBlwres_context_create()\fR
52 creates a
53 \fBlwres_context_t\fR
54 structure for use in lightweight resolver operations. It holds a socket and other data needed for communicating with a resolver daemon. The new
55 \fBlwres_context_t\fR
56 is returned through
57 \fIcontextp\fR, a pointer to a
58 \fBlwres_context_t\fR
59 pointer. This
60 \fBlwres_context_t\fR
61 pointer must initially be NULL, and is modified to point to the newly created
62 \fBlwres_context_t\fR.
63 .PP
64 When the lightweight resolver needs to perform dynamic memory allocation, it will call
65 \fImalloc_function\fR
66 to allocate memory and
67 \fIfree_function\fR
68 to free it. If
69 \fImalloc_function\fR
70 and
71 \fIfree_function\fR
72 are NULL, memory is allocated using .Xr malloc 3 and
73 \fBfree\fR(3). It is not permitted to have a NULL
74 \fImalloc_function\fR
75 and a non\-NULL
76 \fIfree_function\fR
77 or vice versa.
78 \fIarg\fR
79 is passed as the first parameter to the memory allocation functions. If
80 \fImalloc_function\fR
81 and
82 \fIfree_function\fR
83 are NULL,
84 \fIarg\fR
85 is unused and should be passed as NULL.
86 .PP
87 Once memory for the structure has been allocated, it is initialized using
88 \fBlwres_conf_init\fR(3)
89 and returned via
90 \fI*contextp\fR.
91 .PP
92 \fBlwres_context_destroy()\fR
93 destroys a
94 \fBlwres_context_t\fR, closing its socket.
95 \fIcontextp\fR
96 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.
97 .PP
98 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
99 \fBlwres_context_initserial()\fR
100 and
101 \fBlwres_context_nextserial()\fR.
102 \fBlwres_context_initserial()\fR
103 sets the serial number for context
104 \fI*ctx\fR
105 to
106 \fIserial\fR.
107 \fBlwres_context_nextserial()\fR
108 increments the serial number and returns the previous value.
109 .PP
110 Memory for a lightweight resolver context is allocated and freed using
111 \fBlwres_context_allocmem()\fR
112 and
113 \fBlwres_context_freemem()\fR. These use whatever allocations were defined when the context was created with
114 \fBlwres_context_create()\fR.
115 \fBlwres_context_allocmem()\fR
116 allocates
117 \fIlen\fR
118 bytes of memory and if successful returns a pointer to the allocated storage.
119 \fBlwres_context_freemem()\fR
120 frees
121 \fIlen\fR
122 bytes of space starting at location
123 \fImem\fR.
124 .PP
125 \fBlwres_context_sendrecv()\fR
126 performs I/O for the context
127 \fIctx\fR. Data are read and written from the context's socket. It writes data from
128 \fIsendbase\fR
129 \(em typically a lightweight resolver query packet \(em and waits for a reply which is copied to the receive buffer at
130 \fIrecvbase\fR. The number of bytes that were written to this receive buffer is returned in
131 \fI*recvd_len\fR.
132 .SH "RETURN VALUES"
133 .PP
134 \fBlwres_context_create()\fR
135 returns
136 \fBLWRES_R_NOMEMORY\fR
137 if memory for the
138 \fBstruct lwres_context\fR
139 could not be allocated,
140 \fBLWRES_R_SUCCESS\fR
141 otherwise.
142 .PP
143 Successful calls to the memory allocator
144 \fBlwres_context_allocmem()\fR
145 return a pointer to the start of the allocated space. It returns NULL if memory could not be allocated.
146 .PP
147 \fBLWRES_R_SUCCESS\fR
148 is returned when
149 \fBlwres_context_sendrecv()\fR
150 completes successfully.
151 \fBLWRES_R_IOERROR\fR
152 is returned if an I/O error occurs and
153 \fBLWRES_R_TIMEOUT\fR
154 is returned if
155 \fBlwres_context_sendrecv()\fR
156 times out waiting for a response.
157 .SH "SEE ALSO"
158 .PP
159 \fBlwres_conf_init\fR(3),
160 \fBmalloc\fR(3),
161 \fBfree\fR(3 ).