IPX.H 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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\ipx.h_v 2.17 16 Oct 1995 16:46:26 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 : IPX.H *
  26. * *
  27. * Programmer : Barry Nance *
  28. * from Client/Server LAN Programming *
  29. * Westwood-ized by Bill Randolph *
  30. * *
  31. * Start Date : December 14, 1994 *
  32. * *
  33. * Last Update : December 14, 1994 [BR] *
  34. * *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef IPX_H
  37. #define IPX_H
  38. /*
  39. ******************************** Structures *********************************
  40. */
  41. typedef unsigned char NetNumType[4];
  42. typedef unsigned char NetNodeType[6];
  43. typedef char UserID[48];
  44. /*---------------------------------------------------------------------------
  45. This is the IPX Packet structure. It's followed by the data itself, which
  46. can be up to 546 bytes long. Annotation of 'IPX' means IPX will set this
  47. field; annotation of 'APP' means the application must set the field.
  48. NOTE: All header fields are ordered high-byte,low-byte.
  49. ---------------------------------------------------------------------------*/
  50. typedef struct IPXHEADER {
  51. unsigned short CheckSum; // IPX: Not used; always 0xffff
  52. unsigned short Length; // IPX: Total size, incl header & data
  53. unsigned char TransportControl; // IPX: # bridges message crossed
  54. unsigned char PacketType; // APP: Set to 4 for IPX (5 for SPX)
  55. unsigned char DestNetworkNumber[4]; // APP: destination Network Number
  56. unsigned char DestNetworkNode[6]; // APP: destination Node Address
  57. unsigned short DestNetworkSocket; // APP: destination Socket Number
  58. unsigned char SourceNetworkNumber[4]; // IPX: source Network Number
  59. unsigned char SourceNetworkNode[6]; // IPX: source Node Address
  60. unsigned short SourceNetworkSocket; // IPX: source Socket Number
  61. } IPXHeaderType;
  62. /*---------------------------------------------------------------------------
  63. This is the IPX Event Control Block. It serves as a communications area
  64. between IPX and the application for a single IPX operation. You should set
  65. up a separate ECB for each IPX operation you perform.
  66. ---------------------------------------------------------------------------*/
  67. typedef struct ECB {
  68. void *Link_Address;
  69. void (*Event_Service_Routine)(void); // APP: event handler (NULL=none)
  70. unsigned char InUse; // IPX: 0 = event complete
  71. unsigned char CompletionCode; // IPX: event's return code
  72. unsigned short SocketNumber; // APP: socket to send data through
  73. unsigned short ConnectionID; // returned by Listen (???)
  74. unsigned short RestOfWorkspace;
  75. unsigned char DriverWorkspace[12];
  76. unsigned char ImmediateAddress[6]; // returned by Get_Local_Target
  77. unsigned short PacketCount;
  78. struct {
  79. void *Address;
  80. unsigned short Length;
  81. } Packet[2];
  82. } ECBType;
  83. /*---------------------------------------------------------------------------
  84. This structure is used for calling DPMI function 0x300, Call-Real-Mode-
  85. Interrupt. It passes register values to & from the interrupt handler.
  86. ---------------------------------------------------------------------------*/
  87. typedef struct {
  88. long edi;
  89. long esi;
  90. long ebp;
  91. long Reserved;
  92. long ebx;
  93. long edx;
  94. long ecx;
  95. long eax;
  96. short Flags;
  97. short es;
  98. short ds;
  99. short fs;
  100. short gs;
  101. short ip;
  102. short cs;
  103. short sp;
  104. short ss;
  105. } RMIType;
  106. /*
  107. ********************************** Defines **********************************
  108. */
  109. /*---------------------------------------------------------------------------
  110. These defines are for the IPX functions. The function number is specified
  111. by placing it in BX when IPX is called. There are two ways to invoke IPX:
  112. use interrupt 0x7a, or use a function whose address is obtained by calling
  113. interrupt 0x2f with AX=0x7a00; the function address is returned in ES:DI.
  114. This is the preferred method, since other apps are known to use int 0x7a.
  115. ---------------------------------------------------------------------------*/
  116. #define IPX_OPEN_SOCKET 0x0000
  117. #define IPX_CLOSE_SOCKET 0x0001
  118. #define IPX_GET_LOCAL_TARGET 0x0002
  119. #define IPX_SEND_PACKET 0x0003
  120. #define IPX_LISTEN_FOR_PACKET 0x0004
  121. #define IPX_SCHEDULE_EVENT 0x0005
  122. #define IPX_CANCEL_EVENT 0x0006
  123. #define IPX_GET_INTERVAL_MARKER 0x0008
  124. #define IPX_GET_INTERNETWORK_ADDRESS 0x0009
  125. #define IPX_RELINQUISH_CONTROL 0x000A
  126. #define IPX_DISCONNECT_FROM_TARGET 0x000B
  127. /*---------------------------------------------------------------------------
  128. These defines are for various IPX error codes:
  129. ---------------------------------------------------------------------------*/
  130. #define IPXERR_CONNECTION_SEVERED 0x00ec
  131. #define IPXERR_CONNECTION_FAILED 0x00ed
  132. #define IPXERR_NO_CONNECTION 0x00ee
  133. #define IPXERR_CONNECTION_TABLE_FULL 0x00ef
  134. #define IPXERR_NO_CANCEL_ECB 0x00f9
  135. #define IPXERR_NO_PATH 0x00fa
  136. #define IPXERR_ECB_INACTIVE 0x00fc
  137. #define IPXERR_INVALID_PACKET_LENGTH 0x00fd
  138. #define IPXERR_SOCKET_TABLE_FULL 0x00fe
  139. #define IPXERR_SOCKET_ERROR 0x00ff
  140. /*---------------------------------------------------------------------------
  141. These defines are for various interrupt vectors and DPMI functions:
  142. ---------------------------------------------------------------------------*/
  143. #define IPX_INT 0x007a
  144. #define DPMI_INT 0x0031
  145. #define DPMI_ALLOC_DOS_MEM 0x0100
  146. #define DPMI_FREE_DOS_MEM 0x0101
  147. #define DPMI_CALL_REAL_INT 0x0300
  148. #define DPMI_LOCK_MEM 0x0600
  149. #define DPMI_UNLOCK_MEM 0x0601
  150. /*
  151. ******************************** Prototypes *********************************
  152. */
  153. /*---------------------------------------------------------------------------
  154. NOTE: All routines return 0 for a success code and one of the above IPX
  155. error codes if there's an error, EXCEPT:
  156. - IPX_SPX_Installed (0 = not installed)
  157. - Get_Connection_Number / Get_1st_Connection_Number (0 = no connection)
  158. ---------------------------------------------------------------------------*/
  159. /*
  160. .................................. ipx.cpp ..................................
  161. */
  162. int IPX_SPX_Installed(void);
  163. int IPX_Open_Socket(unsigned short socket);
  164. int IPX_Close_Socket(unsigned short socket);
  165. int IPX_Get_Connection_Number(void);
  166. int IPX_Get_1st_Connection_Num (char *username);
  167. int IPX_Get_Internet_Address(int connection_number,
  168. unsigned char *network_number, unsigned char *physical_node);
  169. int IPX_Get_User_ID(int connection_number, char *user_id);
  170. int IPX_Listen_For_Packet(struct ECB *ecb_ptr);
  171. void IPX_Send_Packet(struct ECB *ecb_ptr);
  172. int IPX_Get_Local_Target(unsigned char *dest_network, unsigned char *dest_node,
  173. unsigned short dest_socket, unsigned char *bridge_address);
  174. int IPX_Cancel_Event(struct ECB *ecb_ptr);
  175. void Let_IPX_Breath(void);
  176. #endif