jpayne@69: /****************************************************************************** jpayne@69: jpayne@69: jpayne@69: Copyright 1993, 1998 The Open Group jpayne@69: jpayne@69: Permission to use, copy, modify, distribute, and sell this software and its jpayne@69: documentation for any purpose is hereby granted without fee, provided that jpayne@69: the above copyright notice appear in all copies and that both that jpayne@69: copyright notice and this permission notice appear in supporting jpayne@69: documentation. jpayne@69: jpayne@69: The above copyright notice and this permission notice shall be included in jpayne@69: all copies or substantial portions of the Software. jpayne@69: jpayne@69: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR jpayne@69: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, jpayne@69: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE jpayne@69: OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN jpayne@69: AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN jpayne@69: CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jpayne@69: jpayne@69: Except as contained in this notice, the name of The Open Group shall not be jpayne@69: used in advertising or otherwise to promote the sale, use or other dealings jpayne@69: in this Software without prior written authorization from The Open Group. jpayne@69: jpayne@69: Author: Ralph Mor, X Consortium jpayne@69: ******************************************************************************/ jpayne@69: jpayne@69: #ifndef _ICECONN_H_ jpayne@69: #define _ICECONN_H_ jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* jpayne@69: * Data structures for ICE connection object jpayne@69: */ jpayne@69: jpayne@69: typedef struct _IceSavedReplyWait { jpayne@69: IceReplyWaitInfo *reply_wait; jpayne@69: Bool reply_ready; jpayne@69: struct _IceSavedReplyWait *next; jpayne@69: } _IceSavedReplyWait; jpayne@69: jpayne@69: typedef struct _IcePingWait { jpayne@69: IcePingReplyProc ping_reply_proc; jpayne@69: IcePointer client_data; jpayne@69: struct _IcePingWait *next; jpayne@69: } _IcePingWait; jpayne@69: jpayne@69: typedef struct { jpayne@69: char *vendor; jpayne@69: char *release; jpayne@69: int version_count; jpayne@69: IcePoVersionRec *version_recs; jpayne@69: int auth_count; jpayne@69: char **auth_names; jpayne@69: IcePoAuthProc *auth_procs; jpayne@69: IceIOErrorProc io_error_proc; jpayne@69: } _IcePoProtocol; jpayne@69: jpayne@69: typedef struct { jpayne@69: char *vendor; jpayne@69: char *release; jpayne@69: int version_count; jpayne@69: IcePaVersionRec *version_recs; jpayne@69: IceProtocolSetupProc protocol_setup_proc; jpayne@69: IceProtocolActivateProc protocol_activate_proc; jpayne@69: int auth_count; jpayne@69: char **auth_names; jpayne@69: IcePaAuthProc *auth_procs; jpayne@69: IceHostBasedAuthProc host_based_auth_proc; jpayne@69: IceIOErrorProc io_error_proc; jpayne@69: } _IcePaProtocol; jpayne@69: jpayne@69: typedef struct { jpayne@69: char *protocol_name; jpayne@69: _IcePoProtocol *orig_client; jpayne@69: _IcePaProtocol *accept_client; jpayne@69: } _IceProtocol; jpayne@69: jpayne@69: typedef struct { jpayne@69: Bool in_use; jpayne@69: int my_opcode; jpayne@69: _IceProtocol *protocol; jpayne@69: IcePointer client_data; jpayne@69: Bool accept_flag; jpayne@69: union { jpayne@69: IcePaProcessMsgProc accept_client; jpayne@69: IcePoProcessMsgProc orig_client; jpayne@69: } process_msg_proc; jpayne@69: } _IceProcessMsgInfo; jpayne@69: jpayne@69: typedef struct { jpayne@69: int his_version_index; jpayne@69: int my_version_index; jpayne@69: char *his_vendor; jpayne@69: char *his_release; jpayne@69: char my_auth_index; jpayne@69: IcePointer my_auth_state; jpayne@69: Bool must_authenticate; jpayne@69: } _IceConnectToMeInfo; jpayne@69: jpayne@69: typedef struct { jpayne@69: int his_opcode; jpayne@69: int my_opcode; jpayne@69: int his_version_index; jpayne@69: int my_version_index; jpayne@69: char *his_vendor; jpayne@69: char *his_release; jpayne@69: char my_auth_index; jpayne@69: IcePointer my_auth_state; jpayne@69: Bool must_authenticate; jpayne@69: } _IceProtoSetupToMeInfo; jpayne@69: jpayne@69: typedef struct { jpayne@69: Bool auth_active; jpayne@69: char my_auth_index; jpayne@69: IcePointer my_auth_state; jpayne@69: } _IceConnectToYouInfo; jpayne@69: jpayne@69: typedef struct { jpayne@69: int my_opcode; jpayne@69: int my_auth_count; jpayne@69: int *my_auth_indices; jpayne@69: Bool auth_active; jpayne@69: char my_auth_index; jpayne@69: IcePointer my_auth_state; jpayne@69: } _IceProtoSetupToYouInfo; jpayne@69: jpayne@69: jpayne@69: struct _IceConn { jpayne@69: jpayne@69: unsigned int io_ok : 1; /* did an IO error occur? */ jpayne@69: unsigned int swap : 1; /* do we need to swap on reads? */ jpayne@69: unsigned int waiting_for_byteorder : 1; /* waiting for a ByteOrder msg? */ jpayne@69: unsigned int skip_want_to_close : 1; /* avoid shutdown negotiation? */ jpayne@69: unsigned int want_to_close : 1; /* did we send a WantToClose? */ jpayne@69: unsigned int free_asap : 1; /* free as soon as possible */ jpayne@69: unsigned int unused1 : 2; /* future use */ jpayne@69: unsigned int unused2 : 8; /* future use */ jpayne@69: jpayne@69: IceConnectStatus connection_status; /* pending, accepted, rejected */ jpayne@69: jpayne@69: unsigned char my_ice_version_index; /* which version are we using? */ jpayne@69: jpayne@69: struct _XtransConnInfo *trans_conn; /* transport connection object */ jpayne@69: unsigned long send_sequence; /* Sequence # of last msg sent */ jpayne@69: unsigned long receive_sequence; /* Sequence # of last msg received */ jpayne@69: jpayne@69: char *connection_string; /* network connection string */ jpayne@69: char *vendor; /* other client's vendor */ jpayne@69: char *release; /* other client's release */ jpayne@69: jpayne@69: char *inbuf; /* Input buffer starting address */ jpayne@69: char *inbufptr; /* Input buffer index pointer */ jpayne@69: char *inbufmax; /* Input buffer maximum+1 address */ jpayne@69: jpayne@69: char *outbuf; /* Output buffer starting address */ jpayne@69: char *outbufptr; /* Output buffer index pointer */ jpayne@69: char *outbufmax; /* Output buffer maximum+1 address */ jpayne@69: jpayne@69: char *scratch; /* scratch buffer */ jpayne@69: unsigned long scratch_size; /* scratch size */ jpayne@69: jpayne@69: int dispatch_level; /* IceProcessMessages dispatch level */ jpayne@69: jpayne@69: IcePointer context; /* context associated with caller jpayne@69: of IceOpenConnection */ jpayne@69: jpayne@69: /* jpayne@69: * Before we read a message, the major opcode of the message must be jpayne@69: * mapped to our corresponding major opcode (the two clients can use jpayne@69: * different opcodes for the same protocol). In order to save space, jpayne@69: * we keep track of the minimum and maximum major opcodes used by the jpayne@69: * other client. To get the information on how to process this message, jpayne@69: * we do the following... jpayne@69: * jpayne@69: * processMsgInfo = iceConn->process_msg_info[ jpayne@69: * message->majorOpcode - iceConn->his_min_opcode] jpayne@69: * jpayne@69: * Note that the number of elements in the iceConn->process_msg_info jpayne@69: * array is always (iceConn->his_max_opcode - iceConn->his_min_opcode + 1). jpayne@69: * We check process_msg_info->in_use to see if the opcode is being used. jpayne@69: */ jpayne@69: jpayne@69: _IceProcessMsgInfo *process_msg_info; jpayne@69: char his_min_opcode; /* [1..255] */ jpayne@69: char his_max_opcode; /* [1..255] */ jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Number of times this iceConn was returned in IceOpenConnection jpayne@69: * or IceAcceptConnection. jpayne@69: */ jpayne@69: jpayne@69: unsigned char open_ref_count; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Number of active protocols. jpayne@69: */ jpayne@69: jpayne@69: unsigned char proto_ref_count; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * If this ICE connection was created with IceAcceptConnection, jpayne@69: * the listen_obj field is set to the listen object. Otherwise, jpayne@69: * the listen_obj field is NULL. jpayne@69: */ jpayne@69: jpayne@69: IceListenObj listen_obj; jpayne@69: jpayne@69: jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * We need to keep track of all the replies we're waiting for. jpayne@69: * Check the comments in process.c for how this works. jpayne@69: */ jpayne@69: jpayne@69: _IceSavedReplyWait *saved_reply_waits; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * We keep track of all Pings sent from the client. When the Ping reply jpayne@69: * arrives, we remove it from the list. jpayne@69: */ jpayne@69: jpayne@69: _IcePingWait *ping_waits; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Some state for a client doing a Connection/Protocol Setup jpayne@69: */ jpayne@69: jpayne@69: _IceConnectToYouInfo *connect_to_you; jpayne@69: _IceProtoSetupToYouInfo *protosetup_to_you; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Some state for a client receiving a Connection/Protocol Setup jpayne@69: */ jpayne@69: jpayne@69: _IceConnectToMeInfo *connect_to_me; jpayne@69: _IceProtoSetupToMeInfo *protosetup_to_me; jpayne@69: jpayne@69: }; jpayne@69: jpayne@69: #endif /* _ICECONN_H_ */