Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

524 lines
19 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1994-1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dplayi.h
  6. * Content: DirectPlay data structures
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 1/96 andyco created it
  11. * 1/26/96 andyco list data structures
  12. * 4/10/96 andyco removed dpmess.h
  13. * 4/23/96 andyco added ipx support
  14. * 4/25/96 andyco messages now have blobs (sockaddr's) instead of dwReserveds
  15. * 8/10/96 kipo update max message size to be (2^20) - 1
  16. * 8/15/96 andyco added local data
  17. * 8/30/96 andyco clean it up b4 you shut it down! added globaldata.
  18. * 9/3/96 andyco bagosockets
  19. * 12/18/96 andyco de-threading - use a fixed # of prealloced threads.
  20. * cruised the enum socket / thread - use the system
  21. * socket / thread instead. updated global struct.
  22. * 2/7/97 andyco moved all per IDirectPlay globals into globaldata
  23. * 3/17/97 kipo GetServerAddress() now returns an error so that we can
  24. * return DPERR_USERCANCEL from the EnumSessions dialog
  25. * 3/25/97 andyco dec debug lock counter b4 dropping lock!
  26. * 4/11/97 andyco added saddrControlSocket
  27. * 5/12/97 kipo added ADDR_BUFFER_SIZE constant and removed unused variables
  28. * 5/15/97 andyco added ipx spare thread to global data - used when nameserver
  29. * migrates to this host to make sure that old system receive
  30. * thread shuts down
  31. * 6/22/97 kipo include wsnwlink.h
  32. * 7/11/97 andyco added support for ws2 + async reply thread
  33. * 8/25/97 sohailm added DEFAULT_RECEIVE_BUFFERSIZE
  34. * 12/5/97 andyco voice support
  35. * 01/5/97 sohailm added fd big set related definitions and macros (#15244).
  36. * 1/20/98 myronth #ifdef'd out voice support
  37. * 1/27/98 sohailm added firewall support
  38. * 2/13/98 aarono added async support
  39. * 2/18/98 a-peterz Comment byte order mess-up with SERVER_xxx_PORT constants
  40. * 3/3/98 aarono Bug#19188 remove accept thread
  41. * 12/15/98 aarono make async enum run async
  42. **************************************************************************/
  43. #ifndef __DPSP_INCLUDED__
  44. #define __DPSP_INCLUDED__
  45. #include "windows.h"
  46. #include "windowsx.h"
  47. #include "wsipx.h"
  48. #include "wsnwlink.h"
  49. #include "dplaysp.h"
  50. #include "bilink.h"
  51. #include "fpm.h"
  52. #ifdef DPLAY_VOICE_SUPPORT
  53. #include "nmvoice.h"
  54. #endif // DPLAY_VOICE_SUPPORT
  55. #include "dpf.h"
  56. #include "dputils.h"
  57. #include "memalloc.h"
  58. #include "resource.h"
  59. #include <winsock.h>
  60. // to turn off SendEx support, comment this flag out.
  61. #define SENDEX 1
  62. // use ddraw's assert code (see orion\misc\dpf.h)
  63. #define ASSERT DDASSERT
  64. typedef WORD PORT;
  65. typedef UINT SOCKERR;
  66. // server ports
  67. // Oops! We forgot to convert these constants to net byte order in the code so we
  68. // are really using port 47624 (0xBA08) instead of 2234 (0x08BA)
  69. // We are living with the mistake.
  70. #define SERVER_STREAM_PORT 2234
  71. #define SERVER_DGRAM_PORT 2234
  72. // range of ports used by sp (these are properly converted in the code)
  73. #define DPSP_MIN_PORT 2300
  74. #define DPSP_MAX_PORT 2400
  75. #define DPSP_NUM_PORTS ((DPSP_MAX_PORT - DPSP_MIN_PORT)+1)
  76. #define SPMESSAGEHEADERLEN (sizeof(DWORD))
  77. #define DEFAULT_RECEIVE_BUFFERSIZE (4*1024) // default receive buffer size per connection
  78. // token means this message was received from a remote
  79. // dplay.
  80. #define TOKEN 0xFAB00000
  81. // helper_token means this message was forwarded by our server helper (host)
  82. #define HELPER_TOKEN 0xCAB00000
  83. // server_token means this message is exchanged with dplaysvr (needed to distinguish
  84. // messages from a remote dpwsockx)
  85. #define SERVER_TOKEN 0xBAB00000
  86. // tells receiver to reuse the connection for replies (needed to support fullduplex
  87. // connections)
  88. #define REUSE_TOKEN 0xAAB00000
  89. // masks
  90. #define TOKEN_MASK 0xFFF00000
  91. #define SIZE_MASK (~TOKEN_MASK)
  92. // maxmessagelen = 2^20 (need 12 bits for token)
  93. #define SPMAXMESSAGELEN ( 1048576 - 1)
  94. #define VALID_SP_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == TOKEN ? TRUE : FALSE)
  95. #define VALID_HELPER_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == HELPER_TOKEN ? TRUE : FALSE)
  96. #define VALID_REUSE_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == REUSE_TOKEN ? TRUE : FALSE)
  97. #define VALID_SERVER_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == SERVER_TOKEN ? TRUE : FALSE)
  98. #define SP_MESSAGE_SIZE(pMsg) ( (*((DWORD *)pMsg) & SIZE_MASK))
  99. #define SP_MESSAGE_TOKEN(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK))
  100. #define VALID_DPWS_MESSAGE(pMsg) ( VALID_SP_MESSAGE(pMsg) || VALID_HELPER_MESSAGE(pMsg) || \
  101. VALID_SERVER_MESSAGE(pMsg) || VALID_REUSE_MESSAGE(pMsg) )
  102. #define VALID_DPLAYSVR_MESSAGE(pMsg) ( VALID_SP_MESSAGE(pMsg) || VALID_SERVER_MESSAGE(pMsg) || \
  103. VALID_REUSE_MESSAGE(pMsg) )
  104. // the actual value is ~ 1500 bytes.
  105. // we use 1024 to be safe (IPX won't packetize for us - it can only
  106. // send what the underlying net can handle (MTU))
  107. #define IPX_MAX_DGRAM 1024
  108. // relation of timeout to latency
  109. #define TIMEOUT_SCALE 10
  110. #define SPTIMEOUT(latency) (TIMEOUT_SCALE * latency)
  111. // the default size of the socket cache (gBagOSockets)
  112. #define MAX_CONNECTED_SOCKETS 64
  113. // the initial size of the receive list
  114. #define INITIAL_RECEIVELIST_SIZE 16
  115. // version number for service provider
  116. #define SPMINORVERSION 0x0000 // service provider-specific version number
  117. #define VERSIONNUMBER (DPSP_MAJORVERSION | SPMINORVERSION) // version number for service provider
  118. // biggest user enterable addess
  119. #define ADDR_BUFFER_SIZE 128
  120. // macro picks the service socket depending on ipx vs. tcp
  121. // ipx uses dgram, tcp uses stream
  122. #define SERVICE_SOCKET(pgd) ( (pgd->AddressFamily == AF_IPX) \
  123. ? pgd->sSystemDGramSocket : pgd->sSystemStreamSocket)
  124. //
  125. // In order to listen to any number of sockets we need our own version
  126. // of fd_set and FD_SET(). We call them fd_big_set and FD_BIG_SET().
  127. //
  128. typedef struct fd_big_set {
  129. u_int fd_count; // how many are SET?
  130. SOCKET fd_array[0]; // an array of SOCKETs
  131. } fd_big_set;
  132. // stolen from winsock2.h
  133. #ifndef _WINSOCK2API_
  134. typedef HANDLE WSAEVENT;
  135. typedef struct _WSAOVERLAPPED {
  136. DWORD Internal;
  137. DWORD InternalHigh;
  138. DWORD Offset;
  139. DWORD OffsetHigh;
  140. WSAEVENT hEvent;
  141. } WSAOVERLAPPED, FAR * LPWSAOVERLAPPED;
  142. typedef struct _WSABUF {
  143. u_long len; /* the length of the buffer */
  144. char FAR * buf; /* the pointer to the buffer */
  145. } WSABUF, FAR * LPWSABUF;
  146. #endif // _WINSOCK2API_
  147. #define MAX_SG 9
  148. typedef WSABUF SENDARRAY[MAX_SG];
  149. typedef SENDARRAY *PSENDARRAY;
  150. #define SI_RELIABLE 0x0000001
  151. #define SI_DATAGRAM 0x0000000
  152. typedef struct _SENDINFO {
  153. WSAOVERLAPPED wsao;
  154. SENDARRAY SendArray; // Array of buffers
  155. DWORD dwFlags;
  156. DWORD dwSendFlags; // DPLAY Send Flags.
  157. UINT iFirstBuf; // First buffer in array to use
  158. UINT cBuffers; // number of buffers to send (starting at iFirstBuf)
  159. BILINK PendingSendQ; // when we're pending
  160. BILINK ReadyToSendQ; // still waiting to send on this queue.
  161. DPID idTo;
  162. DPID idFrom;
  163. SOCKET sSocket; // reliable sends
  164. SOCKADDR sockaddr; // datagram sends
  165. DWORD_PTR dwUserContext;
  166. DWORD dwMessageSize;
  167. DWORD RefCount;
  168. LONG Status;
  169. struct _GLOBALDATA *pgd;
  170. IDirectPlaySP * lpISP; // indication interface
  171. #ifdef DEBUG
  172. DWORD wserr; // winsock extended error on wsasend call
  173. #endif
  174. } SENDINFO, FAR *LPSENDINFO;
  175. //
  176. // This code is stolen from winsock.h. It does the same thing as FD_SET()
  177. // except that it assumes the fd_array is large enough. AddSocketToReceiveList()
  178. // grows the buffer as needed, so this better always be true.
  179. //
  180. #define FD_BIG_SET(fd, address) do { \
  181. ASSERT((address)->dwArraySize > (address)->pfdbigset->fd_count); \
  182. (address)->pfdbigset->fd_array[(address)->pfdbigset->fd_count++]=(fd);\
  183. } while(0)
  184. typedef struct fds {
  185. DWORD dwArraySize; // # of sockets that can be stored in pfdbigset->fd_array buffer
  186. fd_big_set *pfdbigset;
  187. } FDS;
  188. typedef struct _CONNECTION
  189. {
  190. SOCKET socket; // socket we can receive off of
  191. DWORD dwCurMessageSize; // current message size
  192. DWORD dwTotalMessageSize; // total message size
  193. SOCKADDR sockAddr; // addresses connected to
  194. LPBYTE pBuffer; // points to either default or temporary receive buffer
  195. LPBYTE pDefaultBuffer; // default receive buffer (pBuffer points to this by default)
  196. // added in DX6
  197. DWORD dwFlags; // connection attributes e.g. SP_CONNECION_FULLDUPLEX
  198. } CONNECTION, *LPCONNECTION;
  199. typedef struct _RECEIVELIST
  200. {
  201. UINT nConnections; // how many peers are we connected to
  202. LPCONNECTION pConnection;// list of connections
  203. } RECEIVELIST;
  204. typedef struct _REPLYLIST * LPREPLYLIST;
  205. typedef struct _REPLYLIST
  206. {
  207. LPREPLYLIST pNextReply; // next reply in list
  208. LPVOID lpMessage; // bufffer to send
  209. SOCKADDR sockaddr; // addr to send to
  210. DWORD dwMessageSize;
  211. SOCKET sSocket; // socket to send on
  212. LPBYTE pbSend; // index into message pointing to next byte to send
  213. DWORD dwBytesLeft; // how many bytes are left to send
  214. DWORD dwPlayerTo; // dpid of to player, 0=>not in use.
  215. } REPLYLIST;
  216. // w store one of these w/ each sys player
  217. typedef struct _SPPLAYERDATA
  218. {
  219. SOCKADDR saddrStream,saddrDatagram;
  220. }SPPLAYERDATA,*LPSPPLAYERDATA;
  221. // the message header
  222. typedef struct _MESSAGEHEADER
  223. {
  224. DWORD dwMessageSize; // size of message
  225. SOCKADDR sockaddr;
  226. } MESSAGEHEADER,*LPMESSAGEHEADER;
  227. // this is one element in our bagosockets
  228. typedef struct _PLAYERSOCK
  229. {
  230. SOCKET sSocket;
  231. DPID dwPlayerID;
  232. // added in DX6
  233. SOCKADDR sockaddr;
  234. DWORD dwFlags; // SP_CONNECTION_FULLDUPLEX, etc.
  235. } PLAYERSOCK,*LPPLAYERSOCK;
  236. // flags that describe a socket
  237. #define SP_CONNECTION_FULLDUPLEX 0x00000001
  238. // stream accept socket in the socket list.
  239. #define SP_STREAM_ACCEPT 0x00000002
  240. #ifdef SENDEX
  241. typedef struct FPOOL *LPFPOOL;
  242. #endif
  243. typedef struct _GLOBALDATA
  244. {
  245. SOCKET sSystemDGramSocket;
  246. SOCKET sSystemStreamSocket;
  247. HANDLE hStreamReceiveThread; // does receive and accept.
  248. HANDLE hDGramReceiveThread;
  249. HANDLE hReplyThread;
  250. RECEIVELIST ReceiveList; // the list of sockets that StreamReceiveThread is listening on
  251. SOCKET sUnreliableSocket; // cached for unreliable send
  252. // reply thread
  253. LPREPLYLIST pReplyList; // list of replies for reply thread to send
  254. HANDLE hReplyEvent; // signal the replythread that something is up
  255. // bago sockets stuff
  256. LPPLAYERSOCK BagOSockets; // socket cache
  257. UINT nSocketsInBag; // how many sockets in our bag
  258. ULONG uEnumAddress; // address entered by user for game server
  259. ULONG AddressFamily;
  260. SOCKADDR saddrNS; // address for name server
  261. DWORD dwLatency; // from dwreserved1 in registry
  262. BOOL bShutdown;
  263. SOCKADDR saddrControlSocket;
  264. BOOL bHaveServerAddress;
  265. CHAR szServerAddress[ADDR_BUFFER_SIZE];
  266. HANDLE hIPXSpareThread; // if nameserver migrates to this host, we start a new receive thread
  267. // (bound to our well known socket). this is the handle to our old receive
  268. // thread - at shutdown, we need to make sure it's gone
  269. UINT iMaxUdpDg; // maximum udp datagram size
  270. // added in DX6
  271. FDS readfds; // dynamic read fdset
  272. DWORD dwFlags; // DPSP_OUTBOUNDONLY, etc.
  273. DWORD dwSessionFlags; // session flags passed by app
  274. WORD wApplicationPort; // port used for creating system player sockets
  275. #ifdef BIGMESSAGEDEFENSE
  276. DWORD dwMaxMessageSize; // the max message size we should receive
  277. #endif
  278. HANDLE hTCPEnumAsyncThread; // fix async enum.
  279. LPVOID lpEnumMessage;
  280. DWORD dwEnumMessageSize;
  281. SOCKADDR saEnum;
  282. DWORD dwEnumAddrSize;
  283. SOCKET sEnum;
  284. BOOL bOutBoundOnly;
  285. #ifdef SENDEX
  286. CRITICAL_SECTION csSendEx; // locks sendex data.
  287. LPFPOOL pSendInfoPool; // pool for allocating SENDINFO+SPHeaders for scatter gather sends
  288. DWORD dwBytesPending; // count of total bytes in pending messages.
  289. DWORD dwMessagesPending; // count of total bytes pending.
  290. BILINK PendingSendQ;
  291. BILINK ReadyToSendQ;
  292. HANDLE hSendWait; // alert thread wait here.
  293. HANDLE BogusHandle; // don't be fooled by waitfor multiple probs in Win9x, put -1 here.
  294. BOOL bSendThreadRunning;
  295. BOOL bStopSendThread;
  296. #endif
  297. } GLOBALDATA,*LPGLOBALDATA;
  298. /*
  299. * SP Flags (from registry)
  300. */
  301. #define DPSP_OUTBOUNDONLY 0x00000001
  302. /*
  303. * DPLAYSVR - DPWSOCKX communication related information
  304. */
  305. // MSG_HDR indicates a dpwsock system message
  306. #define MSG_HDR 0x736F636B
  307. #define SP_MSG_VERSION 1 // DX6
  308. #define IS_VALID_DPWS_MESSAGE(pMsg) (MSG_HDR == (*((DWORD *)(pMsg))) )
  309. #define COMMAND_MASK 0X0000FFFF
  310. #define GET_MESSAGE_VERSION(pMsg) ( ((pMsg)->dwCmdToken & ~COMMAND_MASK) >> 16 )
  311. #define GET_MESSAGE_COMMAND(pMsg) ( (pMsg)->dwCmdToken & COMMAND_MASK)
  312. #define SET_MESSAGE_HDR(pMsg) (*((DWORD *)(pMsg)) = MSG_HDR )
  313. #define SET_MESSAGE_COMMAND(pMsg,dwCmd) ((pMsg)->dwCmdToken = ((dwCmd & COMMAND_MASK) \
  314. | (SP_MSG_VERSION<<16)) )
  315. typedef struct {
  316. DWORD dwHeader;
  317. DWORD dwCmdToken;
  318. } MSG_GENERIC, *LPMSG_GENERIC;
  319. // DPLAYSVR
  320. // macros for manipulating the sockaddr in the player data
  321. #ifdef DEBUG
  322. extern int gCSCount;
  323. #endif
  324. extern CRITICAL_SECTION gcsDPSPCritSection; // defined in dllmain.c
  325. #define INIT_DPSP_CSECT() InitializeCriticalSection(&gcsDPSPCritSection);
  326. #define FINI_DPSP_CSECT() DeleteCriticalSection(&gcsDPSPCritSection);
  327. #ifdef DEBUG
  328. #define ENTER_DPSP() EnterCriticalSection(&gcsDPSPCritSection),gCSCount++;
  329. #define LEAVE_DPSP() gCSCount--,LeaveCriticalSection(&gcsDPSPCritSection);
  330. #else
  331. #define ENTER_DPSP() EnterCriticalSection(&gcsDPSPCritSection);
  332. #define LEAVE_DPSP() LeaveCriticalSection(&gcsDPSPCritSection);
  333. #endif // DEBUG
  334. // get a pointer to the players socket address - used by macros below
  335. #define DGRAM_PSOCKADDR(ppd) ((SOCKADDR *)&(((LPSPPLAYERDATA)ppd)->saddrDatagram))
  336. #define STREAM_PSOCKADDR(ppd) ((SOCKADDR *)&(((LPSPPLAYERDATA)ppd)->saddrStream))
  337. // get the udp ip addr from a player
  338. #define IP_DGRAM_ADDR(ppd) (((SOCKADDR_IN *)DGRAM_PSOCKADDR(ppd))->sin_addr.s_addr)
  339. #define IP_DGRAM_PORT(ppd) (((SOCKADDR_IN *)DGRAM_PSOCKADDR(ppd))->sin_port)
  340. // get the stream ip addr from a player
  341. #define IP_STREAM_ADDR(ppd) (((SOCKADDR_IN *)STREAM_PSOCKADDR(ppd))->sin_addr.s_addr)
  342. #define IP_STREAM_PORT(ppd) (((SOCKADDR_IN *)STREAM_PSOCKADDR(ppd))->sin_port)
  343. // used to get the name of the computer we're running on in spinit
  344. #define HOST_NAME_LENGTH 50
  345. // if it's not ipx, it's ip
  346. // {685BC400-9D2C-11cf-A9CD-00AA006886E3}
  347. DEFINE_GUID(GUID_IPX,
  348. 0x685bc400, 0x9d2c, 0x11cf, 0xa9, 0xcd, 0x0, 0xaa, 0x0, 0x68, 0x86, 0xe3);
  349. // 36E95EE0-8577-11cf-960C-0080C7534E82
  350. DEFINE_GUID(GUID_TCP,
  351. 0x36E95EE0, 0x8577, 0x11cf, 0x96, 0xc, 0x0, 0x80, 0xc7, 0x53, 0x4e, 0x82);
  352. // {3A826E00-31DF-11d0-9CF9-00A0C90A43CB}
  353. DEFINE_GUID(GUID_LOCAL_TCP,
  354. 0x3a826e00, 0x31df, 0x11d0, 0x9c, 0xf9, 0x0, 0xa0, 0xc9, 0xa, 0x43, 0xcb);
  355. // globals
  356. // ghinstance is used when putting up the dialog box to prompt for ip addr
  357. extern HANDLE ghInstance; // set in dllmain. instance handle for dpwsock.dll
  358. #ifdef DEBUG
  359. extern void DebugPrintAddr(UINT level,LPSTR pStr,SOCKADDR * psockaddr);
  360. #define DEBUGPRINTADDR(n,pstr,psockaddr) DebugPrintAddr(n,pstr,psockaddr);
  361. extern void DebugPrintSocket(UINT level,LPSTR pStr,SOCKET * pSock);
  362. #define DEBUGPRINTSOCK(n,pstr,psock) DebugPrintSocket(n,pstr,psock);
  363. #else // debug
  364. #define DEBUGPRINTADDR(n,pstr,psockaddr)
  365. #define DEBUGPRINTSOCK(n,pstr,psock)
  366. #endif // debug
  367. // global vars
  368. extern BOOL gbVoiceOpen; // set to TRUE if we have nm call open
  369. // from dpsp.c
  370. extern HRESULT WaitForThread(HANDLE hThread);
  371. extern HRESULT SetupControlSocket();
  372. extern HRESULT WINAPI SP_Close(LPDPSP_CLOSEDATA pcd);
  373. extern HRESULT InternalReliableSend(LPGLOBALDATA pgd, DPID idPlayerTo, SOCKADDR *
  374. lpSockAddr, LPBYTE lpMessage, DWORD dwMessageSize);
  375. extern HRESULT DoTCPEnumSessions(LPGLOBALDATA pgd, SOCKADDR *lpSockAddr, DWORD dwAddrSize,
  376. LPDPSP_ENUMSESSIONSDATA ped, BOOL bHostWillReuseConnection);
  377. extern HRESULT SendControlMessage(LPGLOBALDATA pgd);
  378. extern HRESULT SendReuseConnectionMessage(SOCKET sSocket);
  379. extern HRESULT AddSocketToBag(LPGLOBALDATA pgd, SOCKET socket, DPID dpid, SOCKADDR *psockaddr, DWORD dwFlags);
  380. extern BOOL FindSocketInReceiveList(LPGLOBALDATA pgd, SOCKADDR *pSockAddr, SOCKET * psSocket);
  381. extern void RemoveSocketFromReceiveList(LPGLOBALDATA pgd, SOCKET socket);
  382. extern void RemoveSocketFromBag(LPGLOBALDATA pgd, SOCKET socket);
  383. extern BOOL FindSocketInBag(LPGLOBALDATA pgd, SOCKADDR *pSockAddr, SOCKET * psSocket, LPDPID lpdpidPlayer);
  384. extern HRESULT GetSocketFromBag(LPGLOBALDATA pgd,SOCKET * psSocket, DWORD dwID, LPSOCKADDR psockaddr);
  385. extern HRESULT CreateAndConnectSocket(LPGLOBALDATA pgd,SOCKET * psSocket,DWORD dwType,LPSOCKADDR psockaddr, BOOL bOutBoundOnly);
  386. extern void RemovePlayerFromSocketBag(LPGLOBALDATA pgd,DWORD dwID);
  387. extern void SetMessageHeader(LPDWORD pdwMsg,DWORD dwSize, DWORD dwToken);
  388. extern void KillTCPEnumAsyncThread(LPGLOBALDATA pgd);
  389. // Support for SendEx in dpsp.c
  390. extern HRESULT UnreliableSendEx(LPDPSP_SENDEXDATA psd, LPSENDINFO lpSendInfo);
  391. extern HRESULT ReliableSendEx(LPDPSP_SENDEXDATA psd, LPSENDINFO pSendInfo);
  392. extern VOID RemovePendingAsyncSends(LPGLOBALDATA pgd, DPID dwPlayerTo);
  393. extern BOOL bAsyncSendsPending(LPGLOBALDATA pgd, DPID dwPlayerTo);
  394. // from winsock.c
  395. extern HRESULT FAR PASCAL CreateSocket(LPGLOBALDATA pgd,SOCKET * psock,INT type,
  396. WORD port,ULONG address,SOCKERR * perr, BOOL bInRange);
  397. extern HRESULT SPConnect(SOCKET* psSocket, LPSOCKADDR psockaddr,UINT addrlen, BOOL bOutBoundOnly);
  398. extern HRESULT CreateAndInitStreamSocket(LPGLOBALDATA pgd);
  399. extern HRESULT SetPlayerAddress(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,SOCKET sSocket,BOOL fStream);
  400. extern HRESULT CreatePlayerDgramSocket(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,DWORD dwFlags);
  401. extern HRESULT CreatePlayerStreamSocket(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,DWORD dwFlags);
  402. extern HRESULT SetDescriptionAddress(LPSPPLAYERDATA ppd,LPDPSESSIONDESC2 lpsdDesc);
  403. extern HRESULT SetReturnAddress(LPVOID pmsg,SOCKET sSocket);
  404. extern HRESULT GetReturnAddress(LPVOID pmsg,LPSOCKADDR psockaddr);
  405. extern HRESULT GetServerAddress(LPGLOBALDATA pgd,LPSOCKADDR psockaddr) ;
  406. extern void IPX_SetNodenum(LPVOID pmsg,SOCKADDR_IPX * psockaddr);
  407. extern void IP_GetAddr(SOCKADDR_IN * paddrDest,SOCKADDR_IN * paddrSrc) ;
  408. extern void IP_SetAddr(LPVOID pBuffer,SOCKADDR_IN * psockaddr);
  409. extern void IPX_GetNodenum(SOCKADDR_IPX * paddrDest,SOCKADDR_IPX * paddrSrc) ;
  410. extern HRESULT KillSocket(SOCKET sSocket,BOOL fStream,BOOL fHard);
  411. extern HRESULT KillPlayerSockets();
  412. extern HRESULT GetAddress(ULONG * puAddress,char *pBuffer,int cch);
  413. extern HRESULT KillThread(HANDLE hThread);
  414. // from wsock2.c
  415. extern DWORD WINAPI AsyncSendThreadProc(LPVOID pvCast);
  416. extern HRESULT InitWinsock2();
  417. extern HRESULT GetMaxUdpBufferSize(SOCKET socket, unsigned int * lpiSize);
  418. extern HRESULT InternalReliableSendEx(LPGLOBALDATA pgd, LPDPSP_SENDEXDATA psd,
  419. LPSENDINFO pSendInfo, SOCKADDR *lpSockAddr);
  420. extern DWORD WINAPI SPSendThread(LPVOID lpv);
  421. #ifdef DPLAY_VOICE_SUPPORT
  422. // from spvoice.c
  423. extern HRESULT WINAPI SP_OpenVoice(LPDPSP_OPENVOICEDATA pod) ;
  424. extern HRESULT WINAPI SP_CloseVoice(LPDPSP_CLOSEVOICEDATA pod) ;
  425. #endif // DPLAY_VOICE_SUPPORT
  426. // from handler.c
  427. HRESULT HandleServerMessage(LPGLOBALDATA pgd, SOCKET sSocket, LPBYTE pBuffer, DWORD dwSize);
  428. #ifdef FULLDUPLEX_SUPPORT
  429. // from registry.c
  430. HRESULT GetFlagsFromRegistry(LPGUID lpguidSP, LPDWORD lpdwFlags);
  431. #endif // FULLDUPLEX_SUPPORT
  432. // MACROS based on fixed pool manager.
  433. #endif