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.

518 lines
15 KiB

  1. //***************************************************************************
  2. //
  3. // CLUSTERPAGE.CPP
  4. //
  5. // Module: NLB Manager
  6. //
  7. // Purpose: LeftView, the tree view of NlbManager, and a few other
  8. // smaller classes.
  9. //
  10. // Copyright (c)2001-2002 Microsoft Corporation, All Rights Reserved
  11. //
  12. // History:
  13. //
  14. // 02/12/01 Mhakim created
  15. // 07/30/01 JosephJ complete rewrite
  16. // 09/15/01 SHouse ctxt sensitive help
  17. // 01/22/02 SHouse misc cleanup and features
  18. //
  19. //
  20. //***************************************************************************
  21. #include "precomp.h"
  22. #pragma hdrstop
  23. #include "private.h"
  24. #include "ClusterPage.h"
  25. BEGIN_MESSAGE_MAP( ClusterPage, CPropertyPage )
  26. ON_WM_HELPINFO()
  27. ON_WM_CONTEXTMENU()
  28. END_MESSAGE_MAP()
  29. ClusterPage::ClusterPage(
  30. CPropertySheet *pshOwner,
  31. LeftView::OPERATION op,
  32. NLB_EXTENDED_CLUSTER_CONFIGURATION *pNlbCfg,
  33. ENGINEHANDLE ehCluster OPTIONAL
  34. // ENGINEHANDLE ehInterface OPTIONAL
  35. )
  36. :
  37. m_pshOwner(pshOwner),
  38. CPropertyPage( ClusterPage::IDD ),
  39. m_pNlbCfg( pNlbCfg ),
  40. m_ehCluster(ehCluster)
  41. // m_ehInterface(ehInterface)
  42. {
  43. m_operation = op;
  44. switch(op)
  45. {
  46. case LeftView::OP_NEWCLUSTER:
  47. m_fWizard=TRUE;
  48. m_fDisableClusterProperties=FALSE;
  49. break;
  50. case LeftView::OP_CLUSTERPROPERTIES:
  51. m_fWizard=FALSE;
  52. m_fDisableClusterProperties=FALSE;
  53. break;
  54. case LeftView::OP_HOSTPROPERTIES:
  55. m_fWizard=FALSE;
  56. m_fDisableClusterProperties=TRUE;
  57. break;
  58. default:
  59. ASSERT(FALSE);
  60. break;
  61. }
  62. ZeroMemory(&m_WlbsConfig, sizeof(m_WlbsConfig));
  63. mfn_LoadFromNlbCfg();
  64. m_pCommonClusterPage = new CCommonClusterPage(AfxGetInstanceHandle(),
  65. &m_WlbsConfig, false, NULL);
  66. }
  67. void
  68. ClusterPage::mfn_LoadFromNlbCfg()
  69. {
  70. ZeroMemory(&m_WlbsConfig, sizeof(m_WlbsConfig));
  71. ARRAYSTRCPY(m_WlbsConfig.cl_ip_addr, m_pNlbCfg->NlbParams.cl_ip_addr);
  72. ARRAYSTRCPY(m_WlbsConfig.cl_net_mask, m_pNlbCfg->NlbParams.cl_net_mask);
  73. ARRAYSTRCPY(m_WlbsConfig.domain_name, m_pNlbCfg->NlbParams.domain_name);
  74. ARRAYSTRCPY(m_WlbsConfig.cl_mac_addr, m_pNlbCfg->NlbParams.cl_mac_addr);
  75. //
  76. // pClusterProperty->multicastIpAddress could be NULL
  77. //
  78. if (m_pNlbCfg->NlbParams.szMCastIpAddress[0] != 0)
  79. {
  80. ARRAYSTRCPY(m_WlbsConfig.szMCastIpAddress, m_pNlbCfg->NlbParams.szMCastIpAddress);
  81. }
  82. m_WlbsConfig.fMcastSupport = m_pNlbCfg->NlbParams.mcast_support;
  83. m_WlbsConfig.fIGMPSupport = m_pNlbCfg->NlbParams.fIGMPSupport;
  84. m_WlbsConfig.fRctEnabled = m_pNlbCfg->NlbParams.rct_enabled;
  85. m_WlbsConfig.fMcastSupport = m_pNlbCfg->NlbParams.mcast_support;
  86. m_WlbsConfig.fIpToMCastIp = m_pNlbCfg->NlbParams.fIpToMCastIp;
  87. // m_WlbsConfig.fConvertMac = m_pNlbCfg->NlbParams.i_convert_mac;
  88. // TODO: check: Always generate the MAC address from IP
  89. m_WlbsConfig.fConvertMac = TRUE;
  90. *m_WlbsConfig.szPassword = 0;
  91. }
  92. void
  93. ClusterPage::mfn_SaveToNlbCfg(void)
  94. {
  95. //
  96. // Replace the old cluster IP address/subnet with the new one in the
  97. // list of network addresses.
  98. //
  99. {
  100. WBEMSTATUS wStat;
  101. wStat = m_pNlbCfg->ModifyNetworkAddress(
  102. m_pNlbCfg->NlbParams.cl_ip_addr,
  103. m_WlbsConfig.cl_ip_addr,
  104. m_WlbsConfig.cl_net_mask
  105. );
  106. if (FAILED(wStat))
  107. {
  108. _bstr_t bstrMsg = GETRESOURCEIDSTRING(IDS_INVALID_IP_OR_SUBNET);
  109. _bstr_t bstrTitle = GETRESOURCEIDSTRING(IDS_INVALID_INFORMATION);
  110. ::MessageBox(
  111. NULL,
  112. bstrMsg,
  113. bstrTitle,
  114. MB_ICONINFORMATION | MB_OK
  115. );
  116. goto end;
  117. }
  118. }
  119. ARRAYSTRCPY(m_pNlbCfg->NlbParams.cl_ip_addr, m_WlbsConfig.cl_ip_addr);
  120. ARRAYSTRCPY(m_pNlbCfg->NlbParams.cl_net_mask, m_WlbsConfig.cl_net_mask);
  121. ARRAYSTRCPY(m_pNlbCfg->NlbParams.domain_name, m_WlbsConfig.domain_name);
  122. ARRAYSTRCPY(m_pNlbCfg->NlbParams.cl_mac_addr, m_WlbsConfig.cl_mac_addr);
  123. //
  124. // pClusterProperty->multicastIpAddress could be NULL
  125. //
  126. if (m_WlbsConfig.szMCastIpAddress[0] != 0)
  127. {
  128. ARRAYSTRCPY(m_pNlbCfg->NlbParams.szMCastIpAddress, m_WlbsConfig.szMCastIpAddress);
  129. }
  130. m_pNlbCfg->NlbParams.mcast_support = m_WlbsConfig.fMcastSupport;
  131. m_pNlbCfg->NlbParams.fIGMPSupport = m_WlbsConfig.fIGMPSupport;
  132. m_pNlbCfg->NlbParams.rct_enabled= m_WlbsConfig.fRctEnabled;
  133. m_pNlbCfg->NlbParams.mcast_support = m_WlbsConfig.fMcastSupport;
  134. m_pNlbCfg->NlbParams.fIpToMCastIp = m_WlbsConfig.fIpToMCastIp;
  135. // m_pNlbCfg->NlbParams.i_convert_mac= m_WlbsConfig.fConvertMac;
  136. // TODO: check: Always generate the MAC address from IP
  137. // m_pNlbCfg->NlbParams.i_convert_mac = m_WlbsConfig.fConvertMac;
  138. // TODO: *m_pNlbCfg->NlbParams.password = 0;
  139. if (m_WlbsConfig.fChangePassword)
  140. {
  141. m_pNlbCfg->SetNewRemoteControlPassword(m_WlbsConfig.szPassword);
  142. }
  143. else
  144. {
  145. m_pNlbCfg->SetNewRemoteControlPassword(NULL);
  146. }
  147. end:
  148. return;
  149. }
  150. ClusterPage::~ClusterPage()
  151. {
  152. delete m_pCommonClusterPage;
  153. }
  154. //+----------------------------------------------------------------------------
  155. //
  156. // Function: ClusterPage::OnInitDialog
  157. //
  158. // Description: Process WM_INITDIALOG message
  159. //
  160. // Arguments: None
  161. //
  162. // Returns: BOOL -
  163. //
  164. // History: fengsun Created Header 1/4/01
  165. //
  166. //+----------------------------------------------------------------------------
  167. BOOL ClusterPage::OnInitDialog()
  168. {
  169. CPropertyPage::OnInitDialog();
  170. //
  171. // Always set that the page has changed, so we don't have to keep track of this.
  172. //
  173. SetModified(TRUE);
  174. m_pCommonClusterPage->OnInitDialog(m_hWnd);
  175. if (m_fDisableClusterProperties)
  176. {
  177. //
  178. // The page is for host property.
  179. // disable all cluster windows as we are at host level.
  180. //
  181. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_IP), FALSE );
  182. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_MASK), FALSE );
  183. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_UNICAST), FALSE );
  184. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_MULTICAST), FALSE );
  185. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_IGMP), FALSE );
  186. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_DOMAIN), FALSE );
  187. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_RCT), FALSE );
  188. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), FALSE );
  189. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), FALSE );
  190. }
  191. else
  192. {
  193. //
  194. // The page is for cluster property
  195. //
  196. // enable all cluster windows as we are at cluster level.
  197. //
  198. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_IP), TRUE );
  199. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_CL_MASK), TRUE );
  200. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_UNICAST), TRUE );
  201. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_RADIO_MULTICAST), TRUE );
  202. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_IGMP), TRUE );
  203. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_DOMAIN), TRUE );
  204. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK_RCT), TRUE );
  205. // enable remote control check box only if remote control is disabled.
  206. //
  207. // if remote control is enabled , enable password windows
  208. // else disable them.
  209. if (m_WlbsConfig.fRctEnabled)
  210. {
  211. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), TRUE );
  212. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), TRUE );
  213. }
  214. else
  215. {
  216. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW), FALSE );
  217. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_PASSW2), FALSE );
  218. }
  219. }
  220. ::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_ETH), FALSE );
  221. return TRUE;
  222. }
  223. //+----------------------------------------------------------------------------
  224. //
  225. // Function: ClusterPage::OnContextMenu
  226. //
  227. // Description: Process WM_CONTEXTMENU message
  228. //
  229. // Arguments: CWnd* pWnd -
  230. // CPoint point -
  231. //
  232. // Returns: Nothing
  233. //
  234. // History: fengsun Created Header 1/4/01
  235. //
  236. //+----------------------------------------------------------------------------
  237. //+----------------------------------------------------------------------------
  238. //
  239. // Function: ClusterPage::OnCommand
  240. //
  241. // Description: Process WM_COMMAND message
  242. //
  243. // Arguments: WPARAM wParam -
  244. // LPARAM lParam -
  245. //
  246. // Returns: BOOL -
  247. //
  248. // History: fengsun Created Header 1/4/01
  249. //
  250. //+----------------------------------------------------------------------------
  251. BOOL ClusterPage::OnCommand(WPARAM wParam, LPARAM lParam)
  252. {
  253. switch (LOWORD(wParam))
  254. {
  255. case IDC_EDIT_CL_IP:
  256. return m_pCommonClusterPage->OnEditClIp(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  257. break;
  258. case IDC_EDIT_CL_MASK:
  259. return m_pCommonClusterPage->OnEditClMask(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  260. break;
  261. case IDC_CHECK_RCT:
  262. return m_pCommonClusterPage->OnCheckRct(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  263. break;
  264. case IDC_BUTTON_HELP:
  265. return m_pCommonClusterPage->OnButtonHelp(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  266. break;
  267. case IDC_RADIO_UNICAST:
  268. return m_pCommonClusterPage->OnCheckMode(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  269. break;
  270. case IDC_RADIO_MULTICAST:
  271. return m_pCommonClusterPage->OnCheckMode(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  272. break;
  273. case IDC_CHECK_IGMP:
  274. return m_pCommonClusterPage->OnCheckIGMP(HIWORD(wParam),LOWORD(wParam), (HWND)lParam);
  275. break;
  276. }
  277. return CPropertyPage::OnCommand(wParam, lParam);
  278. }
  279. //+----------------------------------------------------------------------------
  280. //
  281. // Function: ClusterPage::OnNotify
  282. //
  283. // Description: Process WM_NOTIFY message
  284. //
  285. // Arguments: WPARAM idCtrl -
  286. // LPARAM pnmh -
  287. // LRESULT* pResult -
  288. //
  289. // Returns: BOOL -
  290. //
  291. // History: fengsun Created Header 1/4/01
  292. //
  293. //+----------------------------------------------------------------------------
  294. BOOL ClusterPage::OnNotify(WPARAM idCtrl , LPARAM pnmh , LRESULT* pResult)
  295. {
  296. NMHDR* pNmhdr = (NMHDR*)pnmh ;
  297. switch(pNmhdr->code)
  298. {
  299. case PSN_KILLACTIVE:
  300. if (KillActive())
  301. {
  302. *pResult = PSNRET_NOERROR;
  303. }
  304. else
  305. {
  306. *pResult = PSNRET_INVALID;
  307. }
  308. return TRUE;
  309. case PSN_SETACTIVE:
  310. if (this->SetActive())
  311. {
  312. *pResult = PSNRET_NOERROR;
  313. }
  314. else
  315. {
  316. *pResult = PSNRET_INVALID;
  317. }
  318. return TRUE;
  319. case IPN_FIELDCHANGED:
  320. *pResult = m_pCommonClusterPage->OnIpFieldChange(idCtrl, pNmhdr, *(BOOL*)pResult);
  321. return TRUE;
  322. }
  323. return CPropertyPage::OnNotify(idCtrl, pnmh, pResult);
  324. }
  325. BOOL
  326. ClusterPage::OnHelpInfo (HELPINFO* helpInfo )
  327. {
  328. if( helpInfo->iContextType == HELPINFO_WINDOW )
  329. {
  330. ::WinHelp( static_cast<HWND> ( helpInfo->hItemHandle ),
  331. CVY_CTXT_HELP_FILE,
  332. HELP_WM_HELP,
  333. (ULONG_PTR ) g_aHelpIDs_IDD_CLUSTER_PAGE);
  334. }
  335. return TRUE;
  336. }
  337. void
  338. ClusterPage::OnContextMenu( CWnd* pWnd, CPoint point )
  339. {
  340. ::WinHelp( m_hWnd,
  341. CVY_CTXT_HELP_FILE,
  342. HELP_CONTEXTMENU,
  343. (ULONG_PTR ) g_aHelpIDs_IDD_CLUSTER_PAGE);
  344. }
  345. BOOL
  346. ClusterPage::SetActive()
  347. {
  348. BOOL fRet = TRUE;
  349. if (m_fWizard)
  350. {
  351. //
  352. // We're the first page, so only enable next.
  353. //
  354. m_pshOwner->SetWizardButtons(
  355. // PSWIZB_BACK|
  356. PSWIZB_NEXT|
  357. // PSWIZB_FINISH|
  358. // PSWIZB_DISABLEDFINISH|
  359. 0
  360. );
  361. }
  362. fRet = m_pCommonClusterPage->Load();
  363. return fRet;
  364. }
  365. BOOL
  366. ClusterPage::KillActive(void)
  367. {
  368. BOOL fRet = FALSE;
  369. fRet = m_pCommonClusterPage->Save();
  370. if (!fRet) goto end;
  371. //
  372. // Do extra checking here...
  373. //
  374. {
  375. //
  376. // Check that cluster IP is not used in any other way...
  377. //
  378. CLocalLogger logConflict;
  379. BOOL fExistsOnRawIterface = FALSE;
  380. NLBERROR nerr;
  381. nerr = gEngine.ValidateNewClusterIp(
  382. m_ehCluster,
  383. m_WlbsConfig.cl_ip_addr,
  384. REF fExistsOnRawIterface,
  385. REF logConflict
  386. );
  387. if (nerr == NLBERR_INVALID_IP_ADDRESS_SPECIFICATION)
  388. {
  389. CLocalLogger logMsg;
  390. if (m_ehCluster == NULL && fExistsOnRawIterface)
  391. {
  392. //
  393. // This is a NEW cluster, and the conflicting entity
  394. // is an existing interface NOT bound to any cluster known to
  395. // NLB Manager.
  396. // We'll give the user the opportunity to proceed...
  397. //
  398. int sel;
  399. logMsg.Log(
  400. IDS_CIP_CONFLICTS_WITH_RAW_INTERFACE,
  401. m_WlbsConfig.cl_ip_addr,
  402. logConflict.GetStringSafe()
  403. );
  404. sel = MessageBox(
  405. logMsg.GetStringSafe(),
  406. GETRESOURCEIDSTRING( IDS_PARM_WARNING ),
  407. MB_YESNO | MB_ICONEXCLAMATION
  408. );
  409. if (sel == IDNO)
  410. {
  411. fRet = FALSE;
  412. goto end;
  413. }
  414. }
  415. else
  416. {
  417. logMsg.Log(
  418. IDS_NEW_CIP_CONFLICTS_WITH_XXX,
  419. logConflict.GetStringSafe()
  420. );
  421. MessageBox(
  422. logMsg.GetStringSafe(),
  423. GETRESOURCEIDSTRING( IDS_PARM_ERROR ),
  424. MB_ICONSTOP | MB_OK
  425. );
  426. fRet = FALSE;
  427. goto end;
  428. }
  429. }
  430. }
  431. //
  432. // Actually save to the passed-in NLB cfg. This "commits" the changes,
  433. // as far as this dialog is concerned.
  434. //
  435. mfn_SaveToNlbCfg();
  436. end:
  437. return fRet;
  438. }