1 .\" $NetBSD: lwres_resutil.3,v 1.5 2014/12/10 04:38:02 christos Exp $
3 .\" Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
4 .\" Copyright (C) 2000, 2001 Internet Software Consortium.
6 .\" Permission to use, copy, modify, and/or distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 .\" PERFORMANCE OF THIS SOFTWARE.
22 .\" Title: lwres_resutil
24 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
25 .\" Date: June 18, 2007
29 .TH "LWRES_RESUTIL" "3" "June 18, 2007" "BIND9" "BIND9"
30 .\" disable hyphenation
32 .\" disable justification (adjust text to left margin only)
35 lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr \- lightweight resolver utility functions
38 #include <lwres/lwres.h>
41 .BI "lwres_result_t lwres_string_parse(lwres_buffer_t\ *" "b" ", char\ **" "c" ", lwres_uint16_t\ *" "len" ");"
43 .BI "lwres_result_t lwres_addr_parse(lwres_buffer_t\ *" "b" ", lwres_addr_t\ *" "addr" ");"
45 .BI "lwres_result_t lwres_getaddrsbyname(lwres_context_t\ *" "ctx" ", const\ char\ *" "name" ", lwres_uint32_t\ " "addrtypes" ", lwres_gabnresponse_t\ **" "structp" ");"
47 .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" ");"
50 \fBlwres_string_parse()\fR
51 retrieves a DNS\-encoded string starting the current pointer of lightweight resolver buffer
53 \fBb\->current\fR. When the function returns, the address of the first byte of the encoded string is returned via
55 and the length of that string is given by
56 \fI*len\fR. The buffer's current pointer is advanced to point at the character following the string length, the encoded string, and the trailing
60 \fBlwres_addr_parse()\fR
61 extracts an address from the buffer
62 \fIb\fR. The buffer's current pointer
64 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
68 indicates the size in bytes of the address that was copied.
70 is advanced to point at the next byte of available data in the buffer following the encoded address.
72 \fBlwres_getaddrsbyname()\fR
74 \fBlwres_getnamebyaddr()\fR
76 \fBlwres_gnbaresponse_t\fR
77 structure defined below:
83 lwres_uint16_t naliases;
84 lwres_uint16_t naddrs;
87 lwres_uint16_t realnamelen;
88 lwres_uint16_t *aliaslen;
89 lwres_addrlist_t addrs;
92 } lwres_gabnresponse_t;
96 The contents of this structure are not manipulated directly but they are controlled through the
100 The lightweight resolver uses
101 \fBlwres_getaddrsbyname()\fR
102 to perform forward lookups. Hostname
104 is looked up using the resolver context
106 for memory allocation.
108 is a bitmask indicating which type of addresses are to be looked up. Current values for this bitmask are
109 \fBLWRES_ADDRTYPE_V4\fR
110 for IPv4 addresses and
111 \fBLWRES_ADDRTYPE_V6\fR
112 for IPv6 addresses. Results of the lookup are returned in
115 \fBlwres_getnamebyaddr()\fR
116 performs reverse lookups. Resolver context
118 is used for memory allocation. The address type is indicated by
120 \fBLWRES_ADDRTYPE_V4\fR
122 \fBLWRES_ADDRTYPE_V6\fR. The address to be looked up is given by
126 bytes. The result of the function call is made available through
131 \fBlwres_string_parse()\fR
133 \fBlwres_addr_parse()\fR
135 \fBLWRES_R_SUCCESS.\fR
136 Both functions return
137 \fBLWRES_R_FAILURE\fR
138 if the buffer is corrupt or
139 \fBLWRES_R_UNEXPECTEDEND\fR
140 if the buffer has less space than expected for the components of the encoded string or address.
142 \fBlwres_getaddrsbyname()\fR
144 \fBLWRES_R_SUCCESS\fR
145 on success and it returns
146 \fBLWRES_R_NOTFOUND\fR
151 \fBLWRES_R_SUCCESS\fR
152 is returned by a successful call to
153 \fBlwres_getnamebyaddr()\fR.
156 \fBlwres_getaddrsbyname()\fR
158 \fBlwres_getnamebyaddr()\fR
160 \fBLWRES_R_NOMEMORY\fR
161 when memory allocation requests fail and
162 \fBLWRES_R_UNEXPECTEDEND\fR
163 if the buffers used for sending queries and receiving replies are too small.
166 \fBlwres_buffer\fR(3),
169 Copyright \(co 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC")
171 Copyright \(co 2000, 2001 Internet Software Consortium.