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.

382 lines
7.7 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. STDMETHODIMP
  236. RefreshTargetComputerAddress(
  237. OLECHAR *pszwName,
  238. ULONG ulAddress
  239. );
  240. //
  241. // IHNetProtocolSettings methods
  242. //
  243. STDMETHODIMP
  244. EnumApplicationProtocols(
  245. BOOLEAN fEnabledOnly,
  246. IEnumHNetApplicationProtocols **ppEnum
  247. );
  248. STDMETHODIMP
  249. CreateApplicationProtocol(
  250. OLECHAR *pszwName,
  251. UCHAR ucOutgoingIPProtocol,
  252. USHORT usOutgoingPort,
  253. USHORT uscResponses,
  254. HNET_RESPONSE_RANGE rgResponses[],
  255. IHNetApplicationProtocol **ppProtocol
  256. );
  257. STDMETHODIMP
  258. EnumPortMappingProtocols(
  259. IEnumHNetPortMappingProtocols **ppEnum
  260. );
  261. STDMETHODIMP
  262. CreatePortMappingProtocol(
  263. OLECHAR *pszwName,
  264. UCHAR ucIPProtocol,
  265. USHORT usPort,
  266. IHNetPortMappingProtocol **ppProtocol
  267. );
  268. STDMETHODIMP
  269. FindPortMappingProtocol(
  270. GUID *pGuid,
  271. IHNetPortMappingProtocol **ppProtocol
  272. );
  273. };
  274. class CHNetCfgMgrChild : public CHNetCfgMgr
  275. {
  276. protected:
  277. // Do our initialization work in Initialize() instead of
  278. // FinalConstruct
  279. HRESULT
  280. FinalConstruct()
  281. {
  282. // Do nothing
  283. return S_OK;
  284. }
  285. public:
  286. HRESULT
  287. Initialize(
  288. IWbemServices *piwsHomenet
  289. )
  290. {
  291. HRESULT hr = S_OK;
  292. //
  293. // Allocate the commonly used BSTRs
  294. //
  295. m_bstrWQL = SysAllocString(c_wszWQL);
  296. if (NULL == m_bstrWQL)
  297. {
  298. hr = E_OUTOFMEMORY;
  299. }
  300. else
  301. {
  302. m_piwsHomenet = piwsHomenet;
  303. m_piwsHomenet->AddRef();
  304. }
  305. return hr;
  306. };
  307. };