Merge from vendor branch LESS:
[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.5 2005/10/13 02:33:58 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" "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 \- introduction to the lightweight resolver library
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/lwres.h>
34 .fi
35 .SH "DESCRIPTION"
36 .PP
37 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
38 \fBlwresd\fR
39 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.
40 .SH "OVERVIEW"
41 .PP
42 The lwresd library implements multiple name service APIs. The standard
43 \fBgethostbyname()\fR,
44 \fBgethostbyaddr()\fR,
45 \fBgethostbyname_r()\fR,
46 \fBgethostbyaddr_r()\fR,
47 \fBgetaddrinfo()\fR,
48 \fBgetipnodebyname()\fR, and
49 \fBgetipnodebyaddr()\fR
50 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
51 lwres_. To define the standard names, applications must include the header file
52 \fI<lwres/netdb.h>\fR
53 which contains macro definitions mapping the standard function names into
54 lwres_
55 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.
56 .PP
57 The library also provides a native API consisting of the functions
58 \fBlwres_getaddrsbyname()\fR
59 and
60 \fBlwres_getnamebyaddr()\fR. These may be called by applications that require more detailed control over the lookup process than the standard functions provide.
61 .PP
62 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
63 \fBlwres_getaddrsbyname()\fR
64 function.
65 .PP
66 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
67 \fBlwresd\fR
68 resolver daemon. The use of this low\-level API in clients and servers is outlined in the following sections.
69 .SH "CLIENT\-SIDE LOW\-LEVEL API CALL FLOW"
70 .PP
71 When a client program wishes to make an lwres request using the native low\-level API, it typically performs the following sequence of actions.
72 .PP
73 (1) Allocate or use an existing
74 \fBlwres_packet_t\fR, called
75 \fIpkt\fR
76 below.
77 .PP
78 (2) Set
79 pkt.recvlength
80 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
81 \fIlwres.h\fR:
82 \fBLWRES_RECVLENGTH = 4096\fR.
83 .PP
84 (3) Set
85 pkt.serial
86 to a unique serial number. This value is echoed back to the application by the remote server.
87 .PP
88 (4) Set
89 pkt.pktflags. Usually this is set to 0.
90 .PP
91 (5) Set
92 pkt.result
93 to 0.
94 .PP
95 (6) Call
96 \fBlwres_*request_render()\fR, or marshall in the data using the primitives such as
97 \fBlwres_packet_render()\fR
98 and storing the packet data.
99 .PP
100 (7) Transmit the resulting buffer.
101 .PP
102 (8) Call
103 \fBlwres_*response_parse()\fR
104 to parse any packets received.
105 .PP
106 (9) Verify that the opcode and serial match a request, and process the packet specific information contained in the body.
107 .SH "SERVER\-SIDE LOW\-LEVEL API CALL FLOW"
108 .PP
109 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.
110 .PP
111 Note that the same
112 \fBlwres_packet_t\fR
113 is used in both the
114 \fB_parse()\fR
115 and
116 \fB_render()\fR
117 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.
118 .PP
119 (1) When a packet is received, call
120 \fBlwres_*request_parse()\fR
121 to unmarshall it. This returns a
122 \fBlwres_packet_t\fR
123 (also called
124 \fIpkt\fR, below) as well as a data specific type, such as
125 \fBlwres_gabnrequest_t\fR.
126 .PP
127 (2) Process the request in the data specific type.
128 .PP
129 (3) Set the
130 pkt.result,
131 pkt.recvlength
132 as above. All other fields can be left untouched since they were filled in by the
133 \fB*_parse()\fR
134 call above. If using
135 \fBlwres_*response_render()\fR,
136 pkt.pktflags
137 will be set up properly. Otherwise, the
138 \fBLWRES_LWPACKETFLAG_RESPONSE\fR
139 bit should be set.
140 .PP
141 (4) Call the data specific rendering function, such as
142 \fBlwres_gabnresponse_render()\fR.
143 .PP
144 (5) Send the resulting packet to the client.
145 .PP
146 .SH "SEE ALSO"
147 .PP
148 \fBlwres_gethostent\fR(3),
149 \fBlwres_getipnode\fR(3),
150 \fBlwres_getnameinfo\fR(3),
151 \fBlwres_noop\fR(3),
152 \fBlwres_gabn\fR(3),
153 \fBlwres_gnba\fR(3),
154 \fBlwres_context\fR(3),
155 \fBlwres_config\fR(3),
156 \fBresolver\fR(5),
157 \fBlwresd\fR(8).