home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Include / dpnathlp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-04  |  13.4 KB  |  319 lines

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