15N/A<!
DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
15N/A - Copyright (C) 2001 Internet Software Consortium. 15N/A - Permission to use, copy, modify, and distribute this software for any 15N/A - purpose with or without fee is hereby granted, provided that the above 15N/A - copyright notice and this permission notice appear in all copies. 15N/A - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 15N/A - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 15N/A - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 15N/A - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 15N/A - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 15N/A - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 15N/A - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 15N/A - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. <
date>Jun 30, 2000</
date>
<
refentrytitle>lwres_resutil</
refentrytitle>
<
refmiscinfo>BIND9</
refmiscinfo>
<
refname>lwres_string_parse</
refname>
<
refname>lwres_addr_parse</
refname>
<
refname>lwres_getaddrsbyname</
refname>
<
refname>lwres_getnamebyaddr</
refname>
<
refpurpose>lightweight resolver utility functions</
refpurpose>
<
funcsynopsisinfo>#include <
lwres/
lwres.h></
funcsynopsisinfo>
<
function>lwres_string_parse</
function></
funcdef>
<
paramdef>lwres_buffer_t *b</
paramdef>
<
paramdef>char **c</
paramdef>
<
paramdef>lwres_uint16_t *len</
paramdef>
<
function>lwres_addr_parse</
function></
funcdef>
<
paramdef>lwres_buffer_t *b</
paramdef>
<
paramdef>lwres_addr_t *addr</
paramdef>
<
function>lwres_getaddrsbyname</
function></
funcdef>
<
paramdef>lwres_context_t *ctx</
paramdef>
<
paramdef>const char *name</
paramdef>
<
paramdef>lwres_uint32_t addrtypes</
paramdef>
<
paramdef>lwres_gabnresponse_t **structp</
paramdef>
<
function>lwres_getnamebyaddr</
function></
funcdef>
<
paramdef>lwres_context_t *ctx</
paramdef>
<
paramdef>lwres_uint32_t addrtype</
paramdef>
<
paramdef>lwres_uint16_t addrlen</
paramdef>
<
paramdef>const unsigned char *addr</
paramdef>
<
paramdef>lwres_gnbaresponse_t **structp</
paramdef>
<
title>DESCRIPTION</
title>
<
function>lwres_string_parse()</
function>
retrieves a DNS-encoded string starting the current pointer of
lightweight resolver buffer
<
parameter>b</
parameter>:
<
constant>b->current</
constant>.
When the function returns, the address of the first byte of the
encoded string is returned via
<
parameter>*c</
parameter>
and the length of that string is given by
<
parameter>*len</
parameter>.
The buffer's current pointer is advanced to point at the character
following the string length, the encoded string, and the trailing
<
function>lwres_string_parse()</
function>
has an assertion check that
<
function>lwres_addr_parse()</
function>
extracts an address from the buffer
<
parameter>b</
parameter>.
<
parameter>addr</
parameter>
The buffer's current pointer
<
constant>b->current</
constant>
is presumed to point at an encoded address: the address preceded by a
32-bit protocol family identifier and a 16-bit length field.
The encoded address is copied to
<
constant>addr->address</
constant>
<
constant>addr->length</
constant>
indicates the size in bytes of the address that was copied.
<
constant>b->current</
constant>
is advanced to point at the next byte of available data in the buffer
following the encoded address.
<
function>lwres_getaddrsbyname()</
function>
<
function>lwres_getnamebyaddr()</
function>
<
type>lwres_gnbaresponse_t</
type>
lwres_uint16_t realnamelen;
lwres_uint16_t *aliaslen;
The contents of this structure are not manipulated directly but
they are controlled through the
<
refentrytitle>lwres_gabn</
refentrytitle><
manvolnum>3
The lightweight resolver uses
<
function>lwres_getaddrsbyname()</
function>
to perform foward lookups.
<
parameter>name</
parameter>
is looked up using the resolver context
<
parameter>ctx</
parameter>
<
parameter>addrtypes</
parameter>
is a bitmask indicating which type of addresses are to be looked up.
Current values for this bitmask are
<
type>LWRES_ADDRTYPE_V4</
type>
<
type>LWRES_ADDRTYPE_V6</
type>
Results of the lookup are returned in
<
parameter>*structp</
parameter>.
<
function>lwres_getaddrsbyname()</
function>
checks that its pointer arguments are not
<
parameter>addrtypes</
parameter>
<
function>lwres_getnamebyaddr()</
function>
performs reverse lookups.
<
parameter>ctx</
parameter>
is used for memory allocation.
The address type is indicated by
<
parameter>addrtype</
parameter>:
<
type>LWRES_ADDRTYPE_V4</
type>
<
type>LWRES_ADDRTYPE_V6</
type>.
The address to be looked up is given by
<
parameter>addr</
parameter>
<
parameter>addrlen</
parameter>
The result of the function call is made available through
<
parameter>*structp</
parameter>.
<
function>lwres_getaddrsbyname()</
function>,
<
function>lwres_getnamebyaddr()</
function>
uses assertion checking to ensure its pointer arguments are not
<
parameter>addrtype</
parameter>
<
function>lwres_getaddrsbyname()</
function>
<
parameter>addrlen</
parameter>
<
title>RETURN VALUES</
title>
<
function>lwres_string_parse()</
function>
<
function>lwres_addr_parse()</
function>
<
errorcode>LWRES_R_SUCCESS.</
errorcode>
<
errorcode>LWRES_R_FAILURE</
errorcode>
if the buffer is corrupt or
<
errorcode>LWRES_R_UNEXPECTEDEND</
errorcode>
if the buffer has less space than expected for the components of the
encoded string or address.
<
function>lwres_getaddrsbyname()</
function>
<
errorcode>LWRES_R_SUCCESS</
errorcode>
on success and it returns
<
errorcode>LWRES_R_NOTFOUND</
errorcode>
<
parameter>name</
parameter>
<
errorcode>LWRES_R_SUCCESS</
errorcode>
is returned by a successful call to
<
function>lwres_getnamebyaddr()</
function>.
<
function>lwres_getaddrsbyname()</
function>
<
function>lwres_getnamebyaddr()</
function>
<
errorcode>LWRES_R_NOMEMORY</
errorcode>
when memory allocation requests fail and
<
errorcode>LWRES_R_UNEXPECTEDEND</
errorcode>
if the buffers used for sending queries and receiving replies are too
<
refentrytitle>lwres_buffer</
refentrytitle><
manvolnum>3</
manvolnum>
<
refentrytitle>lwres_gabn</
refentrytitle><
manvolnum>3</
manvolnum>