PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/bind9/lib/lwres/man/lwres.3

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 165 lines | 165 code | 0 blank | 0 comment | 0 complexity | 18f0ec5807706ba933d294e9ecdce633 MD5 | raw file
  1.\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
  2.\" Copyright (C) 2000, 2001 Internet Software Consortium.
  3.\" 
  4.\" Permission to use, copy, modify, and/or distribute this software for any
  5.\" purpose with or without fee is hereby granted, provided that the above
  6.\" copyright notice and this permission notice appear in all copies.
  7.\" 
  8.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  9.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 10.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 11.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 12.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 13.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 14.\" PERFORMANCE OF THIS SOFTWARE.
 15.\"
 16.\" $Id$
 17.\"
 18.hy 0
 19.ad l
 20.\"     Title: lwres
 21.\"    Author: 
 22.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
 23.\"      Date: Jun 30, 2000
 24.\"    Manual: BIND9
 25.\"    Source: BIND9
 26.\"
 27.TH "LWRES" "3" "Jun 30, 2000" "BIND9" "BIND9"
 28.\" disable hyphenation
 29.nh
 30.\" disable justification (adjust text to left margin only)
 31.ad l
 32.SH "NAME"
 33lwres \- introduction to the lightweight resolver library
 34.SH "SYNOPSIS"
 35.nf
 36#include <lwres/lwres.h>
 37.fi
 38.SH "DESCRIPTION"
 39.PP
 40The 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
 41\fBlwresd\fR
 42running on the local host. The resover 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.
 43.SH "OVERVIEW"
 44.PP
 45The lwresd library implements multiple name service APIs. The standard
 46\fBgethostbyname()\fR,
 47\fBgethostbyaddr()\fR,
 48\fBgethostbyname_r()\fR,
 49\fBgethostbyaddr_r()\fR,
 50\fBgetaddrinfo()\fR,
 51\fBgetipnodebyname()\fR, and
 52\fBgetipnodebyaddr()\fR
 53functions 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
 54lwres_. To define the standard names, applications must include the header file
 55\fI<lwres/netdb.h>\fR
 56which contains macro definitions mapping the standard function names into
 57lwres_
 58prefixed 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.
 59.PP
 60The library also provides a native API consisting of the functions
 61\fBlwres_getaddrsbyname()\fR
 62and
 63\fBlwres_getnamebyaddr()\fR. These may be called by applications that require more detailed control over the lookup process than the standard functions provide.
 64.PP
 65In 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
 66\fBlwres_getaddrsbyname()\fR
 67function.
 68.PP
 69Finally, 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
 70\fBlwresd\fR
 71resolver daemon. The use of this low\-level API in clients and servers is outlined in the following sections.
 72.SH "CLIENT\-SIDE LOW\-LEVEL API CALL FLOW"
 73.PP
 74When a client program wishes to make an lwres request using the native low\-level API, it typically performs the following sequence of actions.
 75.PP
 76(1) Allocate or use an existing
 77\fBlwres_packet_t\fR, called
 78\fIpkt\fR
 79below.
 80.PP
 81(2) Set
 82pkt.recvlength
 83to 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
 84\fIlwres.h\fR:
 85\fBLWRES_RECVLENGTH = 4096\fR.
 86.PP
 87(3) Set
 88pkt.serial
 89to a unique serial number. This value is echoed back to the application by the remote server.
 90.PP
 91(4) Set
 92pkt.pktflags. Usually this is set to 0.
 93.PP
 94(5) Set
 95pkt.result
 96to 0.
 97.PP
 98(6) Call
 99\fBlwres_*request_render()\fR, or marshall in the data using the primitives such as
100\fBlwres_packet_render()\fR
101and storing the packet data.
102.PP
103(7) Transmit the resulting buffer.
104.PP
105(8) Call
106\fBlwres_*response_parse()\fR
107to parse any packets received.
108.PP
109(9) Verify that the opcode and serial match a request, and process the packet specific information contained in the body.
110.SH "SERVER\-SIDE LOW\-LEVEL API CALL FLOW"
111.PP
112When 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.
113.PP
114Note that the same
115\fBlwres_packet_t\fR
116is used in both the
117\fB_parse()\fR
118and
119\fB_render()\fR
120calls, with only a few modifications made to the packet header's contents between uses. This method is recommended as it keeps the serial, opcode, and other fields correct.
121.PP
122(1) When a packet is received, call
123\fBlwres_*request_parse()\fR
124to unmarshall it. This returns a
125\fBlwres_packet_t\fR
126(also called
127\fIpkt\fR, below) as well as a data specific type, such as
128\fBlwres_gabnrequest_t\fR.
129.PP
130(2) Process the request in the data specific type.
131.PP
132(3) Set the
133pkt.result,
134pkt.recvlength
135as above. All other fields can be left untouched since they were filled in by the
136\fB*_parse()\fR
137call above. If using
138\fBlwres_*response_render()\fR,
139pkt.pktflags
140will be set up properly. Otherwise, the
141\fBLWRES_LWPACKETFLAG_RESPONSE\fR
142bit should be set.
143.PP
144(4) Call the data specific rendering function, such as
145\fBlwres_gabnresponse_render()\fR.
146.PP
147(5) Send the resulting packet to the client.
148.PP
149.SH "SEE ALSO"
150.PP
151\fBlwres_gethostent\fR(3),
152\fBlwres_getipnode\fR(3),
153\fBlwres_getnameinfo\fR(3),
154\fBlwres_noop\fR(3),
155\fBlwres_gabn\fR(3),
156\fBlwres_gnba\fR(3),
157\fBlwres_context\fR(3),
158\fBlwres_config\fR(3),
159\fBresolver\fR(5),
160\fBlwresd\fR(8).
161.SH "COPYRIGHT"
162Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
163.br
164Copyright \(co 2000, 2001 Internet Software Consortium.
165.br