]> git.ipfire.org Git - thirdparty/strongswan.git/blob - lib/liblwres/man/lwres.3
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / lib / liblwres / man / lwres.3
1 .\"
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
3 .\"
4 .\" Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
9 .\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 .\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 .\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .TH "LWRES" "3" "Jun 30, 2000" "BIND9" ""
18 .SH NAME
19 lwres \- introduction to the lightweight resolver library
20 .SH SYNOPSIS
21 \fB#include <lwres/lwres.h>\fR
22 .SH "DESCRIPTION"
23 .PP
24 The BIND 9 lightweight resolver library is a simple, name service
25 independent stub resolver library. It provides hostname-to-address
26 and address-to-hostname lookup services to applications by
27 transmitting lookup requests to a resolver daemon
28 \fBlwresd\fR
29 running on the local host. The resover daemon performs the
30 lookup using the DNS or possibly other name service protocols,
31 and returns the results to the application through the library.
32 The library and resolver daemon communicate using a simple
33 UDP-based protocol.
34 .SH "OVERVIEW"
35 .PP
36 The lwresd library implements multiple name service APIs.
37 The standard
38 \fBgethostbyname()\fR,
39 \fBgethostbyaddr()\fR,
40 \fBgethostbyname_r()\fR,
41 \fBgethostbyaddr_r()\fR,
42 \fBgetaddrinfo()\fR,
43 \fBgetipnodebyname()\fR,
44 and
45 \fBgetipnodebyaddr()\fR
46 functions are all supported. To allow the lwres library to coexist
47 with system libraries that define functions of the same name,
48 the library defines these functions with names prefixed by
49 lwres_.
50 To define the standard names, applications must include the
51 header file
52 \fI<lwres/netdb.h>\fR
53 which contains macro definitions mapping the standard function names
54 into
55 lwres_
56 prefixed ones. Operating system vendors who integrate the lwres
57 library into their base distributions should rename the functions
58 in the library proper so that the renaming macros are not needed.
59 .PP
60 The library also provides a native API consisting of the functions
61 \fBlwres_getaddrsbyname()\fR
62 and
63 \fBlwres_getnamebyaddr()\fR.
64 These may be called by applications that require more detailed
65 control over the lookup process than the standard functions
66 provide.
67 .PP
68 In addition to these name service independent address lookup
69 functions, the library implements a new, experimental API
70 for looking up arbitrary DNS resource records, using the
71 \fBlwres_getaddrsbyname()\fR
72 function.
73 .PP
74 Finally, there is a low-level API for converting lookup
75 requests and responses to and from raw lwres protocol packets.
76 This API can be used by clients requiring nonblocking operation,
77 and is also used when implementing the server side of the lwres
78 protocol, for example in the
79 \fBlwresd\fR
80 resolver daemon. The use of this low-level API in clients
81 and servers is outlined in the following sections.
82 .SH "CLIENT-SIDE LOW-LEVEL API CALL FLOW"
83 .PP
84 When a client program wishes to make an lwres request using the
85 native low-level API, it typically performs the following
86 sequence of actions.
87 .PP
88 (1) Allocate or use an existing \fBlwres_packet_t\fR,
89 called pkt below.
90 .PP
91 (2) Set \fBpkt.recvlength\fR to the maximum length we will accept.
92 This is done so the receiver of our packets knows how large our receive
93 buffer is. The "default" is a constant in
94 \fIlwres.h\fR: LWRES_RECVLENGTH = 4096.
95 .PP
96 (3) Set \fBpkt.serial\fR
97 to a unique serial number. This value is echoed
98 back to the application by the remote server.
99 .PP
100 (4) Set \fBpkt.pktflags\fR. Usually this is set to 0.
101 .PP
102 (5) Set \fBpkt.result\fR to 0.
103 .PP
104 (6) Call \fBlwres_*request_render()\fR,
105 or marshall in the data using the primitives
106 such as \fBlwres_packet_render()\fR
107 and storing the packet data.
108 .PP
109 (7) Transmit the resulting buffer.
110 .PP
111 (8) Call \fBlwres_*response_parse()\fR
112 to parse any packets received.
113 .PP
114 (9) Verify that the opcode and serial match a request, and process the
115 packet specific information contained in the body.
116 .SH "SERVER-SIDE LOW-LEVEL API CALL FLOW"
117 .PP
118 When implementing the server side of the lightweight resolver
119 protocol using the lwres library, a sequence of actions like the
120 following is typically involved in processing each request packet.
121 .PP
122 Note that the same \fBlwres_packet_t\fR is used
123 in both the \fB_parse()\fR and \fB_render()\fR calls,
124 with only a few modifications made
125 to the packet header's contents between uses. This method is recommended
126 as it keeps the serial, opcode, and other fields correct.
127 .PP
128 (1) When a packet is received, call \fBlwres_*request_parse()\fR to
129 unmarshall it. This returns a \fBlwres_packet_t\fR (also called pkt, below)
130 as well as a data specific type, such as \fBlwres_gabnrequest_t\fR.
131 .PP
132 (2) Process the request in the data specific type.
133 .PP
134 (3) Set the \fBpkt.result\fR,
135 \fBpkt.recvlength\fR as above. All other fields can
136 be left untouched since they were filled in by the \fB*_parse()\fR call
137 above. If using \fBlwres_*response_render()\fR,
138 \fBpkt.pktflags\fR will be set up
139 properly. Otherwise, the LWRES_LWPACKETFLAG_RESPONSE bit should be
140 set.
141 .PP
142 (4) Call the data specific rendering function, such as
143 \fBlwres_gabnresponse_render()\fR.
144 .PP
145 (5) Send the resulting packet to the client.
146 .PP
147 .SH "SEE ALSO"
148 .PP
149 \fBlwres_gethostent\fR(3),
150 \fBlwres_getipnode\fR(3),
151 \fBlwres_getnameinfo\fR(3),
152 \fBlwres_noop\fR(3),
153 \fBlwres_gabn\fR(3),
154 \fBlwres_gnba\fR(3),
155 \fBlwres_context\fR(3),
156 \fBlwres_config\fR(3),
157 \fBresolver\fR(5),
158 \fBlwresd\fR(8).