lwres_resutil.docbook revision ec5347e2c775f027573ce5648b910361aa926c01
132N/A<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
132N/A "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
132N/A [<!ENTITY mdash "&#8212;">]>
132N/A<!--
132N/A - Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
132N/A - Copyright (C) 2000, 2001 Internet Software Consortium.
132N/A -
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 -
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.
132N/A-->
132N/A
132N/A<!-- $Id: lwres_resutil.docbook,v 1.12 2007/06/18 23:47:51 tbox Exp $ -->
132N/A<refentry>
132N/A
132N/A <refentryinfo>
215N/A <date>Jun 30, 2000</date>
132N/A </refentryinfo>
132N/A
132N/A <refmeta>
132N/A <refentrytitle>lwres_resutil</refentrytitle>
132N/A <manvolnum>3</manvolnum>
132N/A <refmiscinfo>BIND9</refmiscinfo>
132N/A </refmeta>
132N/A
132N/A <docinfo>
132N/A <copyright>
132N/A <year>2004</year>
132N/A <year>2005</year>
132N/A <year>2007</year>
132N/A <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
132N/A </copyright>
132N/A <copyright>
132N/A <year>2000</year>
132N/A <year>2001</year>
132N/A <holder>Internet Software Consortium.</holder>
132N/A </copyright>
132N/A </docinfo>
132N/A
132N/A <refnamediv>
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 </refnamediv>
132N/A <refsynopsisdiv>
132N/A <funcsynopsis>
132N/A<funcsynopsisinfo>#include &lt;lwres/lwres.h&gt;</funcsynopsisinfo>
132N/A<funcprototype>
132N/A <funcdef>
132N/Alwres_result_t
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 </funcprototype>
132N/A<funcprototype>
132N/A <funcdef>
132N/Alwres_result_t
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 </funcprototype>
132N/A<funcprototype>
132N/A <funcdef>
132N/Alwres_result_t
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 </funcprototype>
132N/A<funcprototype>
132N/A <funcdef>
132N/Alwres_result_t
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>
620N/A </funcprototype>
220N/A</funcsynopsis>
341N/A </refsynopsisdiv>
341N/A
379N/A <refsect1>
411N/A <title>DESCRIPTION</title>
487N/A
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-&gt;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>
336N/A
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-&gt;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-&gt;address</constant> and
336N/A <constant>addr-&gt;length</constant> indicates the size in bytes
336N/A of the address that was copied.
379N/A <constant>b-&gt;current</constant> is advanced to point at the
379N/A next byte of available data in the buffer following the encoded
487N/A address.
379N/A </para>
379N/A
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:
487N/A </para>
411N/A
411N/A<para><programlisting>
411N/Atypedef struct {
320N/A lwres_uint32_t flags;
336N/A lwres_uint16_t naliases;
320N/A lwres_uint16_t naddrs;
336N/A char *realname;
320N/A char **aliases;
320N/A lwres_uint16_t realnamelen;
132N/A lwres_uint16_t *aliaslen;
132N/A lwres_addrlist_t addrs;
132N/A void *base;
132N/A size_t baselen;
132N/A} lwres_gabnresponse_t;
132N/A</programlisting></para>
671N/A
671N/A <para>
132N/A The contents of this structure are not manipulated directly but
132N/A they are controlled through the
132N/A <citerefentry>
132N/A <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
244N/A </citerefentry>
244N/A functions.
132N/A </para>
132N/A
132N/A <para>
132N/A The lightweight resolver uses
190N/A <function>lwres_getaddrsbyname()</function> to perform
132N/A foward lookups.
132N/A Hostname <parameter>name</parameter> is looked up using the
132N/A resolver
132N/A context <parameter>ctx</parameter> for memory allocation.
132N/A <parameter>addrtypes</parameter> is a bitmask indicating
132N/A which type of
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>
230N/A
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 </para>
230N/A </refsect1>
230N/A
230N/A <refsect1>
230N/A <title>RETURN VALUES</title>
230N/A <para>
230N/A Successful calls to
230N/A <function>lwres_string_parse()</function>
230N/A and
230N/A <function>lwres_addr_parse()</function>
230N/A return
230N/A <errorcode>LWRES_R_SUCCESS.</errorcode>
230N/A Both functions return
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.
132N/A </para>
132N/A
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.
211N/A </para>
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 </para>
213N/A
213N/A <para>
213N/A Both
213N/A <function>lwres_getaddrsbyname()</function>
487N/A and
213N/A <function>lwres_getnamebyaddr()</function>
213N/A return
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 small.
213N/A </para>
213N/A
213N/A </refsect1>
213N/A <refsect1>
213N/A <title>SEE ALSO</title>
213N/A <para><citerefentry>
213N/A <refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
213N/A </citerefentry>,
213N/A
213N/A <citerefentry>
213N/A <refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
213N/A </citerefentry>.
213N/A </para>
213N/A
213N/A </refsect1>
230N/A</refentry><!--
213N/A - Local variables:
213N/A - mode: sgml
211N/A - End:
211N/A-->
211N/A