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 INTERNET SOFTWARE CONSORTIUM
9 - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 CONTENT=
"Modular DocBook HTML Stylesheet Version 1.61
44 >lwres
--
introduction to the lightweight resolver library
</DIV
46 CLASS=
"REFSYNOPSISDIV"
60 CLASS=
"FUNCSYNOPSISINFO"
61 >#include
<lwres/lwres.h
></PRE
74 >The BIND
9 lightweight resolver library is a simple, name service
75 independent stub resolver library. It provides hostname-to-address
76 and address-to-hostname lookup services to applications by
77 transmitting lookup requests to a resolver daemon
82 running on the local host. The resover daemon performs the
83 lookup using the DNS or possibly other name service protocols,
84 and returns the results to the application through the library.
85 The library and resolver daemon communicate using a simple
86 UDP-based protocol.
</P
96 >The lwresd library implements multiple name service APIs.
108 >gethostbyname_r()
</TT
112 >gethostbyaddr_r()
</TT
120 >getipnodebyname()
</TT
125 >getipnodebyaddr()
</TT
127 functions are all supported. To allow the lwres library to coexist
128 with system libraries that define functions of the same name,
129 the library defines these functions with names prefixed by
134 To define the standard names, applications must include the
138 ><lwres/netdb.h
></TT
140 which contains macro definitions mapping the standard function names
146 prefixed ones. Operating system vendors who integrate the lwres
147 library into their base distributions should rename the functions
148 in the library proper so that the renaming macros are not needed.
</P
150 >The library also provides a native API consisting of the functions
153 >lwres_getaddrsbyname()
</TT
158 >lwres_getnamebyaddr()
</TT
160 These may be called by applications that require more detailed
161 control over the lookup process than the standard functions
164 >In addition to these name service independent address lookup
165 functions, the library implements a new, experimental API
166 for looking up arbitrary DNS resource records, using the
169 >lwres_getaddrsbyname()
</TT
173 >Finally, there is a low-level API for converting lookup
174 requests and responses to and from raw lwres protocol packets.
175 This API can be used by clients requiring nonblocking operation,
176 and is also used when implementing the server side of the lwres
177 protocol, for example in the
182 resolver daemon. The use of this low-level API in clients
183 and servers is outlined in the following sections.
</P
191 >CLIENT-SIDE LOW-LEVEL API CALL FLOW
</H2
193 >When a client program wishes to make an lwres request using the
194 native low-level API, it typically performs the following
195 sequence of actions.
</P
197 >(
1) Allocate or use an existing
<SPAN
199 >lwres_packet_t
</SPAN
211 > to the maximum length we will accept.
212 This is done so the receiver of our packets knows how large our receive
213 buffer is. The
"default" is a constant in
219 >LWRES_RECVLENGTH =
4096</TT
228 to a unique serial number. This value is echoed
229 back to the application by the remote server.
</P
236 >. Usually this is set to
0.
</P
247 >lwres_*request_render()
</TT
249 or marshall in the data using the primitives
252 >lwres_packet_render()
</TT
254 and storing the packet data.
</P
256 >(
7) Transmit the resulting buffer.
</P
260 >lwres_*response_parse()
</TT
262 to parse any packets received.
</P
264 >(
9) Verify that the opcode and serial match a request, and process the
265 packet specific information contained in the body.
</P
273 >SERVER-SIDE LOW-LEVEL API CALL FLOW
</H2
275 >When implementing the server side of the lightweight resolver
276 protocol using the lwres library, a sequence of actions like the
277 following is typically involved in processing each request packet.
</P
279 >Note that the same
<SPAN
281 >lwres_packet_t
</SPAN
290 with only a few modifications made
291 to the packet header's contents between uses. This method is recommended
292 as it keeps the serial, opcode, and other fields correct.
</P
294 >(
1) When a packet is received, call
<TT
296 >lwres_*request_parse()
</TT
298 unmarshall it. This returns a
<SPAN
300 >lwres_packet_t
</SPAN
305 as well as a data specific type, such as
<SPAN
307 >lwres_gabnrequest_t
</SPAN
310 >(
2) Process the request in the data specific type.
</P
323 > as above. All other fields can
324 be left untouched since they were filled in by the
<TT
330 >lwres_*response_render()
</TT
338 properly. Otherwise, the
<TT
340 >LWRES_LWPACKETFLAG_RESPONSE
</TT
344 >(
4) Call the data specific rendering function, such as
347 >lwres_gabnresponse_render()
</TT
350 >(
5) Send the resulting packet to the client.
</P
365 CLASS=
"REFENTRYTITLE"
366 >lwres_gethostent
</SPAN
373 CLASS=
"REFENTRYTITLE"
374 >lwres_getipnode
</SPAN
381 CLASS=
"REFENTRYTITLE"
382 >lwres_getnameinfo
</SPAN
389 CLASS=
"REFENTRYTITLE"
397 CLASS=
"REFENTRYTITLE"
405 CLASS=
"REFENTRYTITLE"
413 CLASS=
"REFENTRYTITLE"
421 CLASS=
"REFENTRYTITLE"
429 CLASS=
"REFENTRYTITLE"
437 CLASS=
"REFENTRYTITLE"