lwres.docbook revision 4b01d45a49f1c2cc4bddc9a1b4c78232867de134
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - Copyright (C) 2000, 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - purpose with or without fee is hereby granted, provided that the above
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - copyright notice and this permission notice appear in all copies.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<!-- $Id: lwres.docbook,v 1.1 2001/03/29 02:43:28 gson Exp $ -->
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont <refentryinfo>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</refentryinfo>
938440694b33cd752e9e4b71a526368b4811c177Tinderbox User<refpurpose>introduction to the lightweight resolver library</refpurpose>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<refsynopsisdiv>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<funcsynopsis>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</funcsynopsis>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont</refsynopsisdiv>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe BIND 9 lightweight resolver library is a simple, name service
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntindependent stub resolver library. It provides hostname-to-address
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntand address-to-hostname lookup services to applications by
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunttransmitting lookup requests to a resolver daemon
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontrunning on the local host. The resover daemon performs the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontlookup using the DNS or possibly other name service protocols,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntand returns the results to the application through the library.
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark AndrewsThe library and resolver daemon communicate using a simple
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontUDP-based protocol.
f1a2709aad7baa4161fdb6f63edf99b0150af252Evan HuntThe lwresd library implements multiple name service APIs.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontfunctions are all supported. To allow the lwres library to coexist
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontwith system libraries that define functions of the same name,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontthe library defines these functions with names prefixed by
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontTo define the standard names, applications must include the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontwhich contains macro definitions mapping the standard function names
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontprefixed ones. Operating system vendors who integrate the lwres
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontlibrary into their base distributions should rename the functions
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontin the library proper so that the renaming macros are not needed.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThe library also provides a native API consisting of the functions
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThese may be called by applications that require more detailed
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontcontrol over the lookup process than the standard functions
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontIn addition to these name service independent address lookup
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontfunctions, the library implements a new, experimental API
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontfor looking up arbitrary DNS resource records, using the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontFinally, there is a low-level API for converting lookup
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontrequests and responses to and from raw lwres protocol packets.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThis API can be used by clients requiring nonblocking operation,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontand is also used when implementing the server side of the lwres
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontprotocol, for example in the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontresolver daemon. The use of this low-level API in clients
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontand servers is outlined in the following sections.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont<title>CLIENT-SIDE LOW-LEVEL API CALL FLOW</title>
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontWhen a client program wishes to make an lwres request using the
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontnative low-level API, it typically performs the following
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontsequence of actions.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont(1) Allocate or use an existing <type>lwres_packet_t</type>,
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont(2) Set <structfield>pkt.recvlength</structfield> to the maximum length we will accept.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis DupontThis is done so the receiver of our packets knows how large our receive
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontbuffer is. The "default" is a constant in
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<filename>lwres.h</filename>: <constant>LWRES_RECVLENGTH = 4096</constant>.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontto a unique serial number. This value is echoed
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontback to the application by the remote server.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont(4) Set <structfield>pkt.pktflags</structfield>. Usually this is set to 0.
b0af7cbe9220775e23127f2f38750e4a281ee871Jeremy C. Reed(5) Set <structfield>pkt.result</structfield> to 0.
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupont(6) Call <function>lwres_*request_render()</function>,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntor marshall in the data using the primitives
a631b30b1ddd8b2ea780371d0d99ba1c05bc7e42Francis Dupontsuch as <function>lwres_packet_render()</function>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntand storing the packet data.