546N/A - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") 546N/A - Copyright (C) 2000, 2001 Internet Software Consortium 546N/A - Permission to use, copy, modify, and distribute this software for any 546N/A - purpose with or without fee is hereby granted, provided that the above 546N/A - copyright notice and this permission notice appear in all copies. 546N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 546N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 546N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 546N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 546N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 546N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 546N/A - PERFORMANCE OF THIS SOFTWARE. 546N/A<
meta http-
equiv="Content-Type" content="text/html; charset=ISO-8859-1">
546N/A<
title>lwres_resutil</
title>
919N/A<
meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
919N/A<
body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><
div class="refentry" lang="en">
919N/A<
a name="id2456618"></
a><
div class="titlepage"></
div>
919N/A<
div class="refnamediv">
919N/A<
p>lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname, lwres_getnamebyaddr — lightweight resolver utility functions</
p>
919N/A<
div class="refsynopsisdiv">
919N/A<
div class="funcsynopsis">
919N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
919N/A<
td><
code class="funcdef">
919N/A<
b class="fsfunc">lwres_string_parse</
b>(</
code></
td>
546N/A<
td>lwres_buffer_t *�</
td>
546N/A<
var class="pdparam">b</
var>, </
td>
546N/A<
var class="pdparam">c</
var>, </
td>
546N/A<
td>lwres_uint16_t *�</
td>
546N/A<
var class="pdparam">len</
var><
code>)</
code>;</
td>
546N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
546N/A<
td><
code class="funcdef">
546N/A<
b class="fsfunc">lwres_addr_parse</
b>(</
code></
td>
546N/A<
td>lwres_buffer_t *�</
td>
546N/A<
var class="pdparam">b</
var>, </
td>
546N/A<
td>lwres_addr_t *�</
td>
546N/A<
var class="pdparam">addr</
var><
code>)</
code>;</
td>
546N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
546N/A<
b class="fsfunc">lwres_getaddrsbyname</
b>(</
code></
td>
546N/A<
var class="pdparam">ctx</
var>, </
td>
546N/A<
var class="pdparam">name</
var>, </
td>
546N/A<
td>lwres_uint32_t �</
td>
546N/A<
var class="pdparam">addrtypes</
var>, </
td>
546N/A<
td>lwres_gabnresponse_t **�</
td>
546N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
546N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
546N/A<
td><
code class="funcdef">
546N/A<
b class="fsfunc">lwres_getnamebyaddr</
b>(</
code></
td>
546N/A<
td>lwres_context_t *�</
td>
546N/A<
var class="pdparam">ctx</
var>, </
td>
546N/A<
td>lwres_uint32_t �</
td>
546N/A<
var class="pdparam">addrtype</
var>, </
td>
546N/A<
td>lwres_uint16_t �</
td>
546N/A<
var class="pdparam">addrlen</
var>, </
td>
546N/A<
td>const unsigned char *�</
td>
546N/A<
var class="pdparam">addr</
var>, </
td>
546N/A<
td>lwres_gnbaresponse_t **�</
td>
546N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
546N/A<
div class="refsect1" lang="en">
546N/A<
a name="id2514081"></
a><
h2>DESCRIPTION</
h2>
546N/A<
p><
code class="function">lwres_string_parse()</
code>
546N/A retrieves a DNS-encoded string starting the current pointer of
546N/A lightweight resolver buffer <
em class="parameter"><
code>b</
code></
em>:
i.e. 546N/A <
code class="constant">b->current</
code>. When the function returns,
546N/A the address of the first byte of the encoded string is returned
546N/A via <
em class="parameter"><
code>*c</
code></
em> and the length of that string is
546N/A given by <
em class="parameter"><
code>*len</
code></
em>. The buffer's current
546N/A pointer is advanced to point at the character following the
546N/A string length, the encoded string, and the trailing
546N/A <
span class="type">NULL</
span> character.
546N/A<
p><
code class="function">lwres_addr_parse()</
code>
546N/A extracts an address from the buffer <
em class="parameter"><
code>b</
code></
em>.
546N/A The buffer's current pointer <
code class="constant">b->current</
code>
546N/A is presumed to point at an encoded address: the address preceded
546N/A by a 32-bit protocol family identifier and a 16-bit length
546N/A field. The encoded address is copied to
546N/A <
code class="constant">addr->address</
code> and
546N/A <
code class="constant">addr->length</
code> indicates the size in bytes
546N/A of the address that was copied.
546N/A <
code class="constant">b->current</
code> is advanced to point at the
546N/A next byte of available data in the buffer following the encoded
546N/A<
p><
code class="function">lwres_getaddrsbyname()</
code>
546N/A and <
code class="function">lwres_getnamebyaddr()</
code> use the
546N/A <
span class="type">lwres_gnbaresponse_t</
span> structure defined below:
546N/A<
pre class="programlisting">
546N/A lwres_uint16_t naliases;
546N/A lwres_uint16_t realnamelen;
546N/A lwres_uint16_t *aliaslen;
546N/A lwres_addrlist_t addrs;
546N/A The contents of this structure are not manipulated directly but
546N/A they are controlled through the
546N/A <
span class="citerefentry"><
span class="refentrytitle">lwres_gabn</
span>(3)</
span>
546N/A The lightweight resolver uses
1233N/A <
code class="function">lwres_getaddrsbyname()</
code> to perform
546N/A Hostname <
em class="parameter"><
code>name</
code></
em> is looked up using the
546N/A context <
em class="parameter"><
code>ctx</
code></
em> for memory allocation.
546N/A <
em class="parameter"><
code>addrtypes</
code></
em> is a bitmask indicating
546N/A addresses are to be looked up. Current values for this bitmask are
546N/A <
span class="type">LWRES_ADDRTYPE_V4</
span> for IPv4 addresses and
546N/A <
span class="type">LWRES_ADDRTYPE_V6</
span> for IPv6 addresses. Results of the
546N/A lookup are returned in <
em class="parameter"><
code>*structp</
code></
em>.
546N/A<
p><
code class="function">lwres_getnamebyaddr()</
code>
546N/A performs reverse lookups. Resolver context
546N/A <
em class="parameter"><
code>ctx</
code></
em> is used for memory allocation. The
546N/A address type is indicated by <
em class="parameter"><
code>addrtype</
code></
em>:
546N/A <
span class="type">LWRES_ADDRTYPE_V4</
span> or
546N/A <
span class="type">LWRES_ADDRTYPE_V6</
span>. The address to be looked up is
546N/A given by <
em class="parameter"><
code>addr</
code></
em> and its length is
546N/A <
em class="parameter"><
code>addrlen</
code></
em> bytes. The result of the
546N/A function call is made available through
546N/A <
em class="parameter"><
code>*structp</
code></
em>.
546N/A<
div class="refsect1" lang="en">
546N/A<
a name="id2514356"></
a><
h2>RETURN VALUES</
h2>
546N/A <
code class="function">lwres_string_parse()</
code>
546N/A <
code class="function">lwres_addr_parse()</
code>
546N/A <
span class="errorcode">LWRES_R_SUCCESS.</
span>
1233N/A <
span class="errorcode">LWRES_R_FAILURE</
span>
1233N/A if the buffer is corrupt or
546N/A <
span class="errorcode">LWRES_R_UNEXPECTEDEND</
span>
546N/A if the buffer has less space than expected for the components of the
546N/A encoded string or address.
546N/A<
p><
code class="function">lwres_getaddrsbyname()</
code>
546N/A returns <
span class="errorcode">LWRES_R_SUCCESS</
span> on success and it
546N/A returns <
span class="errorcode">LWRES_R_NOTFOUND</
span> if the hostname
546N/A <
em class="parameter"><
code>name</
code></
em> could not be found.
546N/A<
p><
span class="errorcode">LWRES_R_SUCCESS</
span>
546N/A is returned by a successful call to
546N/A <
code class="function">lwres_getnamebyaddr()</
code>.
546N/A <
code class="function">lwres_getaddrsbyname()</
code>
546N/A <
code class="function">lwres_getnamebyaddr()</
code>
546N/A <
span class="errorcode">LWRES_R_NOMEMORY</
span>
546N/A when memory allocation requests fail and
546N/A <
span class="errorcode">LWRES_R_UNEXPECTEDEND</
span>
546N/A if the buffers used for sending queries and receiving replies are too
546N/A<
div class="refsect1" lang="en">
546N/A<
a name="id2514427"></
a><
h2>SEE ALSO</
h2>
546N/A<
p><
span class="citerefentry"><
span class="refentrytitle">lwres_buffer</
span>(3)</
span>,
1233N/A <
span class="citerefentry"><
span class="refentrytitle">lwres_gabn</
span>(3)</
span>.