IPXCONN.H (9568B)
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: /CounterStrike/IPXCONN.H 1 3/03/97 10:24a 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_Receive_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 #include "connect.h" 49 #include "ipxaddr.h" 50 51 52 /* 53 ***************************** Class Declaration ***************************** 54 */ 55 class IPXConnClass : public ConnectionClass 56 { 57 /* 58 ---------------------------- Public Interface ---------------------------- 59 */ 60 public: 61 /*..................................................................... 62 Various useful enums: 63 .....................................................................*/ 64 enum IPXConnTag { 65 CONN_NAME_MAX = 40 // max # chars allowed for connection name 66 }; 67 68 /*..................................................................... 69 Constructor/destructor. 70 .....................................................................*/ 71 IPXConnClass(int numsend, int numrecieve, int maxlen, 72 unsigned short magicnum, IPXAddressClass *address, int id, char *name, 73 int extralen = 0); 74 virtual ~IPXConnClass () {}; 75 76 /*..................................................................... 77 Initialization. 78 .....................................................................*/ 79 virtual void Init (void); 80 81 /*..................................................................... 82 The Configure function is for configuring all connections at once. 83 It's static because it doesn't apply to any specific connection, but 84 all of them. 85 .....................................................................*/ 86 static void Configure(unsigned short socket, 87 int conn_num, ECBType *listen_ecb, ECBType *send_ecb, 88 IPXHeaderType *listen_header, IPXHeaderType *send_header, 89 char *listen_buf, char *send_buf, long handler_rm_ptr, 90 int maxpacketlen); 91 92 /*..................................................................... 93 These routines tell IPX to start listening for packets, and to stop 94 listening for packets. They're static because they affect all 95 connections at once (there's no way to turn listening on for only one 96 connection; it's all or nothing). 97 .....................................................................*/ 98 static int Start_Listening (void); 99 static int Stop_Listening (void); 100 101 /*..................................................................... 102 The Destination IPX Address for this connection 103 .....................................................................*/ 104 IPXAddressClass Address; 105 106 /*..................................................................... 107 The "Immediate" (Bridge) address for this connection, and a flag 108 telling if the address has been precomputed. 109 .....................................................................*/ 110 NetNodeType ImmediateAddress; 111 int Immed_Set; 112 113 /*..................................................................... 114 Each IPX Connection can have a Name & Unique numerical ID 115 .....................................................................*/ 116 int ID; 117 char Name[CONN_NAME_MAX]; 118 119 /* 120 -------------------------- Protected Interface --------------------------- 121 */ 122 protected: 123 124 /*..................................................................... 125 This is the overloaded Send routine declared in ConnectionClass, and 126 used in SequencedConnClass. 127 .....................................................................*/ 128 virtual int Send (char *buf, int buflen, void *extrabuf, int extralen); 129 130 /*..................................................................... 131 These are the routines that access IPX. Open_Socket & Close_Socket are 132 static because they're called by Start_Listening & Stop_Listening. 133 Send_To & Broadcast are static since they're direct interfaces to IPX, 134 and there's only one IPX instance running. 135 .....................................................................*/ 136 static int Open_Socket(unsigned short socket); 137 static void Close_Socket(unsigned short socket); 138 static int Send_To(char *buf, int buflen, IPXAddressClass *address, 139 NetNodeType immed); 140 static int Broadcast(char *buf, int buflen); 141 142 /*..................................................................... 143 The socket ID for this connection 144 .....................................................................*/ 145 static unsigned short Socket; 146 147 /*..................................................................... 148 User's local Connection # (0 = not logged in) 149 .....................................................................*/ 150 static int ConnectionNum; 151 152 /*..................................................................... 153 This is a static version of MaxPacketLen, which is the size of the 154 app's packets, plus our internal CommHeaderType. It's used in the 155 Start_Listening routine. 156 .....................................................................*/ 157 static int PacketLen; 158 159 /*..................................................................... 160 Variables for Listening (created by the IPXManagerClass, and passed 161 in via Init). All IPX connections share these buffers. 162 .....................................................................*/ 163 static ECBType *ListenECB; 164 static IPXHeaderType *ListenHeader; 165 static char *ListenBuf; 166 167 /*..................................................................... 168 Variables for Sending (created by the IPXManagerClass, and passed 169 in via Init). All IPX connections share these buffers. 170 .....................................................................*/ 171 static ECBType *SendECB; 172 static IPXHeaderType *SendHeader; 173 static char *SendBuf; 174 175 /*..................................................................... 176 This is a REAL-MODE pointer to the event-service-routine for IPX. 177 If it's 0, IPX will operate in polled mode. Otherwise, the high word 178 must contain the segment, and the low word must contain the offset. 179 CS will be the high word value when the routine is called. (Requiring 180 the segment/offset to be computed by the caller gives the caller 181 control over CS.) 182 .....................................................................*/ 183 static long Handler; 184 185 /*..................................................................... 186 This status flag tells us if Configure() has been called or not. 187 .....................................................................*/ 188 static int Configured; 189 190 /*..................................................................... 191 This status flag tells us if the socket has been opened or not. 192 .....................................................................*/ 193 static int SocketOpen; 194 195 /*..................................................................... 196 This status flag tells us if Start_Listening() has been called or not. 197 .....................................................................*/ 198 static int Listening; 199 }; 200 201 #endif 202 203 /*************************** end of ipxconn.h ******************************/