IPXCONN.H 9.3 KB

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