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