Leaked source code of windows server 2003
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.

295 lines
15 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dnpextern.h
  6. * Content: This header exposes protocol entry points to the rest of Direct Network
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 11/06/1998 ejs Created
  12. * 07/01/2000 masonb Assumed Ownership
  13. *
  14. ***************************************************************************/
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif // __cplusplus
  18. // FOLLOWING FLAGS GO INTO PUBLIC HEADER FILE
  19. #ifndef DPNBUILD_NOSPUI
  20. #define DN_CONNECTFLAGS_OKTOQUERYFORADDRESSING 0x00000001
  21. #endif // ! DPNBUILD_NOSPUI
  22. #ifndef DPNBUILD_ONLYONEADAPTER
  23. #define DN_CONNECTFLAGS_ADDITIONALMULTIPLEXADAPTERS 0x00000002 // there will be more adapters for this connect operation
  24. #endif // ! DPNBUILD_ONLYONEADAPTER
  25. #ifndef DPNBUILD_NOMULTICAST
  26. #define DN_CONNECTFLAGS_MULTICAST_SEND 0x00000004 // Multicast send connect operation
  27. #define DN_CONNECTFLAGS_MULTICAST_RECEIVE 0x00000008 // Multicast receive connect operation
  28. #endif // DPNBUILD_NOMULTICAST
  29. #define DN_CONNECTFLAGS_SESSIONDATA 0x00000010 // connect operation has session data available
  30. #ifndef DPNBUILD_NOSPUI
  31. #define DN_LISTENFLAGS_OKTOQUERYFORADDRESSING 0x00000001
  32. #endif // ! DPNBUILD_NOSPUI
  33. #ifndef DPNBUILD_NOMULTICAST
  34. #define DN_LISTENFLAGS_MULTICAST 0x00000002 // Multicast listen operation
  35. #define DN_LISTENFLAGS_ALLOWUNKNOWNSENDERS 0x00000004 // listen operation should allow data from unknown senders
  36. #endif // ! DPNBUILD_NOMULTICAST
  37. #define DN_LISTENFLAGS_SESSIONDATA 0x00000008 // listen operation has session data available
  38. #define DN_LISTENFLAGS_DISALLOWENUMS 0x00000010 // don't allow enums to come in on the listen
  39. #define DN_LISTENFLAGS_FASTSIGNED 0x00000020 // create all incoming links as fast signed
  40. #define DN_LISTENFLAGS_FULLSIGNED 0x00000040 // create all incoming links as full signed
  41. #ifndef DPNBUILD_NOSPUI
  42. #define DN_ENUMQUERYFLAGS_OKTOQUERYFORADDRESSING 0x00000001
  43. #endif // ! DPNBUILD_NOSPUI
  44. #define DN_ENUMQUERYFLAGS_NOBROADCASTFALLBACK 0x00000002
  45. #ifndef DPNBUILD_ONLYONEADAPTER
  46. #define DN_ENUMQUERYFLAGS_ADDITIONALMULTIPLEXADAPTERS 0x00000004 // there will be more adapters for this enum operation
  47. #endif // ! DPNBUILD_ONLYONEADAPTER
  48. #define DN_ENUMQUERYFLAGS_SESSIONDATA 0x00000008 // enum query operation has session data available
  49. #define DN_SENDFLAGS_RELIABLE 0x00000001 // Deliver Reliably
  50. #define DN_SENDFLAGS_NON_SEQUENTIAL 0x00000002 // Deliver Upon Arrival
  51. #define DN_SENDFLAGS_HIGH_PRIORITY 0x00000004
  52. #define DN_SENDFLAGS_LOW_PRIORITY 0x00000008
  53. #define DN_SENDFLAGS_SET_USER_FLAG 0x00000040 // Protocol will deliver these two...
  54. #define DN_SENDFLAGS_SET_USER_FLAG_TWO 0x00000080 // ...flags to receiver
  55. #define DN_SENDFLAGS_COALESCE 0x00000100 // send is coalescable
  56. #define DN_UPDATELISTEN_HOSTMIGRATE 0x00000001
  57. #define DN_UPDATELISTEN_ALLOWENUMS 0x00000002
  58. #define DN_UPDATELISTEN_DISALLOWENUMS 0x00000004
  59. #define DN_DISCONNECTFLAGS_IMMEDIATE 0x00000001
  60. // END OF PUBLIC FLAGS
  61. typedef struct _DN_PROTOCOL_INTERFACE_VTBL DN_PROTOCOL_INTERFACE_VTBL, *PDN_PROTOCOL_INTERFACE_VTBL;
  62. struct IDirectPlay8ThreadPoolWork;
  63. //
  64. // structure used to pass enum data from the protocol to DPlay
  65. //
  66. typedef struct _PROTOCOL_ENUM_DATA
  67. {
  68. IDirectPlay8Address *pSenderAddress; //
  69. IDirectPlay8Address *pDeviceAddress; //
  70. BUFFERDESC ReceivedData; //
  71. HANDLE hEnumQuery; // handle of this query, returned in enum response
  72. } PROTOCOL_ENUM_DATA;
  73. typedef struct _PROTOCOL_ENUM_RESPONSE_DATA
  74. {
  75. IDirectPlay8Address *pSenderAddress;
  76. IDirectPlay8Address *pDeviceAddress;
  77. BUFFERDESC ReceivedData;
  78. DWORD dwRoundTripTime;
  79. } PROTOCOL_ENUM_RESPONSE_DATA;
  80. // Service Provider interface
  81. typedef struct IDP8ServiceProvider IDP8ServiceProvider;
  82. // Service Provider info data strucure
  83. typedef struct _SPGETADDRESSINFODATA SPGETADDRESSINFODATA, *PSPGETADDRESSINFODATA;
  84. // Service Provider event type
  85. typedef enum _SP_EVENT_TYPE SP_EVENT_TYPE;
  86. /////////////////////////////////////////////////////////////////////////////////////////////////
  87. //
  88. // Constants that define limits for parameters passed to protocol
  89. //
  90. /////////////////////////////////////////////////////////////////////////////////////////////////
  91. #define MAX_SEND_RETRIES_TO_DROP_LINK 256 //maximum number of send retries user can request
  92. //when setting via SetCaps
  93. #define MAX_SEND_RETRY_INTERVAL_LIMIT 60000 //maximum limit user can request on the interval
  94. //betwen send retries when setting via SetCaps
  95. #define MIN_SEND_RETRY_INTERVAL_LIMIT 10 //minimum limit user can set on the interval
  96. //betwen send retries when setting via SetCaps
  97. #define MAX_HARD_DISCONNECT_SENDS 50 //Maximum number of hard disconnect frames that can be sent
  98. #define MIN_HARD_DISCONNECT_SENDS 2 //Minimum number of hard disconnect frames that can be sent
  99. #define MAX_HARD_DISCONNECT_PERIOD 5000 //Maximum period between hard disconnect sends
  100. #define MIN_HARD_DISCONNECT_PERIOD 10 //Minimum period between hard disconnect sends
  101. /////////////////////////////////////////////////////////////////////////////////////////////////
  102. //
  103. // The following are functions that the Core can call in the Protocol
  104. //
  105. /////////////////////////////////////////////////////////////////////////////////////////////////
  106. // These are called at module load and unload time so that the Protocol can create and destroy its pools
  107. extern BOOL DNPPoolsInit(HANDLE hModule);
  108. extern VOID DNPPoolsDeinit();
  109. // These are called to create or destroy a Protocol object
  110. #ifdef DPNBUILD_PREALLOCATEDMEMORYMODEL
  111. extern HRESULT DNPProtocolCreate(const XDP8CREATE_PARAMS * const pDP8CreateParams, VOID** ppvProtocol);
  112. #else // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  113. extern HRESULT DNPProtocolCreate(VOID** ppvProtocol);
  114. #endif // ! DPNBUILD_PREALLOCATEDMEMORYMODEL
  115. extern VOID DNPProtocolDestroy(HANDLE hProtocolData);
  116. // These are called to initialize or shutdown a Protocol object
  117. extern HRESULT DNPProtocolInitialize(HANDLE hProtocolData, PVOID pCoreContext, PDN_PROTOCOL_INTERFACE_VTBL pVtbl, IDirectPlay8ThreadPoolWork* pDPThreadPoolWork, BOOL bAssumeLANConnections);
  118. extern HRESULT DNPProtocolShutdown(HANDLE hProtocolData);
  119. // These are called to add or remove a service provider for use with a Protocol object
  120. extern HRESULT DNPAddServiceProvider(HANDLE hProtocolData, IDP8ServiceProvider* pISP, HANDLE* phSPContext, DWORD dwFlags);
  121. extern HRESULT DNPRemoveServiceProvider(HANDLE hProtocolData, HANDLE hSPContext);
  122. // Connect establish and teardown functions
  123. extern HRESULT DNPConnect(HANDLE hProtocolData, IDirectPlay8Address* paLocal, IDirectPlay8Address* paRemote, HANDLE hSPHandle, ULONG ulFlags, VOID* pvContext, VOID* pvSessionData, DWORD dwSessionDataSize, HANDLE* phConnectHandle);
  124. extern HRESULT DNPListen(HANDLE hProtocolData, IDirectPlay8Address* paTarget, HANDLE hSPHandle, ULONG ulFlags, VOID* pvContext, VOID* pvSessionData, DWORD dwSessionDataSize, HANDLE* phListenHandle);
  125. extern HRESULT DNPDisconnectEndPoint(HANDLE hProtocolData, HANDLE hEndPoint, VOID* pvContext, HANDLE* phDisconnect, const DWORD dwFlags);
  126. // Data sending functions
  127. extern HRESULT DNPSendData(HANDLE hProtocolData, HANDLE hDestination, UINT uiBufferCount, PBUFFERDESC pBufferDesc, UINT uiTimeout, ULONG ulFlags, VOID* pvContext, HANDLE* phSendHandle);
  128. // Get information about an endpoint
  129. extern HRESULT DNPCrackEndPointDescriptor(HANDLE hProtocolData, HANDLE hEndPoint, PSPGETADDRESSINFODATA pSPData);
  130. #ifndef DPNBUILD_NOMULTICAST
  131. HRESULT DNPGetEndPointContextFromAddress(HANDLE hProtocolData, HANDLE hSPHandle, IDirectPlay8Address* paEndpointAddress, IDirectPlay8Address* paDeviceAddress, VOID** ppvContext);
  132. #endif // ! DPNBUILD_NOMULTICAST
  133. // Update the SP
  134. extern HRESULT DNPUpdateListen(HANDLE hProtocolData,HANDLE hEndPt,DWORD dwFlags);
  135. // Cancel a pending operation
  136. extern HRESULT DNPCancelCommand(HANDLE hProtocolData, HANDLE hCommand);
  137. // Enumeration functions
  138. extern HRESULT DNPEnumQuery(HANDLE hProtocolData, IDirectPlay8Address* paHostAddress, IDirectPlay8Address* paDeviceAddress, HANDLE hSPHandle, BUFFERDESC* pBuffers, DWORD dwBufferCount, DWORD dwRetryCount, DWORD dwRetryInterval, DWORD dwTimeout, DWORD dwFlags, VOID* pvUserContext, VOID* pvSessionData, DWORD dwSessionDataSize, HANDLE* phEnumHandle);
  139. extern HRESULT DNPEnumRespond(HANDLE hProtocolData, HANDLE hSPHandle, HANDLE hQueryHandle, BUFFERDESC* pBuffers, DWORD dwBufferCount, DWORD dwFlags, VOID* pvUserContext, HANDLE* phEnumHandle);
  140. // Miscellaneous functions
  141. extern HRESULT DNPReleaseReceiveBuffer(HANDLE hProtocolData, HANDLE hBuffer);
  142. extern HRESULT DNPGetListenAddressInfo(HANDLE hProtocolData, HANDLE hListen, PSPGETADDRESSINFODATA pSPData);
  143. extern HRESULT DNPGetEPCaps(HANDLE hProtocolData, HANDLE hEndpoint, DPN_CONNECTION_INFO* pBuffer);
  144. extern HRESULT DNPSetProtocolCaps(HANDLE hProtocolData, DPN_CAPS* pCaps);
  145. extern HRESULT DNPGetProtocolCaps(HANDLE hProtocolData, DPN_CAPS* pCaps);
  146. // Function for debugging
  147. #ifndef DPNBUILD_NOPROTOCOLTESTITF
  148. extern HRESULT DNPDebug(HANDLE hProtocolData, UINT uiOpCode, HANDLE hEndPoint, VOID* pvData);
  149. // This is a function that can be passed to Debug(PROTDEBUG_SET_ASSERTFUNC) that will be called when an assert
  150. // would occur. The function should throw/catch if it wants to terminate upon the assert.
  151. typedef VOID (*PFNASSERTFUNC)(PSTR psz);
  152. // This is a function that can be passed to Debug(PROTDEBUG_SET_MEMALLOCFUNC) that will be called when memory
  153. // allocation occurs. The function should return FALSE if it wants to fail the allocation.
  154. typedef BOOL (*PFNMEMALLOCFUNC)(ULONG ulAllocID);
  155. // Debug opcodes
  156. #define PROTDEBUG_FREEZELINK 1
  157. #define PROTDEBUG_TOGGLE_KEEPALIVE 2
  158. #define PROTDEBUG_TOGGLE_ACKS 3
  159. #define PROTDEBUG_SET_ASSERTFUNC 4
  160. #define PROTDEBUG_SET_LINK_PARMS 5
  161. #define PROTDEBUG_TOGGLE_LINKSTATE 6
  162. #define PROTDEBUG_TOGGLE_NO_RETRIES 7
  163. #define PROTDEBUG_SET_MEMALLOCFUNC 8
  164. #define PROTDEBUG_TOGGLE_TIMER_FAILURE 9
  165. // Memory Allocation IDs
  166. #define MEMID_SPD 1
  167. #define MEMID_PPD 2
  168. #define MEMID_HUGEBUF 3
  169. #define MEMID_COPYFMD_FMD 4
  170. #define MEMID_SENDCMD_FMD 5
  171. #define MEMID_CHKPT 6
  172. #define MEMID_ACK_FMD 7
  173. #define MEMID_KEEPALIVE_MSD 8
  174. #define MEMID_KEEPALIVE_FMD 9
  175. #define MEMID_DISCONNECT_MSD 10
  176. #define MEMID_DISCONNECT_FMD 11
  177. #define MEMID_CONNECT_MSD 12
  178. #define MEMID_LISTEN_MSD 13
  179. #define MEMID_EPD 14
  180. #define MEMID_ENUMQUERY_MSD 15
  181. #define MEMID_ENUMRESP_MSD 16
  182. #define MEMID_RCD 17
  183. #define MEMID_SMALLBUFF 18
  184. #define MEMID_MEDBUFF 19
  185. #define MEMID_BIGBUFF 20
  186. #define MEMID_CANCEL_RCD 21
  187. #define MEMID_SEND_MSD 22
  188. #define MEMID_SEND_FMD 23
  189. #define MEMID_COALESCE_FMD 24
  190. #define MEMID_MCAST_DISCONNECT_MSD 100
  191. #define MEMID_MCAST_SEND_MSD 101
  192. #define MEMID_MCAST_SEND_FMD 102
  193. #endif // !DPNBUILD_NOPROTOCOLTESTITF
  194. /////////////////////////////////////////////////////////////////////////////////////////////////
  195. //
  196. // The following are functions that the Protocol calls in the Core
  197. //
  198. /////////////////////////////////////////////////////////////////////////////////////////////////
  199. typedef HRESULT (*PFN_PINT_INDICATE_ENUM_QUERY)(void *const pvUserContext, void *const pvEndPtContext, const HANDLE hCommand, void *const pvEnumQueryData, const DWORD dwEnumQueryDataSize);
  200. typedef HRESULT (*PFN_PINT_INDICATE_ENUM_RESPONSE)(void *const pvUserContext,const HANDLE hCommand,void *const pvCommandContext,void *const pvEnumResponseData,const DWORD dwEnumResponseDataSize);
  201. typedef HRESULT (*PFN_PINT_INDICATE_CONNECT)(void *const pvUserContext,void *const pvListenContext,const HANDLE hEndPt,void **const ppvEndPtContext);
  202. typedef HRESULT (*PFN_PINT_INDICATE_DISCONNECT)(void *const pvUserContext,void *const pvEndPtContext);
  203. typedef HRESULT (*PFN_PINT_INDICATE_CONNECTION_TERMINATED)(void *const pvUserContext,void *const pvEndPtContext,const HRESULT hr);
  204. typedef HRESULT (*PFN_PINT_INDICATE_RECEIVE)(void *const pvUserContext,void *const pvEndPtContext,void *const pvData,const DWORD dwDataSize,const HANDLE hBuffer,const DWORD dwFlags);
  205. typedef HRESULT (*PFN_PINT_COMPLETE_LISTEN)(void *const pvUserContext,void **const ppvCommandContext,const HRESULT hr,const HANDLE hCommand);
  206. typedef HRESULT (*PFN_PINT_COMPLETE_LISTEN_TERMINATE)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr);
  207. typedef HRESULT (*PFN_PINT_COMPLETE_ENUM_QUERY)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr);
  208. typedef HRESULT (*PFN_PINT_COMPLETE_ENUM_RESPONSE)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr);
  209. typedef HRESULT (*PFN_PINT_COMPLETE_CONNECT)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr,const HANDLE hEndPt,void **const ppvEndPtContext);
  210. typedef HRESULT (*PFN_PINT_COMPLETE_DISCONNECT)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr);
  211. typedef HRESULT (*PFN_PINT_COMPLETE_SEND)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hr,DWORD dwFirstFrameRTT,DWORD dwFirstFrameRetryCount);
  212. typedef HRESULT (*PFN_PINT_ADDRESS_INFO_CONNECT)(void *const pvUserContext, void *const pvCommandContext, const HRESULT hr, IDirectPlay8Address *const pHostAddress, IDirectPlay8Address *const pDeviceAddress );
  213. typedef HRESULT (*PFN_PINT_ADDRESS_INFO_ENUM)(void *const pvUserContext, void *const pvCommandContext, const HRESULT hr, IDirectPlay8Address *const pHostAddress, IDirectPlay8Address *const pDeviceAddress );
  214. typedef HRESULT (*PFN_PINT_ADDRESS_INFO_LISTEN)(void *const pvUserContext, void *const pvCommandContext, const HRESULT hr, IDirectPlay8Address *const pDeviceAddress );
  215. #ifndef DPNBUILD_NOMULTICAST
  216. typedef HRESULT (*PFN_PINT_INDICATE_RECEIVE_UNKNOWN_SENDER)(void *const pvUserContext,void *const pvListenCommandContext,IDirectPlay8Address *const pSenderAddress,void *const pvData,const DWORD dwDataSize,const HANDLE hBuffer);
  217. typedef HRESULT (*PFN_PINT_COMPLETE_JOIN)(void *const pvUserContext,void *const pvCommandContext,const HRESULT hrProt,const HANDLE hEndPt,void **const ppvEndPtContext);
  218. #endif // DPNBUILD_NOMULTICAST
  219. struct _DN_PROTOCOL_INTERFACE_VTBL
  220. {
  221. PFN_PINT_INDICATE_ENUM_QUERY IndicateEnumQuery;
  222. PFN_PINT_INDICATE_ENUM_RESPONSE IndicateEnumResponse;
  223. PFN_PINT_INDICATE_CONNECT IndicateConnect;
  224. PFN_PINT_INDICATE_DISCONNECT IndicateDisconnect;
  225. PFN_PINT_INDICATE_CONNECTION_TERMINATED IndicateConnectionTerminated;
  226. PFN_PINT_INDICATE_RECEIVE IndicateReceive;
  227. PFN_PINT_COMPLETE_LISTEN CompleteListen;
  228. PFN_PINT_COMPLETE_LISTEN_TERMINATE CompleteListenTerminate;
  229. PFN_PINT_COMPLETE_ENUM_QUERY CompleteEnumQuery;
  230. PFN_PINT_COMPLETE_ENUM_RESPONSE CompleteEnumResponse;
  231. PFN_PINT_COMPLETE_CONNECT CompleteConnect;
  232. PFN_PINT_COMPLETE_DISCONNECT CompleteDisconnect;
  233. PFN_PINT_COMPLETE_SEND CompleteSend;
  234. PFN_PINT_ADDRESS_INFO_CONNECT AddressInfoConnect;
  235. PFN_PINT_ADDRESS_INFO_ENUM AddressInfoEnum;
  236. PFN_PINT_ADDRESS_INFO_LISTEN AddressInfoListen;
  237. #ifndef DPNBUILD_NOMULTICAST
  238. PFN_PINT_INDICATE_RECEIVE_UNKNOWN_SENDER IndicateReceiveUnknownSender;
  239. PFN_PINT_COMPLETE_JOIN CompleteMulticastConnect;
  240. #endif // DPNBUILD_NOMULTICAST
  241. };
  242. #ifdef __cplusplus
  243. }
  244. #endif // __cplusplus