lwres_gabn.html revision ddccd5811feff696ba460dabfb666ce61040f545
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - Copyright (C) 2000, 2001 Internet Software Consortium.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - Permission to use, copy, modify, and distribute this software for any
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - purpose with or without fee is hereby granted, provided that the above
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - copyright notice and this permission notice appear in all copies.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabn</TITLE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonNAME="GENERATOR"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCONTENT="Modular DocBook HTML Stylesheet Version 1.61
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFENTRY"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonBGCOLOR="#FFFFFF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonVLINK="#840084"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonALINK="#0000FF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFNAMEDIV"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_render, lwres_gabnresponse_render, lwres_gabnrequest_parse, lwres_gabnresponse_parse, lwres_gabnresponse_free, lwres_gabnrequest_free -- lightweight resolver getaddrbyname message handling</DIV
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFSYNOPSISDIV"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCSYNOPSIS"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCSYNOPSISINFO"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_result_t
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnrequest_render</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_gabnrequest_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_result_t
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnresponse_render</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_gabnresponse_t *req, lwres_lwpacket_t *pkt, lwres_buffer_t *b);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_result_t
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnrequest_parse</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gabnrequest_t **structp);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_result_t
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnresponse_parse</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_buffer_t *b, lwres_lwpacket_t *pkt, lwres_gabnresponse_t **structp);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnresponse_free</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_gabnresponse_t **structp);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCDEF"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlwres_gabnrequest_free</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>(lwres_context_t *ctx, lwres_gabnrequest_t **structp);</CODE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFSECT1"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>DESCRIPTION</H2
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>These are low-level routines for creating and parsing
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonlightweight resolver name-to-address lookup request and
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonresponse messages.</P
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>There are four main functions for the getaddrbyname opcode.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonOne render function converts a getaddrbyname request structure —
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto the lighweight resolver's canonical format.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonIt is complemented by a parse function that converts a packet in this
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssoncanonical format to a getaddrbyname request structure.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonAnother render function converts the getaddrbyname response structure —
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto the canonical format.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThis is complemented by a parse function which converts a packet in
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssoncanonical format to a getaddrbyname response structure.</P
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>These structures are defined in
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FILENAME"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThey are shown below.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PROGRAMLISTING"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef struct lwres_addr lwres_addr_t;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef struct {
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint32_t flags;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint32_t addrtypes;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint16_t namelen;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson} lwres_gabnrequest_t;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssontypedef struct {
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint32_t flags;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint16_t naliases;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint16_t naddrs;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson char *realname;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson char **aliases;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint16_t realnamelen;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_uint16_t *aliaslen;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson lwres_addrlist_t addrs;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson size_t baselen;
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson} lwres_gabnresponse_t;</PRE
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_render()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonuses resolver context
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto convert getaddrbyname request structure
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto canonical format.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe packet header structure
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis initialised and transferred to
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThe contents of
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonare then appended to the buffer in canonical format.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_render()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonperforms the same task, except it converts a getaddrbyname response structure
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto the lightweight resolver's canonical format.</P
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonto convert the contents of packet
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonprovides space to be used for storing this structure.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonWhen the function succeeds, the resulting
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis made available through
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonoffers the same semantics as
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonexcept it yields a
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_free()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_free()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonrelease the memory in resolver context
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonthat was allocated to the
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstructures referenced via
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonAny memory associated with ancillary buffers and strings for those
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonstructures is also discarded.</P
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFSECT1"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>RETURN VALUES</H2
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>The getaddrbyname opcode functions
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_render()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_render()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="ERRORCODE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>LWRES_R_SUCCESS</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="ERRORCODE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>LWRES_R_NOMEMORY</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonif memory allocation fails.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="ERRORCODE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>LWRES_R_UNEXPECTEDEND</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis returned if the available space in the buffer
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="PARAMETER"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonis too small to accommodate the packet header or the
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnrequest_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="FUNCTION"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_gabnresponse_parse()</TT
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="ERRORCODE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>LWRES_R_UNEXPECTEDEND</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonif the buffer is not empty after decoding the received packet.
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonThese functions will return
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="ERRORCODE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>LWRES_R_FAILURE</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="STRUCTFIELD"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonin the packet header structure
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_lwpacket_t</SPAN
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafssonindicate that the packet is not a response to an earlier query.</P
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFSECT1"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="CITEREFENTRY"
ddccd5811feff696ba460dabfb666ce61040f545Andreas GustafssonCLASS="REFENTRYTITLE"
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson>lwres_packet</SPAN