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.

363 lines
14 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2001-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dpnathlp.h
  6. *
  7. * Content: Header for using DirectPlayNATHelp interface.
  8. *
  9. *
  10. * NOTE: This interface is deprecated and should no longer be used.
  11. *
  12. //@@BEGIN_MSINTERNAL
  13. *
  14. * History:
  15. * Date By Reason
  16. * ======== ======== =========
  17. * 04/16/01 VanceO Split DPNATHLP into DPNHUPNP and DPNHPAST.
  18. * 05/16/01 VanceO Added DPNHADDRESSTYPE_GATEWAYISLOCAL.
  19. * 05/31/01 VanceO Changed DPNHCAPS flags to be more specific about
  20. * type of server(s) detected.
  21. * 06/26/01 VanceO Added DPNHERR_REENTRANT error code.
  22. //@@END_MSINTERNAL
  23. *
  24. ***************************************************************************/
  25. #ifndef __DPNATHLP_H__
  26. #define __DPNATHLP_H__
  27. #include <ole2.h> // for DECLARE_INTERFACE and HRESULT
  28. #ifndef DPNATHLP_EXPORTS
  29. #define DPNATHLPAPI DECLSPEC_IMPORT
  30. #else
  31. #define DPNATHLPAPI
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /****************************************************************************
  37. *
  38. * DirectPlay NAT Helper object class IDs
  39. *
  40. ****************************************************************************/
  41. // {B9C2E9C4-68C1-4d42-A7A1-E76A26982AD6}
  42. DEFINE_GUID(CLSID_DirectPlayNATHelpUPnP,
  43. 0xb9c2e9c4, 0x68c1, 0x4d42, 0xa7, 0xa1, 0xe7, 0x6a, 0x26, 0x98, 0x2a, 0xd6);
  44. // {963AB779-16A1-477c-A36D-CB5E711938F7}
  45. DEFINE_GUID(CLSID_DirectPlayNATHelpPAST,
  46. 0x963ab779, 0x16a1, 0x477c, 0xa3, 0x6d, 0xcb, 0x5e, 0x71, 0x19, 0x38, 0xf7);
  47. /****************************************************************************
  48. *
  49. * DirectPlay NAT Helper interface ID
  50. *
  51. ****************************************************************************/
  52. // {154940B6-2278-4a2f-9101-9BA9F431F603}
  53. DEFINE_GUID(IID_IDirectPlayNATHelp,
  54. 0x154940b6, 0x2278, 0x4a2f, 0x91, 0x1, 0x9b, 0xa9, 0xf4, 0x31, 0xf6, 0x3);
  55. //@@BEGIN_MSINTERNAL
  56. /****************************************************************************
  57. *
  58. * DirectPlay NAT Helper registry base
  59. *
  60. ****************************************************************************/
  61. #define DIRECTPLAYNATHELP_REGKEY L"Software\\Microsoft\\DirectPlayNATHelp"
  62. //@@END_MSINTERNAL
  63. /****************************************************************************
  64. *
  65. * DirectPlay NAT Helper interface pointer definitions
  66. *
  67. ****************************************************************************/
  68. typedef struct IDirectPlayNATHelp *PDIRECTPLAYNATHELP;
  69. /****************************************************************************
  70. *
  71. * DirectPlay NAT Helper data types
  72. *
  73. ****************************************************************************/
  74. //
  75. // Handles used to identify specific port binding groups. If multiple ports
  76. // are registered at the same time, the DPNHHANDLE refers to all ports.
  77. //
  78. typedef DWORD_PTR DPNHHANDLE, * PDPNHHANDLE;
  79. /****************************************************************************
  80. *
  81. * DirectPlay NAT Helper constants
  82. *
  83. ****************************************************************************/
  84. #define DPNH_MAX_SIMULTANEOUS_PORTS 16 // up to 16 ports may be specified in a single RegisterPorts call
  85. /****************************************************************************
  86. *
  87. * DirectPlay NAT Helper API flags
  88. *
  89. ****************************************************************************/
  90. //
  91. // Flags that can be passed to Initialize
  92. //
  93. #define DPNHINITIALIZE_DISABLEGATEWAYSUPPORT 0x01 // disables Internet gateway traversal support (cannot be specified with DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT)
  94. #define DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT 0x02 // disables local firewall traversal support (cannot be specified with DPNHINITIALIZE_DISABLEGATEWAYSUPPORT)
  95. //
  96. // Flags that can be passed to GetCaps.
  97. //
  98. #define DPNHGETCAPS_UPDATESERVERSTATUS 0x01 // automatically extend expiring leases and detect changes in server status
  99. //
  100. // Flags that can be passed to RegisterPorts.
  101. //
  102. #define DPNHREGISTERPORTS_TCP 0x01 // request TCP ports instead of UDP
  103. #define DPNHREGISTERPORTS_FIXEDPORTS 0x02 // asks the server to use the same port numbers on the public interface
  104. #define DPNHREGISTERPORTS_SHAREDPORTS 0x04 // requests that the server allow the UDP fixed ports to be shared with other clients (must be specified with DPNHREGISTERPORTS_FIXEDPORTS and cannot be specified with DPNHREGISTERPORTS_TCP)
  105. //
  106. // Flags that can be passed to GetRegisteredAddresses.
  107. //
  108. #define DPNHGETREGISTEREDADDRESSES_LOCALFIREWALLREMAPONLY 0x01 // retrieve the public address for the local firewall only, even if mapped on remote Internet gateway
  109. //
  110. // Flags that can be passed to QueryAddress.
  111. //
  112. #define DPNHQUERYADDRESS_TCP 0x01 // request a TCP port instead of UDP
  113. #define DPNHQUERYADDRESS_CACHEFOUND 0x02 // cache the discovered address if found
  114. #define DPNHQUERYADDRESS_CACHENOTFOUND 0x04 // cache the fact that no address was found, if that is the case
  115. #define DPNHQUERYADDRESS_CHECKFORPRIVATEBUTUNMAPPED 0x08 // determine if the address is behind the same Internet gateway, but not mapped on that Internet gateway
  116. /****************************************************************************
  117. *
  118. * DirectPlay NAT Helper structure flags
  119. *
  120. ****************************************************************************/
  121. //
  122. // DPNHCAPS flags
  123. //
  124. #define DPNHCAPSFLAG_LOCALFIREWALLPRESENT 0x01 // at least one network connection has a local firewall present
  125. #define DPNHCAPSFLAG_GATEWAYPRESENT 0x02 // at least one network connection has an Internet gateway present
  126. #define DPNHCAPSFLAG_GATEWAYISLOCAL 0x04 // a detected Internet gateway is local (i.e. the public address is another network interface on the same machine)
  127. #define DPNHCAPSFLAG_PUBLICADDRESSAVAILABLE 0x08 // at least one server has a valid public address for registered mappings
  128. #define DPNHCAPSFLAG_NOTALLSUPPORTACTIVENOTIFY 0x10 // at least one available server does not support an active-notification mechanisms and must be polled
  129. /****************************************************************************
  130. *
  131. * DirectPlay NAT Helper structures
  132. *
  133. ****************************************************************************/
  134. typedef struct _DPNHCAPS
  135. {
  136. DWORD dwSize; // size of this structure, must be filled in prior to calling GetCaps
  137. DWORD dwFlags; // flags indicating capabilities of Internet gateway server(s)
  138. DWORD dwNumRegisteredPorts; // number of ports currently registered, including multiple ports registered at the same time (so this may not be equal to the number of DPNHHANDLEs given out)
  139. DWORD dwMinLeaseTimeRemaining; // approximate time remaining, in milliseconds, for the lease that will expire soonest
  140. DWORD dwRecommendedGetCapsInterval; // recommended time, in milliseconds, after which GetCaps should be called again (with DPNHGETCAPS_UPDATESERVERSTATUS flag)
  141. } DPNHCAPS, * PDPNHCAPS;
  142. /****************************************************************************
  143. *
  144. * Address type flags (returned by GetRegisteredAddresses)
  145. *
  146. ****************************************************************************/
  147. #define DPNHADDRESSTYPE_TCP 0x01 // the mappings are for TCP ports instead of UDP
  148. #define DPNHADDRESSTYPE_FIXEDPORTS 0x02 // the mappings are for ports which are the same on the Internet gateway
  149. #define DPNHADDRESSTYPE_SHAREDPORTS 0x04 // the mappings are for shared UDP fixed ports
  150. #define DPNHADDRESSTYPE_LOCALFIREWALL 0x08 // the addresses are opened on a local firewall
  151. #define DPNHADDRESSTYPE_GATEWAY 0x10 // the addresses are registered with an Internet gateway
  152. #define DPNHADDRESSTYPE_GATEWAYISLOCAL 0x20 // the Internet gateway is local (i.e. the public address is another network interface on the same machine)
  153. /****************************************************************************
  154. *
  155. * DirectPlay NAT Helper DLL exported functions
  156. *
  157. ****************************************************************************/
  158. typedef HRESULT (WINAPI * PFN_DIRECTPLAYNATHELPCREATE)(const GUID * pIID, void ** ppvInterface);
  159. /****************************************************************************
  160. *
  161. * DirectPlay NAT Helper application interfaces
  162. *
  163. ****************************************************************************/
  164. #undef INTERFACE
  165. #define INTERFACE IDirectPlayNATHelp
  166. DECLARE_INTERFACE_(IDirectPlayNATHelp, IUnknown)
  167. {
  168. /*** IUnknown methods ***/
  169. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  170. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  171. STDMETHOD_(ULONG,Release) (THIS) PURE;
  172. /*** IDirectPlayNATHelp methods ***/
  173. STDMETHOD(Initialize) (THIS_ const DWORD dwFlags) PURE;
  174. STDMETHOD(Close) (THIS_ const DWORD dwFlags) PURE;
  175. STDMETHOD(GetCaps) (THIS_ DPNHCAPS * const dpnhcaps, const DWORD dwFlags) PURE;
  176. STDMETHOD(RegisterPorts) (THIS_ const SOCKADDR * const aLocalAddresses, const DWORD dwAddressesSize, const DWORD dwNumAddresses, const DWORD dwLeaseTime, DPNHHANDLE * const phRegisteredPorts, const DWORD dwFlags) PURE;
  177. STDMETHOD(GetRegisteredAddresses) (THIS_ const DPNHHANDLE hRegisteredPorts, SOCKADDR * const paPublicAddresses, DWORD * const pdwPublicAddressesSize, DWORD * const pdwAddressTypeFlags, DWORD * const pdwLeaseTimeRemaining, const DWORD dwFlags) PURE;
  178. STDMETHOD(DeregisterPorts) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwFlags) PURE;
  179. STDMETHOD(QueryAddress) (THIS_ const SOCKADDR * const pSourceAddress, const SOCKADDR * const pQueryAddress, SOCKADDR * const pResponseAddress, const int iAddressesSize, const DWORD dwFlags) PURE;
  180. STDMETHOD(SetAlertEvent) (THIS_ const HANDLE hEvent, const DWORD dwFlags) PURE;
  181. STDMETHOD(SetAlertIOCompletionPort) (THIS_ const HANDLE hIOCompletionPort, const DWORD dwCompletionKey, const DWORD dwNumConcurrentThreads, const DWORD dwFlags) PURE;
  182. STDMETHOD(ExtendRegisteredPortsLease) (THIS_ const DPNHHANDLE hRegisteredPorts, const DWORD dwLeaseTime, const DWORD dwFlags) PURE;
  183. };
  184. /****************************************************************************
  185. *
  186. * DirectPlay NAT Helper application interface macros
  187. *
  188. ****************************************************************************/
  189. #if (! defined(__cplusplus) || defined(CINTERFACE))
  190. #define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
  191. #define IDirectPlayNATHelp_AddRef(p) (p)->lpVtbl->AddRef(p)
  192. #define IDirectPlayNATHelp_Release(p) (p)->lpVtbl->Release(p)
  193. #define IDirectPlayNATHelp_Initialize(p,a) (p)->lpVtbl->Initialize(p,a)
  194. #define IDirectPlayNATHelp_Close(p,a) (p)->lpVtbl->Close(p,a)
  195. #define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b)
  196. #define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->lpVtbl->RegisterPorts(p,a,b,c,d,e,f)
  197. #define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->lpVtbl->GetRegisteredAddresses(p,a,b,c,d,e,f)
  198. #define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->lpVtbl->DeregisterPorts(p,a,b)
  199. #define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->lpVtbl->QueryAddress(p,a,b,c,d,e)
  200. #define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->lpVtbl->SetAlertEvent(p,a,b)
  201. #define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->lpVtbl->SetAlertIOCompletionPort(p,a,b,c,d)
  202. #define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->lpVtbl->ExtendRegisteredPortsLease(p,a,b,c)
  203. #else // C++
  204. #define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
  205. #define IDirectPlayNATHelp_AddRef(p) (p)->AddRef()
  206. #define IDirectPlayNATHelp_Release(p) (p)->Release()
  207. #define IDirectPlayNATHelp_Initialize(p,a) (p)->Initialize(a)
  208. #define IDirectPlayNATHelp_Close(p,a) (p)->Close(a)
  209. #define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->GetCaps(a,b)
  210. #define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->RegisterPorts(a,b,c,d,e,f)
  211. #define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->GetRegisteredAddresses(a,b,c,d,e,f)
  212. #define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->DeregisterPorts(a,b)
  213. #define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->QueryAddress(a,b,c,d,e)
  214. #define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->SetAlertEvent(a,b)
  215. #define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->SetAlertIOCompletionPort(a,b,c,d)
  216. #define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->ExtendRegisteredPortsLease(a,b,c)
  217. #endif
  218. /****************************************************************************
  219. *
  220. * DirectPlay NAT Helper return codes
  221. *
  222. * Errors are represented by negative values and cannot be combined.
  223. *
  224. ****************************************************************************/
  225. #define _DPNH_FACILITY_CODE 0x015
  226. #define _DPNH_HRESULT_BASE 0xF000
  227. #define MAKE_DPNHSUCCESS(code) MAKE_HRESULT(0, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE))
  228. #define MAKE_DPNHFAILURE(code) MAKE_HRESULT(1, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE))
  229. #define DPNH_OK S_OK
  230. #define DPNHSUCCESS_ADDRESSESCHANGED MAKE_DPNHSUCCESS(0x10)
  231. #define DPNHERR_ALREADYINITIALIZED MAKE_DPNHFAILURE(0x10)
  232. #define DPNHERR_BUFFERTOOSMALL MAKE_DPNHFAILURE(0x20)
  233. #define DPNHERR_GENERIC E_FAIL
  234. #define DPNHERR_INVALIDFLAGS MAKE_DPNHFAILURE(0x30)
  235. #define DPNHERR_INVALIDOBJECT MAKE_DPNHFAILURE(0x40)
  236. #define DPNHERR_INVALIDPARAM E_INVALIDARG
  237. #define DPNHERR_INVALIDPOINTER E_POINTER
  238. #define DPNHERR_NOMAPPING MAKE_DPNHFAILURE(0x50)
  239. #define DPNHERR_NOMAPPINGBUTPRIVATE MAKE_DPNHFAILURE(0x60)
  240. #define DPNHERR_NOTINITIALIZED MAKE_DPNHFAILURE(0x70)
  241. #define DPNHERR_OUTOFMEMORY E_OUTOFMEMORY
  242. #define DPNHERR_PORTALREADYREGISTERED MAKE_DPNHFAILURE(0x80)
  243. #define DPNHERR_PORTUNAVAILABLE MAKE_DPNHFAILURE(0x90)
  244. #define DPNHERR_REENTRANT MAKE_DPNHFAILURE(0x95)
  245. #define DPNHERR_SERVERNOTAVAILABLE MAKE_DPNHFAILURE(0xA0)
  246. //@@BEGIN_MSINTERNAL
  247. #define DPNHERR_SERVERNOTRESPONDING MAKE_DPNHFAILURE(0xB0)
  248. //@@END_MSINTERNAL
  249. #define DPNHERR_UPDATESERVERSTATUS MAKE_DPNHFAILURE(0xC0)
  250. #ifdef __cplusplus
  251. }
  252. #endif
  253. #endif // __DPNATHLP_H__