132N/A<!
DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 132N/A [<!ENTITY mdash "—">]>
132N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 132N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 132N/A - Permission to use, copy, modify, and/or distribute this software for any 132N/A - purpose with or without fee is hereby granted, provided that the above 132N/A - copyright notice and this permission notice appear in all copies. 132N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 132N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 132N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 132N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 132N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 132N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 132N/A - PERFORMANCE OF THIS SOFTWARE. 215N/A <
date>Jun 30, 2000</
date>
132N/A <
refentrytitle>lwres_resutil</
refentrytitle>
132N/A <
manvolnum>3</
manvolnum>
132N/A <
refmiscinfo>BIND9</
refmiscinfo>
132N/A <
holder>Internet Systems Consortium, Inc. ("ISC")</
holder>
132N/A <
holder>Internet Software Consortium.</
holder>
132N/A <
refname>lwres_string_parse</
refname>
132N/A <
refname>lwres_addr_parse</
refname>
132N/A <
refname>lwres_getaddrsbyname</
refname>
132N/A <
refname>lwres_getnamebyaddr</
refname>
132N/A <
refpurpose>lightweight resolver utility functions</
refpurpose>
132N/A<
function>lwres_string_parse</
function></
funcdef>
132N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
132N/A <
paramdef>char **<
parameter>c</
parameter></
paramdef>
132N/A <
paramdef>lwres_uint16_t *<
parameter>len</
parameter></
paramdef>
132N/A<
function>lwres_addr_parse</
function></
funcdef>
132N/A <
paramdef>lwres_buffer_t *<
parameter>b</
parameter></
paramdef>
132N/A <
paramdef>lwres_addr_t *<
parameter>addr</
parameter></
paramdef>
132N/A<
function>lwres_getaddrsbyname</
function></
funcdef>
132N/A <
paramdef>lwres_context_t *<
parameter>ctx</
parameter></
paramdef>
132N/A <
paramdef>const char *<
parameter>name</
parameter></
paramdef>
132N/A <
paramdef>lwres_uint32_t <
parameter>addrtypes</
parameter></
paramdef>
132N/A <
paramdef>lwres_gabnresponse_t **<
parameter>structp</
parameter></
paramdef>
132N/A<
function>lwres_getnamebyaddr</
function></
funcdef>
132N/A <
paramdef>lwres_context_t *<
parameter>ctx</
parameter></
paramdef>
132N/A <
paramdef>lwres_uint32_t <
parameter>addrtype</
parameter></
paramdef>
132N/A <
paramdef>lwres_uint16_t <
parameter>addrlen</
parameter></
paramdef>
132N/A <
paramdef>const unsigned char *<
parameter>addr</
parameter></
paramdef>
219N/A <
paramdef>lwres_gnbaresponse_t **<
parameter>structp</
parameter></
paramdef>
411N/A <
title>DESCRIPTION</
title>
487N/A <
para><
function>lwres_string_parse()</
function>
704N/A retrieves a DNS-encoded string starting the current pointer of
487N/A lightweight resolver buffer <
parameter>b</
parameter>:
i.e. 704N/A <
constant>b->current</
constant>. When the function returns,
704N/A the address of the first byte of the encoded string is returned
487N/A via <
parameter>*c</
parameter> and the length of that string is
487N/A given by <
parameter>*len</
parameter>. The buffer's current
487N/A pointer is advanced to point at the character following the
320N/A string length, the encoded string, and the trailing
336N/A <
type>NULL</
type> character.
336N/A <
para><
function>lwres_addr_parse()</
function>
336N/A extracts an address from the buffer <
parameter>b</
parameter>.
336N/A The buffer's current pointer <
constant>b->current</
constant>
336N/A is presumed to point at an encoded address: the address preceded
341N/A by a 32-bit protocol family identifier and a 16-bit length
487N/A field. The encoded address is copied to
336N/A <
constant>addr->address</
constant> and
336N/A <
constant>addr->length</
constant> indicates the size in bytes
336N/A of the address that was copied.
379N/A <
constant>b->current</
constant> is advanced to point at the
379N/A next byte of available data in the buffer following the encoded
379N/A <
para><
function>lwres_getaddrsbyname()</
function>
411N/A and <
function>lwres_getnamebyaddr()</
function> use the
411N/A <
type>lwres_gnbaresponse_t</
type> structure defined below:
336N/A lwres_uint16_t naliases;
320N/A lwres_uint16_t realnamelen;
132N/A lwres_uint16_t *aliaslen;
132N/A lwres_addrlist_t addrs;
132N/A</
programlisting></
para>
132N/A The contents of this structure are not manipulated directly but
132N/A they are controlled through the
132N/A <
refentrytitle>lwres_gabn</
refentrytitle><
manvolnum>3</
manvolnum>
132N/A The lightweight resolver uses
190N/A <
function>lwres_getaddrsbyname()</
function> to perform
132N/A Hostname <
parameter>name</
parameter> is looked up using the
132N/A context <
parameter>ctx</
parameter> for memory allocation.
132N/A <
parameter>addrtypes</
parameter> is a bitmask indicating
132N/A addresses are to be looked up. Current values for this bitmask are
132N/A <
type>LWRES_ADDRTYPE_V4</
type> for IPv4 addresses and
230N/A <
type>LWRES_ADDRTYPE_V6</
type> for IPv6 addresses. Results of the
230N/A lookup are returned in <
parameter>*structp</
parameter>.
230N/A <
para><
function>lwres_getnamebyaddr()</
function>
230N/A performs reverse lookups. Resolver context
230N/A <
parameter>ctx</
parameter> is used for memory allocation. The
230N/A address type is indicated by <
parameter>addrtype</
parameter>:
230N/A <
type>LWRES_ADDRTYPE_V4</
type> or
230N/A <
type>LWRES_ADDRTYPE_V6</
type>. The address to be looked up is
230N/A given by <
parameter>addr</
parameter> and its length is
230N/A <
parameter>addrlen</
parameter> bytes. The result of the
230N/A function call is made available through
230N/A <
parameter>*structp</
parameter>.
230N/A <
title>RETURN VALUES</
title>
230N/A <
function>lwres_string_parse()</
function>
230N/A <
function>lwres_addr_parse()</
function>
230N/A <
errorcode>LWRES_R_SUCCESS.</
errorcode>
230N/A <
errorcode>LWRES_R_FAILURE</
errorcode>
230N/A if the buffer is corrupt or
230N/A <
errorcode>LWRES_R_UNEXPECTEDEND</
errorcode>
301N/A if the buffer has less space than expected for the components of the
132N/A encoded string or address.
213N/A <
para><
function>lwres_getaddrsbyname()</
function>
301N/A returns <
errorcode>LWRES_R_SUCCESS</
errorcode> on success and it
132N/A returns <
errorcode>LWRES_R_NOTFOUND</
errorcode> if the hostname
132N/A <
parameter>name</
parameter> could not be found.
213N/A <
para><
errorcode>LWRES_R_SUCCESS</
errorcode>
213N/A is returned by a successful call to
213N/A <
function>lwres_getnamebyaddr()</
function>.
213N/A <
function>lwres_getaddrsbyname()</
function>
213N/A <
function>lwres_getnamebyaddr()</
function>
213N/A <
errorcode>LWRES_R_NOMEMORY</
errorcode>
213N/A when memory allocation requests fail and
213N/A <
errorcode>LWRES_R_UNEXPECTEDEND</
errorcode>
213N/A if the buffers used for sending queries and receiving replies are too
213N/A <
title>SEE ALSO</
title>
213N/A <
refentrytitle>lwres_buffer</
refentrytitle><
manvolnum>3</
manvolnum>
213N/A <
refentrytitle>lwres_gabn</
refentrytitle><
manvolnum>3</
manvolnum>