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.

526 lines
21 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 <winsock2.h>
  60. #include <ws2tcpip.h>
  61. #include <ntddip6.h>
  62. // to turn off SendEx support, comment this flag out.
  63. #define SENDEX 1
  64. // use ddraw's assert code (see orion\misc\dpf.h)
  65. #define ASSERT DDASSERT
  66. typedef WORD PORT;
  67. typedef UINT SOCKERR;
  68. // server ports
  69. // Oops! We forgot to convert these constants to net byte order in the code so we
  70. // are really using port 47624 (0xBA08) instead of 2234 (0x08BA)
  71. // We are living with the mistake.
  72. #define SERVER_STREAM_PORT 2234
  73. #define SERVER_DGRAM_PORT 2234
  74. // range of ports used by sp (these are properly converted in the code)
  75. #define DPSP_MIN_PORT 2300
  76. #define DPSP_MAX_PORT 2400
  77. #define DPSP_NUM_PORTS ((DPSP_MAX_PORT - DPSP_MIN_PORT)+1)
  78. #define SPMESSAGEHEADERLEN (sizeof(DWORD))
  79. #define DEFAULT_RECEIVE_BUFFERSIZE (4*1024) // default receive buffer size per connection
  80. // token means this message was received from a remote
  81. // dplay.
  82. #define TOKEN 0xFAB00000
  83. // helper_token means this message was forwarded by our server helper (host)
  84. #define HELPER_TOKEN 0xCAB00000
  85. // server_token means this message is exchanged with dplaysvr (needed to distinguish
  86. // messages from a remote dpwsockx)
  87. #define SERVER_TOKEN 0xBAB00000
  88. // tells receiver to reuse the connection for replies (needed to support fullduplex
  89. // connections)
  90. #define REUSE_TOKEN 0xAAB00000
  91. // masks
  92. #define TOKEN_MASK 0xFFF00000
  93. #define SIZE_MASK (~TOKEN_MASK)
  94. // maxmessagelen = 2^20 (need 12 bits for token)
  95. #define SPMAXMESSAGELEN ( 1048576 - 1)
  96. #define VALID_SP_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == TOKEN ? TRUE : FALSE)
  97. #define VALID_HELPER_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == HELPER_TOKEN ? TRUE : FALSE)
  98. #define VALID_REUSE_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == REUSE_TOKEN ? TRUE : FALSE)
  99. #define VALID_SERVER_MESSAGE(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK) == SERVER_TOKEN ? TRUE : FALSE)
  100. #define SP_MESSAGE_SIZE(pMsg) ( (*((DWORD *)pMsg) & SIZE_MASK))
  101. #define SP_MESSAGE_TOKEN(pMsg) ( (*((DWORD *)pMsg) & TOKEN_MASK))
  102. #define VALID_DPWS_MESSAGE(pMsg) ( VALID_SP_MESSAGE(pMsg) || VALID_HELPER_MESSAGE(pMsg) || \
  103. VALID_SERVER_MESSAGE(pMsg) || VALID_REUSE_MESSAGE(pMsg) )
  104. #define VALID_DPLAYSVR_MESSAGE(pMsg) ( VALID_SP_MESSAGE(pMsg) || VALID_SERVER_MESSAGE(pMsg) || \
  105. VALID_REUSE_MESSAGE(pMsg) )
  106. // relation of timeout to latency
  107. #define TIMEOUT_SCALE 10
  108. #define SPTIMEOUT(latency) (TIMEOUT_SCALE * latency)
  109. // the default size of the socket cache (gBagOSockets)
  110. #define MAX_CONNECTED_SOCKETS 64
  111. // the initial size of the receive list
  112. #define INITIAL_RECEIVELIST_SIZE 16
  113. // version number for service provider
  114. #define SPMINORVERSION 0x0000 // service provider-specific version number
  115. #define VERSIONNUMBER (DPSP_MAJORVERSION | SPMINORVERSION) // version number for service provider
  116. // biggest user enterable addess
  117. #define ADDR_BUFFER_SIZE 128
  118. // macro picks the service socket depending on ipx vs. tcp
  119. // ipx uses dgram, tcp uses stream
  120. #define SERVICE_SOCKET(pgd) ( pgd->sSystemStreamSocket)
  121. //
  122. // In order to listen to any number of sockets we need our own version
  123. // of fd_set and FD_SET(). We call them fd_big_set and FD_BIG_SET().
  124. //
  125. typedef struct fd_big_set {
  126. u_int fd_count; // how many are SET?
  127. SOCKET fd_array[0]; // an array of SOCKETs
  128. } fd_big_set;
  129. // stolen from winsock2.h
  130. #ifndef _WINSOCK2API_
  131. typedef HANDLE WSAEVENT;
  132. typedef struct _WSAOVERLAPPED {
  133. DWORD Internal;
  134. DWORD InternalHigh;
  135. DWORD Offset;
  136. DWORD OffsetHigh;
  137. WSAEVENT hEvent;
  138. } WSAOVERLAPPED, FAR * LPWSAOVERLAPPED;
  139. typedef struct _WSABUF {
  140. u_long len; /* the length of the buffer */
  141. char FAR * buf; /* the pointer to the buffer */
  142. } WSABUF, FAR * LPWSABUF;
  143. #endif // _WINSOCK2API_
  144. #define MAX_SG 9
  145. typedef WSABUF SENDARRAY[MAX_SG];
  146. typedef SENDARRAY *PSENDARRAY;
  147. #define SI_RELIABLE 0x0000001
  148. #define SI_DATAGRAM 0x0000000
  149. typedef struct _SENDINFO {
  150. WSAOVERLAPPED wsao;
  151. SENDARRAY SendArray; // Array of buffers
  152. DWORD dwFlags;
  153. DWORD dwSendFlags; // DPLAY Send Flags.
  154. UINT iFirstBuf; // First buffer in array to use
  155. UINT cBuffers; // number of buffers to send (starting at iFirstBuf)
  156. BILINK PendingSendQ; // when we're pending
  157. BILINK ReadyToSendQ; // still waiting to send on this queue.
  158. DPID idTo;
  159. DPID idFrom;
  160. SOCKET sSocket; // reliable sends
  161. SOCKADDR_IN6 sockaddr; // datagram sends
  162. DWORD_PTR dwUserContext;
  163. DWORD dwMessageSize;
  164. DWORD RefCount;
  165. LONG Status;
  166. struct _GLOBALDATA *pgd;
  167. IDirectPlaySP * lpISP; // indication interface
  168. #ifdef DEBUG
  169. DWORD wserr; // winsock extended error on wsasend call
  170. #endif
  171. } SENDINFO, FAR *LPSENDINFO;
  172. //
  173. // This code is stolen from winsock.h. It does the same thing as FD_SET()
  174. // except that it assumes the fd_array is large enough. AddSocketToReceiveList()
  175. // grows the buffer as needed, so this better always be true.
  176. //
  177. #define FD_BIG_SET(fd, address) do { \
  178. ASSERT((address)->dwArraySize > (address)->pfdbigset->fd_count); \
  179. (address)->pfdbigset->fd_array[(address)->pfdbigset->fd_count++]=(fd);\
  180. } while(0)
  181. typedef struct fds {
  182. DWORD dwArraySize; // # of sockets that can be stored in pfdbigset->fd_array buffer
  183. fd_big_set *pfdbigset;
  184. } FDS;
  185. typedef struct _CONNECTION
  186. {
  187. SOCKET socket; // socket we can receive off of
  188. DWORD dwCurMessageSize; // current message size
  189. DWORD dwTotalMessageSize; // total message size
  190. SOCKADDR_IN6 sockAddr; // addresses connected to
  191. LPBYTE pBuffer; // points to either default or temporary receive buffer
  192. LPBYTE pDefaultBuffer; // default receive buffer (pBuffer points to this by default)
  193. // added in DX6
  194. DWORD dwFlags; // connection attributes e.g. SP_CONNECION_FULLDUPLEX
  195. } CONNECTION, *LPCONNECTION;
  196. typedef struct _RECEIVELIST
  197. {
  198. UINT nConnections; // how many peers are we connected to
  199. LPCONNECTION pConnection;// list of connections
  200. } RECEIVELIST;
  201. typedef struct _REPLYLIST * LPREPLYLIST;
  202. typedef struct _REPLYLIST
  203. {
  204. LPREPLYLIST pNextReply; // next reply in list
  205. LPVOID lpMessage; // bufffer to send
  206. SOCKADDR_IN6 sockaddr; // addr to send to
  207. DWORD dwMessageSize;
  208. SOCKET sSocket; // socket to send on
  209. LPBYTE pbSend; // index into message pointing to next byte to send
  210. DWORD dwBytesLeft; // how many bytes are left to send
  211. DWORD dwPlayerTo; // dpid of to player, 0=>not in use.
  212. } REPLYLIST;
  213. // w store one of these w/ each sys player
  214. typedef struct _SPPLAYERDATA
  215. {
  216. SOCKADDR_IN6 saddrStream,saddrDatagram;
  217. }SPPLAYERDATA,*LPSPPLAYERDATA;
  218. // the message header
  219. typedef struct _MESSAGEHEADER
  220. {
  221. DWORD dwMessageSize; // size of message
  222. SOCKADDR_IN6 sockaddr;
  223. } MESSAGEHEADER,*LPMESSAGEHEADER;
  224. // this is one element in our bagosockets
  225. typedef struct _PLAYERSOCK
  226. {
  227. SOCKET sSocket;
  228. DPID dwPlayerID;
  229. // added in DX6
  230. SOCKADDR_IN6 sockaddr;
  231. DWORD dwFlags; // SP_CONNECTION_FULLDUPLEX, etc.
  232. } PLAYERSOCK,*LPPLAYERSOCK;
  233. // flags that describe a socket
  234. #define SP_CONNECTION_FULLDUPLEX 0x00000001
  235. // stream accept socket in the socket list.
  236. #define SP_STREAM_ACCEPT 0x00000002
  237. #ifdef SENDEX
  238. typedef struct FPOOL *LPFPOOL;
  239. #endif
  240. typedef struct _GLOBALDATA
  241. {
  242. SOCKET sSystemDGramSocket;
  243. SOCKET sSystemStreamSocket;
  244. HANDLE hStreamReceiveThread; // does receive and accept.
  245. HANDLE hDGramReceiveThread;
  246. HANDLE hReplyThread;
  247. RECEIVELIST ReceiveList; // the list of sockets that StreamReceiveThread is listening on
  248. SOCKET sUnreliableSocket; // cached for unreliable send
  249. // reply thread
  250. LPREPLYLIST pReplyList; // list of replies for reply thread to send
  251. HANDLE hReplyEvent; // signal the replythread that something is up
  252. // bago sockets stuff
  253. LPPLAYERSOCK BagOSockets; // socket cache
  254. UINT nSocketsInBag; // how many sockets in our bag
  255. SOCKADDR_IN6 saddrEnumAddress; // address entered by user for game server
  256. ULONG AddressFamily;
  257. SOCKADDR_IN6 saddrNS; // address for name server
  258. DWORD dwLatency; // from dwreserved1 in registry
  259. BOOL bShutdown;
  260. SOCKADDR_IN6 saddrControlSocket;
  261. BOOL bHaveServerAddress;
  262. CHAR szServerAddress[ADDR_BUFFER_SIZE];
  263. UINT iMaxUdpDg; // maximum udp datagram size
  264. // added in DX6
  265. FDS readfds; // dynamic read fdset
  266. DWORD dwFlags; // DPSP_OUTBOUNDONLY, etc.
  267. DWORD dwSessionFlags; // session flags passed by app
  268. WORD wApplicationPort; // port used for creating system player sockets
  269. #ifdef BIGMESSAGEDEFENSE
  270. DWORD dwMaxMessageSize; // the max message size we should receive
  271. #endif
  272. HANDLE hTCPEnumAsyncThread; // fix async enum.
  273. LPVOID lpEnumMessage;
  274. DWORD dwEnumMessageSize;
  275. SOCKADDR_IN6 saEnum;
  276. DWORD dwEnumAddrSize;
  277. SOCKET sEnum;
  278. BOOL bOutBoundOnly;
  279. #ifdef SENDEX
  280. CRITICAL_SECTION csSendEx; // locks sendex data.
  281. LPFPOOL pSendInfoPool; // pool for allocating SENDINFO+SPHeaders for scatter gather sends
  282. DWORD dwBytesPending; // count of total bytes in pending messages.
  283. DWORD dwMessagesPending; // count of total bytes pending.
  284. BILINK PendingSendQ;
  285. BILINK ReadyToSendQ;
  286. HANDLE hSendWait; // alert thread wait here.
  287. HANDLE BogusHandle; // don't be fooled by waitfor multiple probs in Win9x, put -1 here.
  288. BOOL bSendThreadRunning;
  289. BOOL bStopSendThread;
  290. #endif
  291. } GLOBALDATA,*LPGLOBALDATA;
  292. /*
  293. * SP Flags (from registry)
  294. */
  295. #define DPSP_OUTBOUNDONLY 0x00000001
  296. /*
  297. * DPLAYSVR - DPWSOCKX communication related information
  298. */
  299. // MSG_HDR indicates a dpwsock system message
  300. #define MSG_HDR 0x736F636B
  301. #define SP_MSG_VERSION 1 // DX6
  302. #define IS_VALID_DPWS_MESSAGE(pMsg) (MSG_HDR == (*((DWORD *)(pMsg))) )
  303. #define COMMAND_MASK 0X0000FFFF
  304. #define GET_MESSAGE_VERSION(pMsg) ( ((pMsg)->dwCmdToken & ~COMMAND_MASK) >> 16 )
  305. #define GET_MESSAGE_COMMAND(pMsg) ( (pMsg)->dwCmdToken & COMMAND_MASK)
  306. #define SET_MESSAGE_HDR(pMsg) (*((DWORD *)(pMsg)) = MSG_HDR )
  307. #define SET_MESSAGE_COMMAND(pMsg,dwCmd) ((pMsg)->dwCmdToken = ((dwCmd & COMMAND_MASK) \
  308. | (SP_MSG_VERSION<<16)) )
  309. typedef struct {
  310. DWORD dwHeader;
  311. DWORD dwCmdToken;
  312. } MSG_GENERIC, *LPMSG_GENERIC;
  313. // DPLAYSVR
  314. // macros for manipulating the sockaddr in the player data
  315. #ifdef DEBUG
  316. extern int gCSCount;
  317. #endif
  318. extern CRITICAL_SECTION gcsDPSPCritSection; // defined in dllmain.c
  319. #define INIT_DPSP_CSECT() InitializeCriticalSection(&gcsDPSPCritSection);
  320. #define FINI_DPSP_CSECT() DeleteCriticalSection(&gcsDPSPCritSection);
  321. #ifdef DEBUG
  322. #define ENTER_DPSP() EnterCriticalSection(&gcsDPSPCritSection),gCSCount++;
  323. #define LEAVE_DPSP() gCSCount--,LeaveCriticalSection(&gcsDPSPCritSection);
  324. #else
  325. #define ENTER_DPSP() EnterCriticalSection(&gcsDPSPCritSection);
  326. #define LEAVE_DPSP() LeaveCriticalSection(&gcsDPSPCritSection);
  327. #endif // DEBUG
  328. // get a pointer to the players socket address - used by macros below
  329. #define DGRAM_PSOCKADDR(ppd) ((SOCKADDR_IN6 *)&(((LPSPPLAYERDATA)ppd)->saddrDatagram))
  330. #define STREAM_PSOCKADDR(ppd) ((SOCKADDR_IN6 *)&(((LPSPPLAYERDATA)ppd)->saddrStream))
  331. // get the udp ip addr from a player
  332. #define IP_DGRAM_PORT(ppd) (DGRAM_PSOCKADDR(ppd)->sin6_port)
  333. // get the stream ip addr from a player
  334. #define IP_STREAM_PORT(ppd) (STREAM_PSOCKADDR(ppd)->sin6_port)
  335. // used to get the name of the computer we're running on in spinit
  336. #define HOST_NAME_LENGTH 50
  337. // 84a22c0b-45af-4ad9-a4f1-4bf547f7d0d2
  338. DEFINE_GUID(GUID_IPV6,
  339. 0x84a22c0b, 0x45af, 0x4ad9, 0xa4, 0xf1, 0x4b, 0xf5, 0x47, 0xf7, 0xd0, 0xd2);
  340. // 0855c42a-4193-4ed1-bbbc-39a9c597157e
  341. DEFINE_GUID(GUID_LOCAL_IPV6,
  342. 0x0855c42a, 0x4193, 0x4ed1, 0xbb, 0xbc, 0x39, 0xa9, 0xc5, 0x97, 0x15, 0x7e);
  343. // globals
  344. // ghinstance is used when putting up the dialog box to prompt for ip addr
  345. extern HANDLE ghInstance; // set in dllmain. instance handle for dpwsock.dll
  346. extern const IN6_ADDR in6addr_multicast;
  347. extern const SOCKADDR_IN6 sockaddr_any;
  348. #ifdef DEBUG
  349. extern void DebugPrintAddr(UINT level,LPSTR pStr,SOCKADDR * psockaddr);
  350. #define DEBUGPRINTADDR(n,pstr,psockaddr) DebugPrintAddr(n,pstr,(LPSOCKADDR)psockaddr);
  351. extern void DebugPrintSocket(UINT level,LPSTR pStr,SOCKET * pSock);
  352. #define DEBUGPRINTSOCK(n,pstr,psock) DebugPrintSocket(n,pstr,psock);
  353. #else // debug
  354. #define DEBUGPRINTADDR(n,pstr,psockaddr)
  355. #define DEBUGPRINTSOCK(n,pstr,psock)
  356. #endif // debug
  357. // global vars
  358. extern BOOL gbVoiceOpen; // set to TRUE if we have nm call open
  359. // from dpsp.c
  360. #define IN6ADDR_MULTICAST_INIT {0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0x01,0x30}
  361. extern HRESULT WaitForThread(HANDLE hThread);
  362. extern HRESULT SetupControlSocket();
  363. extern HRESULT WINAPI SP_Close(LPDPSP_CLOSEDATA pcd);
  364. extern HRESULT InternalReliableSend(LPGLOBALDATA pgd, DPID idPlayerTo, SOCKADDR_IN6 *
  365. lpSockAddr, LPBYTE lpMessage, DWORD dwMessageSize);
  366. extern HRESULT DoTCPEnumSessions(LPGLOBALDATA pgd, SOCKADDR *lpSockAddr, DWORD dwAddrSize,
  367. LPDPSP_ENUMSESSIONSDATA ped, BOOL bHostWillReuseConnection);
  368. extern HRESULT SendControlMessage(LPGLOBALDATA pgd);
  369. extern HRESULT SendReuseConnectionMessage(SOCKET sSocket);
  370. extern HRESULT AddSocketToBag(LPGLOBALDATA pgd, SOCKET socket, DPID dpid, SOCKADDR_IN6 *psockaddr, DWORD dwFlags);
  371. extern BOOL FindSocketInReceiveList(LPGLOBALDATA pgd, SOCKADDR *pSockAddr, SOCKET * psSocket);
  372. extern void RemoveSocketFromReceiveList(LPGLOBALDATA pgd, SOCKET socket);
  373. extern void RemoveSocketFromBag(LPGLOBALDATA pgd, SOCKET socket);
  374. extern BOOL FindSocketInBag(LPGLOBALDATA pgd, SOCKADDR *pSockAddr, SOCKET * psSocket, LPDPID lpdpidPlayer);
  375. extern HRESULT GetSocketFromBag(LPGLOBALDATA pgd,SOCKET * psSocket, DWORD dwID, LPSOCKADDR_IN6 psockaddr);
  376. extern HRESULT CreateAndConnectSocket(LPGLOBALDATA pgd,SOCKET * psSocket,DWORD dwType,LPSOCKADDR_IN6 psockaddr, BOOL bOutBoundOnly);
  377. extern void RemovePlayerFromSocketBag(LPGLOBALDATA pgd,DWORD dwID);
  378. extern void SetMessageHeader(LPDWORD pdwMsg,DWORD dwSize, DWORD dwToken);
  379. extern void KillTCPEnumAsyncThread(LPGLOBALDATA pgd);
  380. extern SOCKET_ADDRESS_LIST *GetHostAddr(void);
  381. extern void FreeHostAddr(SOCKET_ADDRESS_LIST *pList);
  382. // Support for SendEx in dpsp.c
  383. extern HRESULT UnreliableSendEx(LPDPSP_SENDEXDATA psd, LPSENDINFO lpSendInfo);
  384. extern HRESULT ReliableSendEx(LPDPSP_SENDEXDATA psd, LPSENDINFO pSendInfo);
  385. extern VOID RemovePendingAsyncSends(LPGLOBALDATA pgd, DPID dwPlayerTo);
  386. extern BOOL bAsyncSendsPending(LPGLOBALDATA pgd, DPID dwPlayerTo);
  387. // from winsock.c
  388. extern HRESULT FAR PASCAL CreateSocket(LPGLOBALDATA pgd,SOCKET * psock,INT type,
  389. WORD port,const SOCKADDR_IN6 * psockaddr,SOCKERR * perr, BOOL bInRange);
  390. extern HRESULT SPConnect(SOCKET* psSocket, LPSOCKADDR psockaddr,UINT addrlen, BOOL bOutBoundOnly);
  391. extern HRESULT CreateAndInitStreamSocket(LPGLOBALDATA pgd);
  392. extern HRESULT SetPlayerAddress(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,SOCKET sSocket,BOOL fStream);
  393. extern HRESULT CreatePlayerDgramSocket(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,DWORD dwFlags);
  394. extern HRESULT CreatePlayerStreamSocket(LPGLOBALDATA pgd,LPSPPLAYERDATA ppd,DWORD dwFlags);
  395. extern HRESULT SetDescriptionAddress(LPSPPLAYERDATA ppd,LPDPSESSIONDESC2 lpsdDesc);
  396. extern HRESULT SetReturnAddress(LPVOID pmsg,SOCKET sSocket);
  397. extern HRESULT GetReturnAddress(LPVOID pmsg,LPSOCKADDR_IN6 psockaddr);
  398. extern HRESULT GetServerAddress(LPGLOBALDATA pgd,LPSOCKADDR_IN6 psockaddr) ;
  399. extern void IP6_GetAddr(SOCKADDR_IN6 * paddrDest,SOCKADDR_IN6 * paddrSrc) ;
  400. extern void IP6_SetAddr(LPVOID pBuffer,SOCKADDR_IN6 * psockaddr);
  401. extern HRESULT KillSocket(SOCKET sSocket,BOOL fStream,BOOL fHard);
  402. extern HRESULT KillPlayerSockets();
  403. extern HRESULT GetAddress(SOCKADDR_IN6 * puAddress,char *pBuffer,int cch);
  404. extern HRESULT KillThread(HANDLE hThread);
  405. // from wsock2.c
  406. extern DWORD WINAPI AsyncSendThreadProc(LPVOID pvCast);
  407. extern HRESULT InitWinsock2();
  408. extern HRESULT GetMaxUdpBufferSize(SOCKET socket, unsigned int * lpiSize);
  409. extern HRESULT InternalReliableSendEx(LPGLOBALDATA pgd, LPDPSP_SENDEXDATA psd,
  410. LPSENDINFO pSendInfo, SOCKADDR_IN6 *lpSockAddr);
  411. extern DWORD WINAPI SPSendThread(LPVOID lpv);
  412. extern int Dplay_GetAddrInfo(const char FAR *nodename, const char FAR *servname,
  413. LPADDRINFO hints, ADDRINFO FAR * FAR * res);
  414. extern void Dplay_FreeAddrInfo(LPADDRINFO pai);
  415. #ifdef DPLAY_VOICE_SUPPORT
  416. // from spvoice.c
  417. extern HRESULT WINAPI SP_OpenVoice(LPDPSP_OPENVOICEDATA pod) ;
  418. extern HRESULT WINAPI SP_CloseVoice(LPDPSP_CLOSEVOICEDATA pod) ;
  419. #endif // DPLAY_VOICE_SUPPORT
  420. // from handler.c
  421. HRESULT HandleServerMessage(LPGLOBALDATA pgd, SOCKET sSocket, LPBYTE pBuffer, DWORD dwSize);
  422. // from ipv6.c
  423. extern DWORD ForEachInterface(void (*func)(IPV6_INFO_INTERFACE *, void *,void *,
  424. void *), void *Context1, void *Context2, void *Context3);
  425. extern void ForEachAddress(IPV6_INFO_INTERFACE *IF, void
  426. (*func)(IPV6_INFO_INTERFACE *IF, IPV6_INFO_ADDRESS *, void *),
  427. void *);
  428. extern UINT JoinEnumGroup(SOCKET sSocket, UINT ifindex);
  429. #ifdef FULLDUPLEX_SUPPORT
  430. // from registry.c
  431. HRESULT GetFlagsFromRegistry(LPGUID lpguidSP, LPDWORD lpdwFlags);
  432. #endif // FULLDUPLEX_SUPPORT
  433. // MACROS based on fixed pool manager.
  434. #endif