ccmsg.h

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

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