Manual Reference Pages - LWRES (3)
lwres - introduction to the lightweight resolver library
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
running on the local host. The resolver 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.
The lwresd library implements multiple name service APIs. The standard
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
lwres_. To define the standard names, applications must include the header file
which contains macro definitions mapping the standard function names into
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.
The library also provides a native API consisting of the functions
lwres_getnamebyaddr(). These may be called by applications that require more detailed control over the lookup process than the standard functions provide.
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
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
resolver daemon. The use of this low-level API in clients and 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 the native low-level API, it typically performs the following sequence of actions.
(1) Allocate or use an existing
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
LWRES_RECVLENGTH = 4096.
to a unique serial number. This value is echoed back to the application by the remote server.
pkt.pktflags. Usually this is set to 0.
lwres_*request_render(), or marshall in the data using the primitives such as
and storing the packet data.
(7) Transmit the resulting buffer.
to parse any packets received.
(9) Verify that the opcode and serial match a request, and process the packet specific information contained in the body.
SERVER-SIDE LOW-LEVEL API CALL FLOW
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.
Note that the same
is used in both the
calls, with only a few modifications made to the packet headers contents between uses. This method is recommended as it keeps the serial, opcode, and other fields correct.
(1) When a packet is received, call
to unmarshall it. This returns a
pkt, below) as well as a data specific type, such as
(2) Process the request in the data specific type.
(3) Set the
as above. All other fields can be left untouched since they were filled in by the
call above. If using
will be set up properly. Otherwise, the
bit should be set.
(4) Call the data specific rendering function, such as
(5) Send the resulting packet to the client.
Copyright © 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
Copyright © 2000, 2001 Internet Software Consortium.
|BIND9 ||LWRES (3) ||June 18, 2007 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.