Merge from vendor branch GROFF:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / lwres / man / lwres_gabn.3
1 .\" Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001  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_gabn.3,v 1.13.2.2 2004/03/15 04:45:01 marka Exp $
17 .\"
18 .TH "LWRES_GABN" "3" "Jun 30, 2000" "BIND9" ""
19 .SH NAME
20 lwres_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free \- lightweight resolver getaddrbyname message handling
21 .SH SYNOPSIS
22 \fB#include <lwres/lwres.h>
23 .sp
24 .na
25 lwres_result_t
26 lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);
27 .ad
28 .sp
29 .na
30 lwres_result_t
31 lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);
32 .ad
33 .sp
34 .na
35 lwres_result_t
36 lwres_gabnrequest_parse(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gabnrequest_t **structp);
37 .ad
38 .sp
39 .na
40 lwres_result_t
41 lwres_gabnresponse_parse(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gabnresponse_t **structp);
42 .ad
43 .sp
44 .na
45 void
46 lwres_gabnresponse_free(lwres_context_t *ctx, lwres_gabnresponse_t **structp);
47 .ad
48 .sp
49 .na
50 void
51 lwres_gabnrequest_free(lwres_context_t *ctx, lwres_gabnrequest_t **structp);
52 .ad
53 \fR
54 .SH "DESCRIPTION"
55 .PP
56 These are low-level routines for creating and parsing
57 lightweight resolver name-to-address lookup request and 
58 response messages.
59 .PP
60 There are four main functions for the getaddrbyname opcode.
61 One render function converts a getaddrbyname request structure \(em
62 \fBlwres_gabnrequest_t\fR \(em
63 to the lighweight resolver's canonical format.
64 It is complemented by a parse function that converts a packet in this
65 canonical format to a getaddrbyname request structure.
66 Another render function converts the getaddrbyname response structure \(em
67 \fBlwres_gabnresponse_t\fR \(em
68 to the canonical format.
69 This is complemented by a parse function which converts a packet in
70 canonical format to a getaddrbyname response structure.
71 .PP
72 These structures are defined in
73 \fI<lwres/lwres.h>\fR.
74 They are shown below.
75 .sp
76 .nf
77 #define LWRES_OPCODE_GETADDRSBYNAME     0x00010001U
78
79 typedef struct lwres_addr lwres_addr_t;
80 typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
81
82 typedef struct {
83         lwres_uint32_t  flags;
84         lwres_uint32_t  addrtypes;
85         lwres_uint16_t  namelen;
86         char           *name;
87 } lwres_gabnrequest_t;
88
89 typedef struct {
90         lwres_uint32_t          flags;
91         lwres_uint16_t          naliases;
92         lwres_uint16_t          naddrs;
93         char                   *realname;
94         char                  **aliases;
95         lwres_uint16_t          realnamelen;
96         lwres_uint16_t         *aliaslen;
97         lwres_addrlist_t        addrs;
98         void                   *base;
99         size_t                  baselen;
100 } lwres_gabnresponse_t;
101 .sp
102 .fi
103 .PP
104 \fBlwres_gabnrequest_render()\fR
105 uses resolver context
106 \fIctx\fR
107 to convert getaddrbyname request structure
108 \fIreq\fR
109 to canonical format.
110 The packet header structure
111 \fIpkt\fR
112 is initialised and transferred to
113 buffer
114 \fIb\fR.
115 The contents of
116 \fI*req\fR
117 are then appended to the buffer in canonical format.
118 \fBlwres_gabnresponse_render()\fR
119 performs the same task, except it converts a getaddrbyname response structure
120 \fBlwres_gabnresponse_t\fR
121 to the lightweight resolver's canonical format.
122 .PP
123 \fBlwres_gabnrequest_parse()\fR
124 uses context
125 \fIctx\fR
126 to convert the contents of packet
127 \fIpkt\fR
128 to a
129 \fBlwres_gabnrequest_t\fR
130 structure.
131 Buffer
132 \fIb\fR
133 provides space to be used for storing this structure.
134 When the function succeeds, the resulting
135 \fBlwres_gabnrequest_t\fR
136 is made available through
137 \fI*structp\fR.
138 \fBlwres_gabnresponse_parse()\fR
139 offers the same semantics as
140 \fBlwres_gabnrequest_parse()\fR
141 except it yields a
142 \fBlwres_gabnresponse_t\fR
143 structure.
144 .PP
145 \fBlwres_gabnresponse_free()\fR
146 and
147 \fBlwres_gabnrequest_free()\fR
148 release the memory in resolver context
149 \fIctx\fR
150 that was allocated to the
151 \fBlwres_gabnresponse_t\fR
152 or
153 \fBlwres_gabnrequest_t\fR
154 structures referenced via
155 \fIstructp\fR.
156 Any memory associated with ancillary buffers and strings for those
157 structures is also discarded.
158 .SH "RETURN VALUES"
159 .PP
160 The getaddrbyname opcode functions
161 \fBlwres_gabnrequest_render()\fR, 
162 \fBlwres_gabnresponse_render()\fR
163 \fBlwres_gabnrequest_parse()\fR
164 and
165 \fBlwres_gabnresponse_parse()\fR
166 all return
167 LWRES_R_SUCCESS
168 on success.
169 They return
170 LWRES_R_NOMEMORY
171 if memory allocation fails.
172 LWRES_R_UNEXPECTEDEND
173 is returned if the available space in the buffer
174 \fIb\fR
175 is too small to accommodate the packet header or the
176 \fBlwres_gabnrequest_t\fR
177 and
178 \fBlwres_gabnresponse_t\fR
179 structures.
180 \fBlwres_gabnrequest_parse()\fR
181 and
182 \fBlwres_gabnresponse_parse()\fR
183 will return
184 LWRES_R_UNEXPECTEDEND
185 if the buffer is not empty after decoding the received packet.
186 These functions will return
187 LWRES_R_FAILURE
188 if
189 \fBpktflags\fR
190 in the packet header structure
191 \fBlwres_lwpacket_t\fR
192 indicate that the packet is not a response to an earlier query.
193 .SH "SEE ALSO"
194 .PP
195 \fBlwres_packet\fR(3)