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.

406 lines
7.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000
  5. //
  6. // File: H N E T C O N N. H
  7. //
  8. // Contents: CHNetConn declarations
  9. //
  10. // Notes:
  11. //
  12. // Author: jonburs 23 May 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. class ATL_NO_VTABLE CHNetConn :
  17. public CComObjectRootEx<CComMultiThreadModel>,
  18. public IHNetConnection
  19. {
  20. protected:
  21. //
  22. // IWbemServices for our namespace
  23. //
  24. IWbemServices *m_piwsHomenet;
  25. //
  26. // Path to the WMI instance for the connection
  27. //
  28. BSTR m_bstrConnection;
  29. //
  30. // Path to the WMI instance for the connection properties
  31. //
  32. BSTR m_bstrProperties;
  33. //
  34. // Pointer to our corresponding INetConnection. May
  35. // be null, depending on how we were created.
  36. //
  37. INetConnection *m_pNetConn;
  38. //
  39. // Cached connection type. Always valid and read-only
  40. // after construction
  41. //
  42. BOOLEAN m_fLanConnection;
  43. //
  44. // Cached GUID. Will be NULL until someone (possibly internal)
  45. // asks for our GUID.
  46. //
  47. GUID *m_pGuid;
  48. //
  49. // Cached connection name. Will be NULL until someone
  50. // asks for our name
  51. //
  52. LPWSTR m_wszName;
  53. //
  54. // Commonly used BSTR
  55. //
  56. BSTR m_bstrWQL;
  57. //
  58. // Policy check helper object
  59. //
  60. INetConnectionUiUtilities *m_pNetConnUiUtil;
  61. //
  62. // Netman update object
  63. //
  64. INetConnectionHNetUtil *m_pNetConnHNetUtil;
  65. //
  66. // Netman UI refresh object
  67. //
  68. INetConnectionRefresh *m_pNetConnRefresh;
  69. //
  70. // Retrieves the HNet_FwIcmpSettings associated with
  71. // this connection
  72. //
  73. HRESULT
  74. GetIcmpSettingsInstance(
  75. IWbemClassObject **ppwcoSettings
  76. );
  77. //
  78. // Copies from an IWbemClassObject representing an ICMP settings
  79. // instance to an HNET_FW_ICMP_SETTINGS structure
  80. //
  81. HRESULT
  82. CopyIcmpSettingsInstanceToStruct(
  83. IWbemClassObject *pwcoSettings,
  84. HNET_FW_ICMP_SETTINGS *pSettings
  85. );
  86. //
  87. // Copies from an HNET_FW_ICMP_SETTINGS structure to
  88. // an IWbemClassObject representing an ICMP settings
  89. // instance.
  90. //
  91. HRESULT
  92. CopyStructToIcmpSettingsInstance(
  93. HNET_FW_ICMP_SETTINGS *pSettings,
  94. IWbemClassObject *pwcoSettings
  95. );
  96. //
  97. // Ensures that all port mapping bindings have been created
  98. // for this connection. Called when EnumPortMappings is
  99. // called on the connection, and fEnabledOnly is false.
  100. //
  101. HRESULT
  102. CreatePortMappingBindings();
  103. //
  104. // Copies our property instance into an allocated structure
  105. //
  106. HRESULT
  107. InternalGetProperties(
  108. IWbemClassObject *pwcoProperties,
  109. HNET_CONN_PROPERTIES *pProperties
  110. );
  111. //
  112. // Configures the connection to be the private adapter
  113. //
  114. HRESULT
  115. SetupConnectionAsPrivateLan();
  116. //
  117. // Saves the current IP configuration into the store
  118. //
  119. HRESULT
  120. BackupIpConfiguration();
  121. //
  122. // Set's the IP configuration to what was saved in the store
  123. //
  124. HRESULT
  125. RestoreIpConfiguration();
  126. //
  127. // Open a registry key to our IP settings
  128. //
  129. HRESULT
  130. OpenIpConfigurationRegKey(
  131. ACCESS_MASK DesiredAccess,
  132. HANDLE *phKey
  133. );
  134. //
  135. // Retrieves our GUID. The caller must NOT free the pointer
  136. // that is returned.
  137. HRESULT
  138. GetGuidInternal(
  139. GUID **ppGuid
  140. );
  141. //
  142. // Retrieves the underlying connection object
  143. //
  144. HRESULT
  145. GetConnectionObject(
  146. IWbemClassObject **ppwcoConnection
  147. );
  148. //
  149. // Retrieves the underlying connection properties object
  150. //
  151. HRESULT
  152. GetConnectionPropertiesObject(
  153. IWbemClassObject **ppwcoProperties
  154. );
  155. //
  156. // Helper routine to perform policy checks. Returns
  157. // TRUE if this action is prohibited.
  158. //
  159. BOOLEAN
  160. ProhibitedByPolicy(
  161. DWORD dwPerm
  162. );
  163. //
  164. // Helper routine to update netman that some homenet
  165. // property changed
  166. //
  167. HRESULT
  168. UpdateNetman();
  169. //
  170. // Creates the association between the connection and the
  171. // ICMP settings block
  172. //
  173. HRESULT
  174. CreateIcmpSettingsAssociation(
  175. BSTR bstrIcmpSettingsPath
  176. );
  177. //
  178. // Obtains the name of a RAS connection from the
  179. // appropriate phonebook.
  180. //
  181. HRESULT
  182. GetRasConnectionName(
  183. OLECHAR **ppszwConnectionName
  184. );
  185. //
  186. // Helper routine to inform netman that a change requiring
  187. // a UI refresh has occured.
  188. //
  189. HRESULT
  190. RefreshNetConnectionsUI(
  191. VOID
  192. );
  193. public:
  194. BEGIN_COM_MAP(CHNetConn)
  195. COM_INTERFACE_ENTRY(IHNetConnection)
  196. END_COM_MAP()
  197. //
  198. // Inline constructor
  199. //
  200. CHNetConn()
  201. {
  202. m_piwsHomenet = NULL;
  203. m_bstrConnection = NULL;
  204. m_bstrProperties = NULL;
  205. m_pNetConn = NULL;
  206. m_fLanConnection = FALSE;
  207. m_pGuid = NULL;
  208. m_wszName = NULL;
  209. m_bstrWQL = NULL;
  210. m_pNetConnUiUtil = NULL;
  211. m_pNetConnHNetUtil = NULL;
  212. m_pNetConnRefresh = NULL;
  213. };
  214. //
  215. // ATL Methods
  216. //
  217. HRESULT
  218. FinalConstruct();
  219. HRESULT
  220. FinalRelease();
  221. //
  222. // Ojbect initialization
  223. //
  224. HRESULT
  225. Initialize(
  226. IWbemServices *piwsNamespace,
  227. IWbemClassObject *pwcoProperties
  228. );
  229. HRESULT
  230. InitializeFromConnection(
  231. IWbemServices *piwsNamespace,
  232. IWbemClassObject *pwcoConnection
  233. );
  234. HRESULT
  235. InitializeFromInstances(
  236. IWbemServices *piwsNamespace,
  237. IWbemClassObject *pwcoConnection,
  238. IWbemClassObject *pwcoProperties
  239. );
  240. HRESULT
  241. InitializeFull(
  242. IWbemServices *piwsNamespace,
  243. BSTR bstrConnection,
  244. BSTR bstrProperties,
  245. BOOLEAN fLanConnection
  246. );
  247. HRESULT
  248. SetINetConnection(
  249. INetConnection *pConn
  250. );
  251. //
  252. // IHNetConnection methods
  253. //
  254. STDMETHODIMP
  255. GetINetConnection(
  256. INetConnection **ppNetConnection
  257. );
  258. STDMETHODIMP
  259. GetGuid(
  260. GUID **ppGuid
  261. );
  262. STDMETHODIMP
  263. GetName(
  264. OLECHAR **ppszwName
  265. );
  266. STDMETHODIMP
  267. GetRasPhonebookPath(
  268. OLECHAR **ppszwPath
  269. );
  270. STDMETHODIMP
  271. GetProperties(
  272. HNET_CONN_PROPERTIES **ppProperties
  273. );
  274. STDMETHODIMP
  275. GetControlInterface(
  276. REFIID iid,
  277. void **ppv
  278. );
  279. STDMETHODIMP
  280. Firewall(
  281. IHNetFirewalledConnection **ppFirewalledConn
  282. );
  283. STDMETHODIMP
  284. SharePublic(
  285. IHNetIcsPublicConnection **ppIcsPublicConn
  286. );
  287. STDMETHODIMP
  288. SharePrivate(
  289. IHNetIcsPrivateConnection **ppIcsPrivateConn
  290. );
  291. STDMETHODIMP
  292. EnumPortMappings(
  293. BOOLEAN fEnabledOnly,
  294. IEnumHNetPortMappingBindings **ppEnum
  295. );
  296. STDMETHODIMP
  297. GetBindingForPortMappingProtocol(
  298. IHNetPortMappingProtocol *pProtocol,
  299. IHNetPortMappingBinding **ppBinding
  300. );
  301. STDMETHODIMP
  302. GetIcmpSettings(
  303. HNET_FW_ICMP_SETTINGS **ppSettings
  304. );
  305. STDMETHODIMP
  306. SetIcmpSettings(
  307. HNET_FW_ICMP_SETTINGS *pSettings
  308. );
  309. STDMETHODIMP
  310. ShowAutoconfigBalloon(
  311. BOOLEAN *pfShowBalloon
  312. );
  313. STDMETHODIMP
  314. DeleteRasConnectionEntry();
  315. };