lwres_resutil.docbook revision 8eea877894ea5bcf5cdd9ca124a8601ad421d753
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - Copyright (C) 2001 Internet Software Consortium.
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - Permission to use, copy, modify, and distribute this software for any
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - purpose with or without fee is hereby granted, provided that the above
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - copyright notice and this permission notice appear in all copies.
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User<!-- $Id: lwres_resutil.docbook,v 1.3 2001/04/24 18:11:26 gson Exp $ -->
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User <refentryinfo>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</refentryinfo>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<refpurpose>lightweight resolver utility functions</refpurpose>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</refnamediv>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<refsynopsisdiv>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<funcsynopsis>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<funcprototype>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntlwres_result_t
c42708dcc8ca18a41152251654d29f0cdd5b9533Tinderbox User</funcprototype>
c42708dcc8ca18a41152251654d29f0cdd5b9533Tinderbox User<funcprototype>
c42708dcc8ca18a41152251654d29f0cdd5b9533Tinderbox Userlwres_result_t
c42708dcc8ca18a41152251654d29f0cdd5b9533Tinderbox User<function>lwres_addr_parse</function></funcdef>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</funcprototype>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<funcprototype>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntlwres_result_t
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<function>lwres_getaddrsbyname</function></funcdef>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<paramdef>lwres_gabnresponse_t **structp</paramdef>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</funcprototype>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<funcprototype>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Userlwres_result_t
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User<paramdef>lwres_gnbaresponse_t **structp</paramdef>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</funcprototype>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</funcsynopsis>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</refsynopsisdiv>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntretrieves a DNS-encoded string starting the current pointer of
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntlightweight resolver buffer
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox UserWhen the function returns, the address of the first byte of the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntencoded string is returned via
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntand the length of that string is given by
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe buffer's current pointer is advanced to point at the character
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntfollowing the string length, the encoded string, and the trailing
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunthas an assertion check that
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Userextracts an address from the buffer
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntIt checks that
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe buffer's current pointer
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntis presumed to point at an encoded address: the address preceded by a
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt32-bit protocol family identifier and a 16-bit length field.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe encoded address is copied to
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntindicates the size in bytes of the address that was copied.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntis advanced to point at the next byte of available data in the buffer
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Userfollowing the encoded address.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntstructure defined below:
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<programlisting>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunttypedef struct {
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_uint32_t flags;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_uint16_t naliases;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_uint16_t naddrs;
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User char *realname;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt char **aliases;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_uint16_t realnamelen;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_uint16_t *aliaslen;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt lwres_addrlist_t addrs;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt size_t baselen;
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User} lwres_gabnresponse_t;
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</programlisting>
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox UserThe contents of this structure are not manipulated directly but
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Userthey are controlled through the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<citerefentry>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<refentrytitle>lwres_gabn</refentrytitle><manvolnum>3
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</citerefentry>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe lightweight resolver uses
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntto perform foward lookups.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntis looked up using the resolver context
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntfor memory allocation.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntis a bitmask indicating which type of addresses are to be looked up.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntCurrent values for this bitmask are
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntfor IPv4 addresses and
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntfor IPv6 addresses.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntResults of the lookup are returned in
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntchecks that its pointer arguments are not
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntperforms reverse lookups.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntResolver context
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Useris used for memory allocation.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe address type is indicated by
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox UserThe address to be looked up is given by
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntand its length is
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntThe result of the function call is made available through
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Useruses assertion checking to ensure its pointer arguments are not
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntalso checks that
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox UserSuccessful calls to
14a656f94b1fd0ababd84a772228dfa52276ba15Evan HuntBoth functions return
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntif the buffer is corrupt or
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Userif the buffer has less space than expected for the components of the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntencoded string or address.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunton success and it returns
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntif the hostname
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox Usercould not be found.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntis returned by a successful call to
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntwhen memory allocation requests fail and
e2b184f84e846bbcb764b6f0aef5dcd583d3d7a1Tinderbox Userif the buffers used for sending queries and receiving replies are too
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<citerefentry>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<refentrytitle>lwres_buffer</refentrytitle><manvolnum>3</manvolnum>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</citerefentry>,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<citerefentry>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt<refentrytitle>lwres_gabn</refentrytitle><manvolnum>3</manvolnum>
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt</citerefentry>.