lwres_gnba.html revision 7911e6f9de303bca5a3d8b34f4330c8f7cecffae
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
32098293b78922a5fbd10906afa28624820d3756Tinderbox User - Copyright (C) 2000, 2001, 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - This Source Code Form is subject to the terms of the Mozilla Public
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - License, v. 2.0. If a copy of the MPL was not distributed with this
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User - file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbarequest_render,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbaresponse_render,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbarequest_parse,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbaresponse_parse,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbaresponse_free,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_gnbarequest_free
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User — lightweight resolver getnamebyaddress message handling
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlwres_result_t
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<b class="fsfunc">lwres_gnbarequest_render</b>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<td>lwres_gnbarequest_t *<var class="pdparam">req</var>, </td>
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<td>lwres_gnbaresponse_t *<var class="pdparam">req</var>, </td>
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<td>lwres_buffer_t *<var class="pdparam">b</var><code>)</code>;</td>
af40ebed6257e4ac1996144530b3de317cf4da11Tinderbox User<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntlwres_result_t
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<b class="fsfunc">lwres_gnbarequest_parse</b>(</code></td>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrewslwres_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gnbaresponse_parse</b>(</code></td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_buffer_t *<var class="pdparam">b</var>, </td>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<td>lwres_lwpacket_t *<var class="pdparam">pkt</var>, </td>
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User<td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<td>lwres_gnbaresponse_t **<var class="pdparam">structp</var><code>)</code>;</td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;">
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<b class="fsfunc">lwres_gnbarequest_free</b>(</code></td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_context_t *<var class="pdparam">ctx</var>, </td>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<td>lwres_gnbarequest_t **<var class="pdparam">structp</var><code>)</code>;</td>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews These are low-level routines for creating and parsing
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews lightweight resolver address-to-name lookup request and
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews response messages.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews There are four main functions for the getnamebyaddr opcode.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews One render function converts a getnamebyaddr request structure —
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews <span class="type">lwres_gnbarequest_t</span> —
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews to the lightweight resolver's canonical format.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews It is complemented by a parse function that converts a packet in this
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews canonical format to a getnamebyaddr request structure.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews Another render function converts the getnamebyaddr response structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein to the canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein This is complemented by a parse function which converts a packet in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format to a getnamebyaddr response structure.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein These structures are defined in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein They are shown below.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U
afb33f777af856f8c3382604a7a8ffdfe2b512c5Automatic Updatertypedef struct {
afb33f777af856f8c3382604a7a8ffdfe2b512c5Automatic Updater lwres_uint32_t flags;
afb33f777af856f8c3382604a7a8ffdfe2b512c5Automatic Updater lwres_addr_t addr;
afb33f777af856f8c3382604a7a8ffdfe2b512c5Automatic Updater} lwres_gnbarequest_t;
afb33f777af856f8c3382604a7a8ffdfe2b512c5Automatic Updatertypedef struct {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_uint32_t flags;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_uint16_t naliases;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein char *realname;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein char **aliases;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_uint16_t realnamelen;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein lwres_uint16_t *aliaslen;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein size_t baselen;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt} lwres_gnbaresponse_t;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <p><code class="function">lwres_gnbarequest_render()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein uses resolver context <code class="varname">ctx</code> to convert
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein getnamebyaddr request structure <code class="varname">req</code> to
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format. The packet header structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="varname">pkt</code> is initialised and transferred to buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="varname">b</code>. The contents of <code class="varname">*req</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein are then appended to the buffer in canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gnbaresponse_render()</code> performs the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein same task, except it converts a getnamebyaddr response structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_gnbaresponse_t</span> to the lightweight resolver's
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein canonical format.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <p><code class="function">lwres_gnbarequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein uses context <code class="varname">ctx</code> to convert the contents of
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_gnbarequest_t</span> structure. Buffer
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="varname">b</code> provides space to be used for storing this
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein structure. When the function succeeds, the resulting
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="type">lwres_gnbarequest_t</span> is made available through
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt <code class="function">lwres_gnbaresponse_parse()</code> offers the same
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews semantics as <code class="function">lwres_gnbarequest_parse()</code>
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews except it yields a <span class="type">lwres_gnbaresponse_t</span> structure.
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews <p><code class="function">lwres_gnbaresponse_free()</code>
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews and <code class="function">lwres_gnbarequest_free()</code> release the
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews memory in resolver context <code class="varname">ctx</code> that was
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews allocated to the <span class="type">lwres_gnbaresponse_t</span> or
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews <span class="type">lwres_gnbarequest_t</span> structures referenced via
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="varname">structp</code>. Any memory associated with
ceeb18e6907a10547859faa340ecad83bedae90cMark Andrews ancillary buffers and strings for those structures is also
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein The getnamebyaddr opcode functions
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gnbarequest_render()</code>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gnbaresponse_render()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gnbarequest_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <code class="function">lwres_gnbaresponse_parse()</code>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if memory allocation fails.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein is returned if the available space in the buffer
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User is too small to accommodate the packet header or the
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <span class="type">lwres_gnbarequest_t</span>
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <span class="type">lwres_gnbaresponse_t</span>
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <code class="function">lwres_gnbarequest_parse()</code>
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <code class="function">lwres_gnbaresponse_parse()</code>
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <span class="errorcode">LWRES_R_UNEXPECTEDEND</span>
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User if the buffer is not empty after decoding the received packet.
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User These functions will return
3a32ac2a720653083c7a22cb654b86c398f6d4c8Tinderbox User <span class="errorcode">LWRES_R_FAILURE</span>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein in the packet header structure
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein indicate that the packet is not a response to an earlier query.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <span class="refentrytitle">lwres_packet</span>(3)