lwres_context.html revision 83217b5fdc70ea66fedf2ab3e9b9169c2b8a200a
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<!--
3b7f610bec248f85e25a52a0ad7dec9894389ca5Tinderbox User - Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence - Copyright (C) 2000, 2001, 2003 Internet Software Consortium
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews -
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews - purpose with or without fee is hereby granted, provided that the above
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - copyright notice and this permission notice appear in all copies.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff -
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff - PERFORMANCE OF THIS SOFTWARE.
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews-->
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<!-- $Id: lwres_context.html,v 1.14 2005/05/12 23:54:34 sra Exp $ -->
ce24330566b66a5ca8522fa948fb36b94a4d6981Mark Andrews<html>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence<head>
ce24330566b66a5ca8522fa948fb36b94a4d6981Mark Andrews<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence<title>lwres_context</title>
364a82f7c25b62967678027043425201a5e5171aBob Halley<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff</head>
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence<a name="id2456694"></a><div class="titlepage"></div>
7d823f705d9d3a8cb4d43fcf11249515e2845364Andreas Gustafsson<div class="refnamediv">
531eafa3026663020f4a2ac5587cce44341e3442Andreas Gustafsson<h2>Name</h2>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p>lwres_context_create, lwres_context_destroy, lwres_context_nextserial, lwres_context_initserial, lwres_context_freemem, lwres_context_allocmem, lwres_context_sendrecv &#8212; lightweight resolver context management</p>
5bd76af084edfdcd1cb4db9453ac781d32dde6f7Mark Andrews</div>
f647c0df9fd334b19a5bdc9c252f90d94c0abf1eMark Andrews<div class="refsynopsisdiv">
f9df80f4348ef68043903efa08299480324f4823Michael Graff<h2>Synopsis</h2>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<div class="funcsynopsis">
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence<pre class="funcsynopsisinfo">#include &lt;lwres/lwres.h&gt;</pre>
0f80bfec687db08a6e6ce945ef1d818da06c7ca9Brian Wellington<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence<tr>
6d4886fa7430889a96dbf9b88a2a4eb6f9d04674Brian Wellington<td><code class="funcdef">
6cba0b8e61859e37cbf16818cc95ba1da85d68fdEvan Huntlwres_result_t
b984520acca2532d048eae929dc0682dd334c7a3Brian Wellington<b class="fsfunc">lwres_context_create</b>(</code></td>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<td>lwres_context_t **�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<var class="pdparam">contextp</var>, </td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews</tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>void *�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<var class="pdparam">arg</var>, </td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews</tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>lwres_malloc_t �</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<var class="pdparam">malloc_function</var>, </td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews</tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>lwres_free_t �</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<var class="pdparam">free_function</var><code>)</code>;</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews</tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews</table>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td><code class="funcdef">
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewslwres_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<b class="fsfunc">lwres_context_destroy</b>(</code></td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>lwres_context_t **�</td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<td>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews<var class="pdparam">contextp</var><code>)</code>;</td>
75ec9bc9c7b4f2485647414330122e7b8e188097Andreas Gustafsson</tr></table>
ac77fece9a62537a9e0e5852498ebeda7b2978c3Bob Halley<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<td><code class="funcdef">
ac77fece9a62537a9e0e5852498ebeda7b2978c3Bob Halleyvoid
ac77fece9a62537a9e0e5852498ebeda7b2978c3Bob Halley<b class="fsfunc">lwres_context_initserial</b>(</code></td>
ac77fece9a62537a9e0e5852498ebeda7b2978c3Bob Halley<td>lwres_context_t *�</td>
ac77fece9a62537a9e0e5852498ebeda7b2978c3Bob Halley<td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<var class="pdparam">ctx</var>, </td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff</tr>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<tr>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>lwres_uint32_t �</td>
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington<td>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk<var class="pdparam">serial</var><code>)</code>;</td>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk</tr>
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk</table>
2a2618356ecdf5962230fe11606d2b106a638295Tinderbox User<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr>
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington<td><code class="funcdef">
1ed4ba5a1fcb6aecd1c92fdcc75c6b4bbb7cc60fMichael Sawyerlwres_uint32_t
1ed4ba5a1fcb6aecd1c92fdcc75c6b4bbb7cc60fMichael Sawyer<b class="fsfunc">lwres_context_nextserial</b>(</code></td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>lwres_context_t *�</td>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews<td>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews<var class="pdparam">ctx</var><code>)</code>;</td>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein</tr></table>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
f9df80f4348ef68043903efa08299480324f4823Michael Graff<tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<td><code class="funcdef">
f9df80f4348ef68043903efa08299480324f4823Michael Graffvoid
e223094b2248afa2697c531f75e6f84855638becMichael Graff<b class="fsfunc">lwres_context_freemem</b>(</code></td>
16f43564c6875e2bedd346c18c494933ad51e4faMukund Sivaraman<td>lwres_context_t *�</td>
be066f0629a12e11bc17f27671036b3f451bd5eaBrian Wellington<td>
b02262cbcd550c63f85df76edc6fff556ea5e95dMichael Graff<var class="pdparam">ctx</var>, </td>
b02262cbcd550c63f85df76edc6fff556ea5e95dMichael Graff</tr>
16f43564c6875e2bedd346c18c494933ad51e4faMukund Sivaraman<tr>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>�</td>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein<td>void *�</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<var class="pdparam">mem</var>, </td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</tr>
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence<tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>�</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>size_t �</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<var class="pdparam">len</var><code>)</code>;</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</table>
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em">
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<tr>
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<td><code class="funcdef">
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyervoid
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<b class="fsfunc">lwres_context_allocmem</b>(</code></td>
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<td>lwres_context_t *�</td>
58c40ca8bda08458804d7f15cf97942dea2a17acMichael Sawyer<td>
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence<var class="pdparam">ctx</var>, </td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>�</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>size_t �</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<var class="pdparam">len</var><code>)</code>;</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</table>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0">
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td><code class="funcdef">
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyervoid *
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<b class="fsfunc">lwres_context_sendrecv</b>(</code></td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>lwres_context_t *�</td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<var class="pdparam">ctx</var>, </td>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer</tr>
c95a89b433e42ecf9108b6c263f405fecc0d8a65Michael Sawyer<tr>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein<td>�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>void *�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>
47b7dfffe5d806c6a5e99ef17f07bcde812c2132Francis Dupont<var class="pdparam">sendbase</var>, </td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff</tr>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<td>�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>int �</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<var class="pdparam">sendlen</var>, </td>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff</tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<td>�</td>
fccf7905e8a06067d49ec00c53d4d57a38a71e52Michael Graff<td>void *�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<var class="pdparam">recvbase</var>, </td>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff</tr>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<tr>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>�</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>int �</td>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<td>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<var class="pdparam">recvlen</var>, </td>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff</tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<tr>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<td>�</td>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<td>int *�</td>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews<td>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews<var class="pdparam">recvd_len</var><code>)</code>;</td>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews</tr>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews</table>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews</div>
dda69168ead4bb44f5a23949a04ee2069b7d4ef0Mark Andrews</div>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<div class="refsect1" lang="en">
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<a name="id2514219"></a><h2>DESCRIPTION</h2>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p><code class="function">lwres_context_create()</code>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff creates a <span class="type">lwres_context_t</span> structure for use in
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff lightweight resolver operations. It holds a socket and other
f9df80f4348ef68043903efa08299480324f4823Michael Graff data needed for communicating with a resolver daemon. The new
f9df80f4348ef68043903efa08299480324f4823Michael Graff <span class="type">lwres_context_t</span> is returned through
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>contextp</code></em>, a pointer to a
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="type">lwres_context_t</span> pointer. This
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="type">lwres_context_t</span> pointer must initially be NULL, and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff is modified to point to the newly created
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="type">lwres_context_t</span>.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff </p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff When the lightweight resolver needs to perform dynamic memory
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff allocation, it will call
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>malloc_function</code></em>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff to allocate memory and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>free_function</code></em>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff to free it. If
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>malloc_function</code></em>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>free_function</code></em>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff are NULL, memory is allocated using
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="citerefentry"><span class="refentrytitle">malloc</span>(3)</span>.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="citerefentry"><span class="refentrytitle">free</span>(3)</span>.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff It is not permitted to have a NULL
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>malloc_function</code></em> and a non-NULL
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence <em class="parameter"><code>free_function</code></em> or vice versa.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>arg</code></em> is passed as the first parameter to
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff the memory allocation functions. If
8c55a67a6d185de7036e39da30561a5c1637d22bAndreas Gustafsson <em class="parameter"><code>malloc_function</code></em> and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>free_function</code></em> are NULL,
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <em class="parameter"><code>arg</code></em> is unused and should be passed as
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff NULL.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff </p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff Once memory for the structure has been allocated,
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff it is initialized using
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <span class="citerefentry"><span class="refentrytitle">lwres_conf_init</span>(3)</span>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff and returned via <em class="parameter"><code>*contextp</code></em>.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff </p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p><code class="function">lwres_context_destroy()</code>
f9df80f4348ef68043903efa08299480324f4823Michael Graff destroys a <span class="type">lwres_context_t</span>, closing its socket.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence <em class="parameter"><code>contextp</code></em> is a pointer to a pointer to the
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff context that is to be destroyed. The pointer will be set to
f9df80f4348ef68043903efa08299480324f4823Michael Graff NULL when the context has been destroyed.
f9df80f4348ef68043903efa08299480324f4823Michael Graff </p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff<p>
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff The context holds a serial number that is used to identify
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff resolver request packets and associate responses with the
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff corresponding requests. This serial number is controlled using
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence <code class="function">lwres_context_initserial()</code> and
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff <code class="function">lwres_context_nextserial()</code>.
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff <code class="function">lwres_context_initserial()</code> sets the serial
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff number for context <em class="parameter"><code>*ctx</code></em> to
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff <em class="parameter"><code>serial</code></em>.
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff <code class="function">lwres_context_nextserial()</code> increments the
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff serial number and returns the previous value.
9178881e1bf6a4b01db886b355406c8bed61cc2aMichael Graff </p>
f9df80f4348ef68043903efa08299480324f4823Michael Graff<p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff Memory for a lightweight resolver context is allocated and freed
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff using <code class="function">lwres_context_allocmem()</code> and
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <code class="function">lwres_context_freemem()</code>. These use
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff whatever allocations were defined when the context was created
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff with <code class="function">lwres_context_create()</code>.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff <code class="function">lwres_context_allocmem()</code> allocates
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence <em class="parameter"><code>len</code></em> bytes of memory and if successful
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff returns a pointer to the allocated storage.
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff <code class="function">lwres_context_freemem()</code> frees
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <em class="parameter"><code>len</code></em> bytes of space starting at location
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <em class="parameter"><code>mem</code></em>.
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence </p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<p><code class="function">lwres_context_sendrecv()</code>
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff performs I/O for the context <em class="parameter"><code>ctx</code></em>. Data
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff are read and written from the context's socket. It writes data
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff from <em class="parameter"><code>sendbase</code></em> &#8212; typically a
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff lightweight resolver query packet &#8212; and waits for a reply
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff which is copied to the receive buffer at
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <em class="parameter"><code>recvbase</code></em>. The number of bytes that were
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff written to this receive buffer is returned in
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence <em class="parameter"><code>*recvd_len</code></em>.
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff </p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff</div>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<div class="refsect1" lang="en">
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff<a name="id2514475"></a><h2>RETURN VALUES</h2>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<p><code class="function">lwres_context_create()</code>
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff returns <span class="errorcode">LWRES_R_NOMEMORY</span> if memory for
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff the <span class="type">struct lwres_context</span> could not be allocated,
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <span class="errorcode">LWRES_R_SUCCESS</span> otherwise.
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff </p>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence<p>
70fd62761dfe44f2254fb63ac3ded1b02663713fMichael Graff Successful calls to the memory allocator
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <code class="function">lwres_context_allocmem()</code>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff return a pointer to the start of the allocated space.
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff It returns NULL if memory could not be allocated.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence </p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<p><span class="errorcode">LWRES_R_SUCCESS</span>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff is returned when
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <code class="function">lwres_context_sendrecv()</code>
70fd62761dfe44f2254fb63ac3ded1b02663713fMichael Graff completes successfully.
70fd62761dfe44f2254fb63ac3ded1b02663713fMichael Graff <span class="errorcode">LWRES_R_IOERROR</span>
70fd62761dfe44f2254fb63ac3ded1b02663713fMichael Graff is returned if an I/O error occurs and
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <span class="errorcode">LWRES_R_TIMEOUT</span>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff is returned if
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <code class="function">lwres_context_sendrecv()</code>
97e7d389d54a9e3a1ba8313ed140b04afabc7081Michael Graff times out waiting for a response.
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff </p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff</div>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<div class="refsect1" lang="en">
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<a name="id2514525"></a><h2>SEE ALSO</h2>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff<p><span class="citerefentry"><span class="refentrytitle">lwres_conf_init</span>(3)</span>,
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <span class="citerefentry"><span class="refentrytitle">malloc</span>(3)</span>,
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff <span class="citerefentry"><span class="refentrytitle">free</span>(3)</span>.
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff </p>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff</div>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff</div></body>
5e589b5356a4125b5af32605dead82ab8b467c88Mark Andrews</html>
d68838693666ba930ec4143f848c18bff2bfc244Michael Graff