1 #undef INTERFACE 2 /* 3 * Copyright (C) 2006 Maarten Lankhorst 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 20 #ifndef __DPNATHLP_H__ 21 #define __DPNATHLP_H__ 22 23 #include <ole2.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 HRESULT DirectPlayNATHelpCreate(LPCGUID pIID, LPVOID *ppvInterface); 30 31 DEFINE_GUID(CLSID_DirectPlayNATHelpUPnP, 0xb9c2e9c4,0x68c1,0x4d42,0xa7,0xa1,0xe7,0x6a,0x26,0x98,0x2a,0xd6); 32 DEFINE_GUID(CLSID_DirectPlayNATHelpPAST, 0x963ab779,0x16a1,0x477c,0xa3,0x6d,0xcb,0x5e,0x71,0x19,0x38,0xf7); 33 DEFINE_GUID(IID_IDirectPlayNATHelp, 0x154940b6,0x2278,0x4a2f,0x91,0x01,0x9b,0xa9,0xf4,0x31,0xf6,0x03); 34 35 #define DPNHGETCAPS_UPDATESERVERSTATUS 0x01 36 37 #define DPNHREGISTERPORTS_TCP 0x01 38 #define DPNHREGISTERPORTS_FIXEDPORTS 0x02 39 #define DPNHREGISTERPORTS_SHAREDPORTS 0x04 40 41 #define DPNHADDRESSTYPE_TCP 0x01 42 #define DPNHADDRESSTYPE_FIXEDPORTS 0x02 43 #define DPNHADDRESSTYPE_SHAREDPORTS 0x04 44 #define DPNHADDRESSTYPE_LOCALFIREWALL 0x08 45 #define DPNHADDRESSTYPE_GATEWAY 0x10 46 #define DPNHADDRESSTYPE_GATEWAYISLOCAL 0x20 47 48 #define DPNHCAPSFLAG_LOCALFIREWALLPRESENT 0x01 49 #define DPNHCAPSFLAG_GATEWAYPRESENT 0x02 50 #define DPNHCAPSFLAG_GATEWAYISLOCAL 0x04 51 #define DPNHCAPSFLAG_PUBLICADDRESSAVAILABLE 0x08 52 #define DPNHCAPSFLAG_NOTALLSUPPORTACTIVENOTIFY 0x10 53 54 #define DPNHINITIALIZE_DISABLEGATEWAYSUPPORT 0x01 55 #define DPNHINITIALIZE_DISABLELOCALFIREWALLSUPPORT 0x02 56 57 #define DPNHQUERYADDRESS_TCP 0x01 58 #define DPNHQUERYADDRESS_CACHEFOUND 0x02 59 #define DPNHQUERYADDRESS_CACHENOTFOUND 0x04 60 #define DPNHQUERYADDRESS_CHECKFORPRIVATEBUTUNMAPPED 0x08 61 62 #define DPNHGETREGISTEREDADDRESSES_LOCALFIREWALLREMAPONLY 0x01 63 64 #define _DPNH_FACILITY_CODE 0x015 65 #define _DPNH_HRESULT_BASE 0xF000 66 67 #define MAKE_DPNHSUCCESS(code) \ 68 MAKE_HRESULT(0, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) 69 #define MAKE_DPNHFAILURE(code) \ 70 MAKE_HRESULT(1, _DPNH_FACILITY_CODE, (code + _DPNH_HRESULT_BASE)) 71 72 #define DPNH_OK S_OK 73 #define DPNHSUCCESS_ADDRESSESCHANGED MAKE_DPNHSUCCESS(0x10) 74 75 #define DPNHERR_ALREADYINITIALIZED MAKE_DPNHFAILURE(0x10) 76 #define DPNHERR_BUFFERTOOSMALL MAKE_DPNHFAILURE(0x20) 77 #define DPNHERR_GENERIC E_FAIL 78 #define DPNHERR_INVALIDFLAGS MAKE_DPNHFAILURE(0x30) 79 #define DPNHERR_INVALIDOBJECT MAKE_DPNHFAILURE(0x40) 80 #define DPNHERR_INVALIDPARAM E_INVALIDARG 81 #define DPNHERR_INVALIDPOINTER E_POINTER 82 #define DPNHERR_NOMAPPING MAKE_DPNHFAILURE(0x50) 83 #define DPNHERR_NOMAPPINGBUTPRIVATE MAKE_DPNHFAILURE(0x60) 84 #define DPNHERR_NOTINITIALIZED MAKE_DPNHFAILURE(0x70) 85 #define DPNHERR_OUTOFMEMORY E_OUTOFMEMORY 86 #define DPNHERR_PORTALREADYREGISTERED MAKE_DPNHFAILURE(0x80) 87 #define DPNHERR_PORTUNAVAILABLE MAKE_DPNHFAILURE(0x90) 88 #define DPNHERR_REENTRANT MAKE_DPNHFAILURE(0x95) 89 #define DPNHERR_SERVERNOTAVAILABLE MAKE_DPNHFAILURE(0xA0) 90 #define DPNHERR_UPDATESERVERSTATUS MAKE_DPNHFAILURE(0xC0) 91 92 typedef DWORD_PTR DPNHHANDLE; 93 typedef DWORD_PTR *PDPNHHANDLE; 94 95 typedef struct _DPNHCAPS 96 { 97 DWORD dwSize; 98 DWORD dwFlags; 99 DWORD dwNumRegisteredPorts; 100 DWORD dwMinLeaseTimeRemaining; 101 DWORD dwRecommendedGetCapsInterval; 102 } DPNHCAPS, *PDPNHCAPS; 103 104 105 #define INTERFACE IDirectPlayNATHelp 106 DECLARE_INTERFACE_(IDirectPlayNATHelp,IUnknown) 107 { 108 /*** IUnknown methods ***/ 109 STDMETHOD(QueryInterface) (THIS_ 110 REFIID riid, 111 void** ppvObject) PURE; 112 113 STDMETHOD_(ULONG,AddRef) (THIS) PURE; 114 115 STDMETHOD_(ULONG,Release) (THIS) PURE; 116 117 /*** IDirectPlayNATHelp functions ***/ 118 STDMETHOD(Initialize) (THIS_ 119 const DWORD dwFlags) PURE; 120 121 STDMETHOD(Close) (THIS_ 122 const DWORD dwFlags) PURE; 123 124 STDMETHOD(GetCaps) (THIS_ 125 const PDPNHCAPS pCaps, 126 const DWORD dwFlags) PURE; 127 128 STDMETHOD(RegisterPorts) (THIS_ 129 const PSOCKADDR aLocalAddresses, 130 const DWORD dwAddressSize, 131 const DWORD dwAddresses, 132 const DWORD dwTime, 133 const PDPNHHANDLE phRegisteredPorts, 134 const DWORD dwFlags) PURE; 135 136 STDMETHOD(GetRegisteredAddresses) (THIS_ 137 const PDPNHHANDLE hRegisteredPorts, 138 const PSOCKADDR paPublicAddresses, 139 const DWORD *dwAddressSize, 140 const DWORD *dwAddressFlags, 141 const DWORD *dwRemaining, 142 const DWORD dwFlags) PURE; 143 144 STDMETHOD(DeregisterPorts)(THIS_ 145 const DPNHHANDLE hRegPorts, 146 const DWORD dwFlags) PURE; 147 148 STDMETHOD(QueryAddress) (THIS_ 149 const PSOCKADDR pSource, 150 const PSOCKADDR pQuery, 151 const PSOCKADDR pResponse, 152 const INT iAddresses, 153 const DWORD dwFlags) PURE; 154 155 STDMETHOD(SetAlertEvent) (THIS_ 156 const HANDLE hEvent, 157 const DWORD dwFlags) PURE; 158 159 STDMETHOD(SetAlertIOCompletionPort)(THIS_ 160 const HANDLE hIOCompletionPort, 161 const DWORD dwCompletion, 162 const DWORD dwMaxThreads, 163 const DWORD dwFlags) PURE; 164 165 STDMETHOD(ExtendRegisteredPortsLease)(THIS_ 166 const DPNHHANDLE hRegisteredPorts, 167 const DWORD dwLeaseTime, 168 const DWORD dwFlags) PURE; 169 }; 170 171 #undef INTERFACE 172 173 #ifdef COBJMACROS 174 #define IDirectPlayNATHelp_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) 175 #define IDirectPlayNATHelp_AddRef(p) (p)->lpVtbl->AddRef(p) 176 #define IDirectPlayNATHelp_Release(p) (p)->lpVtbl->Release(p) 177 #define IDirectPlayNATHelp_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) 178 #define IDirectPlayNATHelp_Close(p,a) (p)->lpVtbl->Close(p,a) 179 #define IDirectPlayNATHelp_GetCaps(p,a,b) (p)->lpVtbl->GetCaps(p,a,b) 180 #define IDirectPlayNATHelp_RegisterPorts(p,a,b,c,d,e,f) (p)->lpVtbl->RegisterPorts(p,a,b,c,d,e,f) 181 #define IDirectPlayNATHelp_GetRegisteredAddresses(p,a,b,c,d,e,f) (p)->lpVtbl->GetRegisteredAddresses(p,a,b,c,d,e,f) 182 #define IDirectPlayNATHelp_DeregisterPorts(p,a,b) (p)->lpVtbl->DeregisterPorts(p,a,b) 183 #define IDirectPlayNATHelp_QueryAddress(p,a,b,c,d,e) (p)->lpVtbl->QueryAddress(p,a,b,c,d,e) 184 #define IDirectPlayNATHelp_SetAlertEvent(p,a,b) (p)->lpVtbl->SetAlertEvent(p,a,b) 185 #define IDirectPlayNATHelp_SetAlertIOCompletionPort(p,a,b,c,d) (p)->lpVtbl->SetAlertIOCompletionPort(p,a,b,c,d) 186 #define IDirectPlayNATHelp_ExtendRegisteredPortsLease(p,a,b,c) (p)->lpVtbl->SetAlertIOCompletionPort(p,a,b,c) 187 #endif 188 189 #ifdef __cplusplus 190 } 191 #endif 192 193 #endif /* __DPNATHLP_H__ */ 194