1 .\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
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.
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.
16 .\" $Id: lwres.3,v 1.17.18.11 2007/01/30 00:23:44 marka Exp $
22 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
23 .\" Date: Jun 30, 2000
27 .TH "LWRES" "3" "Jun 30, 2000" "BIND9" "BIND9"
28 .\" disable hyphenation
30 .\" disable justification (adjust text to left margin only)
33 lwres \- introduction to the lightweight resolver library
36 #include <lwres/lwres.h>
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
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.
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,
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
56 which contains macro definitions mapping the standard function names into
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.
60 The library also provides a native API consisting of the functions
61 \fBlwres_getaddrsbyname()\fR
63 \fBlwres_getnamebyaddr()\fR. These may be called by applications that require more detailed control over the lookup process than the standard functions provide.
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
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
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"
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.
76 (1) Allocate or use an existing
77 \fBlwres_packet_t\fR, called
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
85 \fBLWRES_RECVLENGTH = 4096\fR.
89 to a unique serial number. This value is echoed back to the application by the remote server.
92 pkt.pktflags. Usually this is set to 0.
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.
103 (7) Transmit the resulting buffer.
106 \fBlwres_*response_parse()\fR
107 to parse any packets received.
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"
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.
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.
122 (1) When a packet is received, call
123 \fBlwres_*request_parse()\fR
124 to unmarshall it. This returns a
127 \fIpkt\fR, below) as well as a data specific type, such as
128 \fBlwres_gabnrequest_t\fR.
130 (2) Process the request in the data specific type.
135 as above. All other fields can be left untouched since they were filled in by the
138 \fBlwres_*response_render()\fR,
140 will be set up properly. Otherwise, the
141 \fBLWRES_LWPACKETFLAG_RESPONSE\fR
144 (4) Call the data specific rendering function, such as
145 \fBlwres_gabnresponse_render()\fR.
147 (5) Send the resulting packet to the client.
151 \fBlwres_gethostent\fR(3),
152 \fBlwres_getipnode\fR(3),
153 \fBlwres_getnameinfo\fR(3),
157 \fBlwres_context\fR(3),
158 \fBlwres_config\fR(3),
162 Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
164 Copyright \(co 2000, 2001 Internet Software Consortium.