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.

1086 lines
26 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CProxyCfgNetworkInfo.cpp
  7. //
  8. // Description:
  9. // CProxyCfgNetworkInfo implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-SEP-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "Pch.h"
  19. #include "CProxyCfgNetworkInfo.h"
  20. #include "CProxyCfgIPAddressInfo.h"
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Constant Definitions
  23. //////////////////////////////////////////////////////////////////////////////
  24. DEFINE_THISCLASS("CProxyCfgNetworkInfo")
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CProxyCfgNetworkInfo::S_HrCreateInstance
  29. //
  30. // Description:
  31. // Create a CProxyCfgNetworkInfo instance.
  32. //
  33. // Arguments:
  34. // ppunkOut
  35. //
  36. // Return Values:
  37. // S_OK
  38. // Success.
  39. //
  40. // E_POINTER
  41. // A passed in argument is NULL.
  42. //
  43. // E_OUTOFMEMORY
  44. // Out of memory.
  45. //
  46. // Other HRESULT error.
  47. //
  48. //--
  49. //////////////////////////////////////////////////////////////////////////////
  50. HRESULT
  51. CProxyCfgNetworkInfo::S_HrCreateInstance(
  52. IUnknown ** ppunkOut,
  53. IUnknown * punkOuterIn,
  54. HCLUSTER * phClusterIn,
  55. CLSID * pclsidMajorIn,
  56. LPCWSTR pcszNetworkNameIn
  57. )
  58. {
  59. TraceFunc( "" );
  60. HRESULT hr S_OK;
  61. CProxyCfgNetworkInfo * ppcni = NULL;
  62. if ( ppunkOut == NULL )
  63. {
  64. hr = THR( E_POINTER );
  65. goto Cleanup;
  66. } // if:
  67. ppcni = new CProxyCfgNetworkInfo;
  68. if ( ppcni == NULL )
  69. {
  70. hr = THR( E_OUTOFMEMORY );
  71. goto Cleanup;
  72. } // if:
  73. hr = THR( ppcni->HrInit( punkOuterIn, phClusterIn, pclsidMajorIn, pcszNetworkNameIn ) );
  74. if ( FAILED( hr ) )
  75. {
  76. goto Cleanup;
  77. }
  78. hr = THR( ppcni->TypeSafeQI( IUnknown, ppunkOut ) );
  79. if ( FAILED( hr ) )
  80. {
  81. goto Cleanup;
  82. }
  83. Cleanup:
  84. if ( ppcni != NULL )
  85. {
  86. ppcni->Release();
  87. } // if:
  88. HRETURN( hr );
  89. } //*** CProxyCfgNetworkInfo::S_HrCreateInstance
  90. //////////////////////////////////////////////////////////////////////////////
  91. //++
  92. //
  93. // CProxyCfgNetworkInfo::CProxyCfgNetworkInfo
  94. //
  95. // Description:
  96. // Constructor of the CProxyCfgNetworkInfo class. This initializes
  97. // the m_cRef variable to 1 instead of 0 to account of possible
  98. // QueryInterface failure in DllGetClassObject.
  99. //
  100. // Arguments:
  101. // None.
  102. //
  103. // Return Value:
  104. // None.
  105. //
  106. // Remarks:
  107. // None.
  108. //
  109. //--
  110. //////////////////////////////////////////////////////////////////////////////
  111. CProxyCfgNetworkInfo::CProxyCfgNetworkInfo( void )
  112. : m_cRef( 1 )
  113. {
  114. TraceFunc( "" );
  115. InterlockedIncrement( &g_cObjects );
  116. Assert( m_punkOuter == NULL );
  117. Assert( m_pcccb == NULL );
  118. Assert( m_phCluster == NULL );
  119. Assert( m_pclsidMajor == NULL );
  120. // m_cplNetwork??
  121. // m_cplNetworkRO??
  122. TraceFuncExit();
  123. } //*** CProxyCfgNetworkInfo::CProxyCfgNetworkInfo
  124. //////////////////////////////////////////////////////////////////////////////
  125. //++
  126. //
  127. // CProxyCfgNetworkInfo::~CProxyCfgNetworkInfo
  128. //
  129. // Description:
  130. // Destructor of the CProxyCfgNetworkInfo class.
  131. //
  132. // Arguments:
  133. // None.
  134. //
  135. // Return Value:
  136. // None.
  137. //
  138. // Remarks:
  139. // None.
  140. //
  141. //--
  142. //////////////////////////////////////////////////////////////////////////////
  143. CProxyCfgNetworkInfo::~CProxyCfgNetworkInfo( void )
  144. {
  145. TraceFunc( "" );
  146. // m_cRef - noop
  147. if ( m_punkOuter != NULL )
  148. {
  149. m_punkOuter->Release();
  150. }
  151. if ( m_pcccb != NULL )
  152. {
  153. m_pcccb->Release();
  154. } // if:
  155. // m_phCluster - DO NOT CLOSE
  156. // m_pclsidMajor - noop
  157. // m_cplNetwork - has own dtor code
  158. // m_cplNetworkRO - has own dtor code
  159. InterlockedDecrement( &g_cObjects );
  160. TraceFuncExit();
  161. } //*** CProxyCfgNetworkInfo::~CProxyCfgNetworkInfo
  162. //
  163. //
  164. //
  165. HRESULT
  166. CProxyCfgNetworkInfo::HrInit(
  167. IUnknown * punkOuterIn,
  168. HCLUSTER * phClusterIn,
  169. CLSID * pclsidMajorIn,
  170. LPCWSTR pcszNetworkNameIn
  171. )
  172. {
  173. TraceFunc( "" );
  174. HRESULT hr;
  175. DWORD sc;
  176. HNETWORK hNetwork = NULL;
  177. // IUnknown
  178. Assert( m_cRef == 1 );
  179. if ( punkOuterIn != NULL )
  180. {
  181. m_punkOuter = punkOuterIn;
  182. m_punkOuter->AddRef();
  183. }
  184. if ( phClusterIn == NULL )
  185. goto InvalidArg;
  186. m_phCluster = phClusterIn;
  187. if ( pclsidMajorIn != NULL )
  188. {
  189. m_pclsidMajor = pclsidMajorIn;
  190. }
  191. else
  192. {
  193. m_pclsidMajor = (CLSID *) &TASKID_Major_Client_And_Server_Log;
  194. }
  195. if ( punkOuterIn != NULL )
  196. {
  197. hr = THR( punkOuterIn->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  198. if ( FAILED( hr ) )
  199. goto Cleanup;
  200. }
  201. if ( pcszNetworkNameIn == NULL )
  202. goto InvalidArg;
  203. //
  204. // Gather network properties
  205. //
  206. hNetwork = OpenClusterNetwork( *m_phCluster, pcszNetworkNameIn );
  207. if ( hNetwork == NULL )
  208. {
  209. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  210. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_OpenClusterNetInterface_Failed, hr );
  211. goto Cleanup;
  212. }
  213. //
  214. // Retrieve the properties.
  215. //
  216. sc = TW32( m_cplNetwork.ScGetNetworkProperties( hNetwork, CLUSCTL_NETWORK_GET_COMMON_PROPERTIES ) );
  217. if ( sc != ERROR_SUCCESS )
  218. {
  219. hr = HRESULT_FROM_WIN32( sc );
  220. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetNetworkProperties_Failed, hr );
  221. goto Cleanup;
  222. } // if:
  223. //
  224. // Rettrieve the READ ONLY properties
  225. //
  226. sc = TW32( m_cplNetworkRO.ScGetNetworkProperties( hNetwork, CLUSCTL_NETWORK_GET_RO_COMMON_PROPERTIES ) );
  227. if ( sc != ERROR_SUCCESS )
  228. {
  229. hr = HRESULT_FROM_WIN32( sc );
  230. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetNetworkProperties_Failed, hr );
  231. goto Cleanup;
  232. } // if:
  233. hr = S_OK;
  234. Cleanup:
  235. if ( hNetwork != NULL )
  236. {
  237. CloseClusterNetwork( hNetwork );
  238. }
  239. HRETURN( hr );
  240. InvalidArg:
  241. hr = THR( E_INVALIDARG );
  242. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NetworkInfo_HrInit_InvalidArg, hr );
  243. goto Cleanup;
  244. } //*** CProxyCfgNetworkInfo::HrInit
  245. //*************************************************************************//
  246. /////////////////////////////////////////////////////////////////////////////
  247. // CProxyCfgNetworkInfo -- IUknkown interface.
  248. /////////////////////////////////////////////////////////////////////////////
  249. //////////////////////////////////////////////////////////////////////////////
  250. //++
  251. //
  252. // CProxyCfgNetworkInfo::QueryInterface
  253. //
  254. // Description:
  255. // Query this object for the passed in interface.
  256. //
  257. // Arguments:
  258. // riidIn
  259. // Id of interface requested.
  260. //
  261. // ppvOut
  262. // Pointer to the requested interface.
  263. //
  264. // Return Value:
  265. // S_OK
  266. // If the interface is available on this object.
  267. //
  268. // E_NOINTERFACE
  269. // If the interface is not available.
  270. //
  271. // E_POINTER
  272. // ppvOut was NULL.
  273. //
  274. // Remarks:
  275. // None.
  276. //
  277. //--
  278. //////////////////////////////////////////////////////////////////////////////
  279. STDMETHODIMP
  280. CProxyCfgNetworkInfo::QueryInterface(
  281. REFIID riidIn
  282. , void ** ppvOut
  283. )
  284. {
  285. TraceQIFunc( riidIn, ppvOut );
  286. HRESULT hr = S_OK;
  287. //
  288. // Validate arguments.
  289. //
  290. Assert( ppvOut != NULL );
  291. if ( ppvOut == NULL )
  292. {
  293. hr = THR( E_POINTER );
  294. goto Cleanup;
  295. }
  296. //
  297. // Handle known interfaces.
  298. //
  299. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  300. {
  301. *ppvOut = static_cast< IClusCfgNetworkInfo * >( this );
  302. } // if: IUnknown
  303. else if ( IsEqualIID( riidIn, IID_IClusCfgNetworkInfo ) )
  304. {
  305. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgNetworkInfo, this, 0 );
  306. } // else if: IClusCfgNetworkInfo
  307. else if ( IsEqualIID( riidIn, IID_IEnumClusCfgIPAddresses ) )
  308. {
  309. *ppvOut = TraceInterface( __THISCLASS__, IEnumClusCfgIPAddresses, this, 0 );
  310. } // else if: IEnumClusCfgIPAddresses
  311. else
  312. {
  313. *ppvOut = NULL;
  314. hr = E_NOINTERFACE;
  315. } // else
  316. //
  317. // Add a reference to the interface if successful.
  318. //
  319. if ( SUCCEEDED( hr ) )
  320. {
  321. ((IUnknown *) *ppvOut)->AddRef();
  322. } // if: success
  323. Cleanup:
  324. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  325. } //*** CConfigClusApi::QueryInterface
  326. //////////////////////////////////////////////////////////////////////////////
  327. //++
  328. //
  329. // CProxyCfgNetworkInfo::AddRef
  330. //
  331. // Description:
  332. // Increment the reference count of this object by one.
  333. //
  334. // Arguments:
  335. // None.
  336. //
  337. // Return Value:
  338. // The new reference count.
  339. //
  340. // Remarks:
  341. // None.
  342. //
  343. //--
  344. //////////////////////////////////////////////////////////////////////////////
  345. STDMETHODIMP_( ULONG )
  346. CProxyCfgNetworkInfo::AddRef( void )
  347. {
  348. TraceFunc( "[IUnknown]" );
  349. InterlockedIncrement( &m_cRef );
  350. CRETURN( m_cRef );
  351. } //*** CProxyCfgNetworkInfo::AddRef
  352. //////////////////////////////////////////////////////////////////////////////
  353. //++
  354. //
  355. // CProxyCfgNetworkInfo::Release
  356. //
  357. // Description:
  358. // Decrement the reference count of this object by one.
  359. //
  360. // Arguments:
  361. // None.
  362. //
  363. // Return Value:
  364. // The new reference count.
  365. //
  366. // Remarks:
  367. // None.
  368. //
  369. //--
  370. //////////////////////////////////////////////////////////////////////////////
  371. STDMETHODIMP_( ULONG )
  372. CProxyCfgNetworkInfo::Release( void )
  373. {
  374. TraceFunc( "[IUnknown]" );
  375. LONG cRef;
  376. cRef = InterlockedDecrement( &m_cRef );
  377. if ( cRef == 0 )
  378. {
  379. TraceDo( delete this );
  380. }
  381. CRETURN( cRef );
  382. } //*** CProxyCfgNetworkInfo::Release
  383. //*************************************************************************//
  384. /////////////////////////////////////////////////////////////////////////////
  385. // CProxyCfgNetworkInfo -- IClusCfgNetworkInfo interface.
  386. /////////////////////////////////////////////////////////////////////////////
  387. //
  388. //
  389. //
  390. STDMETHODIMP
  391. CProxyCfgNetworkInfo::GetUID( BSTR * pbstrUIDOut )
  392. {
  393. TraceFunc( "[IClusCfgNetworkInfo]" );
  394. HRESULT hr ;
  395. DWORD sc;
  396. LPWSTR psz = NULL;
  397. DWORD ulIPAddress;
  398. DWORD ulSubnetMask;
  399. DWORD ulNetwork;
  400. if ( pbstrUIDOut == NULL )
  401. {
  402. hr = THR( E_POINTER );
  403. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NetworkInfo_GetUID_InvalidPointer, hr );
  404. goto Cleanup;
  405. }
  406. sc = TW32( m_cplNetworkRO.ScMoveToPropertyByName( L"Address" ) );
  407. if ( sc != ERROR_SUCCESS )
  408. {
  409. hr = HRESULT_FROM_WIN32( sc );
  410. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ScMoveToPropetyByName_Address_Failed, hr );
  411. goto Cleanup;
  412. }
  413. Assert( m_cplNetworkRO.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  414. sc = TW32( ClRtlTcpipStringToAddress( m_cplNetworkRO.CbhCurrentValue().pStringValue->sz, &ulIPAddress ) );
  415. if ( sc != ERROR_SUCCESS )
  416. {
  417. hr = HRESULT_FROM_WIN32( sc );
  418. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ClRtlTcpipStringToAddress_Address_Failed, hr );
  419. goto Cleanup;
  420. }
  421. sc = TW32( m_cplNetworkRO.ScMoveToPropertyByName( L"AddressMask" ) );
  422. if ( sc != ERROR_SUCCESS )
  423. {
  424. hr = HRESULT_FROM_WIN32( sc );
  425. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ScMoveToPropetyByName_AddressMask_Failed, hr );
  426. goto Cleanup;
  427. }
  428. Assert( m_cplNetworkRO.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  429. sc = TW32( ClRtlTcpipStringToAddress( m_cplNetworkRO.CbhCurrentValue().pStringValue->sz, &ulSubnetMask ) );
  430. if ( sc != ERROR_SUCCESS )
  431. {
  432. hr = HRESULT_FROM_WIN32( sc );
  433. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ClRtlTcpipStringToAddress_AddressMask_Failed, hr );
  434. goto Cleanup;
  435. }
  436. ulNetwork = ulIPAddress & ulSubnetMask;
  437. sc = TW32( ClRtlTcpipAddressToString( ulNetwork, &psz ) ); // KB: Allocates to psz using LocalAlloc().
  438. if ( sc != ERROR_SUCCESS )
  439. {
  440. hr = HRESULT_FROM_WIN32( sc );
  441. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ClRtlTcpipAddressToString_Failed, hr );
  442. goto Cleanup;
  443. } // if:
  444. *pbstrUIDOut = SysAllocString( psz );
  445. if ( *pbstrUIDOut == NULL )
  446. {
  447. hr = THR( E_OUTOFMEMORY );
  448. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NetworkInfo_GetUID_OutOfMemory, hr );
  449. goto Cleanup;
  450. }
  451. hr = S_OK;
  452. Cleanup:
  453. if ( psz != NULL )
  454. {
  455. LocalFree( psz ); // KB: Don't use TraceFree() here!
  456. } // if:
  457. HRETURN( hr );
  458. } //*** CProxyCfgNetworkInfo::GetUID
  459. //
  460. //
  461. //
  462. STDMETHODIMP
  463. CProxyCfgNetworkInfo::GetName(
  464. BSTR * pbstrNameOut
  465. )
  466. {
  467. TraceFunc( "[IClusCfgNetworkInfo]" );
  468. HRESULT hr;
  469. DWORD sc;
  470. if ( pbstrNameOut == NULL )
  471. {
  472. hr = THR( E_INVALIDARG );
  473. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2kProxy_NetworkInfo_GetName_InvalidPointer, hr );
  474. goto Cleanup;
  475. }
  476. //
  477. // "Major Version"
  478. //
  479. sc = TW32( m_cplNetworkRO.ScMoveToPropertyByName( L"Name" ) );
  480. if ( sc != ERROR_SUCCESS )
  481. {
  482. hr = HRESULT_FROM_WIN32( sc );
  483. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NetworkInfo_GetName_ScMoveToPropertyByName_MajorVersion_Failed, hr );
  484. goto Cleanup;
  485. } // if:
  486. Assert( m_cplNetworkRO.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  487. *pbstrNameOut = SysAllocString( m_cplNetworkRO.CbhCurrentValue().pStringValue->sz );
  488. if ( *pbstrNameOut == NULL )
  489. {
  490. hr = THR( E_OUTOFMEMORY );
  491. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NetworkInfo_GetUID_OutOfMemory, hr );
  492. goto Cleanup;
  493. }
  494. hr = S_OK;
  495. Cleanup:
  496. HRETURN( hr );
  497. } //*** CProxyCfgNetworkInfo::GetName
  498. //
  499. //
  500. //
  501. STDMETHODIMP
  502. CProxyCfgNetworkInfo::GetDescription(
  503. BSTR * pbstrDescriptionOut
  504. )
  505. {
  506. TraceFunc( "[IClusCfgNetworkInfo]" );
  507. HRESULT hr;
  508. DWORD sc;
  509. if ( pbstrDescriptionOut == NULL )
  510. {
  511. hr = THR( E_INVALIDARG );
  512. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetDescription_InvalidPointer, hr );
  513. goto Cleanup;
  514. }
  515. //
  516. // "Major Version"
  517. //
  518. sc = TW32( m_cplNetwork.ScMoveToPropertyByName( L"Description" ) );
  519. if ( sc != ERROR_SUCCESS )
  520. {
  521. hr = HRESULT_FROM_WIN32( sc );
  522. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetDescription_ScMoveToPropertyByName_MajorVersion_Failed, hr );
  523. goto Cleanup;
  524. } // if:
  525. Assert( m_cplNetwork.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  526. *pbstrDescriptionOut = SysAllocString( m_cplNetwork.CbhCurrentValue().pStringValue->sz );
  527. if ( *pbstrDescriptionOut == NULL )
  528. {
  529. hr = THR( E_OUTOFMEMORY );
  530. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetDescription_OutOfMemory, hr );
  531. goto Cleanup;
  532. }
  533. hr = S_OK;
  534. Cleanup:
  535. HRETURN( hr );
  536. } //*** CProxyCfgNetworkInfo::GetDescription
  537. //
  538. //
  539. //
  540. STDMETHODIMP
  541. CProxyCfgNetworkInfo::GetPrimaryNetworkAddress(
  542. IClusCfgIPAddressInfo ** ppIPAddressOut
  543. )
  544. {
  545. TraceFunc( "[IClusCfgNetworkInfo]" );
  546. HRESULT hr;
  547. DWORD sc;
  548. DWORD ulIPAddress;
  549. DWORD ulSubnetMask;
  550. IUnknown * punk = NULL;
  551. if ( ppIPAddressOut == NULL )
  552. goto InvalidPointer;
  553. sc = TW32( m_cplNetworkRO.ScMoveToPropertyByName( L"Address" ) );
  554. if ( sc != ERROR_SUCCESS )
  555. {
  556. hr = HRESULT_FROM_WIN32( sc );
  557. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_ScMoveToPropetyByName_Address_Failed, hr );
  558. goto Cleanup;
  559. }
  560. Assert( m_cplNetworkRO.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  561. sc = TW32( ClRtlTcpipStringToAddress( m_cplNetworkRO.CbhCurrentValue().pStringValue->sz, &ulIPAddress ) );
  562. if ( sc != ERROR_SUCCESS )
  563. {
  564. hr = HRESULT_FROM_WIN32( sc );
  565. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_ClRtlTcpipStringToAddress_Address_Failed, hr );
  566. goto Cleanup;
  567. }
  568. sc = TW32( m_cplNetworkRO.ScMoveToPropertyByName( L"AddressMask" ) );
  569. if ( sc != ERROR_SUCCESS )
  570. {
  571. hr = HRESULT_FROM_WIN32( sc );
  572. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_ScMoveToPropetyByName_AddressMask_Failed, hr );
  573. goto Cleanup;
  574. }
  575. Assert( m_cplNetworkRO.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  576. sc = TW32( ClRtlTcpipStringToAddress( m_cplNetworkRO.CbhCurrentValue().pStringValue->sz, &ulSubnetMask ) );
  577. if ( sc != ERROR_SUCCESS )
  578. {
  579. hr = HRESULT_FROM_WIN32( sc );
  580. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_ClRtlTcpipStringToAddress_AddressMask_Failed, hr );
  581. goto Cleanup;
  582. }
  583. hr = THR( CProxyCfgIPAddressInfo::S_HrCreateInstance( &punk,
  584. m_punkOuter,
  585. m_phCluster,
  586. m_pclsidMajor,
  587. ulIPAddress,
  588. ulSubnetMask
  589. ) );
  590. if ( FAILED( hr ) )
  591. {
  592. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_Create_CProxyCfgIPAddressInfo_Failed, hr );
  593. goto Cleanup;
  594. }
  595. hr = THR( punk->TypeSafeQI( IClusCfgIPAddressInfo, ppIPAddressOut ) );
  596. Cleanup:
  597. if ( punk != NULL )
  598. {
  599. punk->Release();
  600. }
  601. HRETURN( hr );
  602. InvalidPointer:
  603. hr = THR( E_INVALIDARG );
  604. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetPrimaryNetworkAddress_InvalidPointer, hr );
  605. goto Cleanup;
  606. } //*** CProxyCfgNetworkInfo::GetPrimaryNetworkAddress
  607. //
  608. //
  609. //
  610. STDMETHODIMP
  611. CProxyCfgNetworkInfo::IsPublic( void )
  612. {
  613. TraceFunc( "[IClusCfgNetworkInfo]" );
  614. HRESULT hr;
  615. DWORD dwRole;
  616. hr = THR( HrGetNetworkRole( &dwRole ) );
  617. if ( FAILED( hr ) )
  618. {
  619. goto Cleanup;
  620. } // if:
  621. if ( dwRole == ClusterNetworkRoleClientAccess
  622. || dwRole == ClusterNetworkRoleInternalAndClient
  623. )
  624. {
  625. hr = S_OK;
  626. } // if:
  627. else
  628. {
  629. hr = S_FALSE;
  630. }
  631. Cleanup:
  632. HRETURN( hr );
  633. } //*** CProxyCfgNetworkInfo::IsPublic
  634. //
  635. //
  636. //
  637. STDMETHODIMP
  638. CProxyCfgNetworkInfo::IsPrivate( void )
  639. {
  640. TraceFunc( "[IClusCfgNetworkInfo]" );
  641. HRESULT hr;
  642. DWORD dwRole;
  643. hr = THR( HrGetNetworkRole( &dwRole ) );
  644. if ( FAILED( hr ) )
  645. {
  646. goto Cleanup;
  647. } // if:
  648. if ( dwRole == ClusterNetworkRoleInternalUse
  649. || dwRole == ClusterNetworkRoleInternalAndClient
  650. )
  651. {
  652. hr = S_OK;
  653. } // if:
  654. else
  655. {
  656. hr = S_FALSE;
  657. }
  658. Cleanup:
  659. HRETURN( hr );
  660. } //*** CProxyCfgNetworkInfo::IsPrivate
  661. //
  662. //
  663. //
  664. STDMETHODIMP
  665. CProxyCfgNetworkInfo::SetPublic(
  666. BOOL fIsPublicIn
  667. )
  668. {
  669. TraceFunc( "[IClusCfgNetworkInfo]" );
  670. HRESULT hr = S_FALSE;
  671. HRETURN( hr );
  672. } //*** CProxyCfgNetworkInfo::SetPublic
  673. //
  674. //
  675. //
  676. STDMETHODIMP
  677. CProxyCfgNetworkInfo::SetPrivate(
  678. BOOL fIsPrivateIn
  679. )
  680. {
  681. TraceFunc( "[IClusCfgNetworkInfo]" );
  682. HRESULT hr = S_FALSE;
  683. HRETURN( hr );
  684. } //*** CProxyCfgNetworkInfo::SetPrivate
  685. //
  686. //
  687. //
  688. STDMETHODIMP
  689. CProxyCfgNetworkInfo::SetPrimaryNetworkAddress( IClusCfgIPAddressInfo * pIPAddressIn )
  690. {
  691. TraceFunc( "[IClusCfgNetworkInfo]" );
  692. HRESULT hr = S_FALSE;
  693. HRETURN( hr );
  694. } //*** CProxyCfgNetworkInfo::SetPrimaryNetworkAddress
  695. //
  696. //
  697. //
  698. STDMETHODIMP
  699. CProxyCfgNetworkInfo::SetDescription(
  700. LPCWSTR pcszDescriptionIn
  701. )
  702. {
  703. TraceFunc1( "[IClusCfgNetworkInfo] bstrDescription = '%ls'", pcszDescriptionIn );
  704. HRESULT hr = THR( E_NOTIMPL );
  705. HRETURN( hr );
  706. } //*** CProxyCfgNetworkInfo::SetDescription
  707. //
  708. //
  709. //
  710. STDMETHODIMP
  711. CProxyCfgNetworkInfo::SetName(
  712. LPCWSTR pcszNameIn
  713. )
  714. {
  715. TraceFunc1( "[IClusCfgNetworkInfo] pcszNameIn = '%ls'", pcszNameIn );
  716. HRESULT hr = THR( E_NOTIMPL );
  717. HRETURN( hr );
  718. } //*** CProxyCfgNetworkInfo::SetName
  719. //*************************************************************************//
  720. /////////////////////////////////////////////////////////////////////////////
  721. // CProxyCfgNetworkInfo -- IEnumClusCfgIPAddresses interface.
  722. /////////////////////////////////////////////////////////////////////////////
  723. //////////////////////////////////////////////////////////////////////////////
  724. //
  725. // This interface exists and must be supported, but since we only have the
  726. // information about the primary network address available, All we can do is
  727. // return an empty iterator.
  728. //
  729. //////////////////////////////////////////////////////////////////////////////
  730. STDMETHODIMP
  731. CProxyCfgNetworkInfo::Next(
  732. ULONG cNumberRequestedIn,
  733. IClusCfgIPAddressInfo ** rgpIPAddressInfoOut,
  734. ULONG * pcNumberFetchedOut
  735. )
  736. {
  737. TraceFunc( "[IEnumClusCfgIPAddresses]" );
  738. HRESULT hr = S_FALSE;
  739. if ( pcNumberFetchedOut != NULL )
  740. {
  741. *pcNumberFetchedOut = 0;
  742. } // if:
  743. HRETURN( hr );
  744. } // *** CProxyCfgNetworkInfo::Next
  745. //
  746. //
  747. //
  748. STDMETHODIMP
  749. CProxyCfgNetworkInfo::Reset( void )
  750. {
  751. TraceFunc( "[IEnumClusCfgIPAddresses]" );
  752. HRESULT hr = THR( E_NOTIMPL );
  753. HRETURN( hr );
  754. } // *** CProxyCfgNetworkInfo::Reset
  755. //
  756. //
  757. //
  758. STDMETHODIMP
  759. CProxyCfgNetworkInfo::Skip( ULONG cNumberToSkipIn )
  760. {
  761. TraceFunc( "[IEnumClusCfgIPAddresses]" );
  762. HRESULT hr = THR( E_NOTIMPL );
  763. HRETURN( hr );
  764. } // *** CProxyCfgNetworkInfo::Skip
  765. //
  766. //
  767. //
  768. STDMETHODIMP
  769. CProxyCfgNetworkInfo::Clone( IEnumClusCfgIPAddresses ** ppiIPAddressInfoOut )
  770. {
  771. TraceFunc( "[IEnumClusCfgIPAddresses]" );
  772. HRESULT hr = THR( E_NOTIMPL );
  773. HRETURN( hr );
  774. } // *** CProxyCfgNetworkInfo::Clone
  775. //
  776. //
  777. //
  778. STDMETHODIMP
  779. CProxyCfgNetworkInfo::Count ( DWORD * pnCountOut )
  780. {
  781. TraceFunc( "[IEnumClusCfgIPAddresses]" );
  782. HRESULT hr = THR( S_OK );
  783. if ( pnCountOut == NULL )
  784. {
  785. hr = THR( E_POINTER );
  786. goto Cleanup;
  787. }
  788. *pnCountOut = 0;
  789. Cleanup:
  790. HRETURN( hr );
  791. } // *** CProxyCfgNetworkInfo::Count
  792. //****************************************************************************
  793. //
  794. // IClusCfgCallback
  795. //
  796. //****************************************************************************
  797. //////////////////////////////////////////////////////////////////////////////
  798. //++
  799. //
  800. // CProxyCfgNetworkInfo::SendStatusReport
  801. //
  802. // Description:
  803. //
  804. // Arguments:
  805. //
  806. // Return Value:
  807. //
  808. // Remarks:
  809. // None.
  810. //
  811. //--
  812. //////////////////////////////////////////////////////////////////////////////
  813. STDMETHODIMP
  814. CProxyCfgNetworkInfo::SendStatusReport(
  815. LPCWSTR pcszNodeNameIn
  816. , CLSID clsidTaskMajorIn
  817. , CLSID clsidTaskMinorIn
  818. , ULONG ulMinIn
  819. , ULONG ulMaxIn
  820. , ULONG ulCurrentIn
  821. , HRESULT hrStatusIn
  822. , LPCWSTR pcszDescriptionIn
  823. , FILETIME * pftTimeIn
  824. , LPCWSTR pcszReferenceIn
  825. )
  826. {
  827. TraceFunc( "[IClusCfgCallback]" );
  828. HRESULT hr = S_OK;
  829. if ( m_pcccb != NULL )
  830. {
  831. hr = THR( m_pcccb->SendStatusReport( pcszNodeNameIn,
  832. clsidTaskMajorIn,
  833. clsidTaskMinorIn,
  834. ulMinIn,
  835. ulMaxIn,
  836. ulCurrentIn,
  837. hrStatusIn,
  838. pcszDescriptionIn,
  839. pftTimeIn,
  840. pcszReferenceIn
  841. ) );
  842. } // if:
  843. HRETURN( hr );
  844. } //*** CProxyCfgNetworkInfo::SendStatusReport
  845. //
  846. //
  847. //
  848. HRESULT
  849. CProxyCfgNetworkInfo::HrGetNetworkRole(
  850. DWORD * pdwRoleOut
  851. )
  852. {
  853. TraceFunc( "" );
  854. Assert( pdwRoleOut != NULL );
  855. HRESULT hr = S_OK;
  856. DWORD sc;
  857. CLUSPROP_BUFFER_HELPER cpbh;
  858. sc = TW32( m_cplNetwork.ScMoveToPropertyByName( L"Role" ) );
  859. if ( sc != ERROR_SUCCESS )
  860. {
  861. hr = HRESULT_FROM_WIN32( sc );
  862. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrGetNetworkRole_ScMoveToPropetyByName_Failed, hr );
  863. goto Cleanup;
  864. }
  865. cpbh = m_cplNetwork.CbhCurrentValue();
  866. Assert( cpbh.pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_DWORD );
  867. *pdwRoleOut = cpbh.pDwordValue->dw;
  868. Cleanup:
  869. HRETURN( hr );
  870. } //*** CProxyCfgNetworkInfo::HrGetNetworkRole