IPXGCONN.H 10 KB

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