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.

376 lines
7.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000
  5. //
  6. // File: H N C F G M G R . H
  7. //
  8. // Contents: CHNetCfgMgr declarations
  9. //
  10. // Notes:
  11. //
  12. // Author: jonburs 23 May 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. class ATL_NO_VTABLE CHNetCfgMgr :
  17. public CComObjectRootEx<CComMultiThreadModel>,
  18. public CComCoClass<CHNetCfgMgr, &CLSID_HNetCfgMgr>,
  19. public IHNetCfgMgr,
  20. public IHNetBridgeSettings,
  21. public IHNetFirewallSettings,
  22. public IHNetIcsSettings,
  23. public IHNetProtocolSettings
  24. {
  25. protected:
  26. //
  27. // Connection to \\.\Root\Microsoft\HomeNet WMI namespace. Obtained
  28. // through IWbemLocator::ConnectServer
  29. //
  30. IWbemServices *m_piwsHomenet;
  31. //
  32. // Policy check object
  33. //
  34. INetConnectionUiUtilities *m_pNetConnUiUtil;
  35. //
  36. // Netman update object
  37. //
  38. INetConnectionHNetUtil *m_pNetConnHNetUtil;
  39. //
  40. // Commonly used BSTRs.
  41. //
  42. BSTR m_bstrWQL;
  43. //
  44. // Copies an HNet_FirewallLoggingSettings instance to an
  45. // HNET_FW_LOGGING_SETTINGS struct
  46. //
  47. HRESULT
  48. CopyLoggingInstanceToStruct(
  49. IWbemClassObject *pwcoInstance,
  50. HNET_FW_LOGGING_SETTINGS *pfwSettings
  51. );
  52. //
  53. // Copies an HNET_FW_LOGGING_SETTINGS struct to
  54. // an HNet_FirewallLoggingSettings instance
  55. //
  56. HRESULT
  57. CopyStructToLoggingInstance(
  58. HNET_FW_LOGGING_SETTINGS *pfwSettings,
  59. IWbemClassObject *pwcoInstance
  60. );
  61. //
  62. // Installs the bridge protocol and miniport
  63. //
  64. HRESULT
  65. InstallBridge(
  66. GUID *pguid,
  67. INetCfg *pnetcfgExisting
  68. );
  69. //
  70. // Creates the appropriate instances for a connection that there is
  71. // no record of in the store. The returned instances must be commited
  72. // (through IWbemServices::PutInstance)
  73. //
  74. HRESULT
  75. CreateConnectionAndPropertyInstances(
  76. GUID *pGuid,
  77. BOOLEAN fLanConnection,
  78. LPCWSTR pszwName,
  79. IWbemClassObject **ppwcoConnection,
  80. IWbemClassObject **ppwcoProperties
  81. );
  82. //
  83. // Helper routine to perform policy checks. Returns
  84. // TRUE if this action is prohibited.
  85. //
  86. BOOLEAN
  87. ProhibitedByPolicy(
  88. DWORD dwPerm
  89. );
  90. //
  91. // Helper routine to update netman that some homenet
  92. // property changed
  93. //
  94. HRESULT
  95. UpdateNetman();
  96. public:
  97. BEGIN_COM_MAP(CHNetCfgMgr)
  98. COM_INTERFACE_ENTRY(IHNetCfgMgr)
  99. COM_INTERFACE_ENTRY(IHNetBridgeSettings)
  100. COM_INTERFACE_ENTRY(IHNetFirewallSettings)
  101. COM_INTERFACE_ENTRY(IHNetIcsSettings)
  102. COM_INTERFACE_ENTRY(IHNetProtocolSettings)
  103. END_COM_MAP()
  104. DECLARE_REGISTRY_RESOURCEID(IDR_HNETCFG)
  105. DECLARE_PROTECT_FINAL_CONSTRUCT()
  106. //
  107. // Inline constructor.
  108. //
  109. CHNetCfgMgr()
  110. {
  111. m_piwsHomenet = NULL;
  112. m_bstrWQL = NULL;
  113. m_pNetConnUiUtil = NULL;
  114. m_pNetConnHNetUtil = NULL;
  115. };
  116. //
  117. // Atl methods
  118. //
  119. HRESULT
  120. FinalConstruct();
  121. HRESULT
  122. FinalRelease();
  123. //
  124. // IHNetCfgMgr methods
  125. //
  126. STDMETHODIMP
  127. GetIHNetConnectionForINetConnection(
  128. INetConnection *pNetConnection,
  129. IHNetConnection **ppHNetConnection
  130. );
  131. STDMETHODIMP
  132. GetIHNetConnectionForGuid(
  133. GUID *pGuid,
  134. BOOLEAN fLanConnection,
  135. BOOLEAN fCreateEntries,
  136. IHNetConnection **ppHNetConnection
  137. );
  138. //
  139. // IHNetBridgeSettings methods
  140. //
  141. STDMETHODIMP
  142. EnumBridges(
  143. IEnumHNetBridges **ppEnum
  144. );
  145. STDMETHODIMP
  146. CreateBridge(
  147. IHNetBridge **ppHNetBridge,
  148. INetCfg *pnetcfgExisting
  149. );
  150. STDMETHODIMP
  151. DestroyAllBridges(
  152. ULONG *pcBridges,
  153. INetCfg *pnetcfgExisting
  154. );
  155. //
  156. // IHNetFirewallSettings methods
  157. //
  158. STDMETHODIMP
  159. EnumFirewalledConnections(
  160. IEnumHNetFirewalledConnections **ppEnum
  161. );
  162. STDMETHODIMP
  163. GetFirewallLoggingSettings(
  164. HNET_FW_LOGGING_SETTINGS **ppSettings
  165. );
  166. STDMETHODIMP
  167. SetFirewallLoggingSettings(
  168. HNET_FW_LOGGING_SETTINGS *pSettings
  169. );
  170. STDMETHODIMP
  171. DisableAllFirewalling(
  172. ULONG *pcFirewalledConnections
  173. );
  174. //
  175. // IHNetIcsSettings methods
  176. //
  177. STDMETHODIMP
  178. EnumIcsPublicConnections(
  179. IEnumHNetIcsPublicConnections **ppEnum
  180. );
  181. STDMETHODIMP
  182. EnumIcsPrivateConnections(
  183. IEnumHNetIcsPrivateConnections **ppEnum
  184. );
  185. STDMETHODIMP
  186. DisableIcs(
  187. ULONG *pcIcsPublicConnections,
  188. ULONG *pcIcsPrivateConnections
  189. );
  190. STDMETHODIMP
  191. GetPossiblePrivateConnections(
  192. IHNetConnection *pConn,
  193. ULONG *pcPrivateConnections,
  194. IHNetConnection **pprgPrivateConnections[],
  195. LONG *pxCurrentPrivate
  196. );
  197. STDMETHODIMP
  198. GetAutodialSettings(
  199. BOOLEAN *pfAutodialEnabled
  200. );
  201. STDMETHODIMP
  202. SetAutodialSettings(
  203. BOOLEAN fEnableAutodial
  204. );
  205. STDMETHODIMP
  206. GetDhcpEnabled(
  207. BOOLEAN *pfDhcpEnabled
  208. );
  209. STDMETHODIMP
  210. SetDhcpEnabled(
  211. BOOLEAN fEnableDhcp
  212. );
  213. STDMETHODIMP
  214. GetDhcpScopeSettings(
  215. DWORD *pdwScopeAddress,
  216. DWORD *pdwScopeMask
  217. );
  218. STDMETHODIMP
  219. SetDhcpScopeSettings(
  220. DWORD dwScopeAddress,
  221. DWORD dwScopeMask
  222. );
  223. STDMETHODIMP
  224. EnumDhcpReservedAddresses(
  225. IEnumHNetPortMappingBindings **ppEnum
  226. );
  227. STDMETHODIMP
  228. GetDnsEnabled(
  229. BOOLEAN *pfDnsEnabled
  230. );
  231. STDMETHODIMP
  232. SetDnsEnabled(
  233. BOOLEAN fEnableDns
  234. );
  235. //
  236. // IHNetProtocolSettings methods
  237. //
  238. STDMETHODIMP
  239. EnumApplicationProtocols(
  240. BOOLEAN fEnabledOnly,
  241. IEnumHNetApplicationProtocols **ppEnum
  242. );
  243. STDMETHODIMP
  244. CreateApplicationProtocol(
  245. OLECHAR *pszwName,
  246. UCHAR ucOutgoingIPProtocol,
  247. USHORT usOutgoingPort,
  248. USHORT uscResponses,
  249. HNET_RESPONSE_RANGE rgResponses[],
  250. IHNetApplicationProtocol **ppProtocol
  251. );
  252. STDMETHODIMP
  253. EnumPortMappingProtocols(
  254. IEnumHNetPortMappingProtocols **ppEnum
  255. );
  256. STDMETHODIMP
  257. CreatePortMappingProtocol(
  258. OLECHAR *pszwName,
  259. UCHAR ucIPProtocol,
  260. USHORT usPort,
  261. IHNetPortMappingProtocol **ppProtocol
  262. );
  263. STDMETHODIMP
  264. FindPortMappingProtocol(
  265. GUID *pGuid,
  266. IHNetPortMappingProtocol **ppProtocol
  267. );
  268. };
  269. class CHNetCfgMgrChild : public CHNetCfgMgr
  270. {
  271. protected:
  272. // Do our initialization work in Initialize() instead of
  273. // FinalConstruct
  274. HRESULT
  275. FinalConstruct()
  276. {
  277. // Do nothing
  278. return S_OK;
  279. }
  280. public:
  281. HRESULT
  282. Initialize(
  283. IWbemServices *piwsHomenet
  284. )
  285. {
  286. HRESULT hr = S_OK;
  287. //
  288. // Allocate the commonly used BSTRs
  289. //
  290. m_bstrWQL = SysAllocString(c_wszWQL);
  291. if (NULL == m_bstrWQL)
  292. {
  293. hr = E_OUTOFMEMORY;
  294. }
  295. else
  296. {
  297. m_piwsHomenet = piwsHomenet;
  298. m_piwsHomenet->AddRef();
  299. }
  300. return hr;
  301. };
  302. };