lwres_gnba.docbook revision 9ffbbce6a624b6051b3d001edcbad1e02c69bd45
012a352f4b26cfd874db8d06debc495c2303e8b2Bob Halley<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
178f6ad061e54bc5babfca3577f72058fa0797c1Bob Halley<!--
33cc94f04cb44dc247f605a954e45e5adc699977Automatic Updater - Copyright (C) 2000, 2001 Internet Software Consortium.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews -
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence - Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater - purpose with or without fee is hereby granted, provided that the above
178f6ad061e54bc5babfca3577f72058fa0797c1Bob Halley - copyright notice and this permission notice appear in all copies.
178f6ad061e54bc5babfca3577f72058fa0797c1Bob Halley -
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
b897c52f865b2fc4e220e2110b874e59c716456bBob Halley-->
f5cfcbf2f7906fb59c2b8b9b8fc9c7a75ac44dabMark Andrews
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence<!-- $Id: lwres_gnba.docbook,v 1.1 2001/03/29 02:23:11 gson Exp $ -->
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<refentry>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<refentryinfo>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<date>Jun 30, 2000</date>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</refentryinfo>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley <refmeta>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley <refentrytitle>lwres_gnba</refentrytitle>
b897c52f865b2fc4e220e2110b874e59c716456bBob Halley <manvolnum>3</manvolnum>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley <refmiscinfo>BIND9</refmiscinfo>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley </refmeta>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<refnamediv>
b897c52f865b2fc4e220e2110b874e59c716456bBob Halley<refname>lwres_gnbarequest_render</refname>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<refname>lwres_gnbaresponse_render</refname>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<refname>lwres_gnbarequest_parse</refname>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<refname>lwres_gnbaresponse_parse</refname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<refname>lwres_gnbaresponse_free</refname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<refname>lwres_gnbarequest_free</refname>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<refpurpose>lightweight resolver getnamebyaddress message handling</refpurpose>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence</refnamediv>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence
fcb54ce0a4f7377486df5bec83b3aa4711bf4131Mark Andrews<refsynopsisdiv>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<funcsynopsis>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<funcsynopsisinfo>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence#include &lt;lwres/lwres.h&gt;
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence</funcsynopsisinfo>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<funcprototype>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<funcdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrencelwres_result_t
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<function>lwres_gnbarequest_render</function>
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews</funcdef>
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews<paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews<paramdef>lwres_gnbarequest_t *<parameter>req</parameter></paramdef>
f5cfcbf2f7906fb59c2b8b9b8fc9c7a75ac44dabMark Andrews<paramdef>lwres_lwpacket_t *<parameter>pkt</parameter></paramdef>
f5cfcbf2f7906fb59c2b8b9b8fc9c7a75ac44dabMark Andrews<paramdef>lwres_buffer_t *<parameter>b</parameter></paramdef>
2d46d268ccff30bb50e661b47c6496d23d9156c7Mark Andrews</funcprototype>
2d46d268ccff30bb50e661b47c6496d23d9156c7Mark Andrews
dabea86dac4c01f852b7aea728f73b4f55a89d44Mark Andrews<funcprototype>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<funcdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrencelwres_result_t
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<function>lwres_gnbaresponse_render</function>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence</funcdef>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<paramdef>lwres_context_t *ctx</paramdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<paramdef>lwres_gnbaresponse_t *req</paramdef>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<paramdef>lwres_lwpacket_t *pkt</paramdef>
596912ee9ca8eb14d30707ec286ab5d28bd39b3eMark Andrews<paramdef>lwres_buffer_t *b</paramdef>
8319af16557b81eba3277ee67215285f0823b587Mark Andrews</funcprototype>
8319af16557b81eba3277ee67215285f0823b587Mark Andrews<funcprototype>
aee5e9cbacd8f88325840b8a498876f4319b0890Mark Andrews<funcdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrencelwres_result_t
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<function>lwres_gnbarequest_parse</function></funcdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<paramdef>lwres_context_t *ctx</paramdef>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<paramdef>lwres_buffer_t *b</paramdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<paramdef>lwres_lwpacket_t *pkt</paramdef>
c32b87bc54abacf95fb3b063d72b7d1855c1643bMichael Graff<paramdef>lwres_gnbarequest_t **structp</paramdef>
7f9f8c13c5e5e26e0ba2b82c0900d11ecf6269ceMark Andrews</funcprototype>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<funcprototype>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<funcdef>
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrencelwres_result_t
12e63bfe1d111ccb57f482b28d56c785cccc7cf7David Lawrence<function>lwres_gnbaresponse_parse</function></funcdef>
460b427411b72da26b1836b9424e2e70d65d9394David Lawrence<paramdef>lwres_context_t *ctx</paramdef>
b616f6ed69209ab4c87f610b472aeb20760652f2Mark Andrews<paramdef>lwres_buffer_t *b</paramdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<paramdef>lwres_lwpacket_t *pkt</paramdef>
2320f230995995595438a9d9301d84931fd266ceMark Andrews<paramdef>lwres_gnbaresponse_t **structp</paramdef>
c427260a8678f2e99a2337fb95ec98d9c9ee8c05Mark Andrews</funcprototype>
620a452ebe92fff63e85c5930a6e6dc8d9455918Mark Andrews
620a452ebe92fff63e85c5930a6e6dc8d9455918Mark Andrews<funcprototype>
6dcb47e37f9f0cdb94bdabc3fa157ff07983c590Mark Andrews<funcdef>
6dcb47e37f9f0cdb94bdabc3fa157ff07983c590Mark Andrewsvoid
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<function>lwres_gnbaresponse_free</function>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</funcdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<paramdef>lwres_context_t *ctx</paramdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<paramdef>lwres_gnbaresponse_t **structp</paramdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</funcprototype>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<funcprototype>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<funcdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyvoid
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<function>lwres_gnbarequest_free</function></funcdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<paramdef>lwres_context_t *ctx</paramdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<paramdef>lwres_gnbarequest_t **structp</paramdef>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</funcprototype>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</funcsynopsis>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</refsynopsisdiv>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<refsect1>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<title>DESCRIPTION</title>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<para>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob HalleyThese are low-level routines for creating and parsing
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleylightweight resolver address-to-name lookup request and
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyresponse messages.
0014d6342b0d50ae37126ac16d5bf821d02ffff7David Lawrence</para>
0014d6342b0d50ae37126ac16d5bf821d02ffff7David Lawrence<para>
0014d6342b0d50ae37126ac16d5bf821d02ffff7David LawrenceThere are four main functions for the getnamebyaddr opcode.
0014d6342b0d50ae37126ac16d5bf821d02ffff7David LawrenceOne render function converts a getnamebyaddr request structure -
0014d6342b0d50ae37126ac16d5bf821d02ffff7David Lawrence<type>lwres_gnbarequest_t</type> -
0014d6342b0d50ae37126ac16d5bf821d02ffff7David Lawrenceto the lightweight resolver's canonical format.
a9558a6c63d9c6dbb2f3800b39ccb008652fcde3Mark AndrewsIt is complemented by a parse function that converts a packet in this
a9558a6c63d9c6dbb2f3800b39ccb008652fcde3Mark Andrewscanonical format to a getnamebyaddr request structure.
a9558a6c63d9c6dbb2f3800b39ccb008652fcde3Mark AndrewsAnother render function converts the getnamebyaddr response structure -
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews<type>lwres_gnbaresponse_t</type>
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsto the canonical format.
0014d6342b0d50ae37126ac16d5bf821d02ffff7David LawrenceThis is complemented by a parse function which converts a packet in
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleycanonical format to a getnamebyaddr response structure.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</para>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<para>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob HalleyThese structures are defined in
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<filename>lwres/lwres.h</filename>.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob HalleyThey are shown below.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<programlisting>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleytypedef struct {
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_uint32_t flags;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_addr_t addr;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley} lwres_gnbarequest_t;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleytypedef struct {
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_uint32_t flags;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_uint16_t naliases;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley char *realname;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley char **aliases;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_uint16_t realnamelen;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley lwres_uint16_t *aliaslen;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley void *base;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley size_t baselen;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley} lwres_gnbaresponse_t;
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</programlisting>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley</para>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<para>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<function>lwres_gnbarequest_render()</function>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyuses resolver context
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<varname>ctx</varname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyto convert getnamebyaddr request structure
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<varname>req</varname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyto canonical format.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob HalleyThe packet header structure
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<varname>pkt</varname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyis initialised and transferred to
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleybuffer
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<varname>b</varname>.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob HalleyThe contents of
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<varname>*req</varname>
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halleyare then appended to the buffer in canonical format.
0b72c791466d0807bcf22522b5ddb7da902c2720Bob Halley<function>lwres_gnbaresponse_render()</function>
performs the same task, except it converts a getnamebyaddr response structure
<type>lwres_gnbaresponse_t</type>
to the lightweight resolver's canonical format.
</para>
<para>
<function>lwres_gnbarequest_parse()</function>
uses context
<varname>ctx</varname>
to convert the contents of packet
<varname>pkt</varname>
to a
<type>lwres_gnbarequest_t</type>
structure.
Buffer
<varname>b</varname>
provides space to be used for storing this structure.
When the function succeeds, the resulting
<type>lwres_gnbarequest_t</type>
is made available through
<varname>*structp</varname>.
<function>lwres_gnbaresponse_parse()</function>
offers the same semantics as
<function>lwres_gnbarequest_parse()</function>
except it yields a
<type>lwres_gnbaresponse_t</type>
structure.
</para>
<para>
<function>lwres_gnbaresponse_free()</function>
and
<function>lwres_gnbarequest_free()</function>
release the memory in resolver context
<varname>ctx</varname>
that was allocated to the
<type>lwres_gnbaresponse_t</type>
or
<type>lwres_gnbarequest_t</type>
structures referenced via
<varname>structp</varname>.
Any memory associated with ancillary buffers and strings for those
structures is also discarded.
</para>
</refsect1>
<refsect1>
<title>RETURN VALUES</title>
<para>
The getnamebyaddr opcode functions
<function>lwres_gnbarequest_render()</function>,
<function>lwres_gnbaresponse_render()</function>
<function>lwres_gnbarequest_parse()</function>
and
<function>lwres_gnbaresponse_parse()</function>
all return
<errorname>LWRES_R_SUCCESS</errorname>
on success.
They return
<errorname>LWRES_R_NOMEMORY</errorname>
if memory allocation fails.
<errorname>LWRES_R_UNEXPECTEDEND</errorname>
is returned if the available space in the buffer
<varname>b</varname>
is too small to accommodate the packet header or the
<type>lwres_gnbarequest_t</type>
and
<type>lwres_gnbaresponse_t</type>
structures.
<function>lwres_gnbarequest_parse()</function>
and
<function>lwres_gnbaresponse_parse()</function>
will return
<errorname>LWRES_R_UNEXPECTEDEND</errorname>
if the buffer is not empty after decoding the received packet.
These functions will return
<errorname>LWRES_R_FAILURE</errorname>
if
<structfield>pktflags</structfield>
in the packet header structure
<type>lwres_lwpacket_t</type>
indicate that the packet is not a response to an earlier query.
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>lwres_packet</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>.
</refsect1>
</refentry>