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