1 .\" Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
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.
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.
19 .\" Title: lwres_resutil
21 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
27 .TH "LWRES_RESUTIL" "3" "2007\-06\-18" "ISC" "BIND9"
28 .\" -----------------------------------------------------------------
29 .\" * Define some portability stuff
30 .\" -----------------------------------------------------------------
31 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 .\" http://bugs.debian.org/507673
33 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
34 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 .\" -----------------------------------------------------------------
38 .\" * set default formatting
39 .\" -----------------------------------------------------------------
40 .\" disable hyphenation
42 .\" disable justification (adjust text to left margin only)
44 .\" -----------------------------------------------------------------
45 .\" * MAIN CONTENT STARTS HERE *
46 .\" -----------------------------------------------------------------
48 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
53 #include <lwres/lwres\&.h>
56 .HP \w'lwres_result_t\ lwres_string_parse('u
57 .BI "lwres_result_t lwres_string_parse(lwres_buffer_t\ *" "b" ", char\ **" "c" ", lwres_uint16_t\ *" "len" ");"
58 .HP \w'lwres_result_t\ lwres_addr_parse('u
59 .BI "lwres_result_t lwres_addr_parse(lwres_buffer_t\ *" "b" ", lwres_addr_t\ *" "addr" ");"
60 .HP \w'lwres_result_t\ lwres_getaddrsbyname('u
61 .BI "lwres_result_t lwres_getaddrsbyname(lwres_context_t\ *" "ctx" ", const\ char\ *" "name" ", lwres_uint32_t\ " "addrtypes" ", lwres_gabnresponse_t\ **" "structp" ");"
62 .HP \w'lwres_result_t\ lwres_getnamebyaddr('u
63 .BI "lwres_result_t lwres_getnamebyaddr(lwres_context_t\ *" "ctx" ", lwres_uint32_t\ " "addrtype" ", lwres_uint16_t\ " "addrlen" ", const\ unsigned\ char\ *" "addr" ", lwres_gnbaresponse_t\ **" "structp" ");"
66 \fBlwres_string_parse()\fR
67 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
69 \fBb\->current\fR\&. When the function returns, the address of the first byte of the encoded string is returned via
71 and the length of that string is given by
72 \fI*len\fR\&. The buffer\*(Aqs current pointer is advanced to point at the character following the string length, the encoded string, and the trailing
76 \fBlwres_addr_parse()\fR
77 extracts an address from the buffer
78 \fIb\fR\&. The buffer\*(Aqs current pointer
80 is presumed to point at an encoded address: the address preceded by a 32\-bit protocol family identifier and a 16\-bit length field\&. The encoded address is copied to
84 indicates the size in bytes of the address that was copied\&.
86 is advanced to point at the next byte of available data in the buffer following the encoded address\&.
88 \fBlwres_getaddrsbyname()\fR
90 \fBlwres_getnamebyaddr()\fR
92 \fBlwres_gnbaresponse_t\fR
93 structure defined below:
100 lwres_uint32_t flags;
101 lwres_uint16_t naliases;
102 lwres_uint16_t naddrs;
105 lwres_uint16_t realnamelen;
106 lwres_uint16_t *aliaslen;
107 lwres_addrlist_t addrs;
110 } lwres_gabnresponse_t;
116 The contents of this structure are not manipulated directly but they are controlled through the
120 The lightweight resolver uses
121 \fBlwres_getaddrsbyname()\fR
122 to perform forward lookups\&. Hostname
124 is looked up using the resolver context
126 for memory allocation\&.
128 is a bitmask indicating which type of addresses are to be looked up\&. Current values for this bitmask are
129 \fBLWRES_ADDRTYPE_V4\fR
130 for IPv4 addresses and
131 \fBLWRES_ADDRTYPE_V6\fR
132 for IPv6 addresses\&. Results of the lookup are returned in
135 \fBlwres_getnamebyaddr()\fR
136 performs reverse lookups\&. Resolver context
138 is used for memory allocation\&. The address type is indicated by
140 \fBLWRES_ADDRTYPE_V4\fR
142 \fBLWRES_ADDRTYPE_V6\fR\&. The address to be looked up is given by
146 bytes\&. The result of the function call is made available through
151 \fBlwres_string_parse()\fR
153 \fBlwres_addr_parse()\fR
155 \fBLWRES_R_SUCCESS\&.\fR
156 Both functions return
157 \fBLWRES_R_FAILURE\fR
158 if the buffer is corrupt or
159 \fBLWRES_R_UNEXPECTEDEND\fR
160 if the buffer has less space than expected for the components of the encoded string or address\&.
162 \fBlwres_getaddrsbyname()\fR
164 \fBLWRES_R_SUCCESS\fR
165 on success and it returns
166 \fBLWRES_R_NOTFOUND\fR
169 could not be found\&.
171 \fBLWRES_R_SUCCESS\fR
172 is returned by a successful call to
173 \fBlwres_getnamebyaddr()\fR\&.
176 \fBlwres_getaddrsbyname()\fR
178 \fBlwres_getnamebyaddr()\fR
180 \fBLWRES_R_NOMEMORY\fR
181 when memory allocation requests fail and
182 \fBLWRES_R_UNEXPECTEDEND\fR
183 if the buffers used for sending queries and receiving replies are too small\&.
186 \fBlwres_buffer\fR(3),
187 \fBlwres_gabn\fR(3)\&.
190 \fBInternet Systems Consortium, Inc\&.\fR
193 Copyright \(co 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
195 Copyright \(co 2000, 2001 Internet Software Consortium.