IPXCONN.H 9.3 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/IPXCONN.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 : IPXCONN.H *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : December 19, 1994 *
  26. * *
  27. * Last Update : April 9, 1995 [BR] *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * *
  31. * This is the Connection Class for IPX communications. It inherits *
  32. * a Queue, PacketBuf, timeout variables from ConnectionClass. It *
  33. * inherits its Send_/Receive_/Get_Packet functions, and the sequenced *
  34. * ACK/Retry logic in Service_Send_Queue & Service_Receive_Queue from *
  35. * SequencedConnClass. It guarantees order of delivery of packets. *
  36. * *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #ifndef IPXCONN_H
  39. #define IPXCONN_H
  40. /*
  41. ********************************* Includes **********************************
  42. */
  43. #include "connect.h"
  44. #include "ipxaddr.h"
  45. /*
  46. ***************************** Class Declaration *****************************
  47. */
  48. class IPXConnClass : public ConnectionClass
  49. {
  50. /*
  51. ---------------------------- Public Interface ----------------------------
  52. */
  53. public:
  54. /*.....................................................................
  55. Various useful enums:
  56. .....................................................................*/
  57. enum IPXConnTag {
  58. CONN_NAME_MAX = 40 // max # chars allowed for connection name
  59. };
  60. /*.....................................................................
  61. Constructor/destructor.
  62. .....................................................................*/
  63. IPXConnClass(int numsend, int numrecieve, int maxlen,
  64. unsigned short magicnum, IPXAddressClass *address, int id, char *name,
  65. int extralen = 0);
  66. virtual ~IPXConnClass () {};
  67. /*.....................................................................
  68. Initialization.
  69. .....................................................................*/
  70. virtual void Init (void);
  71. /*.....................................................................
  72. The Configure function is for configuring all connections at once.
  73. It's static because it doesn't apply to any specific connection, but
  74. all of them.
  75. .....................................................................*/
  76. static void Configure(unsigned short socket,
  77. int conn_num, ECBType *listen_ecb, ECBType *send_ecb,
  78. IPXHeaderType *listen_header, IPXHeaderType *send_header,
  79. char *listen_buf, char *send_buf, long handler_rm_ptr,
  80. int maxpacketlen);
  81. /*.....................................................................
  82. These routines tell IPX to start listening for packets, and to stop
  83. listening for packets. They're static because they affect all
  84. connections at once (there's no way to turn listening on for only one
  85. connection; it's all or nothing).
  86. .....................................................................*/
  87. static int Start_Listening (void);
  88. static int Stop_Listening (void);
  89. /*.....................................................................
  90. The Destination IPX Address for this connection
  91. .....................................................................*/
  92. IPXAddressClass Address;
  93. /*.....................................................................
  94. The "Immediate" (Bridge) address for this connection, and a flag
  95. telling if the address has been precomputed.
  96. .....................................................................*/
  97. NetNodeType ImmediateAddress;
  98. int Immed_Set;
  99. /*.....................................................................
  100. Each IPX Connection can have a Name & Unique numerical ID
  101. .....................................................................*/
  102. int ID;
  103. char Name[CONN_NAME_MAX];
  104. /*
  105. -------------------------- Protected Interface ---------------------------
  106. */
  107. protected:
  108. /*.....................................................................
  109. This is the overloaded Send routine declared in ConnectionClass, and
  110. used in SequencedConnClass.
  111. .....................................................................*/
  112. virtual int Send (char *buf, int buflen, void *extrabuf, int extralen);
  113. /*.....................................................................
  114. These are the routines that access IPX. Open_Socket & Close_Socket are
  115. static because they're called by Start_Listening & Stop_Listening.
  116. Send_To & Broadcast are static since they're direct interfaces to IPX,
  117. and there's only one IPX instance running.
  118. .....................................................................*/
  119. static int Open_Socket(unsigned short socket);
  120. static void Close_Socket(unsigned short socket);
  121. static int Send_To(char *buf, int buflen, IPXAddressClass *address,
  122. NetNodeType immed);
  123. static int Broadcast(char *buf, int buflen);
  124. /*.....................................................................
  125. The socket ID for this connection
  126. .....................................................................*/
  127. static unsigned short Socket;
  128. /*.....................................................................
  129. User's local Connection # (0 = not logged in)
  130. .....................................................................*/
  131. static int ConnectionNum;
  132. /*.....................................................................
  133. This is a static version of MaxPacketLen, which is the size of the
  134. app's packets, plus our internal CommHeaderType. It's used in the
  135. Start_Listening routine.
  136. .....................................................................*/
  137. static int PacketLen;
  138. /*.....................................................................
  139. Variables for Listening (created by the IPXManagerClass, and passed
  140. in via Init). All IPX connections share these buffers.
  141. .....................................................................*/
  142. static ECBType *ListenECB;
  143. static IPXHeaderType *ListenHeader;
  144. static char *ListenBuf;
  145. /*.....................................................................
  146. Variables for Sending (created by the IPXManagerClass, and passed
  147. in via Init). All IPX connections share these buffers.
  148. .....................................................................*/
  149. static ECBType *SendECB;
  150. static IPXHeaderType *SendHeader;
  151. static char *SendBuf;
  152. /*.....................................................................
  153. This is a REAL-MODE pointer to the event-service-routine for IPX.
  154. If it's 0, IPX will operate in polled mode. Otherwise, the high word
  155. must contain the segment, and the low word must contain the offset.
  156. CS will be the high word value when the routine is called. (Requiring
  157. the segment/offset to be computed by the caller gives the caller
  158. control over CS.)
  159. .....................................................................*/
  160. static long Handler;
  161. /*.....................................................................
  162. This status flag tells us if Configure() has been called or not.
  163. .....................................................................*/
  164. static int Configured;
  165. /*.....................................................................
  166. This status flag tells us if the socket has been opened or not.
  167. .....................................................................*/
  168. static int SocketOpen;
  169. /*.....................................................................
  170. This status flag tells us if Start_Listening() has been called or not.
  171. .....................................................................*/
  172. static int Listening;
  173. };
  174. #endif
  175. /*************************** end of ipxconn.h ******************************/