lwres_gabn.html revision 75c0816e8295e180f4bc7f10db3d0d880383bc1c
823N/A<!--
823N/A - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
823N/A - Copyright (C) 2000, 2001 Internet Software Consortium.
823N/A -
823N/A - Permission to use, copy, modify, and distribute this software for any
823N/A - purpose with or without fee is hereby granted, provided that the above
823N/A - copyright notice and this permission notice appear in all copies.
823N/A -
823N/A - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
823N/A - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
823N/A - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
823N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
823N/A - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
823N/A - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
823N/A - PERFORMANCE OF THIS SOFTWARE.
823N/A-->
823N/A<!-- $Id: lwres_gabn.html,v 1.15 2005/05/13 03:14:13 marka Exp $ -->
823N/A<html>
873N/A<head>
823N/A<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
823N/A<title>lwres_gabn</title>
823N/A<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
823N/A</head>
823N/A<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
3215N/A<a name="id2456836"></a><div class="titlepage"></div>
823N/A<div class="refnamediv">
823N/A<h2>Name</h2>
823N/A<p>lwres_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free &#8212; lightweight resolver getaddrbyname message handling</p>
2086N/A</div>
823N/A<div class="refsynopsisdiv">
2086N/A<h2>Synopsis</h2>
823N/A<div class="funcsynopsis">
823N/A<pre class="funcsynopsisinfo">#include &lt;lwres/lwres.h&gt;</pre>
1593N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Alwres_result_t
823N/A<b class="fsfunc">lwres_gabnrequest_render</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
897N/A<td>lwres_gabnrequest_t *�</td>
823N/A<td>
823N/A<var class="pdparam">req</var>, </td>
823N/A</tr>
897N/A<tr>
897N/A<td>�</td>
897N/A<td>lwres_lwpacket_t *�</td>
897N/A<td>
897N/A<var class="pdparam">pkt</var>, </td>
823N/A</tr>
897N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_buffer_t *�</td>
823N/A<td>
823N/A<var class="pdparam">b</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Alwres_result_t
823N/A<b class="fsfunc">lwres_gabnresponse_render</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_gabnresponse_t *�</td>
823N/A<td>
823N/A<var class="pdparam">req</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_lwpacket_t *�</td>
823N/A<td>
823N/A<var class="pdparam">pkt</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_buffer_t *�</td>
823N/A<td>
823N/A<var class="pdparam">b</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Alwres_result_t
823N/A<b class="fsfunc">lwres_gabnrequest_parse</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
2086N/A<td>lwres_buffer_t *�</td>
2086N/A<td>
2086N/A<var class="pdparam">b</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_lwpacket_t *�</td>
823N/A<td>
823N/A<var class="pdparam">pkt</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_gabnrequest_t **�</td>
823N/A<td>
823N/A<var class="pdparam">structp</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Alwres_result_t
823N/A<b class="fsfunc">lwres_gabnresponse_parse</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_buffer_t *�</td>
823N/A<td>
823N/A<var class="pdparam">b</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_lwpacket_t *�</td>
823N/A<td>
823N/A<var class="pdparam">pkt</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_gabnresponse_t **�</td>
823N/A<td>
823N/A<var class="pdparam">structp</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Avoid
823N/A<b class="fsfunc">lwres_gabnresponse_free</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_gabnresponse_t **�</td>
823N/A<td>
823N/A<var class="pdparam">structp</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
823N/A<tr>
823N/A<td><code class="funcdef">
823N/Avoid
823N/A<b class="fsfunc">lwres_gabnrequest_free</b>(</code></td>
823N/A<td>lwres_context_t *�</td>
823N/A<td>
823N/A<var class="pdparam">ctx</var>, </td>
823N/A</tr>
823N/A<tr>
823N/A<td>�</td>
823N/A<td>lwres_gabnrequest_t **�</td>
823N/A<td>
823N/A<var class="pdparam">structp</var><code>)</code>;</td>
823N/A</tr>
823N/A</table>
823N/A</div>
823N/A</div>
823N/A<div class="refsect1" lang="en">
823N/A<a name="id2514347"></a><h2>DESCRIPTION</h2>
823N/A<p>
823N/A These are low-level routines for creating and parsing
823N/A lightweight resolver name-to-address lookup request and
823N/A response messages.
823N/A </p>
823N/A<p>
823N/A There are four main functions for the getaddrbyname opcode.
823N/A One render function converts a getaddrbyname request structure &#8212;
823N/A <span class="type">lwres_gabnrequest_t</span> &#8212;
823N/A to the lighweight resolver's canonical format.
823N/A It is complemented by a parse function that converts a packet in this
823N/A canonical format to a getaddrbyname request structure.
823N/A Another render function converts the getaddrbyname response structure
823N/A &#8212; <span class="type">lwres_gabnresponse_t</span> &#8212;
823N/A to the canonical format.
823N/A This is complemented by a parse function which converts a packet in
823N/A canonical format to a getaddrbyname response structure.
823N/A </p>
823N/A<p>
823N/A These structures are defined in
823N/A <code class="filename">&lt;lwres/lwres.h&gt;</code>.
823N/A They are shown below.
823N/A </p>
823N/A<pre class="programlisting">
823N/A#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
823N/A</pre>
823N/A<p>
823N/A </p>
823N/A<pre class="programlisting">
823N/Atypedef struct lwres_addr lwres_addr_t;
823N/Atypedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
823N/A</pre>
823N/A<p>
823N/A </p>
823N/A<pre class="programlisting">
823N/Atypedef struct {
823N/A lwres_uint32_t flags;
823N/A lwres_uint32_t addrtypes;
823N/A lwres_uint16_t namelen;
823N/A char *name;
823N/A} lwres_gabnrequest_t;
823N/A</pre>
823N/A<p>
823N/A </p>
823N/A<pre class="programlisting">
823N/Atypedef struct {
823N/A lwres_uint32_t flags;
823N/A lwres_uint16_t naliases;
823N/A lwres_uint16_t naddrs;
823N/A char *realname;
823N/A char **aliases;
823N/A lwres_uint16_t realnamelen;
823N/A lwres_uint16_t *aliaslen;
823N/A lwres_addrlist_t addrs;
823N/A void *base;
823N/A size_t baselen;
823N/A} lwres_gabnresponse_t;
823N/A</pre>
823N/A<p>
823N/A </p>
823N/A<p><code class="function">lwres_gabnrequest_render()</code>
823N/A uses resolver context <em class="parameter"><code>ctx</code></em> to convert
823N/A getaddrbyname request structure <em class="parameter"><code>req</code></em> to
823N/A canonical format. The packet header structure
823N/A <em class="parameter"><code>pkt</code></em> is initialised and transferred to
823N/A buffer <em class="parameter"><code>b</code></em>.
823N/A
823N/A The contents of <em class="parameter"><code>*req</code></em> are then appended to
823N/A the buffer in canonical format.
823N/A <code class="function">lwres_gabnresponse_render()</code> performs the
823N/A same task, except it converts a getaddrbyname response structure
1593N/A <span class="type">lwres_gabnresponse_t</span> to the lightweight resolver's
1593N/A canonical format.
1593N/A </p>
1593N/A<p><code class="function">lwres_gabnrequest_parse()</code>
1593N/A uses context <em class="parameter"><code>ctx</code></em> to convert the contents
1593N/A of packet <em class="parameter"><code>pkt</code></em> to a
1593N/A <span class="type">lwres_gabnrequest_t</span> structure. Buffer
1593N/A <em class="parameter"><code>b</code></em> provides space to be used for storing
1593N/A this structure. When the function succeeds, the resulting
1593N/A <span class="type">lwres_gabnrequest_t</span> is made available through
1593N/A <em class="parameter"><code>*structp</code></em>.
1593N/A
1593N/A <code class="function">lwres_gabnresponse_parse()</code> offers the same
1593N/A semantics as <code class="function">lwres_gabnrequest_parse()</code>
823N/A except it yields a <span class="type">lwres_gabnresponse_t</span> structure.
823N/A </p>
823N/A<p><code class="function">lwres_gabnresponse_free()</code>
823N/A and <code class="function">lwres_gabnrequest_free()</code> release the
823N/A memory in resolver context <em class="parameter"><code>ctx</code></em> that was
823N/A allocated to the <span class="type">lwres_gabnresponse_t</span> or
823N/A <span class="type">lwres_gabnrequest_t</span> structures referenced via
823N/A <em class="parameter"><code>structp</code></em>.
823N/A
1022N/A Any memory associated with ancillary buffers and strings for
823N/A those structures is also discarded.
823N/A </p>
823N/A</div>
823N/A<div class="refsect1" lang="en">
823N/A<a name="id2514629"></a><h2>RETURN VALUES</h2>
1022N/A<p>
823N/A The getaddrbyname opcode functions
1022N/A <code class="function">lwres_gabnrequest_render()</code>,
823N/A <code class="function">lwres_gabnresponse_render()</code>
1022N/A <code class="function">lwres_gabnrequest_parse()</code>
823N/A and
1022N/A <code class="function">lwres_gabnresponse_parse()</code>
1022N/A all return
1022N/A <span class="errorcode">LWRES_R_SUCCESS</span>
823N/A on success.
823N/A They return
823N/A <span class="errorcode">LWRES_R_NOMEMORY</span>
823N/A if memory allocation fails.
823N/A <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
823N/A is returned if the available space in the buffer
823N/A <em class="parameter"><code>b</code></em>
823N/A is too small to accommodate the packet header or the
823N/A <span class="type">lwres_gabnrequest_t</span>
823N/A and
823N/A <span class="type">lwres_gabnresponse_t</span>
823N/A structures.
823N/A <code class="function">lwres_gabnrequest_parse()</code>
823N/A and
823N/A <code class="function">lwres_gabnresponse_parse()</code>
823N/A will return
823N/A <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
823N/A if the buffer is not empty after decoding the received packet.
823N/A These functions will return
823N/A <span class="errorcode">LWRES_R_FAILURE</span>
823N/A if
823N/A <em class="structfield"><code>pktflags</code></em>
823N/A in the packet header structure
823N/A <span class="type">lwres_lwpacket_t</span>
823N/A indicate that the packet is not a response to an earlier query.
823N/A </p>
823N/A</div>
823N/A<div class="refsect1" lang="en">
823N/A<a name="id2514695"></a><h2>SEE ALSO</h2>
823N/A<p><span class="citerefentry"><span class="refentrytitle">lwres_packet</span>(3)</span>
823N/A </p>
939N/A</div>
939N/A</div></body>
939N/A</html>
939N/A