Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:23

0001 /******************************************************************************
0002 
0003 
0004 Copyright 1993, 1998  The Open Group
0005 
0006 Permission to use, copy, modify, distribute, and sell this software and its
0007 documentation for any purpose is hereby granted without fee, provided that
0008 the above copyright notice appear in all copies and that both that
0009 copyright notice and this permission notice appear in supporting
0010 documentation.
0011 
0012 The above copyright notice and this permission notice shall be included in
0013 all copies or substantial portions of the Software.
0014 
0015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0018 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0021 
0022 Except as contained in this notice, the name of The Open Group shall not be
0023 used in advertising or otherwise to promote the sale, use or other dealings
0024 in this Software without prior written authorization from The Open Group.
0025 
0026 Author: Ralph Mor, X Consortium
0027 ******************************************************************************/
0028 
0029 #ifndef _ICECONN_H_
0030 #define _ICECONN_H_
0031 
0032 #include <X11/ICE/ICElib.h>
0033 
0034 /*
0035  * Data structures for ICE connection object
0036  */
0037 
0038 typedef struct _IceSavedReplyWait {
0039     IceReplyWaitInfo        *reply_wait;
0040     Bool            reply_ready;
0041     struct _IceSavedReplyWait   *next;
0042 } _IceSavedReplyWait;
0043 
0044 typedef struct _IcePingWait {
0045     IcePingReplyProc        ping_reply_proc;
0046     IcePointer          client_data;
0047     struct _IcePingWait     *next;
0048 } _IcePingWait;
0049 
0050 typedef struct {
0051     char        *vendor;
0052     char        *release;
0053     int         version_count;
0054     IcePoVersionRec *version_recs;
0055     int         auth_count;
0056     char        **auth_names;
0057     IcePoAuthProc   *auth_procs;
0058     IceIOErrorProc  io_error_proc;
0059 } _IcePoProtocol;
0060 
0061 typedef struct {
0062     char            *vendor;
0063     char            *release;
0064     int             version_count;
0065     IcePaVersionRec     *version_recs;
0066     IceProtocolSetupProc    protocol_setup_proc;
0067     IceProtocolActivateProc protocol_activate_proc;
0068     int             auth_count;
0069     char            **auth_names;
0070     IcePaAuthProc       *auth_procs;
0071     IceHostBasedAuthProc    host_based_auth_proc;
0072     IceIOErrorProc      io_error_proc;
0073 } _IcePaProtocol;
0074 
0075 typedef struct {
0076     char        *protocol_name;
0077     _IcePoProtocol  *orig_client;
0078     _IcePaProtocol      *accept_client;
0079 } _IceProtocol;
0080 
0081 typedef struct {
0082     Bool            in_use;
0083     int             my_opcode;
0084     _IceProtocol        *protocol;
0085     IcePointer          client_data;
0086     Bool            accept_flag;
0087     union {
0088     IcePaProcessMsgProc accept_client;
0089     IcePoProcessMsgProc orig_client;
0090     } process_msg_proc;
0091 } _IceProcessMsgInfo;
0092 
0093 typedef struct {
0094     int     his_version_index;
0095     int     my_version_index;
0096     char    *his_vendor;
0097     char    *his_release;
0098     char    my_auth_index;
0099     IcePointer  my_auth_state;
0100     Bool    must_authenticate;
0101 } _IceConnectToMeInfo;
0102 
0103 typedef struct {
0104     int     his_opcode;
0105     int     my_opcode;
0106     int     his_version_index;
0107     int     my_version_index;
0108     char    *his_vendor;
0109     char    *his_release;
0110     char    my_auth_index;
0111     IcePointer  my_auth_state;
0112     Bool    must_authenticate;
0113 } _IceProtoSetupToMeInfo;
0114 
0115 typedef struct {
0116     Bool    auth_active;
0117     char    my_auth_index;
0118     IcePointer  my_auth_state;
0119 } _IceConnectToYouInfo;
0120 
0121 typedef struct {
0122     int     my_opcode;
0123     int     my_auth_count;
0124     int     *my_auth_indices;
0125     Bool    auth_active;
0126     char    my_auth_index;
0127     IcePointer  my_auth_state;
0128 } _IceProtoSetupToYouInfo;
0129 
0130 
0131 struct _IceConn {
0132 
0133     unsigned int io_ok : 1;          /* did an IO error occur? */
0134     unsigned int swap : 1;               /* do we need to swap on reads? */
0135     unsigned int waiting_for_byteorder : 1;  /* waiting for a ByteOrder msg? */
0136     unsigned int skip_want_to_close : 1;     /* avoid shutdown negotiation? */
0137     unsigned int want_to_close : 1;      /* did we send a WantToClose? */
0138     unsigned int free_asap : 1;          /* free as soon as possible */
0139     unsigned int unused1 : 2;            /* future use */
0140     unsigned int unused2 : 8;            /* future use */
0141 
0142     IceConnectStatus connection_status; /* pending, accepted, rejected */
0143 
0144     unsigned char my_ice_version_index; /* which version are we using? */
0145 
0146     struct _XtransConnInfo *trans_conn; /* transport connection object */
0147     unsigned long send_sequence;        /* Sequence # of last msg sent */
0148     unsigned long receive_sequence;     /* Sequence # of last msg received */
0149 
0150     char *connection_string;        /* network connection string */
0151     char *vendor;           /* other client's vendor */
0152     char *release;          /* other client's release */
0153 
0154     char *inbuf;            /* Input buffer starting address */
0155     char *inbufptr;         /* Input buffer index pointer */
0156     char *inbufmax;         /* Input buffer maximum+1 address */
0157 
0158     char *outbuf;           /* Output buffer starting address */
0159     char *outbufptr;            /* Output buffer index pointer */
0160     char *outbufmax;            /* Output buffer maximum+1 address */
0161 
0162     char *scratch;          /* scratch buffer */
0163     unsigned long scratch_size;     /* scratch size */
0164 
0165     int dispatch_level;         /* IceProcessMessages dispatch level */
0166 
0167     IcePointer context;         /* context associated with caller
0168                        of IceOpenConnection */
0169 
0170     /*
0171      * Before we read a message, the major opcode of the message must be
0172      * mapped to our corresponding major opcode (the two clients can use
0173      * different opcodes for the same protocol).  In order to save space,
0174      * we keep track of the minimum and maximum major opcodes used by the
0175      * other client.  To get the information on how to process this message,
0176      * we do the following...
0177      *
0178      * processMsgInfo = iceConn->process_msg_info[
0179      *     message->majorOpcode - iceConn->his_min_opcode]
0180      *
0181      * Note that the number of elements in the iceConn->process_msg_info
0182      * array is always (iceConn->his_max_opcode - iceConn->his_min_opcode + 1).
0183      * We check process_msg_info->in_use to see if the opcode is being used.
0184      */
0185 
0186     _IceProcessMsgInfo      *process_msg_info;
0187     char            his_min_opcode;   /* [1..255] */
0188     char            his_max_opcode;   /* [1..255] */
0189 
0190 
0191     /*
0192      * Number of times this iceConn was returned in IceOpenConnection
0193      * or IceAcceptConnection.
0194      */
0195 
0196     unsigned char       open_ref_count;
0197 
0198 
0199     /*
0200      * Number of active protocols.
0201      */
0202 
0203     unsigned char       proto_ref_count;
0204 
0205 
0206     /*
0207      * If this ICE connection was created with IceAcceptConnection,
0208      * the listen_obj field is set to the listen object.  Otherwise,
0209      * the listen_obj field is NULL.
0210      */
0211 
0212     IceListenObj        listen_obj;
0213 
0214 
0215 
0216 
0217     /*
0218      * We need to keep track of all the replies we're waiting for.
0219      * Check the comments in process.c for how this works.
0220      */
0221 
0222     _IceSavedReplyWait      *saved_reply_waits;
0223 
0224 
0225     /*
0226      * We keep track of all Pings sent from the client.  When the Ping reply
0227      * arrives, we remove it from the list.
0228      */
0229 
0230     _IcePingWait        *ping_waits;
0231 
0232 
0233     /*
0234      * Some state for a client doing a Connection/Protocol Setup
0235      */
0236 
0237     _IceConnectToYouInfo    *connect_to_you;
0238     _IceProtoSetupToYouInfo *protosetup_to_you;
0239 
0240 
0241     /*
0242      * Some state for a client receiving a Connection/Protocol Setup
0243      */
0244 
0245     _IceConnectToMeInfo     *connect_to_me;
0246     _IceProtoSetupToMeInfo  *protosetup_to_me;
0247 
0248 };
0249 
0250 #endif /* _ICECONN_H_ */