823N/A - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") 823N/A - Copyright (C) 2000, 2001 Internet Software Consortium. 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 - 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<
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<
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<
p>lwres_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free — lightweight resolver getaddrbyname message handling</
p>
823N/A<
div class="refsynopsisdiv">
823N/A<
div class="funcsynopsis">
1593N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnrequest_render</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
897N/A<
td>lwres_gabnrequest_t *�</
td>
823N/A<
var class="pdparam">req</
var>, </
td>
897N/A<
td>lwres_lwpacket_t *�</
td>
897N/A<
var class="pdparam">pkt</
var>, </
td>
823N/A<
td>lwres_buffer_t *�</
td>
823N/A<
var class="pdparam">b</
var><
code>)</
code>;</
td>
823N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnresponse_render</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
823N/A<
td>lwres_gabnresponse_t *�</
td>
823N/A<
var class="pdparam">req</
var>, </
td>
823N/A<
td>lwres_lwpacket_t *�</
td>
823N/A<
var class="pdparam">pkt</
var>, </
td>
823N/A<
td>lwres_buffer_t *�</
td>
823N/A<
var class="pdparam">b</
var><
code>)</
code>;</
td>
823N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnrequest_parse</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
2086N/A<
var class="pdparam">b</
var>, </
td>
823N/A<
td>lwres_lwpacket_t *�</
td>
823N/A<
var class="pdparam">pkt</
var>, </
td>
823N/A<
td>lwres_gabnrequest_t **�</
td>
823N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
823N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnresponse_parse</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
823N/A<
td>lwres_buffer_t *�</
td>
823N/A<
var class="pdparam">b</
var>, </
td>
823N/A<
td>lwres_lwpacket_t *�</
td>
823N/A<
var class="pdparam">pkt</
var>, </
td>
823N/A<
td>lwres_gabnresponse_t **�</
td>
823N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
823N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnresponse_free</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
823N/A<
td>lwres_gabnresponse_t **�</
td>
823N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
823N/A<
table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
823N/A<
td><
code class="funcdef">
823N/A<
b class="fsfunc">lwres_gabnrequest_free</
b>(</
code></
td>
823N/A<
td>lwres_context_t *�</
td>
823N/A<
var class="pdparam">ctx</
var>, </
td>
823N/A<
td>lwres_gabnrequest_t **�</
td>
823N/A<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
823N/A<
div class="refsect1" lang="en">
823N/A<
a name="id2514347"></
a><
h2>DESCRIPTION</
h2>
823N/A These are low-level routines for creating and parsing
823N/A lightweight resolver name-to-address lookup request and
823N/A There are four main functions for the getaddrbyname opcode.
823N/A One render function converts a getaddrbyname request structure —
823N/A <
span class="type">lwres_gabnrequest_t</
span> —
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 — <
span class="type">lwres_gabnresponse_t</
span> —
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 These structures are defined in
823N/A<
pre class="programlisting">
823N/A#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
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 class="programlisting">
823N/A lwres_uint32_t addrtypes;
823N/A lwres_uint16_t namelen;
823N/A<
pre class="programlisting">
823N/A lwres_uint16_t naliases;
823N/A lwres_uint16_t realnamelen;
823N/A lwres_uint16_t *aliaslen;
823N/A lwres_addrlist_t addrs;
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 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<
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 <
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><
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>.
1022N/A Any memory associated with ancillary buffers and strings for
823N/A those structures is also discarded.
823N/A<
div class="refsect1" lang="en">
823N/A<
a name="id2514629"></
a><
h2>RETURN VALUES</
h2>
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>
1022N/A <
code class="function">lwres_gabnresponse_parse()</
code>
1022N/A <
span class="errorcode">LWRES_R_SUCCESS</
span>
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 <
span class="type">lwres_gabnresponse_t</
span>
823N/A <
code class="function">lwres_gabnrequest_parse()</
code>
823N/A <
code class="function">lwres_gabnresponse_parse()</
code>
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 <
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<
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>