CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

IPXGCONN.H (10508B)


      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/IPXGCONN.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 : IPXGCONN.H                               *
     24  *                                                                         *
     25  *                   Programmer : Bill Randolph                            *
     26  *                                                                         *
     27  *                   Start Date : December 19, 1994                        *
     28  *                                                                         *
     29  *                  Last Update : April 11, 1995   [BR]                 	*
     30  *                                                                         *
     31  *-------------------------------------------------------------------------*
     32  *                                                                         *
     33  * This class is a special type of IPX Connection.  It can talk to more		*
     34  * than one system at a time.  It can Broadcast packets to all systems,		*
     35  * or send a packet to one individual system.  The packets it sends to		*
     36  * individual systems can be DATA_NOACK or DATA_ACK packets, but the			*
     37  * packets broadcast have to be DATA_NOACK packets.  This class is for		*
     38  * only the crudest "Who-are-you" type of network communications.  Once		*
     39  * the IPX Address of another system is identified, a "real" IPX				*
     40  * Connection should be created, & further communications done through it.	*
     41  *																									*
     42  * This means that the packet ID field no longer can be used to detect		*
     43  * resends, since the receive queue may receive a lot more packets than		*
     44  * we send out.  So, re-sends cannot be detected; the application must be	*
     45  * designed so that it can handle multiple copies of the same packet.		*
     46  *																									*
     47  * The class uses a slightly different header from the normal Connections;	*
     48  * this header includes the ProductID of the sender, so multiple 				*
     49  * applications can share the same socket, but by using different product	*
     50  * ID's, can distinguish between their own packets & others.					*
     51  *																									*
     52  *	Because of this additional header, and because Receive ACK/Retry logic	*
     53  * is different (we can't detect resends), the following routines are		*
     54  * overloaded:																					*
     55  *		Send_Packet:		must embed the product ID into the packet header	*
     56  *		Receive_Packet:	must detect resends via the LastAddress & 			*
     57  *								LastPacketID arrays. This class doesn't ACK 			*
     58  *								packets until Service_Receive_Queue is called; 		*
     59  *								the parent classes ACK the packet when it's 			*
     60  *								received.														*
     61  *		Get_Packet:			extracts the product ID from the header;				*
     62  *								doesn't care about reading packets in order			*
     63  *		Send					is capable of broadcasting the packet, or sending	*
     64  *								to a specific address										*
     65  *																									*
     66  *	This class also has the ability to cross a Novell Network Bridge.			*
     67  * You provide the class with the bridge address, and subsequent				*
     68  * broadcasts are sent across the bridge as well as to the local network.	*
     69  * Address-specific sends contain the destination network's address,			*
     70  * so they cross a bridge automatically; it's just the broadcasts				*
     71  * that need to know the bridge address.												*
     72  *																									*
     73  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     74 
     75 #ifndef IPXGLOBALCONN_H
     76 #define IPXGLOBALCONN_H
     77 
     78 
     79 #include "ipxconn.h"
     80 
     81 
     82 /*
     83 ********************************** Defines **********************************
     84 */
     85 //---------------------------------------------------------------------------
     86 // This is the header for Global Connection messages.  It includes the usual
     87 // "standard" header that the other connections do; but it also includes an
     88 // IPX address field, so the application can get the address of the sender
     89 // of this message.  This address field must be provided in by the IPX
     90 // Connection Manager class, when it calls this class's Receive_Packet
     91 // function.
     92 //---------------------------------------------------------------------------
     93 typedef struct {
     94 	CommHeaderType Header;
     95 	unsigned short ProductID;
     96 } GlobalHeaderType;
     97 
     98 
     99 /*
    100 ***************************** Class Declaration *****************************
    101 */
    102 class IPXGlobalConnClass : public IPXConnClass
    103 {
    104 	//------------------------------------------------------------------------
    105 	// Public Interface
    106 	//------------------------------------------------------------------------
    107 	public:
    108 		//.....................................................................
    109 		// Some useful enums:
    110 		//.....................................................................
    111 		enum GlobalConnectionEnum {
    112 			//..................................................................
    113 			// This is the magic number for all Global Connections.  Having the
    114 			// same magic number across products lets us ID different products
    115 			// on the net.  If you change the fundamental connection protocol,
    116 			// you must use a different magic number.
    117 			//..................................................................
    118 			//GLOBAL_MAGICNUM = 0x1234,	// used for C&C 1
    119 			GLOBAL_MAGICNUM = 0x1235,		// used for C&C 0
    120 			//..................................................................
    121 			// These are the values used for the ProductID field in the Global
    122 			// Message structure.  It also should be the Magic Number used for
    123 			// the private connections within that product.
    124 			// This list should be continually updated & kept current.  Never
    125 			// ever ever use an old product ID for your product!
    126 			//..................................................................
    127 			COMMAND_AND_CONQUER = 0xaa01,
    128 			COMMAND_AND_CONQUER0 = 0xaa00
    129 		};
    130 
    131 		//.....................................................................
    132 		// Constructor/destructor.
    133 		//.....................................................................
    134 		IPXGlobalConnClass (int numsend, int numrecieve, int maxlen,
    135 			unsigned short product_id);
    136 		virtual ~IPXGlobalConnClass () {};
    137 
    138 		//.....................................................................
    139 		// Send/Receive routines.
    140 		//.....................................................................
    141 		virtual int Send_Packet (void * buf, int buflen,
    142 			IPXAddressClass *address, int ack_req);
    143 		virtual int Receive_Packet (void * buf, int buflen,
    144 			IPXAddressClass *address);
    145 		virtual int Get_Packet (void * buf, int *buflen,
    146 			IPXAddressClass *address, unsigned short *product_id);
    147 
    148 		//.....................................................................
    149 		// This is for telling the connection it can cross a bridge.
    150 		//.....................................................................
    151 		void Set_Bridge (NetNumType bridge);
    152 
    153 		//.....................................................................
    154 		// The Product ID for this product.
    155 		//.....................................................................
    156 		unsigned short ProductID;
    157 
    158 		//.....................................................................
    159 		// This describes the address of a bridge we have to cross.  This class
    160 		// supports crossing only one bridge.  Storing the bridge's network
    161 		// number allows us to obtain its local target address only once, then
    162 		// re-use it.
    163 		//.....................................................................
    164 		NetNumType BridgeNet;
    165 		NetNodeType BridgeNode;
    166 		int IsBridge;
    167 
    168 	//------------------------------------------------------------------------
    169 	// Protected Interface
    170 	//------------------------------------------------------------------------
    171 	protected:
    172 
    173 		//.....................................................................
    174 		// This is the overloaded Send routine declared in ConnectionClass, and
    175 		// used in SequencedConnClass.  This special version sends to the address
    176 		// stored in the extra buffer within the Queue.
    177 		//.....................................................................
    178 		virtual int Send (char *buf, int buflen, void *extrabuf, int extralen);
    179 
    180 		//.....................................................................
    181 		// This routine is overloaded from SequencedConnClass, because the
    182 		// Global Connection needs to ACK its packets differently from the
    183 		// other connections.
    184 		//.....................................................................
    185 		virtual int Service_Receive_Queue (void);
    186 
    187 	private:
    188 		//.....................................................................
    189 		// Since we can't detect resends by using the PacketID (since we're
    190 		// receiving packets from a variety of sources, all using different
    191 		// ID's), we'll have to remember the last 'n' packet addresses & id's
    192 		// for comparison purposes.
    193 		// Note that, if network traffic is heavy, it's still possible for an
    194 		// app to receive the same packet twice!
    195 		//.....................................................................
    196 		IPXAddressClass LastAddress[4];	// array of last 4 addresses
    197 		unsigned long LastPacketID[4];	// array of last 4 packet ID's
    198 		int LastRXIndex;						// index of next avail pos
    199 };
    200 
    201 #endif
    202 
    203 /*************************** end of ipxgconn.h *****************************/