Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres.3
1 .\" Copyright (C) 2004, 2005 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.3,v 1.15.206.6 2006/06/29 13:02:31 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\"     Title: lwres
21 .\"    Author: 
22 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
23 .\"      Date: Jun 30, 2000
24 .\"    Manual: BIND9
25 .\"    Source: BIND9
26 .\"
27 .TH "LWRES" "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 \- introduction to the lightweight resolver library
34 .SH "SYNOPSIS"
35 .nf
36 #include <lwres/lwres.h>
37 .fi
38 .SH "DESCRIPTION"
39 .PP
40 The BIND 9 lightweight resolver library is a simple, name service independent stub resolver library. It provides hostname\-to\-address and address\-to\-hostname lookup services to applications by transmitting lookup requests to a resolver daemon
41 \fBlwresd\fR
42 running on the local host. The resover daemon performs the lookup using the DNS or possibly other name service protocols, and returns the results to the application through the library. The library and resolver daemon communicate using a simple UDP\-based protocol.
43 .SH "OVERVIEW"
44 .PP
45 The lwresd library implements multiple name service APIs. The standard
46 \fBgethostbyname()\fR,
47 \fBgethostbyaddr()\fR,
48 \fBgethostbyname_r()\fR,
49 \fBgethostbyaddr_r()\fR,
50 \fBgetaddrinfo()\fR,
51 \fBgetipnodebyname()\fR, and
52 \fBgetipnodebyaddr()\fR
53 functions are all supported. To allow the lwres library to coexist with system libraries that define functions of the same name, the library defines these functions with names prefixed by
54 lwres_. To define the standard names, applications must include the header file
55 \fI<lwres/netdb.h>\fR
56 which contains macro definitions mapping the standard function names into
57 lwres_
58 prefixed ones. Operating system vendors who integrate the lwres library into their base distributions should rename the functions in the library proper so that the renaming macros are not needed.
59 .PP
60 The library also provides a native API consisting of the functions
61 \fBlwres_getaddrsbyname()\fR
62 and
63 \fBlwres_getnamebyaddr()\fR. These may be called by applications that require more detailed control over the lookup process than the standard functions provide.
64 .PP
65 In addition to these name service independent address lookup functions, the library implements a new, experimental API for looking up arbitrary DNS resource records, using the
66 \fBlwres_getaddrsbyname()\fR
67 function.
68 .PP
69 Finally, there is a low\-level API for converting lookup requests and responses to and from raw lwres protocol packets. This API can be used by clients requiring nonblocking operation, and is also used when implementing the server side of the lwres protocol, for example in the
70 \fBlwresd\fR
71 resolver daemon. The use of this low\-level API in clients and servers is outlined in the following sections.
72 .SH "CLIENT\-SIDE LOW\-LEVEL API CALL FLOW"
73 .PP
74 When a client program wishes to make an lwres request using the native low\-level API, it typically performs the following sequence of actions.
75 .PP
76 (1) Allocate or use an existing
77 \fBlwres_packet_t\fR, called
78 \fIpkt\fR
79 below.
80 .PP
81 (2) Set
82 pkt.recvlength
83 to the maximum length we will accept. This is done so the receiver of our packets knows how large our receive buffer is. The "default" is a constant in
84 \fIlwres.h\fR:
85 \fBLWRES_RECVLENGTH = 4096\fR.
86 .PP
87 (3) Set
88 pkt.serial
89 to a unique serial number. This value is echoed back to the application by the remote server.
90 .PP
91 (4) Set
92 pkt.pktflags. Usually this is set to 0.
93 .PP
94 (5) Set
95 pkt.result
96 to 0.
97 .PP
98 (6) Call
99 \fBlwres_*request_render()\fR, or marshall in the data using the primitives such as
100 \fBlwres_packet_render()\fR
101 and storing the packet data.
102 .PP
103 (7) Transmit the resulting buffer.
104 .PP
105 (8) Call
106 \fBlwres_*response_parse()\fR
107 to parse any packets received.
108 .PP
109 (9) Verify that the opcode and serial match a request, and process the packet specific information contained in the body.
110 .SH "SERVER\-SIDE LOW\-LEVEL API CALL FLOW"
111 .PP
112 When implementing the server side of the lightweight resolver protocol using the lwres library, a sequence of actions like the following is typically involved in processing each request packet.
113 .PP
114 Note that the same
115 \fBlwres_packet_t\fR
116 is used in both the
117 \fB_parse()\fR
118 and
119 \fB_render()\fR
120 calls, with only a few modifications made to the packet header's contents between uses. This method is recommended as it keeps the serial, opcode, and other fields correct.
121 .PP
122 (1) When a packet is received, call
123 \fBlwres_*request_parse()\fR
124 to unmarshall it. This returns a
125 \fBlwres_packet_t\fR
126 (also called
127 \fIpkt\fR, below) as well as a data specific type, such as
128 \fBlwres_gabnrequest_t\fR.
129 .PP
130 (2) Process the request in the data specific type.
131 .PP
132 (3) Set the
133 pkt.result,
134 pkt.recvlength
135 as above. All other fields can be left untouched since they were filled in by the
136 \fB*_parse()\fR
137 call above. If using
138 \fBlwres_*response_render()\fR,
139 pkt.pktflags
140 will be set up properly. Otherwise, the
141 \fBLWRES_LWPACKETFLAG_RESPONSE\fR
142 bit should be set.
143 .PP
144 (4) Call the data specific rendering function, such as
145 \fBlwres_gabnresponse_render()\fR.
146 .PP
147 (5) Send the resulting packet to the client.
148 .PP
149 .SH "SEE ALSO"
150 .PP
151 \fBlwres_gethostent\fR(3),
152 \fBlwres_getipnode\fR(3),
153 \fBlwres_getnameinfo\fR(3),
154 \fBlwres_noop\fR(3),
155 \fBlwres_gabn\fR(3),
156 \fBlwres_gnba\fR(3),
157 \fBlwres_context\fR(3),
158 \fBlwres_config\fR(3),
159 \fBresolver\fR(5),
160 \fBlwresd\fR(8).
161 .SH "COPYRIGHT"
162 Copyright \(co 2004, 2005 Internet Systems Consortium, Inc. ("ISC")