IPX.H 8.3 KB

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