]> git.ipfire.org Git - people/ms/strongswan.git/blob - lib/liblwres/man/lwres_resutil.3
- fixed stroke error output to starter
[people/ms/strongswan.git] / lib / liblwres / man / lwres_resutil.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_RESUTIL" "3" "Jun 30, 2000" "BIND9" ""
18 .SH NAME
19 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
20 .SH SYNOPSIS
21 \fB#include <lwres/lwres.h>
22 .sp
23 .na
24 lwres_result_t
25 lwres_string_parse(lwres_buffer_t *b, char **c, lwres_uint16_t *len);
26 .ad
27 .sp
28 .na
29 lwres_result_t
30 lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
31 .ad
32 .sp
33 .na
34 lwres_result_t
35 lwres_getaddrsbyname(lwres_context_t *ctx, const char *name, lwres_uint32_t addrtypes, lwres_gabnresponse_t **structp);
36 .ad
37 .sp
38 .na
39 lwres_result_t
40 lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, lwres_uint16_t addrlen, const unsigned char *addr, lwres_gnbaresponse_t **structp);
41 .ad
42 \fR.SH "DESCRIPTION"
43 .PP
44 \fBlwres_string_parse()\fR retrieves a DNS-encoded
45 string starting the current pointer of lightweight resolver buffer
46 \fIb\fR: i.e. b->current.
47 When the function returns, the address of the first byte of the
48 encoded string is returned via \fI*c\fR and the
49 length of that string is given by \fI*len\fR. The
50 buffer's current pointer is advanced to point at the character
51 following the string length, the encoded string, and the trailing
52 \fBNULL\fR character.
53 .PP
54 \fBlwres_addr_parse()\fR extracts an address from the
55 buffer \fIb\fR. The buffer's current pointer
56 b->current is presumed to point at an encoded
57 address: the address preceded by a 32-bit protocol family identifier
58 and a 16-bit length field. The encoded address is copied to
59 addr->address and
60 addr->length indicates the size in bytes of
61 the address that was copied. b->current is
62 advanced to point at the next byte of available data in the buffer
63 following the encoded address.
64 .PP
65 \fBlwres_getaddrsbyname()\fR
66 and
67 \fBlwres_getnamebyaddr()\fR
68 use the
69 \fBlwres_gnbaresponse_t\fR
70 structure defined below:
71 .sp
72 .nf
73 typedef struct {
74 lwres_uint32_t flags;
75 lwres_uint16_t naliases;
76 lwres_uint16_t naddrs;
77 char *realname;
78 char **aliases;
79 lwres_uint16_t realnamelen;
80 lwres_uint16_t *aliaslen;
81 lwres_addrlist_t addrs;
82 void *base;
83 size_t baselen;
84 } lwres_gabnresponse_t;
85 .sp
86 .fi
87 The contents of this structure are not manipulated directly but
88 they are controlled through the
89 \fBlwres_gabn\fR(3)
90 functions.
91 .PP
92 The lightweight resolver uses
93 \fBlwres_getaddrsbyname()\fR to perform foward lookups.
94 Hostname \fIname\fR is looked up using the resolver
95 context \fIctx\fR for memory allocation.
96 \fIaddrtypes\fR is a bitmask indicating which type of
97 addresses are to be looked up. Current values for this bitmask are
98 \fBLWRES_ADDRTYPE_V4\fR for IPv4 addresses and
99 \fBLWRES_ADDRTYPE_V6\fR for IPv6 addresses. Results of the
100 lookup are returned in \fI*structp\fR.
101 .PP
102 \fBlwres_getnamebyaddr()\fR performs reverse lookups.
103 Resolver context \fIctx\fR is used for memory
104 allocation. The address type is indicated by
105 \fIaddrtype\fR: \fBLWRES_ADDRTYPE_V4\fR or
106 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given
107 by \fIaddr\fR and its length is
108 \fIaddrlen\fR bytes. The result of the function call
109 is made available through \fI*structp\fR.
110 .SH "RETURN VALUES"
111 .PP
112 Successful calls to
113 \fBlwres_string_parse()\fR
114 and
115 \fBlwres_addr_parse()\fR
116 return
117 LWRES_R_SUCCESS.
118 Both functions return
119 LWRES_R_FAILURE
120 if the buffer is corrupt or
121 LWRES_R_UNEXPECTEDEND
122 if the buffer has less space than expected for the components of the
123 encoded string or address.
124 .PP
125 \fBlwres_getaddrsbyname()\fR
126 returns
127 LWRES_R_SUCCESS
128 on success and it returns
129 LWRES_R_NOTFOUND
130 if the hostname
131 \fIname\fR
132 could not be found.
133 .PP
134 LWRES_R_SUCCESS
135 is returned by a successful call to
136 \fBlwres_getnamebyaddr()\fR.
137 .PP
138 Both
139 \fBlwres_getaddrsbyname()\fR
140 and
141 \fBlwres_getnamebyaddr()\fR
142 return
143 LWRES_R_NOMEMORY
144 when memory allocation requests fail and
145 LWRES_R_UNEXPECTEDEND
146 if the buffers used for sending queries and receiving replies are too
147 small.
148 .SH "SEE ALSO"
149 .PP
150 \fBlwres_buffer\fR(3),
151 \fBlwres_gabn\fR(3).