Blame lib/lwres/man/lwres_context.3

Packit Service ae04f2
.\" Copyright (C) 2000, 2001, 2003-2005, 2007, 2014-2016, 2018-2020 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
.hy 0
Packit Service ae04f2
.ad l
Packit Service ae04f2
'\" t
Packit Service ae04f2
.\"     Title: lwres_context
Packit Service ae04f2
.\"    Author: 
Packit Service ae04f2
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
Packit Service ae04f2
.\"      Date: 2007-06-18
Packit Service ae04f2
.\"    Manual: BIND9
Packit Service ae04f2
.\"    Source: ISC
Packit Service ae04f2
.\"  Language: English
Packit Service ae04f2
.\"
Packit Service ae04f2
.TH "LWRES_CONTEXT" "3" "2007\-06\-18" "ISC" "BIND9"
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * Define some portability stuff
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit Service ae04f2
.\" http://bugs.debian.org/507673
Packit Service ae04f2
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
Packit Service ae04f2
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit Service ae04f2
.ie \n(.g .ds Aq \(aq
Packit Service ae04f2
.el       .ds Aq '
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * set default formatting
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" disable hyphenation
Packit Service ae04f2
.nh
Packit Service ae04f2
.\" disable justification (adjust text to left margin only)
Packit Service ae04f2
.ad l
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * MAIN CONTENT STARTS HERE *
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.SH "NAME"
Packit Service ae04f2
lwres_context_create, lwres_context_destroy, lwres_context_nextserial, lwres_context_initserial, lwres_context_freemem, lwres_context_allocmem, lwres_context_sendrecv \- lightweight resolver context management
Packit Service ae04f2
.SH "SYNOPSIS"
Packit Service ae04f2
.sp
Packit Service ae04f2
.ft B
Packit Service ae04f2
.nf
Packit Service ae04f2
#include <lwres/lwres\&.h>
Packit Service ae04f2
.fi
Packit Service ae04f2
.ft
Packit Service ae04f2
.HP \w'lwres_result_t\ lwres_context_create('u
Packit Service ae04f2
.BI "lwres_result_t lwres_context_create(lwres_context_t\ **" "contextp" ", void\ *" "arg" ", lwres_malloc_t\ " "malloc_function" ", lwres_free_t\ " "free_function" ");"
Packit Service ae04f2
.HP \w'lwres_result_t\ lwres_context_destroy('u
Packit Service ae04f2
.BI "lwres_result_t lwres_context_destroy(lwres_context_t\ **" "contextp" ");"
Packit Service ae04f2
.HP \w'void\ lwres_context_initserial('u
Packit Service ae04f2
.BI "void lwres_context_initserial(lwres_context_t\ *" "ctx" ", uint32_t\ " "serial" ");"
Packit Service ae04f2
.HP \w'uint32_t\ lwres_context_nextserial('u
Packit Service ae04f2
.BI "uint32_t lwres_context_nextserial(lwres_context_t\ *" "ctx" ");"
Packit Service ae04f2
.HP \w'void\ lwres_context_freemem('u
Packit Service ae04f2
.BI "void lwres_context_freemem(lwres_context_t\ *" "ctx" ", void\ *" "mem" ", size_t\ " "len" ");"
Packit Service ae04f2
.HP \w'void\ lwres_context_allocmem('u
Packit Service ae04f2
.BI "void lwres_context_allocmem(lwres_context_t\ *" "ctx" ", size_t\ " "len" ");"
Packit Service ae04f2
.HP \w'void\ *\ lwres_context_sendrecv('u
Packit Service ae04f2
.BI "void * lwres_context_sendrecv(lwres_context_t\ *" "ctx" ", void\ *" "sendbase" ", int\ " "sendlen" ", void\ *" "recvbase" ", int\ " "recvlen" ", int\ *" "recvd_len" ");"
Packit Service ae04f2
.SH "DESCRIPTION"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_context_create()\fR
Packit Service ae04f2
creates a
Packit Service ae04f2
\fBlwres_context_t\fR
Packit Service ae04f2
structure for use in lightweight resolver operations\&. It holds a socket and other data needed for communicating with a resolver daemon\&. The new
Packit Service ae04f2
\fBlwres_context_t\fR
Packit Service ae04f2
is returned through
Packit Service ae04f2
\fIcontextp\fR, a pointer to a
Packit Service ae04f2
\fBlwres_context_t\fR
Packit Service ae04f2
pointer\&. This
Packit Service ae04f2
\fBlwres_context_t\fR
Packit Service ae04f2
pointer must initially be NULL, and is modified to point to the newly created
Packit Service ae04f2
\fBlwres_context_t\fR\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
When the lightweight resolver needs to perform dynamic memory allocation, it will call
Packit Service ae04f2
\fImalloc_function\fR
Packit Service ae04f2
to allocate memory and
Packit Service ae04f2
\fIfree_function\fR
Packit Service ae04f2
to free it\&. If
Packit Service ae04f2
\fImalloc_function\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fIfree_function\fR
Packit Service ae04f2
are NULL, memory is allocated using
Packit Service ae04f2
\fBmalloc\fR(3)\&. and
Packit Service ae04f2
\fBfree\fR(3)\&. It is not permitted to have a NULL
Packit Service ae04f2
\fImalloc_function\fR
Packit Service ae04f2
and a non\-NULL
Packit Service ae04f2
\fIfree_function\fR
Packit Service ae04f2
or vice versa\&.
Packit Service ae04f2
\fIarg\fR
Packit Service ae04f2
is passed as the first parameter to the memory allocation functions\&. If
Packit Service ae04f2
\fImalloc_function\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fIfree_function\fR
Packit Service ae04f2
are NULL,
Packit Service ae04f2
\fIarg\fR
Packit Service ae04f2
is unused and should be passed as NULL\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
Once memory for the structure has been allocated, it is initialized using
Packit Service ae04f2
\fBlwres_conf_init\fR(3)
Packit Service ae04f2
and returned via
Packit Service ae04f2
\fI*contextp\fR\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_context_destroy()\fR
Packit Service ae04f2
destroys a
Packit Service ae04f2
\fBlwres_context_t\fR, closing its socket\&.
Packit Service ae04f2
\fIcontextp\fR
Packit Service ae04f2
is a pointer to a pointer to the context that is to be destroyed\&. The pointer will be set to NULL when the context has been destroyed\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
The context holds a serial number that is used to identify resolver request packets and associate responses with the corresponding requests\&. This serial number is controlled using
Packit Service ae04f2
\fBlwres_context_initserial()\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fBlwres_context_nextserial()\fR\&.
Packit Service ae04f2
\fBlwres_context_initserial()\fR
Packit Service ae04f2
sets the serial number for context
Packit Service ae04f2
\fI*ctx\fR
Packit Service ae04f2
to
Packit Service ae04f2
\fIserial\fR\&.
Packit Service ae04f2
\fBlwres_context_nextserial()\fR
Packit Service ae04f2
increments the serial number and returns the previous value\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
Memory for a lightweight resolver context is allocated and freed using
Packit Service ae04f2
\fBlwres_context_allocmem()\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fBlwres_context_freemem()\fR\&. These use whatever allocations were defined when the context was created with
Packit Service ae04f2
\fBlwres_context_create()\fR\&.
Packit Service ae04f2
\fBlwres_context_allocmem()\fR
Packit Service ae04f2
allocates
Packit Service ae04f2
\fIlen\fR
Packit Service ae04f2
bytes of memory and if successful returns a pointer to the allocated storage\&.
Packit Service ae04f2
\fBlwres_context_freemem()\fR
Packit Service ae04f2
frees
Packit Service ae04f2
\fIlen\fR
Packit Service ae04f2
bytes of space starting at location
Packit Service ae04f2
\fImem\fR\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_context_sendrecv()\fR
Packit Service ae04f2
performs I/O for the context
Packit Service ae04f2
\fIctx\fR\&. Data are read and written from the context\*(Aqs socket\&. It writes data from
Packit Service ae04f2
\fIsendbase\fR
Packit Service ae04f2
\(em typically a lightweight resolver query packet \(em and waits for a reply which is copied to the receive buffer at
Packit Service ae04f2
\fIrecvbase\fR\&. The number of bytes that were written to this receive buffer is returned in
Packit Service ae04f2
\fI*recvd_len\fR\&.
Packit Service ae04f2
.SH "RETURN VALUES"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_context_create()\fR
Packit Service ae04f2
returns
Packit Service ae04f2
\fBLWRES_R_NOMEMORY\fR
Packit Service ae04f2
if memory for the
Packit Service ae04f2
\fBstruct lwres_context\fR
Packit Service ae04f2
could not be allocated,
Packit Service ae04f2
\fBLWRES_R_SUCCESS\fR
Packit Service ae04f2
otherwise\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
Successful calls to the memory allocator
Packit Service ae04f2
\fBlwres_context_allocmem()\fR
Packit Service ae04f2
return a pointer to the start of the allocated space\&. It returns NULL if memory could not be allocated\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBLWRES_R_SUCCESS\fR
Packit Service ae04f2
is returned when
Packit Service ae04f2
\fBlwres_context_sendrecv()\fR
Packit Service ae04f2
completes successfully\&.
Packit Service ae04f2
\fBLWRES_R_IOERROR\fR
Packit Service ae04f2
is returned if an I/O error occurs and
Packit Service ae04f2
\fBLWRES_R_TIMEOUT\fR
Packit Service ae04f2
is returned if
Packit Service ae04f2
\fBlwres_context_sendrecv()\fR
Packit Service ae04f2
times out waiting for a response\&.
Packit Service ae04f2
.SH "SEE ALSO"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_conf_init\fR(3),
Packit Service ae04f2
\fBmalloc\fR(3),
Packit Service ae04f2
\fBfree\fR(3)\&.
Packit Service ae04f2
.SH "AUTHOR"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBInternet Systems Consortium, Inc\&.\fR
Packit Service ae04f2
.SH "COPYRIGHT"
Packit Service ae04f2
.br
Packit Service ae04f2
Copyright \(co 2000, 2001, 2003-2005, 2007, 2014-2016, 2018-2020 Internet Systems Consortium, Inc. ("ISC")
Packit Service ae04f2
.br