Blame lib/lwres/man/lwres_context.docbook

Packit Service ae04f2
Packit Service ae04f2
]>
Packit Service ae04f2
Packit Service ae04f2
 - Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Packit Service ae04f2
 -
Packit Service ae04f2
 - This Source Code Form is subject to the terms of the Mozilla Public
Packit Service ae04f2
 - License, v. 2.0. If a copy of the MPL was not distributed with this
Packit Service ae04f2
 - file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit Service ae04f2
 -
Packit Service ae04f2
 - See the COPYRIGHT file distributed with this work for additional
Packit Service ae04f2
 - information regarding copyright ownership.
Packit Service ae04f2
-->
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
<refentry xmlns:db="http://docbook.org/ns/docbook" version="5.0">
Packit Service ae04f2
  <info>
Packit Service ae04f2
    <date>2007-06-18</date>
Packit Service ae04f2
  </info>
Packit Service ae04f2
  <refentryinfo>
Packit Service ae04f2
    <corpname>ISC</corpname>
Packit Service ae04f2
    <corpauthor>Internet Systems Consortium, Inc.</corpauthor>
Packit Service ae04f2
  </refentryinfo>
Packit Service ae04f2
Packit Service ae04f2
  <refmeta>
Packit Service ae04f2
    <refentrytitle>lwres_context</refentrytitle>
Packit Service ae04f2
    <manvolnum>3</manvolnum>
Packit Service ae04f2
    <refmiscinfo>BIND9</refmiscinfo>
Packit Service ae04f2
  </refmeta>
Packit Service ae04f2
Packit Service ae04f2
  <docinfo>
Packit Service ae04f2
    <copyright>
Packit Service ae04f2
      <year>2000</year>
Packit Service ae04f2
      <year>2001</year>
Packit Service ae04f2
      <year>2003</year>
Packit Service ae04f2
      <year>2004</year>
Packit Service ae04f2
      <year>2005</year>
Packit Service ae04f2
      <year>2007</year>
Packit Service ae04f2
      <year>2014</year>
Packit Service ae04f2
      <year>2015</year>
Packit Service ae04f2
      <year>2016</year>
Packit Service ae04f2
      <year>2018</year>
Packit Service ae04f2
      <year>2019</year>
Packit Service ae04f2
      <year>2020</year>
Packit Service ae04f2
      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
Packit Service ae04f2
    </copyright>
Packit Service ae04f2
  </docinfo>
Packit Service ae04f2
Packit Service ae04f2
  <refnamediv>
Packit Service ae04f2
    <refname>lwres_context_create</refname>
Packit Service ae04f2
    <refname>lwres_context_destroy</refname>
Packit Service ae04f2
    <refname>lwres_context_nextserial</refname>
Packit Service ae04f2
    <refname>lwres_context_initserial</refname>
Packit Service ae04f2
    <refname>lwres_context_freemem</refname>
Packit Service ae04f2
    <refname>lwres_context_allocmem</refname>
Packit Service ae04f2
    <refname>lwres_context_sendrecv</refname>
Packit Service ae04f2
    <refpurpose>lightweight resolver context management</refpurpose>
Packit Service ae04f2
  </refnamediv>
Packit Service ae04f2
  <refsynopsisdiv>
Packit Service ae04f2
    <funcsynopsis>
Packit Service ae04f2
<funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
lwres_result_t
Packit Service ae04f2
<function>lwres_context_create</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t **<parameter>contextp</parameter></paramdef>
Packit Service ae04f2
        <paramdef>void *<parameter>arg</parameter></paramdef>
Packit Service ae04f2
        <paramdef>lwres_malloc_t <parameter>malloc_function</parameter></paramdef>
Packit Service ae04f2
        <paramdef>lwres_free_t <parameter>free_function</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
lwres_result_t
Packit Service ae04f2
<function>lwres_context_destroy</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t **<parameter>contextp</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
void
Packit Service ae04f2
<function>lwres_context_initserial</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
Packit Service ae04f2
        <paramdef>uint32_t <parameter>serial</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
uint32_t
Packit Service ae04f2
<function>lwres_context_nextserial</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
void
Packit Service ae04f2
<function>lwres_context_freemem</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
Packit Service ae04f2
        <paramdef>void *<parameter>mem</parameter></paramdef>
Packit Service ae04f2
        <paramdef>size_t <parameter>len</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
void
Packit Service ae04f2
<function>lwres_context_allocmem</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
Packit Service ae04f2
        <paramdef>size_t <parameter>len</parameter></paramdef>
Packit Service ae04f2
        </funcprototype>
Packit Service ae04f2
<funcprototype>
Packit Service ae04f2
        <funcdef>
Packit Service ae04f2
void *
Packit Service ae04f2
<function>lwres_context_sendrecv</function></funcdef>
Packit Service ae04f2
        <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
Packit Service ae04f2
        <paramdef>void *<parameter>sendbase</parameter></paramdef>
Packit Service ae04f2
        <paramdef>int <parameter>sendlen</parameter></paramdef>
Packit Service ae04f2
        <paramdef>void *<parameter>recvbase</parameter></paramdef>
Packit Service ae04f2
        <paramdef>int <parameter>recvlen</parameter></paramdef>
Packit Service ae04f2
        <paramdef>int *<parameter>recvd_len</parameter></paramdef>
Packit Service ae04f2
      </funcprototype>
Packit Service ae04f2
</funcsynopsis>
Packit Service ae04f2
  </refsynopsisdiv>
Packit Service ae04f2
  <refsection><info><title>DESCRIPTION</title></info>
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_context_create()</function>
Packit Service ae04f2
      creates a <type>lwres_context_t</type> structure for use in
Packit Service ae04f2
      lightweight resolver operations.  It holds a socket and other
Packit Service ae04f2
      data needed for communicating with a resolver daemon.  The new
Packit Service ae04f2
      <type>lwres_context_t</type> is returned through
Packit Service ae04f2
      <parameter>contextp</parameter>, a pointer to a
Packit Service ae04f2
      <type>lwres_context_t</type> pointer.  This
Packit Service ae04f2
      <type>lwres_context_t</type> pointer must initially be NULL, and
Packit Service ae04f2
      is modified to point to the newly created
Packit Service ae04f2
      <type>lwres_context_t</type>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
    <para>
Packit Service ae04f2
      When the lightweight resolver needs to perform dynamic memory
Packit Service ae04f2
      allocation, it will call
Packit Service ae04f2
      <parameter>malloc_function</parameter>
Packit Service ae04f2
      to allocate memory and
Packit Service ae04f2
      <parameter>free_function</parameter>
Packit Service ae04f2
      to free it.  If
Packit Service ae04f2
      <parameter>malloc_function</parameter>
Packit Service ae04f2
      and
Packit Service ae04f2
      <parameter>free_function</parameter>
Packit Service ae04f2
      are NULL, memory is allocated using
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>.
Packit Service ae04f2
      and
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>free</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>.
Packit Service ae04f2
Packit Service ae04f2
      It is not permitted to have a NULL
Packit Service ae04f2
      <parameter>malloc_function</parameter> and a non-NULL
Packit Service ae04f2
      <parameter>free_function</parameter> or vice versa.
Packit Service ae04f2
      <parameter>arg</parameter> is passed as the first parameter to
Packit Service ae04f2
      the memory allocation functions.  If
Packit Service ae04f2
      <parameter>malloc_function</parameter> and
Packit Service ae04f2
      <parameter>free_function</parameter> are NULL,
Packit Service ae04f2
      <parameter>arg</parameter> is unused and should be passed as
Packit Service ae04f2
      NULL.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      Once memory for the structure has been allocated,
Packit Service ae04f2
      it is initialized using
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres_conf_init</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>
Packit Service ae04f2
      and returned via <parameter>*contextp</parameter>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_context_destroy()</function>
Packit Service ae04f2
      destroys a <type>lwres_context_t</type>, closing its socket.
Packit Service ae04f2
      <parameter>contextp</parameter> is a pointer to a pointer to the
Packit Service ae04f2
      context that is to be destroyed.  The pointer will be set to
Packit Service ae04f2
      NULL when the context has been destroyed.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      The context holds a serial number that is used to identify
Packit Service ae04f2
      resolver request packets and associate responses with the
Packit Service ae04f2
      corresponding requests.  This serial number is controlled using
Packit Service ae04f2
      <function>lwres_context_initserial()</function> and
Packit Service ae04f2
      <function>lwres_context_nextserial()</function>.
Packit Service ae04f2
      <function>lwres_context_initserial()</function> sets the serial
Packit Service ae04f2
      number for context <parameter>*ctx</parameter> to
Packit Service ae04f2
      <parameter>serial</parameter>.
Packit Service ae04f2
      <function>lwres_context_nextserial()</function> increments the
Packit Service ae04f2
      serial number and returns the previous value.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para>
Packit Service ae04f2
      Memory for a lightweight resolver context is allocated and freed
Packit Service ae04f2
      using <function>lwres_context_allocmem()</function> and
Packit Service ae04f2
      <function>lwres_context_freemem()</function>.  These use
Packit Service ae04f2
      whatever allocations were defined when the context was created
Packit Service ae04f2
      with <function>lwres_context_create()</function>.
Packit Service ae04f2
      <function>lwres_context_allocmem()</function> allocates
Packit Service ae04f2
      <parameter>len</parameter> bytes of memory and if successful
Packit Service ae04f2
      returns a pointer to the allocated storage.
Packit Service ae04f2
      <function>lwres_context_freemem()</function> frees
Packit Service ae04f2
      <parameter>len</parameter> bytes of space starting at location
Packit Service ae04f2
      <parameter>mem</parameter>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_context_sendrecv()</function>
Packit Service ae04f2
      performs I/O for the context <parameter>ctx</parameter>.  Data
Packit Service ae04f2
      are read and written from the context's socket.  It writes data
Packit Service ae04f2
      from <parameter>sendbase</parameter> — typically a
Packit Service ae04f2
      lightweight resolver query packet — and waits for a reply
Packit Service ae04f2
      which is copied to the receive buffer at
Packit Service ae04f2
      <parameter>recvbase</parameter>.  The number of bytes that were
Packit Service ae04f2
      written to this receive buffer is returned in
Packit Service ae04f2
      <parameter>*recvd_len</parameter>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
Packit Service ae04f2
  <refsection><info><title>RETURN VALUES</title></info>
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    <para><function>lwres_context_create()</function>
Packit Service ae04f2
      returns <errorcode>LWRES_R_NOMEMORY</errorcode> if memory for
Packit Service ae04f2
      the <type>struct lwres_context</type> could not be allocated,
Packit Service ae04f2
      <errorcode>LWRES_R_SUCCESS</errorcode> otherwise.
Packit Service ae04f2
    </para>
Packit Service ae04f2
    <para>
Packit Service ae04f2
      Successful calls to the memory allocator
Packit Service ae04f2
      <function>lwres_context_allocmem()</function>
Packit Service ae04f2
      return a pointer to the start of the allocated space.
Packit Service ae04f2
      It returns NULL if memory could not be allocated.
Packit Service ae04f2
    </para>
Packit Service ae04f2
    <para><errorcode>LWRES_R_SUCCESS</errorcode>
Packit Service ae04f2
      is returned when
Packit Service ae04f2
      <function>lwres_context_sendrecv()</function>
Packit Service ae04f2
      completes successfully.
Packit Service ae04f2
      <errorcode>LWRES_R_IOERROR</errorcode>
Packit Service ae04f2
      is returned if an I/O error occurs and
Packit Service ae04f2
      <errorcode>LWRES_R_TIMEOUT</errorcode>
Packit Service ae04f2
      is returned if
Packit Service ae04f2
      <function>lwres_context_sendrecv()</function>
Packit Service ae04f2
      times out waiting for a response.
Packit Service ae04f2
    </para>
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
  <refsection><info><title>SEE ALSO</title></info>
Packit Service ae04f2
Packit Service ae04f2
    <para><citerefentry>
Packit Service ae04f2
        <refentrytitle>lwres_conf_init</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>,
Packit Service ae04f2
Packit Service ae04f2
      <citerefentry>
Packit Service ae04f2
        <refentrytitle>free</refentrytitle><manvolnum>3</manvolnum>
Packit Service ae04f2
      </citerefentry>.
Packit Service ae04f2
    </para>
Packit Service ae04f2
  </refsection>
Packit Service ae04f2
</refentry>