📄 lwres.3
字号:
.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC").\" Copyright (C) 2000, 2001 Internet Software Consortium..\".\" Permission to use, copy, modify, and distribute this software for any.\" purpose with or without fee is hereby granted, provided that the above.\" copyright notice and this permission notice appear in all copies..\".\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR.\" PERFORMANCE OF THIS SOFTWARE..\".\" $Id: lwres.3,v 1.15.206.1 2004/03/06 07:41:42 marka Exp $.\".TH "LWRES" "3" "Jun 30, 2000" "BIND9" "".SH NAMElwres \- introduction to the lightweight resolver library.SH SYNOPSIS\fB#include <lwres/lwres.h>\fR.SH "DESCRIPTION".PPThe 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 daemon\fBlwresd\fRrunning 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..SH "OVERVIEW".PPThe lwresd library implements multiple name service APIs.The standard\fBgethostbyname()\fR,\fBgethostbyaddr()\fR,\fBgethostbyname_r()\fR,\fBgethostbyaddr_r()\fR,\fBgetaddrinfo()\fR,\fBgetipnodebyname()\fR,and\fBgetipnodebyaddr()\fRfunctions 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\fI<lwres/netdb.h>\fRwhich 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..PPThe library also provides a native API consisting of the functions\fBlwres_getaddrsbyname()\fRand\fBlwres_getnamebyaddr()\fR.These may be called by applications that require more detailedcontrol over the lookup process than the standard functionsprovide..PPIn addition to these name service independent address lookupfunctions, the library implements a new, experimental APIfor looking up arbitrary DNS resource records, using the\fBlwres_getaddrsbyname()\fRfunction..PPFinally, 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 the\fBlwresd\fRresolver daemon. The use of this low-level API in clientsand servers is outlined in the following sections..SH "CLIENT-SIDE LOW-LEVEL API CALL FLOW".PPWhen a client program wishes to make an lwres request using thenative low-level API, it typically performs the following sequence of actions..PP(1) Allocate or use an existing \fBlwres_packet_t\fR,called pkt below..PP(2) Set \fBpkt.recvlength\fR 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\fIlwres.h\fR: LWRES_RECVLENGTH = 4096..PP(3) Set \fBpkt.serial\fRto a unique serial number. This value is echoedback to the application by the remote server..PP(4) Set \fBpkt.pktflags\fR. Usually this is set to 0..PP(5) Set \fBpkt.result\fR to 0..PP(6) Call \fBlwres_*request_render()\fR, or marshall in the data using the primitivessuch as \fBlwres_packet_render()\fRand storing the packet data..PP(7) Transmit the resulting buffer..PP(8) Call \fBlwres_*response_parse()\fRto parse any packets received..PP(9) Verify that the opcode and serial match a request, and process thepacket specific information contained in the body..SH "SERVER-SIDE LOW-LEVEL API CALL FLOW".PPWhen 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..PPNote that the same \fBlwres_packet_t\fR is usedin both the \fB_parse()\fR and \fB_render()\fR 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..PP(1) When a packet is received, call \fBlwres_*request_parse()\fR tounmarshall it. This returns a \fBlwres_packet_t\fR (also called pkt, below)as well as a data specific type, such as \fBlwres_gabnrequest_t\fR..PP(2) Process the request in the data specific type..PP(3) Set the \fBpkt.result\fR,\fBpkt.recvlength\fR as above. All other fields canbe left untouched since they were filled in by the \fB*_parse()\fR callabove. If using \fBlwres_*response_render()\fR,\fBpkt.pktflags\fR will be set upproperly. Otherwise, the LWRES_LWPACKETFLAG_RESPONSE bit should beset..PP(4) Call the data specific rendering function, such as\fBlwres_gabnresponse_render()\fR..PP(5) Send the resulting packet to the client..PP.SH "SEE ALSO".PP\fBlwres_gethostent\fR(3),\fBlwres_getipnode\fR(3),\fBlwres_getnameinfo\fR(3),\fBlwres_noop\fR(3),\fBlwres_gabn\fR(3),\fBlwres_gnba\fR(3),\fBlwres_context\fR(3),\fBlwres_config\fR(3),\fBresolver\fR(5),\fBlwresd\fR(8).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -