tcpmsg.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: tcpmsg.h,v 1.22 2007/06/19 23:47:17 tbox Exp $ */
00019 
00020 #ifndef DNS_TCPMSG_H
00021 #define DNS_TCPMSG_H 1
00022 
00023 /*! \file dns/tcpmsg.h */
00024 
00025 #include <isc/buffer.h>
00026 #include <isc/lang.h>
00027 #include <isc/socket.h>
00028 
00029 typedef struct dns_tcpmsg {
00030         /* private (don't touch!) */
00031         unsigned int            magic;
00032         isc_uint16_t            size;
00033         isc_buffer_t            buffer;
00034         unsigned int            maxsize;
00035         isc_mem_t              *mctx;
00036         isc_socket_t           *sock;
00037         isc_task_t             *task;
00038         isc_taskaction_t        action;
00039         void                   *arg;
00040         isc_event_t             event;
00041         /* public (read-only) */
00042         isc_result_t            result;
00043         isc_sockaddr_t          address;
00044 } dns_tcpmsg_t;
00045 
00046 ISC_LANG_BEGINDECLS
00047 
00048 void
00049 dns_tcpmsg_init(isc_mem_t *mctx, isc_socket_t *sock, dns_tcpmsg_t *tcpmsg);
00050 /*%<
00051  * Associate a tcp message state with a given memory context and
00052  * TCP socket.
00053  *
00054  * Requires:
00055  *
00056  *\li   "mctx" and "sock" be non-NULL and valid types.
00057  *
00058  *\li   "sock" be a read/write TCP socket.
00059  *
00060  *\li   "tcpmsg" be non-NULL and an uninitialized or invalidated structure.
00061  *
00062  * Ensures:
00063  *
00064  *\li   "tcpmsg" is a valid structure.
00065  */
00066 
00067 void
00068 dns_tcpmsg_setmaxsize(dns_tcpmsg_t *tcpmsg, unsigned int maxsize);
00069 /*%<
00070  * Set the maximum packet size to "maxsize"
00071  *
00072  * Requires:
00073  *
00074  *\li   "tcpmsg" be valid.
00075  *
00076  *\li   512 <= "maxsize" <= 65536
00077  */
00078 
00079 isc_result_t
00080 dns_tcpmsg_readmessage(dns_tcpmsg_t *tcpmsg,
00081                        isc_task_t *task, isc_taskaction_t action, void *arg);
00082 /*%<
00083  * Schedule an event to be delivered when a DNS message is readable, or
00084  * when an error occurs on the socket.
00085  *
00086  * Requires:
00087  *
00088  *\li   "tcpmsg" be valid.
00089  *
00090  *\li   "task", "taskaction", and "arg" be valid.
00091  *
00092  * Returns:
00093  *
00094  *\li   ISC_R_SUCCESS           -- no error
00095  *\li   Anything that the isc_socket_recv() call can return.  XXXMLG
00096  *
00097  * Notes:
00098  *
00099  *\li   The event delivered is a fully generic event.  It will contain no
00100  *      actual data.  The sender will be a pointer to the dns_tcpmsg_t.
00101  *      The result code inside that structure should be checked to see
00102  *      what the final result was.
00103  */
00104 
00105 void
00106 dns_tcpmsg_cancelread(dns_tcpmsg_t *tcpmsg);
00107 /*%<
00108  * Cancel a readmessage() call.  The event will still be posted with a
00109  * CANCELED result code.
00110  *
00111  * Requires:
00112  *
00113  *\li   "tcpmsg" be valid.
00114  */
00115 
00116 void
00117 dns_tcpmsg_keepbuffer(dns_tcpmsg_t *tcpmsg, isc_buffer_t *buffer);
00118 /*%<
00119  * If a dns buffer is to be kept between calls, this function marks the
00120  * internal state-machine buffer as invalid, and copies all the contents
00121  * of the state into "buffer".
00122  *
00123  * Requires:
00124  *
00125  *\li   "tcpmsg" be valid.
00126  *
00127  *\li   "buffer" be non-NULL.
00128  */
00129 
00130 void
00131 dns_tcpmsg_invalidate(dns_tcpmsg_t *tcpmsg);
00132 /*%<
00133  * Clean up all allocated state, and invalidate the structure.
00134  *
00135  * Requires:
00136  *
00137  *\li   "tcpmsg" be valid.
00138  *
00139  * Ensures:
00140  *
00141  *\li   "tcpmsg" is invalidated and disassociated with all memory contexts,
00142  *      sockets, etc.
00143  */
00144 
00145 ISC_LANG_ENDDECLS
00146 
00147 #endif /* DNS_TCPMSG_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha