lwres.html revision 02004b6ff1357b0b97147058d54b58e9f29d8452
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - Copyright (C) 2000, 2001 Internet Software Consortium.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - Permission to use, copy, modify, and distribute this software for any
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - purpose with or without fee is hereby granted, provided that the above
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - copyright notice and this permission notice appear in all copies.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync - PERFORMANCE OF THIS SOFTWARE.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<!-- $Id: lwres.html,v 1.14 2005/07/18 02:57:53 marka Exp $ -->
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<a name="id2456972"></a><div class="titlepage"></div>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<p>lwres — introduction to the lightweight resolver library</p>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <lwres/lwres.h></pre></div>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync The BIND 9 lightweight resolver library is a simple, name service
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync independent stub resolver library. It provides hostname-to-address
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync and address-to-hostname lookup services to applications by
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync transmitting lookup requests to a resolver daemon
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <span><strong class="command">lwresd</strong></span>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync running on the local host. The resover daemon performs the
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync lookup using the DNS or possibly other name service protocols,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync and returns the results to the application through the library.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync The library and resolver daemon communicate using a simple
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync UDP-based protocol.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync The lwresd library implements multiple name service APIs.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync The standard
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync functions are all supported. To allow the lwres library to coexist
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync with system libraries that define functions of the same name,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync the library defines these functions with names prefixed by
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync To define the standard names, applications must include the
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync header file
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <code class="filename"><lwres/netdb.h></code>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync which contains macro definitions mapping the standard function names
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync prefixed ones. Operating system vendors who integrate the lwres
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync library into their base distributions should rename the functions
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync in the library proper so that the renaming macros are not needed.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync The library also provides a native API consisting of the functions
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <code class="function">lwres_getaddrsbyname()</code>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <code class="function">lwres_getnamebyaddr()</code>.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync These may be called by applications that require more detailed
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync control over the lookup process than the standard functions
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync In addition to these name service independent address lookup
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync functions, the library implements a new, experimental API
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync for looking up arbitrary DNS resource records, using the
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <code class="function">lwres_getaddrsbyname()</code>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync Finally, there is a low-level API for converting lookup
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync requests and responses to and from raw lwres protocol packets.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync This API can be used by clients requiring nonblocking operation,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync and is also used when implementing the server side of the lwres
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync protocol, for example in the
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync <span><strong class="command">lwresd</strong></span>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync resolver daemon. The use of this low-level API in clients
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync and servers is outlined in the following sections.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync<a name="id2514660"></a><h2>CLIENT-SIDE LOW-LEVEL API CALL FLOW</h2>
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync When a client program wishes to make an lwres request using the
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync native low-level API, it typically performs the following
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync sequence of actions.
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync (1) Allocate or use an existing <span class="type">lwres_packet_t</span>,
03532efdc331b598d3dedc8cc7477641c3b0dd12vboxsync (2) Set <em class="structfield"><code>pkt.recvlength</code></em> to the maximum length
in both the <code class="function">_parse()</code> and <code class="function">_render()</code> calls,