IPXCONN.H (9665B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: F:\projects\c&c\vcs\code\ipxconn.h_v 1.12 16 Oct 1995 16:45:10 JOE_BOSTIC $ */ 17 /*************************************************************************** 18 ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ** 19 *************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : IPXCONN.H * 24 * * 25 * Programmer : Bill Randolph * 26 * * 27 * Start Date : December 19, 1994 * 28 * * 29 * Last Update : April 9, 1995 [BR] * 30 * * 31 *-------------------------------------------------------------------------* 32 * * 33 * This is the Connection Class for IPX communications. It inherits * 34 * a Queue, PacketBuf, timeout variables from ConnectionClass. It * 35 * inherits its Send_/Receive_/Get_Packet functions, and the sequenced * 36 * ACK/Retry logic in Service_Send_Queue & Service_Recieve_Queue from * 37 * SequencedConnClass. It guarantees order of delivery of packets. * 38 * * 39 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 40 41 #ifndef IPXCONN_H 42 #define IPXCONN_H 43 44 45 /* 46 ********************************* Includes ********************************** 47 */ 48 #ifdef SEQ_NET 49 #include "seqconn.h" 50 #else 51 #include "noseqcon.h" 52 #endif 53 #include "ipxaddr.h" 54 55 56 /* 57 ***************************** Class Declaration ***************************** 58 */ 59 #ifdef SEQ_NET 60 class IPXConnClass : public SequencedConnClass 61 #else 62 class IPXConnClass : public NonSequencedConnClass 63 #endif 64 { 65 /* 66 ---------------------------- Public Interface ---------------------------- 67 */ 68 public: 69 /*..................................................................... 70 Various useful enums: 71 .....................................................................*/ 72 enum IPXConnTag { 73 CONN_NAME_MAX = 40, // max # chars allowed for connection name 74 CONNECTION_NONE = -1, // value of an invalid connection ID 75 }; 76 77 /*..................................................................... 78 Constructor/destructor. 79 .....................................................................*/ 80 IPXConnClass(int numsend, int numrecieve, int maxlen, 81 unsigned short magicnum, IPXAddressClass *address, int id, char *name); 82 virtual ~IPXConnClass () {}; 83 84 /*..................................................................... 85 Initialization. 86 .....................................................................*/ 87 virtual void Init (void); 88 89 /*..................................................................... 90 The Configure function is for configuring all connections at once. 91 It's static because it doesn't apply to any specific connection, but 92 all of them. 93 .....................................................................*/ 94 static void Configure(unsigned short socket, 95 int conn_num, ECBType *listen_ecb, ECBType *send_ecb, 96 IPXHeaderType *listen_header, IPXHeaderType *send_header, 97 char *listen_buf, char *send_buf, long handler_rm_ptr, 98 int maxpacketlen); 99 100 /*..................................................................... 101 These routines tell IPX to start listening for packets, and to stop 102 listening for packets. They're static because they affect all 103 connections at once (there's no way to turn listening on for only one 104 connection; it's all or nothing). 105 .....................................................................*/ 106 static bool Start_Listening (void); 107 static bool Stop_Listening (void); 108 109 /*..................................................................... 110 The Destination IPX Address for this connection 111 .....................................................................*/ 112 IPXAddressClass Address; 113 114 /*..................................................................... 115 The "Immediate" (Bridge) address for this connection, and a flag 116 telling if the address has been precomputed. 117 .....................................................................*/ 118 NetNodeType ImmediateAddress; 119 int Immed_Set; 120 121 /*..................................................................... 122 Each IPX Connection can have a Name & Unique numerical ID 123 .....................................................................*/ 124 int ID; 125 char Name[CONN_NAME_MAX]; 126 127 /* 128 -------------------------- Protected Interface --------------------------- 129 */ 130 protected: 131 132 /*..................................................................... 133 This is the overloaded Send routine declared in ConnectionClass, and 134 used in SequencedConnClass. 135 .....................................................................*/ 136 virtual int Send (char *buf, int buflen); 137 138 /*..................................................................... 139 These are the routines that access IPX. Open_Socket & Close_Socket are 140 static because they're called by Start_Listening & Stop_Listening. 141 Send_To & Broadcast are static since they're direct interfaces to IPX, 142 and there's only one IPX instance running. 143 .....................................................................*/ 144 static int Open_Socket(unsigned short socket); 145 static void Close_Socket(unsigned short socket); 146 static int Send_To(char *buf, int buflen, IPXAddressClass *address, NetNodeType immed); 147 static int Broadcast(char *buf, int buflen); 148 149 /*..................................................................... 150 The socket ID for this connection 151 .....................................................................*/ 152 static unsigned short Socket; 153 154 /*..................................................................... 155 User's local Connection # (0 = not logged in) 156 .....................................................................*/ 157 static int ConnectionNum; 158 159 /*..................................................................... 160 This is a static version of MaxPacketLen, which is the size of the 161 app's packets, plus our internal CommHeaderType. It's used in the 162 Start_Listening routine. 163 .....................................................................*/ 164 static int PacketLen; 165 166 /*..................................................................... 167 Variables for Listening (created by the IPXManagerClass, and passed 168 in via Init). All IPX connections share these buffers. 169 .....................................................................*/ 170 static ECBType *ListenECB; 171 static IPXHeaderType *ListenHeader; 172 static char *ListenBuf; 173 174 /*..................................................................... 175 Variables for Sending (created by the IPXManagerClass, and passed 176 in via Init). All IPX connections share these buffers. 177 .....................................................................*/ 178 static ECBType *SendECB; 179 static IPXHeaderType *SendHeader; 180 static char *SendBuf; 181 182 /*..................................................................... 183 This is a REAL-MODE pointer to the event-service-routine for IPX. 184 If it's 0, IPX will operate in polled mode. Otherwise, the high word 185 must contain the segment, and the low word must contain the offset. 186 CS will be the high word value when the routine is called. (Requiring 187 the segment/offset to be computed by the caller gives the caller 188 control over CS.) 189 .....................................................................*/ 190 static long Handler; 191 192 /*..................................................................... 193 This status flag tells us if Configure() has been called or not. 194 .....................................................................*/ 195 static int Configured; 196 197 /*..................................................................... 198 This status flag tells us if the socket has been opened or not. 199 .....................................................................*/ 200 static int SocketOpen; 201 202 /*..................................................................... 203 This status flag tells us if Start_Listening() has been called or not. 204 .....................................................................*/ 205 static int Listening; 206 }; 207 208 #endif