lwres_context.docbook revision 83a28ca274521e15086fc39febde507bcc4e145e
9805ac88e1befa6dea11d8513023f150d8f8e807fanf<!ENTITY mdash "—">]>
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj - Copyright (C) 2000, 2001, 2003-2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
2deb319e6b3de239f45c16a3e9e836d44f1f7108rbb - This Source Code Form is subject to the terms of the Mozilla Public
2deb319e6b3de239f45c16a3e9e836d44f1f7108rbb - License, v. 2.0. If a copy of the MPL was not distributed with this
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb - file, You can obtain one at http://mozilla.org/MPL/2.0/.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj<!-- Converted by db4-upgrade version 1.0 -->
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard<refentry xmlns:db="http://docbook.org/ns/docbook" version="5.0">
91a71946d0fb28c0866139edef3dd59f36ba5b9cstoddard <refentryinfo>
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb <corpauthor>Internet Systems Consortium, Inc.</corpauthor>
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb </refentryinfo>
f6a6245816cd866361da8c576b1f47c7a54b6610fanf </refmeta>
b7663b97a437dc089ac7a1a9ebd42e0c372a48b6gstein <copyright>
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
d208bda4a893cc81ed5d3ed1cdd7d706e012bd42stoddard </copyright>
10b386767f6c87b45937244371cb751f0b454d16wrowe <refnamediv>
10b386767f6c87b45937244371cb751f0b454d16wrowe <refpurpose>lightweight resolver context management</refpurpose>
10b386767f6c87b45937244371cb751f0b454d16wrowe </refnamediv>
10b386767f6c87b45937244371cb751f0b454d16wrowe <refsynopsisdiv>
10b386767f6c87b45937244371cb751f0b454d16wrowe <funcsynopsis>
10b386767f6c87b45937244371cb751f0b454d16wrowe<funcsynopsisinfo>#include <lwres/lwres.h></funcsynopsisinfo>
10b386767f6c87b45937244371cb751f0b454d16wrowe<funcprototype>
10b386767f6c87b45937244371cb751f0b454d16wrowelwres_result_t
10b386767f6c87b45937244371cb751f0b454d16wrowe <paramdef>lwres_context_t **<parameter>contextp</parameter></paramdef>
a9e07e4f90adcc7bc768db3055431c3dcd560cd1manoj <paramdef>lwres_malloc_t <parameter>malloc_function</parameter></paramdef>
f6a6245816cd866361da8c576b1f47c7a54b6610fanf <paramdef>lwres_free_t <parameter>free_function</parameter></paramdef>
f6a6245816cd866361da8c576b1f47c7a54b6610fanf </funcprototype>
97b758d0b174d7b7c5a1de1a583f5840ec3fc910trawick<funcprototype>
2a6c49cfaef5979a5a06098f3ce987cd76769409manojlwres_result_t
8bed76428f56e5c643174a2d6807c3f18016af5cbjh <paramdef>lwres_context_t **<parameter>contextp</parameter></paramdef>
8bed76428f56e5c643174a2d6807c3f18016af5cbjh </funcprototype>
8bed76428f56e5c643174a2d6807c3f18016af5cbjh<funcprototype>
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard<function>lwres_context_initserial</function></funcdef>
cfc020d6d6fc9b31d8945915e65a8787a796eb73stoddard <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard <paramdef>lwres_uint32_t <parameter>serial</parameter></paramdef>
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard </funcprototype>
f824925ac58ff729289c017235eeb3bdd21ec3a2stoddard<funcprototype>
2aae6faee508221efbeaba5547ca79b7a20ef047stoddardlwres_uint32_t
2aae6faee508221efbeaba5547ca79b7a20ef047stoddard<function>lwres_context_nextserial</function></funcdef>
10b386767f6c87b45937244371cb751f0b454d16wrowe <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
10b386767f6c87b45937244371cb751f0b454d16wrowe </funcprototype>
10b386767f6c87b45937244371cb751f0b454d16wrowe<funcprototype>
10b386767f6c87b45937244371cb751f0b454d16wrowe <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
75960f20f88dad6bc67892c711c429946063d133stoddard <paramdef>size_t <parameter>len</parameter></paramdef>
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard </funcprototype>
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard<funcprototype>
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard<function>lwres_context_allocmem</function></funcdef>
56ca30c968906053ae61acb218420667bb58d996rbb <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
56ca30c968906053ae61acb218420667bb58d996rbb </funcprototype>
56ca30c968906053ae61acb218420667bb58d996rbb<funcprototype>
56ca30c968906053ae61acb218420667bb58d996rbb <paramdef>lwres_context_t *<parameter>ctx</parameter></paramdef>
0bff2f28ef945280c17099c142126178a78e1e54manoj <paramdef>void *<parameter>sendbase</parameter></paramdef>
0bff2f28ef945280c17099c142126178a78e1e54manoj <paramdef>int <parameter>sendlen</parameter></paramdef>
0bff2f28ef945280c17099c142126178a78e1e54manoj <paramdef>void *<parameter>recvbase</parameter></paramdef>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard <paramdef>int <parameter>recvlen</parameter></paramdef>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard <paramdef>int *<parameter>recvd_len</parameter></paramdef>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard </funcprototype>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard</funcsynopsis>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard </refsynopsisdiv>
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard <refsection><info><title>DESCRIPTION</title></info>
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard creates a <type>lwres_context_t</type> structure for use in
0bff2f28ef945280c17099c142126178a78e1e54manoj lightweight resolver operations. It holds a socket and other
0bff2f28ef945280c17099c142126178a78e1e54manoj data needed for communicating with a resolver daemon. The new
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard <type>lwres_context_t</type> pointer must initially be NULL, and
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard is modified to point to the newly created
f03d292915be9977eaf74e9be7b0404aec226f84manoj When the lightweight resolver needs to perform dynamic memory
aa1faea36e4ae357bc603a2337b6adc54f5daec1manoj allocation, it will call
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj to allocate memory and
302dc1f7b3feee23a91ad8f3cf3cb2edd95a557bmanoj to free it. If
ff849e4163ed879288f0df15f78b6c9d278ec804fanf are NULL, memory is allocated using
9805ac88e1befa6dea11d8513023f150d8f8e807fanf <citerefentry>
9805ac88e1befa6dea11d8513023f150d8f8e807fanf <refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum>
9805ac88e1befa6dea11d8513023f150d8f8e807fanf </citerefentry>.
df4a7c143b27b489dd2d865bb3f6668c8420b3a9fanf <citerefentry>
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein <refentrytitle>free</refentrytitle><manvolnum>3</manvolnum>
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein </citerefentry>.
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein It is not permitted to have a NULL
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein <parameter>malloc_function</parameter> and a non-NULL
c03566fa0156d3a1500a42e4fe539e3e0fc8a11dgstein <parameter>arg</parameter> is passed as the first parameter to
db3ccce11afac4fc1d4f51a65424412f7480c46cgstein the memory allocation functions. If
db3ccce11afac4fc1d4f51a65424412f7480c46cgstein <parameter>arg</parameter> is unused and should be passed as
d5defd5a0c5cdbaf74b85939484dc2b6c8317d19manoj Once memory for the structure has been allocated,
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj it is initialized using
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj <citerefentry>
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj <refentrytitle>lwres_conf_init</refentrytitle><manvolnum>3</manvolnum>
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj </citerefentry>
0bff2f28ef945280c17099c142126178a78e1e54manoj destroys a <type>lwres_context_t</type>, closing its socket.
d6b3cb141f0667101c1bca883ad15b383402c93bfielding <parameter>contextp</parameter> is a pointer to a pointer to the
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj context that is to be destroyed. The pointer will be set to
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj NULL when the context has been destroyed.
dbf0c7bef06259486cd2748a2d0e82f27e099d6efielding The context holds a serial number that is used to identify
dbf0c7bef06259486cd2748a2d0e82f27e099d6efielding resolver request packets and associate responses with the
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj corresponding requests. This serial number is controlled using
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj <function>lwres_context_initserial()</function> sets the serial
f6a6245816cd866361da8c576b1f47c7a54b6610fanf <function>lwres_context_nextserial()</function> increments the
f6a6245816cd866361da8c576b1f47c7a54b6610fanf serial number and returns the previous value.
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj Memory for a lightweight resolver context is allocated and freed
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj using <function>lwres_context_allocmem()</function> and
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj <function>lwres_context_freemem()</function>. These use
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj whatever allocations were defined when the context was created
d6b3cb141f0667101c1bca883ad15b383402c93bfielding <function>lwres_context_allocmem()</function> allocates
d6b3cb141f0667101c1bca883ad15b383402c93bfielding <parameter>len</parameter> bytes of memory and if successful
d6b3cb141f0667101c1bca883ad15b383402c93bfielding returns a pointer to the allocated storage.
d6b3cb141f0667101c1bca883ad15b383402c93bfielding <parameter>len</parameter> bytes of space starting at location
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj performs I/O for the context <parameter>ctx</parameter>. Data
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj are read and written from the context's socket. It writes data
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj from <parameter>sendbase</parameter> — typically a
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj lightweight resolver query packet — and waits for a reply
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj which is copied to the receive buffer at
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj <parameter>recvbase</parameter>. The number of bytes that were
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj written to this receive buffer is returned in
d6b3cb141f0667101c1bca883ad15b383402c93bfielding </refsection>
d6b3cb141f0667101c1bca883ad15b383402c93bfielding <refsection><info><title>RETURN VALUES</title></info>