Merge from vendor branch FILE:
[dragonfly.git] / contrib / bind-9.3 / lib / isccc / include / isccc / ccmsg.h
1 /*
2  * Portions Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Portions Copyright (C) 2001  Internet Software Consortium.
4  * Portions Copyright (C) 2001  Nominum, Inc.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
13  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18
19 /* $Id: ccmsg.h,v 1.3.206.1 2004/03/06 08:15:21 marka Exp $ */
20
21 #ifndef ISCCC_CCMSG_H
22 #define ISCCC_CCMSG_H 1
23
24 #include <isc/buffer.h>
25 #include <isc/lang.h>
26 #include <isc/socket.h>
27
28 typedef struct isccc_ccmsg {
29         /* private (don't touch!) */
30         unsigned int            magic;
31         isc_uint32_t            size;
32         isc_buffer_t            buffer;
33         unsigned int            maxsize;
34         isc_mem_t              *mctx;
35         isc_socket_t           *sock;
36         isc_task_t             *task;
37         isc_taskaction_t        action;
38         void                   *arg;
39         isc_event_t             event;
40         /* public (read-only) */
41         isc_result_t            result;
42         isc_sockaddr_t          address;
43 } isccc_ccmsg_t;
44
45 ISC_LANG_BEGINDECLS
46
47 void
48 isccc_ccmsg_init(isc_mem_t *mctx, isc_socket_t *sock, isccc_ccmsg_t *ccmsg);
49 /*
50  * Associate a cc message state with a given memory context and
51  * TCP socket.
52  *
53  * Requires:
54  *
55  *      "mctx" and "sock" be non-NULL and valid types.
56  *
57  *      "sock" be a read/write TCP socket.
58  *
59  *      "ccmsg" be non-NULL and an uninitialized or invalidated structure.
60  *
61  * Ensures:
62  *
63  *      "ccmsg" is a valid structure.
64  */
65
66 void
67 isccc_ccmsg_setmaxsize(isccc_ccmsg_t *ccmsg, unsigned int maxsize);
68 /*
69  * Set the maximum packet size to "maxsize"
70  *
71  * Requires:
72  *
73  *      "ccmsg" be valid.
74  *
75  *      512 <= "maxsize" <= 4294967296
76  */
77
78 isc_result_t
79 isccc_ccmsg_readmessage(isccc_ccmsg_t *ccmsg,
80                        isc_task_t *task, isc_taskaction_t action, void *arg);
81 /*
82  * Schedule an event to be delivered when a command channel message is
83  * readable, or when an error occurs on the socket.
84  *
85  * Requires:
86  *
87  *      "ccmsg" be valid.
88  *
89  *      "task", "taskaction", and "arg" be valid.
90  *
91  * Returns:
92  *
93  *      ISC_R_SUCCESS           -- no error
94  *      Anything that the isc_socket_recv() call can return.  XXXMLG
95  *
96  * Notes:
97  *
98  *      The event delivered is a fully generic event.  It will contain no
99  *      actual data.  The sender will be a pointer to the isccc_ccmsg_t.
100  *      The result code inside that structure should be checked to see
101  *      what the final result was.
102  */
103
104 void
105 isccc_ccmsg_cancelread(isccc_ccmsg_t *ccmsg);
106 /*
107  * Cancel a readmessage() call.  The event will still be posted with a
108  * CANCELED result code.
109  *
110  * Requires:
111  *
112  *      "ccmsg" be valid.
113  */
114
115 void
116 isccc_ccmsg_invalidate(isccc_ccmsg_t *ccmsg);
117 /*
118  * Clean up all allocated state, and invalidate the structure.
119  *
120  * Requires:
121  *
122  *      "ccmsg" be valid.
123  *
124  * Ensures:
125  *
126  *      "ccmsg" is invalidated and disassociated with all memory contexts,
127  *      sockets, etc.
128  */
129
130 ISC_LANG_ENDDECLS
131
132 #endif /* ISCCC_CCMSG_H */