📄 lwres_context.3
字号:
.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC").\" Copyright (C) 2000, 2001 Internet Software Consortium..\".\" Permission to use, copy, modify, and distribute this software for any.\" purpose with or without fee is hereby granted, provided that the above.\" copyright notice and this permission notice appear in all copies..\".\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR.\" PERFORMANCE OF THIS SOFTWARE..\".\" $Id: lwres_context.3,v 1.13.2.2.2.2 2004/03/08 09:05:12 marka Exp $.\".TH "LWRES_CONTEXT" "3" "Jun 30, 2000" "BIND9" "".SH NAMElwres_context_create, lwres_context_destroy, lwres_context_nextserial, lwres_context_initserial, lwres_context_freemem, lwres_context_allocmem, lwres_context_sendrecv \- lightweight resolver context management.SH SYNOPSIS\fB#include <lwres/lwres.h>.sp.nalwres_result_tlwres_context_create(lwres_context_t **contextp, void *arg, lwres_malloc_t malloc_function, lwres_free_t free_function);.ad.sp.nalwres_result_tlwres_context_destroy(lwres_context_t **contextp);.ad.sp.navoidlwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);.ad.sp.nalwres_uint32_tlwres_context_nextserial(lwres_context_t *ctx);.ad.sp.navoidlwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);.ad.sp.navoidlwres_context_allocmem(lwres_context_t *ctx, size_t len);.ad.sp.navoid *lwres_context_sendrecv(lwres_context_t *ctx, void *sendbase, int sendlen, void *recvbase, int recvlen, int *recvd_len);.ad\fR.SH "DESCRIPTION".PP\fBlwres_context_create()\fRcreates a\fBlwres_context_t\fRstructure for use in lightweight resolver operations.It holds a socket and other data needed for communicatingwith a resolver daemon.The new\fBlwres_context_t\fRis returned through\fIcontextp\fR,a pointer to a\fBlwres_context_t\fRpointer. This \fBlwres_context_t\fRpointer must initially be NULL, and is modified to point to the newly created\fBlwres_context_t\fR..PPWhen the lightweight resolver needs to perform dynamic memoryallocation, it will call\fImalloc_function\fRto allocate memory and\fIfree_function\fRto free it. If \fImalloc_function\fRand\fIfree_function\fRare NULL, memory is allocated using\&.Xr malloc 3and\fBfree\fR(3).It is not permitted to have a NULL\fImalloc_function\fRand a non-NULL\fIfree_function\fRor vice versa.\fIarg\fRis passed as the first parameter to the memoryallocation functions. If\fImalloc_function\fRand\fIfree_function\fRare NULL,\fIarg\fRis unused and should be passed as NULL..PPOnce memory for the structure has been allocated,it is initialized using\fBlwres_conf_init\fR(3)and returned via\fI*contextp\fR..PP\fBlwres_context_destroy()\fRdestroys a \fBlwres_context_t\fR,closing its socket.\fIcontextp\fRis 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..PPThe context holds a serial number that is used to identify resolverrequest packets and associate responses with the corresponding requests.This serial number is controlled using\fBlwres_context_initserial()\fRand\fBlwres_context_nextserial()\fR.\fBlwres_context_initserial()\fRsets the serial number for context\fI*ctx\fRto\fIserial\fR.\fBlwres_context_nextserial()\fRincrements the serial number and returns the previous value..PPMemory for a lightweight resolver context is allocated and freed using\fBlwres_context_allocmem()\fRand\fBlwres_context_freemem()\fR.These use whatever allocations were defined when the context wascreated with\fBlwres_context_create()\fR.\fBlwres_context_allocmem()\fRallocates\fIlen\fRbytes of memory and if successful returns a pointer to the allocatedstorage.\fBlwres_context_freemem()\fRfrees\fIlen\fRbytes of space starting at location\fImem\fR..PP\fBlwres_context_sendrecv()\fRperforms I/O for the context\fIctx\fR.Data are read and written from the context's socket.It writes data from\fIsendbase\fR\(em typically a lightweight resolver query packet \(emand waits for a reply which is copied to the receive buffer at\fIrecvbase\fR.The number of bytes that were written to this receive buffer isreturned in\fI*recvd_len\fR..SH "RETURN VALUES".PP\fBlwres_context_create()\fRreturnsLWRES_R_NOMEMORYif memory for the\fBstruct lwres_context\fRcould not be allocated, LWRES_R_SUCCESSotherwise..PPSuccessful calls to the memory allocator\fBlwres_context_allocmem()\fRreturn a pointer to the start of the allocated space.It returns NULL if memory could not be allocated..PPLWRES_R_SUCCESSis returned when\fBlwres_context_sendrecv()\fRcompletes successfully.LWRES_R_IOERRORis returned if an I/O error occurs andLWRES_R_TIMEOUTis returned if\fBlwres_context_sendrecv()\fRtimes out waiting for a response..SH "SEE ALSO".PP\fBlwres_conf_init\fR(3),\fBmalloc\fR(3),\fBfree\fR(3).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -