SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from Trustix bind-light-devel-9.2.2-9tr.i586.rpm

LWRES

Section: (3)
Updated: Jun 30, 2000
Index 

NAME

lwres - introduction to the lightweight resolver library 

SYNOPSIS

#include <lwres/lwres.h> 

DESCRIPTION

The BIND 9 lightweight resolver library is a simple, name serviceindependent stub resolver library. It provides hostname-to-addressand address-to-hostname lookup services to applications bytransmitting lookup requests to a resolver daemonlwresdrunning on the local host. The resover daemon performs thelookup 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 simpleUDP-based protocol. 

OVERVIEW

The lwresd library implements multiple name service APIs.The standardgethostbyname(),gethostbyaddr(),gethostbyname_r(),gethostbyaddr_r(),getaddrinfo(),getipnodebyname(),andgetipnodebyaddr()functions are all supported. To allow the lwres library to coexistwith system libraries that define functions of the same name,the library defines these functions with names prefixed bylwres_.To define the standard names, applications must include theheader file<lwres/netdb.h>which contains macro definitions mapping the standard function namesintolwres_prefixed ones. Operating system vendors who integrate the lwreslibrary into their base distributions should rename the functionsin the library proper so that the renaming macros are not needed.

The library also provides a native API consisting of the functionslwres_getaddrsbyname()andlwres_getnamebyaddr().These may be called by applications that require more detailedcontrol over the lookup process than the standard functionsprovide.

In addition to these name service independent address lookupfunctions, the library implements a new, experimental APIfor looking up arbitrary DNS resource records, using thelwres_getaddrsbyname()function.

Finally, there is a low-level API for converting lookuprequests 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 lwresprotocol, for example in thelwresdresolver daemon. The use of this low-level API in clientsand servers is outlined in the following sections. 

CLIENT-SIDE LOW-LEVEL API CALL FLOW

When a client program wishes to make an lwres request using thenative low-level API, it typically performs the following sequence of actions.

(1) Allocate or use an existing lwres_packet_t,called pkt below.

(2) Set pkt.recvlength 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 inlwres.h: LWRES_RECVLENGTH = 4096.

(3) Set pkt.serialto a unique serial number. This value is echoedback to the application by the remote server.

(4) Set pkt.pktflags. Usually this is set to 0.

(5) Set pkt.result to 0.

(6) Call lwres_*request_render(), or marshall in the data using the primitivessuch as lwres_packet_render()and storing the packet data.

(7) Transmit the resulting buffer.

(8) Call lwres_*response_parse()to parse any packets received.

(9) Verify that the opcode and serial match a request, and process thepacket specific information contained in the body. 

SERVER-SIDE LOW-LEVEL API CALL FLOW

When implementing the server side of the lightweight resolverprotocol using the lwres library, a sequence of actions like thefollowing is typically involved in processing each request packet.

Note that the same lwres_packet_t is usedin both the _parse() and _render() calls,with only a few modifications madeto the packet header's contents between uses. This method is recommendedas it keeps the serial, opcode, and other fields correct.

(1) When a packet is received, call lwres_*request_parse() tounmarshall it. This returns a lwres_packet_t (also called pkt, below)as well as a data specific type, such as lwres_gabnrequest_t.

(2) Process the request in the data specific type.

(3) Set the pkt.result,pkt.recvlength as above. All other fields canbe left untouched since they were filled in by the *_parse() callabove. If using lwres_*response_render(),pkt.pktflags will be set upproperly. Otherwise, the LWRES_LWPACKETFLAG_RESPONSE bit should beset.

(4) Call the data specific rendering function, such aslwres_gabnresponse_render().

(5) Send the resulting packet to the client.

 

SEE ALSO

lwres_gethostent(3),lwres_getipnode(3),lwres_getnameinfo(3),lwres_noop(3),lwres_gabn(3),lwres_gnba(3),lwres_context(3),lwres_config(3),resolver(5),lwresd(8).


 

Index

NAME
SYNOPSIS
DESCRIPTION
OVERVIEW
CLIENT-SIDE LOW-LEVEL API CALL FLOW
SERVER-SIDE LOW-LEVEL API CALL FLOW
SEE ALSO

This document was created byman2html,using the manual pages.