jpayne@69
|
1 /******************************************************************************
|
jpayne@69
|
2
|
jpayne@69
|
3
|
jpayne@69
|
4 Copyright 1993, 1998 The Open Group
|
jpayne@69
|
5
|
jpayne@69
|
6 Permission to use, copy, modify, distribute, and sell this software and its
|
jpayne@69
|
7 documentation for any purpose is hereby granted without fee, provided that
|
jpayne@69
|
8 the above copyright notice appear in all copies and that both that
|
jpayne@69
|
9 copyright notice and this permission notice appear in supporting
|
jpayne@69
|
10 documentation.
|
jpayne@69
|
11
|
jpayne@69
|
12 The above copyright notice and this permission notice shall be included in
|
jpayne@69
|
13 all copies or substantial portions of the Software.
|
jpayne@69
|
14
|
jpayne@69
|
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
jpayne@69
|
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
jpayne@69
|
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
jpayne@69
|
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
jpayne@69
|
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
jpayne@69
|
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
jpayne@69
|
21
|
jpayne@69
|
22 Except as contained in this notice, the name of The Open Group shall not be
|
jpayne@69
|
23 used in advertising or otherwise to promote the sale, use or other dealings
|
jpayne@69
|
24 in this Software without prior written authorization from The Open Group.
|
jpayne@69
|
25
|
jpayne@69
|
26 Author: Ralph Mor, X Consortium
|
jpayne@69
|
27 ******************************************************************************/
|
jpayne@69
|
28
|
jpayne@69
|
29 #ifndef _ICECONN_H_
|
jpayne@69
|
30 #define _ICECONN_H_
|
jpayne@69
|
31
|
jpayne@69
|
32 #include <X11/ICE/ICElib.h>
|
jpayne@69
|
33
|
jpayne@69
|
34 /*
|
jpayne@69
|
35 * Data structures for ICE connection object
|
jpayne@69
|
36 */
|
jpayne@69
|
37
|
jpayne@69
|
38 typedef struct _IceSavedReplyWait {
|
jpayne@69
|
39 IceReplyWaitInfo *reply_wait;
|
jpayne@69
|
40 Bool reply_ready;
|
jpayne@69
|
41 struct _IceSavedReplyWait *next;
|
jpayne@69
|
42 } _IceSavedReplyWait;
|
jpayne@69
|
43
|
jpayne@69
|
44 typedef struct _IcePingWait {
|
jpayne@69
|
45 IcePingReplyProc ping_reply_proc;
|
jpayne@69
|
46 IcePointer client_data;
|
jpayne@69
|
47 struct _IcePingWait *next;
|
jpayne@69
|
48 } _IcePingWait;
|
jpayne@69
|
49
|
jpayne@69
|
50 typedef struct {
|
jpayne@69
|
51 char *vendor;
|
jpayne@69
|
52 char *release;
|
jpayne@69
|
53 int version_count;
|
jpayne@69
|
54 IcePoVersionRec *version_recs;
|
jpayne@69
|
55 int auth_count;
|
jpayne@69
|
56 char **auth_names;
|
jpayne@69
|
57 IcePoAuthProc *auth_procs;
|
jpayne@69
|
58 IceIOErrorProc io_error_proc;
|
jpayne@69
|
59 } _IcePoProtocol;
|
jpayne@69
|
60
|
jpayne@69
|
61 typedef struct {
|
jpayne@69
|
62 char *vendor;
|
jpayne@69
|
63 char *release;
|
jpayne@69
|
64 int version_count;
|
jpayne@69
|
65 IcePaVersionRec *version_recs;
|
jpayne@69
|
66 IceProtocolSetupProc protocol_setup_proc;
|
jpayne@69
|
67 IceProtocolActivateProc protocol_activate_proc;
|
jpayne@69
|
68 int auth_count;
|
jpayne@69
|
69 char **auth_names;
|
jpayne@69
|
70 IcePaAuthProc *auth_procs;
|
jpayne@69
|
71 IceHostBasedAuthProc host_based_auth_proc;
|
jpayne@69
|
72 IceIOErrorProc io_error_proc;
|
jpayne@69
|
73 } _IcePaProtocol;
|
jpayne@69
|
74
|
jpayne@69
|
75 typedef struct {
|
jpayne@69
|
76 char *protocol_name;
|
jpayne@69
|
77 _IcePoProtocol *orig_client;
|
jpayne@69
|
78 _IcePaProtocol *accept_client;
|
jpayne@69
|
79 } _IceProtocol;
|
jpayne@69
|
80
|
jpayne@69
|
81 typedef struct {
|
jpayne@69
|
82 Bool in_use;
|
jpayne@69
|
83 int my_opcode;
|
jpayne@69
|
84 _IceProtocol *protocol;
|
jpayne@69
|
85 IcePointer client_data;
|
jpayne@69
|
86 Bool accept_flag;
|
jpayne@69
|
87 union {
|
jpayne@69
|
88 IcePaProcessMsgProc accept_client;
|
jpayne@69
|
89 IcePoProcessMsgProc orig_client;
|
jpayne@69
|
90 } process_msg_proc;
|
jpayne@69
|
91 } _IceProcessMsgInfo;
|
jpayne@69
|
92
|
jpayne@69
|
93 typedef struct {
|
jpayne@69
|
94 int his_version_index;
|
jpayne@69
|
95 int my_version_index;
|
jpayne@69
|
96 char *his_vendor;
|
jpayne@69
|
97 char *his_release;
|
jpayne@69
|
98 char my_auth_index;
|
jpayne@69
|
99 IcePointer my_auth_state;
|
jpayne@69
|
100 Bool must_authenticate;
|
jpayne@69
|
101 } _IceConnectToMeInfo;
|
jpayne@69
|
102
|
jpayne@69
|
103 typedef struct {
|
jpayne@69
|
104 int his_opcode;
|
jpayne@69
|
105 int my_opcode;
|
jpayne@69
|
106 int his_version_index;
|
jpayne@69
|
107 int my_version_index;
|
jpayne@69
|
108 char *his_vendor;
|
jpayne@69
|
109 char *his_release;
|
jpayne@69
|
110 char my_auth_index;
|
jpayne@69
|
111 IcePointer my_auth_state;
|
jpayne@69
|
112 Bool must_authenticate;
|
jpayne@69
|
113 } _IceProtoSetupToMeInfo;
|
jpayne@69
|
114
|
jpayne@69
|
115 typedef struct {
|
jpayne@69
|
116 Bool auth_active;
|
jpayne@69
|
117 char my_auth_index;
|
jpayne@69
|
118 IcePointer my_auth_state;
|
jpayne@69
|
119 } _IceConnectToYouInfo;
|
jpayne@69
|
120
|
jpayne@69
|
121 typedef struct {
|
jpayne@69
|
122 int my_opcode;
|
jpayne@69
|
123 int my_auth_count;
|
jpayne@69
|
124 int *my_auth_indices;
|
jpayne@69
|
125 Bool auth_active;
|
jpayne@69
|
126 char my_auth_index;
|
jpayne@69
|
127 IcePointer my_auth_state;
|
jpayne@69
|
128 } _IceProtoSetupToYouInfo;
|
jpayne@69
|
129
|
jpayne@69
|
130
|
jpayne@69
|
131 struct _IceConn {
|
jpayne@69
|
132
|
jpayne@69
|
133 unsigned int io_ok : 1; /* did an IO error occur? */
|
jpayne@69
|
134 unsigned int swap : 1; /* do we need to swap on reads? */
|
jpayne@69
|
135 unsigned int waiting_for_byteorder : 1; /* waiting for a ByteOrder msg? */
|
jpayne@69
|
136 unsigned int skip_want_to_close : 1; /* avoid shutdown negotiation? */
|
jpayne@69
|
137 unsigned int want_to_close : 1; /* did we send a WantToClose? */
|
jpayne@69
|
138 unsigned int free_asap : 1; /* free as soon as possible */
|
jpayne@69
|
139 unsigned int unused1 : 2; /* future use */
|
jpayne@69
|
140 unsigned int unused2 : 8; /* future use */
|
jpayne@69
|
141
|
jpayne@69
|
142 IceConnectStatus connection_status; /* pending, accepted, rejected */
|
jpayne@69
|
143
|
jpayne@69
|
144 unsigned char my_ice_version_index; /* which version are we using? */
|
jpayne@69
|
145
|
jpayne@69
|
146 struct _XtransConnInfo *trans_conn; /* transport connection object */
|
jpayne@69
|
147 unsigned long send_sequence; /* Sequence # of last msg sent */
|
jpayne@69
|
148 unsigned long receive_sequence; /* Sequence # of last msg received */
|
jpayne@69
|
149
|
jpayne@69
|
150 char *connection_string; /* network connection string */
|
jpayne@69
|
151 char *vendor; /* other client's vendor */
|
jpayne@69
|
152 char *release; /* other client's release */
|
jpayne@69
|
153
|
jpayne@69
|
154 char *inbuf; /* Input buffer starting address */
|
jpayne@69
|
155 char *inbufptr; /* Input buffer index pointer */
|
jpayne@69
|
156 char *inbufmax; /* Input buffer maximum+1 address */
|
jpayne@69
|
157
|
jpayne@69
|
158 char *outbuf; /* Output buffer starting address */
|
jpayne@69
|
159 char *outbufptr; /* Output buffer index pointer */
|
jpayne@69
|
160 char *outbufmax; /* Output buffer maximum+1 address */
|
jpayne@69
|
161
|
jpayne@69
|
162 char *scratch; /* scratch buffer */
|
jpayne@69
|
163 unsigned long scratch_size; /* scratch size */
|
jpayne@69
|
164
|
jpayne@69
|
165 int dispatch_level; /* IceProcessMessages dispatch level */
|
jpayne@69
|
166
|
jpayne@69
|
167 IcePointer context; /* context associated with caller
|
jpayne@69
|
168 of IceOpenConnection */
|
jpayne@69
|
169
|
jpayne@69
|
170 /*
|
jpayne@69
|
171 * Before we read a message, the major opcode of the message must be
|
jpayne@69
|
172 * mapped to our corresponding major opcode (the two clients can use
|
jpayne@69
|
173 * different opcodes for the same protocol). In order to save space,
|
jpayne@69
|
174 * we keep track of the minimum and maximum major opcodes used by the
|
jpayne@69
|
175 * other client. To get the information on how to process this message,
|
jpayne@69
|
176 * we do the following...
|
jpayne@69
|
177 *
|
jpayne@69
|
178 * processMsgInfo = iceConn->process_msg_info[
|
jpayne@69
|
179 * message->majorOpcode - iceConn->his_min_opcode]
|
jpayne@69
|
180 *
|
jpayne@69
|
181 * Note that the number of elements in the iceConn->process_msg_info
|
jpayne@69
|
182 * array is always (iceConn->his_max_opcode - iceConn->his_min_opcode + 1).
|
jpayne@69
|
183 * We check process_msg_info->in_use to see if the opcode is being used.
|
jpayne@69
|
184 */
|
jpayne@69
|
185
|
jpayne@69
|
186 _IceProcessMsgInfo *process_msg_info;
|
jpayne@69
|
187 char his_min_opcode; /* [1..255] */
|
jpayne@69
|
188 char his_max_opcode; /* [1..255] */
|
jpayne@69
|
189
|
jpayne@69
|
190
|
jpayne@69
|
191 /*
|
jpayne@69
|
192 * Number of times this iceConn was returned in IceOpenConnection
|
jpayne@69
|
193 * or IceAcceptConnection.
|
jpayne@69
|
194 */
|
jpayne@69
|
195
|
jpayne@69
|
196 unsigned char open_ref_count;
|
jpayne@69
|
197
|
jpayne@69
|
198
|
jpayne@69
|
199 /*
|
jpayne@69
|
200 * Number of active protocols.
|
jpayne@69
|
201 */
|
jpayne@69
|
202
|
jpayne@69
|
203 unsigned char proto_ref_count;
|
jpayne@69
|
204
|
jpayne@69
|
205
|
jpayne@69
|
206 /*
|
jpayne@69
|
207 * If this ICE connection was created with IceAcceptConnection,
|
jpayne@69
|
208 * the listen_obj field is set to the listen object. Otherwise,
|
jpayne@69
|
209 * the listen_obj field is NULL.
|
jpayne@69
|
210 */
|
jpayne@69
|
211
|
jpayne@69
|
212 IceListenObj listen_obj;
|
jpayne@69
|
213
|
jpayne@69
|
214
|
jpayne@69
|
215
|
jpayne@69
|
216
|
jpayne@69
|
217 /*
|
jpayne@69
|
218 * We need to keep track of all the replies we're waiting for.
|
jpayne@69
|
219 * Check the comments in process.c for how this works.
|
jpayne@69
|
220 */
|
jpayne@69
|
221
|
jpayne@69
|
222 _IceSavedReplyWait *saved_reply_waits;
|
jpayne@69
|
223
|
jpayne@69
|
224
|
jpayne@69
|
225 /*
|
jpayne@69
|
226 * We keep track of all Pings sent from the client. When the Ping reply
|
jpayne@69
|
227 * arrives, we remove it from the list.
|
jpayne@69
|
228 */
|
jpayne@69
|
229
|
jpayne@69
|
230 _IcePingWait *ping_waits;
|
jpayne@69
|
231
|
jpayne@69
|
232
|
jpayne@69
|
233 /*
|
jpayne@69
|
234 * Some state for a client doing a Connection/Protocol Setup
|
jpayne@69
|
235 */
|
jpayne@69
|
236
|
jpayne@69
|
237 _IceConnectToYouInfo *connect_to_you;
|
jpayne@69
|
238 _IceProtoSetupToYouInfo *protosetup_to_you;
|
jpayne@69
|
239
|
jpayne@69
|
240
|
jpayne@69
|
241 /*
|
jpayne@69
|
242 * Some state for a client receiving a Connection/Protocol Setup
|
jpayne@69
|
243 */
|
jpayne@69
|
244
|
jpayne@69
|
245 _IceConnectToMeInfo *connect_to_me;
|
jpayne@69
|
246 _IceProtoSetupToMeInfo *protosetup_to_me;
|
jpayne@69
|
247
|
jpayne@69
|
248 };
|
jpayne@69
|
249
|
jpayne@69
|
250 #endif /* _ICECONN_H_ */
|