98N/A - Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC") 70N/A - This Source Code Form is subject to the terms of the Mozilla Public 70N/A - License, v. 2.0. If a copy of the MPL was not distributed with this 70N/A<
meta http-
equiv="Content-Type" content="text/html; charset=ISO-8859-1">
70N/A<
title>lwres_gnba</
title>
70N/A<
meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
70N/A<
body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><
div class="refentry">
70N/A<
a name="id-1"></
a><
div class="titlepage"></
div>
70N/A<
div class="refnamediv">
70N/A<
p>lwres_gnbarequest_render, lwres_gnbaresponse_render, lwres_gnbarequest_parse, lwres_gnbaresponse_parse, lwres_gnbaresponse_free, lwres_gnbarequest_free — lightweight resolver getnamebyaddress message handling</
p>
70N/A<
div class="refsynopsisdiv">
70N/A<
div class="funcsynopsis">
70N/A<
pre class="funcsynopsisinfo">
70N/A<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
70N/A<
td><
code class="funcdef">
262N/A<
b class="fsfunc">lwres_gnbarequest_render</
b>
70N/A<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
231N/A<
td>lwres_gnbarequest_t *<
var class="pdparam">req</
var>, </
td>
70N/A<
td>lwres_lwpacket_t *<
var class="pdparam">pkt</
var>, </
td>
262N/A<
td>lwres_buffer_t *<
var class="pdparam">b</
var><
code>)</
code>;</
td>
70N/A<
div class="funcprototype-spacer">�</
div>
70N/A<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
98N/A<
td><
code class="funcdef">
98N/A<
b class="fsfunc">lwres_gnbaresponse_render</
b>
156N/A<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
70N/A<
td>lwres_gnbaresponse_t *<
var class="pdparam">req</
var>, </
td>
70N/A<
td>lwres_lwpacket_t *<
var class="pdparam">pkt</
var>, </
td>
70N/A<
td>lwres_buffer_t *<
var class="pdparam">b</
var><
code>)</
code>;</
td>
70N/A<
div class="funcprototype-spacer">�</
div>
70N/A<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
70N/A<
td><
code class="funcdef">
253N/A<
b class="fsfunc">lwres_gnbarequest_parse</
b>(</
code></
td>
70N/A<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
<
td>lwres_buffer_t *<
var class="pdparam">b</
var>, </
td>
<
td>lwres_lwpacket_t *<
var class="pdparam">pkt</
var>, </
td>
<
td>lwres_gnbarequest_t **<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
<
div class="funcprototype-spacer">�</
div>
<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_gnbaresponse_parse</
b>(</
code></
td>
<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
<
td>lwres_buffer_t *<
var class="pdparam">b</
var>, </
td>
<
td>lwres_lwpacket_t *<
var class="pdparam">pkt</
var>, </
td>
<
td>lwres_gnbaresponse_t **<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
<
div class="funcprototype-spacer">�</
div>
<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_gnbaresponse_free</
b>
<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
<
td>lwres_gnbaresponse_t **<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
<
div class="funcprototype-spacer">�</
div>
<
table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
<
td><
code class="funcdef">
<
b class="fsfunc">lwres_gnbarequest_free</
b>(</
code></
td>
<
td>lwres_context_t *<
var class="pdparam">ctx</
var>, </
td>
<
td>lwres_gnbarequest_t **<
var class="pdparam">structp</
var><
code>)</
code>;</
td>
<
div class="funcprototype-spacer">�</
div>
<
a name="id-1.7"></
a><
h2>DESCRIPTION</
h2>
These are low-level routines for creating and parsing
lightweight resolver address-to-name lookup request and
There are four main functions for the getnamebyaddr opcode.
One render function converts a getnamebyaddr request structure —
<
span class="type">lwres_gnbarequest_t</
span> —
to the lightweight resolver's canonical format.
It is complemented by a parse function that converts a packet in this
canonical format to a getnamebyaddr request structure.
Another render function converts the getnamebyaddr response structure
<
span class="type">lwres_gnbaresponse_t</
span>
This is complemented by a parse function which converts a packet in
canonical format to a getnamebyaddr response structure.
These structures are defined in
<
pre class="programlisting">
#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
<
pre class="programlisting">
<
pre class="programlisting">
lwres_uint16_t realnamelen;
lwres_uint16_t *aliaslen;
<
p><
code class="function">lwres_gnbarequest_render()</
code>
uses resolver context <
code class="varname">ctx</
code> to convert
getnamebyaddr request structure <
code class="varname">req</
code> to
canonical format. The packet header structure
<
code class="varname">pkt</
code> is initialised and transferred to buffer
<
code class="varname">b</
code>. The contents of <
code class="varname">*req</
code>
are then appended to the buffer in canonical format.
<
code class="function">lwres_gnbaresponse_render()</
code> performs the
same task, except it converts a getnamebyaddr response structure
<
span class="type">lwres_gnbaresponse_t</
span> to the lightweight resolver's
<
p><
code class="function">lwres_gnbarequest_parse()</
code>
uses context <
code class="varname">ctx</
code> to convert the contents of
packet <
code class="varname">pkt</
code> to a
<
span class="type">lwres_gnbarequest_t</
span> structure. Buffer
<
code class="varname">b</
code> provides space to be used for storing this
structure. When the function succeeds, the resulting
<
span class="type">lwres_gnbarequest_t</
span> is made available through
<
code class="varname">*structp</
code>.
<
code class="function">lwres_gnbaresponse_parse()</
code> offers the same
semantics as <
code class="function">lwres_gnbarequest_parse()</
code>
except it yields a <
span class="type">lwres_gnbaresponse_t</
span> structure.
<
p><
code class="function">lwres_gnbaresponse_free()</
code>
and <
code class="function">lwres_gnbarequest_free()</
code> release the
memory in resolver context <
code class="varname">ctx</
code> that was
allocated to the <
span class="type">lwres_gnbaresponse_t</
span> or
<
span class="type">lwres_gnbarequest_t</
span> structures referenced via
<
code class="varname">structp</
code>. Any memory associated with
ancillary buffers and strings for those structures is also
<
a name="id-1.8"></
a><
h2>RETURN VALUES</
h2>
The getnamebyaddr opcode functions
<
code class="function">lwres_gnbarequest_render()</
code>,
<
code class="function">lwres_gnbaresponse_render()</
code>
<
code class="function">lwres_gnbarequest_parse()</
code>
<
code class="function">lwres_gnbaresponse_parse()</
code>
<
span class="errorcode">LWRES_R_SUCCESS</
span>
<
span class="errorcode">LWRES_R_NOMEMORY</
span>
if memory allocation fails.
<
span class="errorcode">LWRES_R_UNEXPECTEDEND</
span>
is returned if the available space in the buffer
<
code class="varname">b</
code>
is too small to accommodate the packet header or the
<
span class="type">lwres_gnbarequest_t</
span>
<
span class="type">lwres_gnbaresponse_t</
span>
<
code class="function">lwres_gnbarequest_parse()</
code>
<
code class="function">lwres_gnbaresponse_parse()</
code>
<
span class="errorcode">LWRES_R_UNEXPECTEDEND</
span>
if the buffer is not empty after decoding the received packet.
These functions will return
<
span class="errorcode">LWRES_R_FAILURE</
span>
<
code class="varname">pktflags</
code>
in the packet header structure
<
span class="type">lwres_lwpacket_t</
span>
indicate that the packet is not a response to an earlier query.
<
a name="id-1.9"></
a><
h2>SEE ALSO</
h2>
<
p><
span class="citerefentry"><
span class="refentrytitle">lwres_packet</
span>(3)</
span>.