IPXGCONN.H 10 KB

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