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.

1640 lines
60 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. #include "private.h"
  4. #include "PortsPage.h"
  5. #include "ClusterPortsDlg.h"
  6. #include "HostPortsDlg.h"
  7. #include "MNLBUIData.h"
  8. #include "portspage.tmh"
  9. using namespace std;
  10. BEGIN_MESSAGE_MAP(PortsPage, CPropertyPage)
  11. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  12. ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
  13. ON_BN_CLICKED(IDC_BUTTON_MODIFY, OnButtonModify)
  14. ON_NOTIFY( NM_DBLCLK, IDC_LIST_PORT_RULE, OnDoubleClick )
  15. ON_NOTIFY( LVN_ITEMCHANGED, IDC_LIST_PORT_RULE, OnSelchanged )
  16. ON_NOTIFY( LVN_COLUMNCLICK, IDC_LIST_PORT_RULE, OnColumnClick )
  17. ON_WM_HELPINFO()
  18. ON_WM_CONTEXTMENU()
  19. END_MESSAGE_MAP()
  20. PortsPage::PortData::PortData()
  21. {
  22. wchar_t buf[Common::BUF_SIZE];
  23. StringCbPrintf( buf, sizeof(buf), L"%d", CVY_MIN_PORT );
  24. start_port = buf;
  25. StringCbPrintf( buf, sizeof(buf), L"%d", CVY_MAX_PORT );
  26. end_port = buf;
  27. virtual_ip_addr = GETRESOURCEIDSTRING( IDS_REPORT_VIP_ALL );
  28. protocol = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  29. mode = GETRESOURCEIDSTRING( IDS_REPORT_MODE_MULTIPLE );
  30. load = GETRESOURCEIDSTRING( IDS_REPORT_LOAD_EQUAL );
  31. affinity = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_SINGLE );
  32. }
  33. PortsPage::PortsPage(
  34. CPropertySheet *psh,
  35. NLB_EXTENDED_CLUSTER_CONFIGURATION *pNlbCfg,
  36. bool fIsClusterLevel,
  37. ENGINEHANDLE ehCluster OPTIONAL
  38. // ENGINEHANDLE ehInterface OPTIONAL
  39. )
  40. :
  41. m_pshOwner(psh),
  42. m_pNlbCfg( pNlbCfg ),
  43. m_isClusterLevel( fIsClusterLevel ),
  44. CPropertyPage(PortsPage::IDD),
  45. m_sort_column( -1 ),
  46. m_ehCluster(ehCluster)
  47. // m_ehInterface(ehInterface)
  48. {}
  49. PortsPage:: ~PortsPage()
  50. {}
  51. void PortsPage::DoDataExchange(CDataExchange* pDX)
  52. {
  53. CPropertyPage::DoDataExchange(pDX);
  54. DDX_Control(pDX, IDC_LIST_PORT_RULE, m_portList);
  55. DDX_Control(pDX, IDC_BUTTON_ADD, buttonAdd );
  56. DDX_Control(pDX, IDC_BUTTON_MODIFY, buttonModify );
  57. DDX_Control(pDX, IDC_BUTTON_DEL, buttonDel );
  58. }
  59. void
  60. PortsPage::OnOK()
  61. {
  62. TRACE_INFO("%!FUNC! ->");
  63. CPropertyPage::OnOK();
  64. mfn_SaveToNlbCfg();
  65. TRACE_INFO("%!FUNC! <-");
  66. }
  67. BOOL
  68. PortsPage::OnSetActive()
  69. {
  70. TRACE_INFO("%!FUNC! ->");
  71. BOOL fRet = CPropertyPage::OnSetActive();
  72. if (fRet)
  73. {
  74. m_pshOwner->SetWizardButtons(
  75. PSWIZB_NEXT|
  76. PSWIZB_BACK |
  77. // PSWIZB_FINISH|
  78. // PSWIZB_DISABLEDFINISH|
  79. 0
  80. );
  81. }
  82. TRACE_INFO("%!FUNC! <- returns %lu", fRet);
  83. return fRet;
  84. }
  85. BOOL
  86. PortsPage::OnKillActive()
  87. {
  88. TRACE_INFO("%!FUNC! ->");
  89. BOOL fRet = CPropertyPage::OnKillActive();
  90. if (fRet)
  91. {
  92. //
  93. // Save the configuration to the NLB configuration structure
  94. // that was passed in the constructor of this dialog.
  95. //
  96. mfn_SaveToNlbCfg();
  97. }
  98. TRACE_INFO("%!FUNC! <- returns %lu", fRet);
  99. return fRet;
  100. }
  101. BOOL PortsPage::OnWizardFinish( )
  102. /*
  103. Overwridden virtual function. Will NOT be called if this is not the last page in the wizard!
  104. */
  105. {
  106. TRACE_INFO("%!FUNC! ->");
  107. BOOL fRet = CPropertyPage::OnWizardFinish();
  108. if (fRet)
  109. {
  110. //
  111. // Save the configuration to the NLB configuration structure
  112. // that was passed in the constructor of this dialog.
  113. //
  114. mfn_SaveToNlbCfg();
  115. }
  116. TRACE_INFO("%!FUNC! <- returns %lu", fRet);
  117. return fRet;
  118. }
  119. BOOL
  120. PortsPage::OnInitDialog()
  121. {
  122. TRACE_INFO("%!FUNC! ->");
  123. CPropertyPage::OnInitDialog();
  124. // Add column headers & form port rule list
  125. PortListUtils::LoadFromNlbCfg(m_pNlbCfg, REF m_portList, m_isClusterLevel, FALSE);
  126. int numItems = m_portList.GetItemCount();
  127. if( numItems > 0 )
  128. {
  129. buttonModify.EnableWindow( TRUE );
  130. buttonDel.EnableWindow( TRUE );
  131. if( numItems >= CVY_MAX_USABLE_RULES )
  132. {
  133. // greater should not happen,
  134. // but just to be sure.
  135. buttonAdd.EnableWindow( FALSE );
  136. }
  137. else
  138. {
  139. buttonAdd.EnableWindow( TRUE );
  140. }
  141. // make selection the first item in list.
  142. //
  143. m_portList.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  144. }
  145. else
  146. {
  147. buttonAdd.EnableWindow( TRUE );
  148. // disable the edit and remove buttons.
  149. buttonModify.EnableWindow( FALSE );
  150. buttonDel.EnableWindow( FALSE );
  151. }
  152. if (!m_isClusterLevel)
  153. {
  154. //
  155. // Can't add/remove port rules in the host version.
  156. //
  157. buttonAdd.EnableWindow( FALSE );
  158. buttonDel.EnableWindow( FALSE );
  159. }
  160. TRACE_INFO("%!FUNC! <- returns %lu", TRUE);
  161. return TRUE;
  162. }
  163. void
  164. PortsPage::OnButtonAdd()
  165. {
  166. PortData portData;
  167. ClusterPortsDlg clusterPortRuleDialog( portData, this );
  168. int rc = clusterPortRuleDialog.DoModal();
  169. if( rc != IDOK )
  170. {
  171. return;
  172. }
  173. else
  174. {
  175. // add this port rule.
  176. int index = 0;
  177. // cluster ip address
  178. LVITEM item;
  179. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  180. item.iItem = index;
  181. item.iSubItem = 0;
  182. item.iImage = 2;
  183. item.lParam = -1;
  184. item.pszText = portData.virtual_ip_addr;
  185. item.cchTextMax = Common::BUF_SIZE;
  186. m_portList.InsertItem( &item );
  187. // start port
  188. item.mask = LVIF_TEXT;
  189. item.iItem = index;
  190. item.iSubItem = 1;
  191. item.pszText = portData.start_port;
  192. item.cchTextMax = Common::BUF_SIZE;
  193. m_portList.SetItem( &item );
  194. // end port
  195. item.mask = LVIF_TEXT;
  196. item.iItem = index;
  197. item.iSubItem = 2;
  198. item.pszText = portData.end_port;
  199. item.cchTextMax = Common::BUF_SIZE;
  200. m_portList.SetItem( &item );
  201. // protocol
  202. item.mask = LVIF_TEXT;
  203. item.iItem = index;
  204. item.iSubItem = 3;
  205. item.pszText = portData.protocol;
  206. item.cchTextMax = Common::BUF_SIZE;
  207. m_portList.SetItem( &item );
  208. // mode
  209. item.mask = LVIF_TEXT;
  210. item.iItem = index;
  211. item.iSubItem = 4;
  212. item.pszText = portData.mode;
  213. item.cchTextMax = Common::BUF_SIZE;
  214. m_portList.SetItem( &item );
  215. // priority
  216. item.mask = LVIF_TEXT;
  217. item.iItem = index;
  218. item.iSubItem = 5;
  219. item.pszText = portData.priority;
  220. item.cchTextMax = Common::BUF_SIZE;
  221. m_portList.SetItem( &item );
  222. // load
  223. item.mask = LVIF_TEXT;
  224. item.iItem = index;
  225. item.iSubItem = 6;
  226. item.pszText = portData.load;
  227. item.cchTextMax = Common::BUF_SIZE;
  228. m_portList.SetItem( &item );
  229. // affinity
  230. item.mask = LVIF_TEXT;
  231. item.iItem = index;
  232. item.iSubItem = 7;
  233. item.pszText = portData.affinity;
  234. item.cchTextMax = Common::BUF_SIZE;
  235. m_portList.SetItem( &item );
  236. // check if max port limit reached.
  237. if( m_portList.GetItemCount() >= CVY_MAX_USABLE_RULES )
  238. {
  239. // as max port rule limit reached.
  240. // disable further additions.
  241. buttonAdd.EnableWindow( FALSE );
  242. buttonDel.EnableWindow( TRUE );
  243. buttonModify.EnableWindow( TRUE );
  244. buttonDel.SetFocus();
  245. }
  246. else
  247. {
  248. buttonAdd.EnableWindow( TRUE );
  249. buttonDel.EnableWindow( TRUE );
  250. buttonModify.EnableWindow( TRUE );
  251. }
  252. // set focus to this item
  253. m_portList.SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  254. }
  255. }
  256. void
  257. PortsPage::OnButtonDel()
  258. {
  259. // get the current selection.
  260. POSITION pos = m_portList.GetFirstSelectedItemPosition();
  261. if( pos == NULL )
  262. {
  263. return;
  264. }
  265. int index = m_portList.GetNextSelectedItem( pos );
  266. // delete it.
  267. m_portList.DeleteItem( index );
  268. // if this was the last port rule.
  269. if( m_portList.GetItemCount() == 0 )
  270. {
  271. // as no more port rules in list
  272. // disable modify and remove buttons.
  273. // also set focus to add button
  274. buttonAdd.EnableWindow( TRUE );
  275. buttonModify.EnableWindow( FALSE );
  276. buttonDel.EnableWindow( FALSE );
  277. buttonAdd.SetFocus();
  278. }
  279. else
  280. {
  281. // enable the add, modify button.
  282. buttonAdd.EnableWindow( TRUE );
  283. buttonModify.EnableWindow( TRUE );
  284. buttonDel.EnableWindow( TRUE );
  285. // make selection the first item in list.
  286. //
  287. m_portList.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  288. }
  289. }
  290. void
  291. PortsPage::OnButtonModify()
  292. {
  293. // get the current selection.
  294. POSITION pos = m_portList.GetFirstSelectedItemPosition();
  295. if( pos == NULL )
  296. {
  297. return;
  298. }
  299. int index = m_portList.GetNextSelectedItem( pos );
  300. PortData portData;
  301. wchar_t buffer[Common::BUF_SIZE];
  302. m_portList.GetItemText( index, 0, buffer, Common::BUF_SIZE );
  303. portData.virtual_ip_addr = buffer;
  304. m_portList.GetItemText( index, 1, buffer, Common::BUF_SIZE );
  305. portData.start_port = buffer;
  306. m_portList.GetItemText( index, 2, buffer, Common::BUF_SIZE );
  307. portData.end_port = buffer;
  308. m_portList.GetItemText( index, 3, buffer, Common::BUF_SIZE );
  309. portData.protocol = buffer;
  310. m_portList.GetItemText( index, 4, buffer, Common::BUF_SIZE );
  311. portData.mode = buffer;
  312. m_portList.GetItemText( index, 5, buffer, Common::BUF_SIZE );
  313. portData.priority = buffer;
  314. m_portList.GetItemText( index, 6, buffer, Common::BUF_SIZE );
  315. portData.load = buffer;
  316. m_portList.GetItemText( index, 7, buffer, Common::BUF_SIZE );
  317. portData.affinity = buffer;
  318. ClusterPortsDlg clusterPortRuleDialog( portData, this, index );
  319. HostPortsDlg hostPortRuleDialog( portData, m_ehCluster, this );
  320. int rc;
  321. if( m_isClusterLevel == true )
  322. {
  323. rc = clusterPortRuleDialog.DoModal();
  324. }
  325. else
  326. {
  327. rc = hostPortRuleDialog.DoModal();
  328. }
  329. if( rc != IDOK )
  330. {
  331. return;
  332. }
  333. else
  334. {
  335. // delete the old item and add the new item.
  336. // before you delete the old item find its param
  337. // value
  338. DWORD key = m_portList.GetItemData( index );
  339. m_portList.DeleteItem( index );
  340. // as this is being modified the
  341. // key remains the old one.
  342. // start port
  343. LVITEM item;
  344. item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
  345. item.iItem = index;
  346. item.iSubItem = 0;
  347. item.iImage = 2;
  348. item.lParam = key;
  349. item.pszText = portData.virtual_ip_addr;
  350. item.cchTextMax = Common::BUF_SIZE;
  351. m_portList.InsertItem( &item );
  352. // start port
  353. item.mask = LVIF_TEXT;
  354. item.iItem = index;
  355. item.iSubItem = 1;
  356. item.pszText = portData.start_port;
  357. item.cchTextMax = Common::BUF_SIZE;
  358. m_portList.SetItem( &item );
  359. // end port
  360. item.mask = LVIF_TEXT;
  361. item.iItem = index;
  362. item.iSubItem = 2;
  363. item.pszText = portData.end_port;
  364. item.cchTextMax = Common::BUF_SIZE;
  365. m_portList.SetItem( &item );
  366. // protocol
  367. item.mask = LVIF_TEXT;
  368. item.iItem = index;
  369. item.iSubItem = 3;
  370. item.pszText = portData.protocol;
  371. item.cchTextMax = Common::BUF_SIZE;
  372. m_portList.SetItem( &item );
  373. // mode
  374. item.mask = LVIF_TEXT;
  375. item.iItem = index;
  376. item.iSubItem = 4;
  377. item.pszText = portData.mode;
  378. item.cchTextMax = Common::BUF_SIZE;
  379. m_portList.SetItem( &item );
  380. // priority
  381. item.mask = LVIF_TEXT;
  382. item.iItem = index;
  383. item.iSubItem = 5;
  384. item.pszText = portData.priority;
  385. item.cchTextMax = Common::BUF_SIZE;
  386. m_portList.SetItem( &item );
  387. // load
  388. item.mask = LVIF_TEXT;
  389. item.iItem = index;
  390. item.iSubItem = 6;
  391. item.pszText = portData.load;
  392. item.cchTextMax = Common::BUF_SIZE;
  393. m_portList.SetItem( &item );
  394. // affinity
  395. item.mask = LVIF_TEXT;
  396. item.iItem = index;
  397. item.iSubItem = 7;
  398. item.pszText = portData.affinity;
  399. item.cchTextMax = Common::BUF_SIZE;
  400. m_portList.SetItem( &item );
  401. // set focus to this item
  402. m_portList.SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  403. }
  404. }
  405. void
  406. PortsPage::OnDoubleClick( NMHDR * pNotifyStruct, LRESULT * result )
  407. {
  408. if( buttonModify.IsWindowEnabled() == TRUE )
  409. {
  410. OnButtonModify();
  411. }
  412. }
  413. void
  414. PortsPage::OnSelchanged( NMHDR * pNotifyStruct, LRESULT * result )
  415. {
  416. LPNMLISTVIEW lv = (LPNMLISTVIEW)pNotifyStruct;
  417. POSITION pos;
  418. int index;
  419. /* When the user selects a port rule, change the port rule description. */
  420. if (lv->uChanged & LVIF_STATE) FillPortRuleDescription();
  421. pos = m_portList.GetFirstSelectedItemPosition();
  422. if (pos == NULL) {
  423. /* If no port rule is selected, then disable the edit and delete buttons. */
  424. buttonModify.EnableWindow( FALSE );
  425. buttonDel.EnableWindow( FALSE );
  426. return;
  427. } else {
  428. /* If one is selected, make sure the edit and delete buttons are enabled. */
  429. buttonModify.EnableWindow( TRUE );
  430. buttonDel.EnableWindow( TRUE );
  431. }
  432. /* Find the index of the currently selected port rule. */
  433. index = m_portList.GetNextSelectedItem(pos);
  434. // if it is not cluster level, which means host level.
  435. if( m_isClusterLevel == false )
  436. {
  437. // initially disable all buttons
  438. buttonModify.EnableWindow( FALSE );
  439. buttonAdd.EnableWindow( FALSE );
  440. buttonDel.EnableWindow( FALSE );
  441. PortData portData;
  442. wchar_t buffer[Common::BUF_SIZE];
  443. m_portList.GetItemText( index, 4, buffer, Common::BUF_SIZE );
  444. portData.mode = buffer;
  445. if( portData.mode != GETRESOURCEIDSTRING( IDS_REPORT_MODE_DISABLED ) )
  446. {
  447. buttonModify.EnableWindow( TRUE );
  448. }
  449. }
  450. }
  451. /*
  452. * Method: FillPortRuleDescription
  453. * Description: Called when the user double clicks an item in the listbox.
  454. */
  455. void PortsPage::FillPortRuleDescription ()
  456. {
  457. CLocalLogger logDesc;
  458. POSITION pos;
  459. int index;
  460. pos = m_portList.GetFirstSelectedItemPosition();
  461. if (pos == NULL) {
  462. /* If there is no port rule selected, then display information about how traffic
  463. not covered by the port rule set is handled. */
  464. ::SetDlgItemText(m_hWnd, IDC_TEXT_PORT_RULE_DESCR, GETRESOURCEIDSTRING(IDS_PORT_RULE_DEFAULT));
  465. return;
  466. }
  467. /* Find the index of the currently selected port rule. */
  468. index = m_portList.GetNextSelectedItem(pos);
  469. PortData portData;
  470. wchar_t buffer[Common::BUF_SIZE];
  471. portData.key = m_portList.GetItemData( index );
  472. m_portList.GetItemText( index, 0, buffer, Common::BUF_SIZE );
  473. portData.virtual_ip_addr = buffer;
  474. m_portList.GetItemText( index, 1, buffer, Common::BUF_SIZE );
  475. portData.start_port = buffer;
  476. m_portList.GetItemText( index, 2, buffer, Common::BUF_SIZE );
  477. portData.end_port = buffer;
  478. m_portList.GetItemText( index, 3, buffer, Common::BUF_SIZE );
  479. portData.protocol = buffer;
  480. m_portList.GetItemText( index, 4, buffer, Common::BUF_SIZE );
  481. portData.mode = buffer;
  482. m_portList.GetItemText( index, 5, buffer, Common::BUF_SIZE );
  483. portData.priority = buffer;
  484. m_portList.GetItemText( index, 6, buffer, Common::BUF_SIZE );
  485. portData.load = buffer;
  486. m_portList.GetItemText( index, 7, buffer, Common::BUF_SIZE );
  487. portData.affinity = buffer;
  488. ARRAYSTRCPY(buffer, portData.virtual_ip_addr);
  489. /* This code is terrible - for localization reasons, we require an essentially static string table entry
  490. for each possible port rule configuration. So, we have to if/switch ourselves to death trying to
  491. match this port rule with the correct string in the table - then we pop in stuff like port ranges. */
  492. if (portData.virtual_ip_addr == GETRESOURCEIDSTRING(IDS_REPORT_VIP_ALL)) {
  493. /* No VIP is specified. */
  494. if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_TCP)) {
  495. /* Rule covers TCP. */
  496. if (portData.start_port == portData.end_port) {
  497. /* Rule covers a single port value, not a range. */
  498. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  499. /* Disabled port rule. */
  500. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORT_DISABLED, _wtoi(portData.start_port));
  501. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  502. /* Single host filtering (failover) port rule. */
  503. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORT_SINGLE, _wtoi(portData.start_port));
  504. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  505. /* Multiple host filtering (load-balanced) port rule. */
  506. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  507. /* Equally balanced amongst members. */
  508. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORT_MULTIPLE_EQUAL, _wtoi(portData.start_port));
  509. else
  510. /* Unequally balanced amongst members by load weight. */
  511. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORT_MULTIPLE_UNEQUAL, _wtoi(portData.start_port));
  512. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  513. /* No client affinity. */
  514. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  515. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  516. /* Single affinity. */
  517. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  518. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  519. /* Class C affinity. */
  520. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  521. }
  522. }
  523. } else {
  524. /* Rule covers a range of ports. */
  525. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  526. /* Disabled port rule. */
  527. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORTS_DISABLED, _wtoi(portData.start_port), _wtoi(portData.end_port));
  528. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  529. /* Single host filtering (failover) port rule. */
  530. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORTS_SINGLE, _wtoi(portData.start_port), _wtoi(portData.end_port));
  531. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  532. /* Multiple host filtering (load-balanced) port rule. */
  533. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  534. /* Equally balanced amongst members. */
  535. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORTS_MULTIPLE_EQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  536. else
  537. /* Unequally balanced amongst members by load weight. */
  538. logDesc.Log(IDS_PORT_RULE_ALL_VIP_TCP_PORTS_MULTIPLE_UNEQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  539. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  540. /* No client affinity. */
  541. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  542. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  543. /* Single affinity. */
  544. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  545. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  546. /* Class C affinity. */
  547. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  548. }
  549. }
  550. }
  551. } else if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_UDP)) {
  552. /* Rule covers UDP. */
  553. if (portData.start_port == portData.end_port) {
  554. /* Rule covers a single port value, not a range. */
  555. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  556. /* Disabled port rule. */
  557. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORT_DISABLED, _wtoi(portData.start_port));
  558. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  559. /* Single host filtering (failover) port rule. */
  560. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORT_SINGLE, _wtoi(portData.start_port));
  561. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  562. /* Multiple host filtering (load-balanced) port rule. */
  563. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  564. /* Equally balanced amongst members. */
  565. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORT_MULTIPLE_EQUAL, _wtoi(portData.start_port));
  566. else
  567. /* Unequally balanced amongst members by load weight. */
  568. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORT_MULTIPLE_UNEQUAL, _wtoi(portData.start_port));
  569. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  570. /* No client affinity. */
  571. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  572. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  573. /* Single affinity. */
  574. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  575. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  576. /* Class C affinity. */
  577. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  578. }
  579. }
  580. } else {
  581. /* Rule covers a range of ports. */
  582. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  583. /* Disabled port rule. */
  584. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORTS_DISABLED, _wtoi(portData.start_port), _wtoi(portData.end_port));
  585. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  586. /* Single host filtering (failover) port rule. */
  587. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORTS_SINGLE, _wtoi(portData.start_port), _wtoi(portData.end_port));
  588. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  589. /* Multiple host filtering (load-balanced) port rule. */
  590. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  591. /* Equally balanced amongst members. */
  592. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORTS_MULTIPLE_EQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  593. else
  594. /* Unequally balanced amongst members by load weight. */
  595. logDesc.Log(IDS_PORT_RULE_ALL_VIP_UDP_PORTS_MULTIPLE_UNEQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  596. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  597. /* No client affinity. */
  598. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  599. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  600. /* Single affinity. */
  601. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  602. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  603. /* Class C affinity. */
  604. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  605. }
  606. }
  607. }
  608. } else if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_BOTH)) {
  609. /* Rule covers both TCP and UDP. */
  610. if (portData.start_port == portData.end_port) {
  611. /* Rule covers a single port value, not a range. */
  612. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  613. /* Disabled port rule. */
  614. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORT_DISABLED, _wtoi(portData.start_port));
  615. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  616. /* Single host filtering (failover) port rule. */
  617. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORT_SINGLE, _wtoi(portData.start_port));
  618. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  619. /* Multiple host filtering (load-balanced) port rule. */
  620. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  621. /* Equally balanced amongst members. */
  622. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORT_MULTIPLE_EQUAL, _wtoi(portData.start_port));
  623. else
  624. /* Unequally balanced amongst members by load weight. */
  625. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORT_MULTIPLE_UNEQUAL, _wtoi(portData.start_port));
  626. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  627. /* No client affinity. */
  628. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  629. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  630. /* Single affinity. */
  631. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  632. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  633. /* Class C affinity. */
  634. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  635. }
  636. }
  637. } else {
  638. /* Rule covers a range of ports. */
  639. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  640. /* Disabled port rule. */
  641. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORTS_DISABLED, _wtoi(portData.start_port), _wtoi(portData.end_port));
  642. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  643. /* Single host filtering (failover) port rule. */
  644. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORTS_SINGLE, _wtoi(portData.start_port), _wtoi(portData.end_port));
  645. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  646. /* Multiple host filtering (load-balanced) port rule. */
  647. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  648. /* Equally balanced amongst members. */
  649. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORTS_MULTIPLE_EQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  650. else
  651. /* Unequally balanced amongst members by load weight. */
  652. logDesc.Log(IDS_PORT_RULE_ALL_VIP_BOTH_PORTS_MULTIPLE_UNEQUAL, _wtoi(portData.start_port), _wtoi(portData.end_port));
  653. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  654. /* No client affinity. */
  655. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  656. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  657. /* Single affinity. */
  658. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  659. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  660. /* Class C affinity. */
  661. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  662. }
  663. }
  664. }
  665. }
  666. } else {
  667. /* VIP is specified. */
  668. if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_TCP)) {
  669. /* Rule covers TCP. */
  670. if (portData.start_port == portData.end_port) {
  671. /* Rule covers a single port value, not a range. */
  672. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  673. /* Disabled port rule. */
  674. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORT_DISABLED, buffer, _wtoi(portData.start_port));
  675. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  676. /* Single host filtering (failover) port rule. */
  677. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORT_SINGLE, buffer, _wtoi(portData.start_port));
  678. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  679. /* Multiple host filtering (load-balanced) port rule. */
  680. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  681. /* Equally balanced amongst members. */
  682. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORT_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port));
  683. else
  684. /* Unequally balanced amongst members by load weight. */
  685. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORT_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port));
  686. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  687. /* No client affinity. */
  688. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  689. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  690. /* Single affinity. */
  691. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  692. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  693. /* Class C affinity. */
  694. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  695. }
  696. }
  697. } else {
  698. /* Rule covers a range of ports. */
  699. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  700. /* Disabled port rule. */
  701. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORTS_DISABLED, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  702. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  703. /* Single host filtering (failover) port rule. */
  704. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORTS_SINGLE, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  705. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  706. /* Multiple host filtering (load-balanced) port rule. */
  707. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  708. /* Equally balanced amongst members. */
  709. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORTS_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  710. else
  711. /* Unequally balanced amongst members by load weight. */
  712. logDesc.Log(IDS_PORT_RULE_VIP_TCP_PORTS_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  713. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  714. /* No client affinity. */
  715. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  716. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  717. /* Single affinity. */
  718. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  719. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  720. /* Class C affinity. */
  721. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  722. }
  723. }
  724. }
  725. } else if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_UDP)) {
  726. /* Rule covers UDP. */
  727. if (portData.start_port == portData.end_port) {
  728. /* Rule covers a single port value, not a range. */
  729. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  730. /* Disabled port rule. */
  731. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORT_DISABLED, buffer, _wtoi(portData.start_port));
  732. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  733. /* Single host filtering (failover) port rule. */
  734. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORT_SINGLE, buffer, _wtoi(portData.start_port));
  735. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  736. /* Multiple host filtering (load-balanced) port rule. */
  737. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  738. /* Equally balanced amongst members. */
  739. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORT_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port));
  740. else
  741. /* Unequally balanced amongst members by load weight. */
  742. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORT_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port));
  743. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  744. /* No client affinity. */
  745. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  746. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  747. /* Single affinity. */
  748. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  749. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  750. /* Class C affinity. */
  751. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  752. }
  753. }
  754. } else {
  755. /* Rule covers a range of ports. */
  756. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  757. /* Disabled port rule. */
  758. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORTS_DISABLED, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  759. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  760. /* Single host filtering (failover) port rule. */
  761. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORTS_SINGLE, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  762. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  763. /* Multiple host filtering (load-balanced) port rule. */
  764. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  765. /* Equally balanced amongst members. */
  766. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORTS_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  767. else
  768. /* Unequally balanced amongst members by load weight. */
  769. logDesc.Log(IDS_PORT_RULE_VIP_UDP_PORTS_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  770. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  771. /* No client affinity. */
  772. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  773. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  774. /* Single affinity. */
  775. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  776. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  777. /* Class C affinity. */
  778. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  779. }
  780. }
  781. }
  782. } else if (portData.protocol == GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_BOTH)) {
  783. /* Rule covers both TCP and UDP. */
  784. if (portData.start_port == portData.end_port) {
  785. /* Rule covers a single port value, not a range. */
  786. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  787. /* Disabled port rule. */
  788. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORT_DISABLED, buffer, _wtoi(portData.start_port));
  789. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  790. /* Single host filtering (failover) port rule. */
  791. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORT_SINGLE, buffer, _wtoi(portData.start_port));
  792. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  793. /* Multiple host filtering (load-balanced) port rule. */
  794. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  795. /* Equally balanced amongst members. */
  796. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORT_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port));
  797. else
  798. /* Unequally balanced amongst members by load weight. */
  799. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORT_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port));
  800. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  801. /* No client affinity. */
  802. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  803. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  804. /* Single affinity. */
  805. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  806. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  807. /* Class C affinity. */
  808. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  809. }
  810. }
  811. } else {
  812. /* Rule covers a range of ports. */
  813. if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED)) {
  814. /* Disabled port rule. */
  815. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORTS_DISABLED, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  816. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE)) {
  817. /* Single host filtering (failover) port rule. */
  818. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORTS_SINGLE, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  819. } else if (portData.mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE)) {
  820. /* Multiple host filtering (load-balanced) port rule. */
  821. if (portData.load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  822. /* Equally balanced amongst members. */
  823. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORTS_MULTIPLE_EQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  824. else
  825. /* Unequally balanced amongst members by load weight. */
  826. logDesc.Log(IDS_PORT_RULE_VIP_BOTH_PORTS_MULTIPLE_UNEQUAL, buffer, _wtoi(portData.start_port), _wtoi(portData.end_port));
  827. if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE)) {
  828. /* No client affinity. */
  829. logDesc.Log(IDS_PORT_RULE_AFFINITY_NONE);
  830. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE)) {
  831. /* Single affinity. */
  832. logDesc.Log(IDS_PORT_RULE_AFFINITY_SINGLE);
  833. } else if (portData.affinity == GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC)) {
  834. /* Class C affinity. */
  835. logDesc.Log(IDS_PORT_RULE_AFFINITY_CLASSC);
  836. }
  837. }
  838. }
  839. }
  840. }
  841. /* Set the port rule description text. */
  842. ::SetDlgItemText(m_hWnd, IDC_TEXT_PORT_RULE_DESCR, logDesc.GetStringSafe());
  843. }
  844. BOOL
  845. PortsPage::OnHelpInfo (HELPINFO* helpInfo )
  846. {
  847. if( helpInfo->iContextType == HELPINFO_WINDOW )
  848. {
  849. ::WinHelp( static_cast<HWND> ( helpInfo->hItemHandle ), CVY_CTXT_HELP_FILE, HELP_WM_HELP, (ULONG_PTR ) g_aHelpIDs_IDD_DIALOG_PORTS);
  850. }
  851. return TRUE;
  852. }
  853. void
  854. PortsPage::OnContextMenu( CWnd* pWnd, CPoint point )
  855. {
  856. ::WinHelp( m_hWnd, CVY_CTXT_HELP_FILE, HELP_CONTEXTMENU, (ULONG_PTR ) g_aHelpIDs_IDD_DIALOG_PORTS);
  857. }
  858. void
  859. PortsPage::OnColumnClick( NMHDR * pNotifyStruct, LRESULT * result )
  860. {
  861. PortListUtils::OnColumnClick((LPNMLISTVIEW) pNotifyStruct,
  862. REF m_portList,
  863. m_isClusterLevel,
  864. REF m_sort_ascending,
  865. REF m_sort_column);
  866. /* The rule selected has likely changed as a result of the sort, so
  867. make sure the port rule description is correct. */
  868. FillPortRuleDescription();
  869. }
  870. void
  871. PortListUtils::OnColumnClick(LPNMLISTVIEW lv,
  872. CListCtrl & portList,
  873. bool isClusterLevel,
  874. bool & sort_ascending,
  875. int & sort_column)
  876. {
  877. // get present port rules in list.
  878. vector<PortsPage::PortData> ports;
  879. getPresentPorts(REF portList, &ports );
  880. // sort these port rules depending upon the header which has
  881. // been clicked.
  882. switch( lv->iSubItem )
  883. {
  884. case 0:
  885. // user has clicked cluster ip address.
  886. sort( ports.begin(), ports.end(), comp_vip() );
  887. break;
  888. case 1:
  889. // user has clicked start port.
  890. sort( ports.begin(), ports.end(), comp_start_port() );
  891. break;
  892. case 2:
  893. // user has clicked end port
  894. sort( ports.begin(), ports.end(), comp_end_port() );
  895. break;
  896. case 3:
  897. // user has clicked protocol
  898. sort( ports.begin(), ports.end(), comp_protocol() );
  899. break;
  900. case 4:
  901. // user has clicked mode
  902. sort( ports.begin(), ports.end(), comp_mode() );
  903. break;
  904. case 5:
  905. // user has clicked priority
  906. if( isClusterLevel == true )
  907. {
  908. sort( ports.begin(), ports.end(), comp_priority_string() );
  909. }
  910. else
  911. {
  912. sort( ports.begin(), ports.end(), comp_priority_int() );
  913. }
  914. break;
  915. case 6:
  916. // user has clicked load
  917. if( isClusterLevel == true )
  918. {
  919. sort( ports.begin(), ports.end(), comp_load_string() );
  920. }
  921. else
  922. {
  923. sort( ports.begin(), ports.end(), comp_load_int() );
  924. }
  925. break;
  926. case 7:
  927. // user has clicked affinity
  928. sort( ports.begin(), ports.end(), comp_affinity() );
  929. break;
  930. default:
  931. break;
  932. }
  933. /* If we are sorting by the same column we were previously sorting by,
  934. then we reverse the sort order. */
  935. if( sort_column == lv->iSubItem )
  936. {
  937. sort_ascending = !sort_ascending;
  938. }
  939. else
  940. {
  941. // default sort is ascending.
  942. sort_ascending = true;
  943. }
  944. sort_column = lv->iSubItem;
  945. int portIndex;
  946. int itemCount = portList.GetItemCount();
  947. for( int index = 0; index < itemCount; ++index )
  948. {
  949. if( sort_ascending == true )
  950. {
  951. portIndex = index;
  952. }
  953. else
  954. {
  955. portIndex = ( itemCount - 1 ) - index;
  956. }
  957. portList.SetItemData( index, ports[portIndex].key );
  958. portList.SetItemText( index, 0, ports[portIndex].virtual_ip_addr );
  959. portList.SetItemText( index, 1, ports[portIndex].start_port );
  960. portList.SetItemText( index, 2, ports[portIndex].end_port );
  961. portList.SetItemText( index, 3, ports[portIndex].protocol );
  962. portList.SetItemText( index, 4, ports[portIndex].mode );
  963. portList.SetItemText( index, 5, ports[portIndex].priority );
  964. portList.SetItemText( index, 6, ports[portIndex].load );
  965. portList.SetItemText( index, 7, ports[portIndex].affinity );
  966. }
  967. return;
  968. }
  969. void
  970. PortListUtils::getPresentPorts(CListCtrl &portList, vector<PortsPage::PortData>* ports )
  971. {
  972. // get all the port rules presently in the list.
  973. for( int index = 0; index < portList.GetItemCount(); ++index )
  974. {
  975. PortsPage::PortData portData;
  976. wchar_t buffer[Common::BUF_SIZE];
  977. portData.key = portList.GetItemData( index );
  978. portList.GetItemText( index, 0, buffer, Common::BUF_SIZE );
  979. portData.virtual_ip_addr = buffer;
  980. portList.GetItemText( index, 1, buffer, Common::BUF_SIZE );
  981. portData.start_port = buffer;
  982. portList.GetItemText( index, 2, buffer, Common::BUF_SIZE );
  983. portData.end_port = buffer;
  984. portList.GetItemText( index, 3, buffer, Common::BUF_SIZE );
  985. portData.protocol = buffer;
  986. portList.GetItemText( index, 4, buffer, Common::BUF_SIZE );
  987. portData.mode = buffer;
  988. portList.GetItemText( index, 5, buffer, Common::BUF_SIZE );
  989. portData.priority = buffer;
  990. portList.GetItemText( index, 6, buffer, Common::BUF_SIZE );
  991. portData.load = buffer;
  992. portList.GetItemText( index, 7, buffer, Common::BUF_SIZE );
  993. portData.affinity = buffer;
  994. ports->push_back( portData );
  995. }
  996. }
  997. void
  998. PortListUtils::LoadFromNlbCfg(
  999. NLB_EXTENDED_CLUSTER_CONFIGURATION * pNlbCfg,
  1000. CListCtrl & portList,
  1001. bool isClusterLevel,
  1002. bool isDetailsView
  1003. )
  1004. {
  1005. WLBS_PORT_RULE *pRules = NULL;
  1006. WLBS_REG_PARAMS *pParams = NULL;
  1007. UINT NumRules = 0;
  1008. WBEMSTATUS wStat;
  1009. TRACE_INFO("%!FUNC! ->");
  1010. // the size of columns is equal
  1011. // to core. Wish there were some defines somewhere.
  1012. //
  1013. if (!isDetailsView) {
  1014. portList.InsertColumn( 0,
  1015. GETRESOURCEIDSTRING( IDS_HEADER_P_VIP ) ,
  1016. LVCFMT_LEFT,
  1017. 98 );
  1018. portList.InsertColumn( 1,
  1019. GETRESOURCEIDSTRING( IDS_HEADER_P_START ) ,
  1020. LVCFMT_LEFT,
  1021. 42 );
  1022. portList.InsertColumn( 2,
  1023. GETRESOURCEIDSTRING( IDS_HEADER_P_END ),
  1024. LVCFMT_LEFT,
  1025. 42 );
  1026. portList.InsertColumn( 3,
  1027. GETRESOURCEIDSTRING( IDS_HEADER_P_PROTOCOL ),
  1028. LVCFMT_LEFT,
  1029. 44 );
  1030. portList.InsertColumn( 4,
  1031. GETRESOURCEIDSTRING( IDS_HEADER_P_MODE ),
  1032. LVCFMT_LEFT,
  1033. 53 );
  1034. portList.InsertColumn( 5,
  1035. GETRESOURCEIDSTRING( IDS_HEADER_P_PRIORITY ),
  1036. LVCFMT_LEFT,
  1037. 43 );
  1038. portList.InsertColumn( 6,
  1039. GETRESOURCEIDSTRING( IDS_HEADER_P_LOAD ),
  1040. LVCFMT_LEFT,
  1041. 52 );
  1042. portList.InsertColumn( 7,
  1043. GETRESOURCEIDSTRING( IDS_HEADER_P_AFFINITY ),
  1044. LVCFMT_LEFT,
  1045. 50 );
  1046. } else {
  1047. portList.InsertColumn( 0,
  1048. GETRESOURCEIDSTRING( IDS_HEADER_P_VIP ) ,
  1049. LVCFMT_LEFT,
  1050. 140 );
  1051. portList.InsertColumn( 1,
  1052. GETRESOURCEIDSTRING( IDS_HEADER_P_START ) ,
  1053. LVCFMT_LEFT,
  1054. 75 );
  1055. portList.InsertColumn( 2,
  1056. GETRESOURCEIDSTRING( IDS_HEADER_P_END ),
  1057. LVCFMT_LEFT,
  1058. 75 );
  1059. portList.InsertColumn( 3,
  1060. GETRESOURCEIDSTRING( IDS_HEADER_P_PROTOCOL ),
  1061. LVCFMT_LEFT,
  1062. 75 );
  1063. portList.InsertColumn( 4,
  1064. GETRESOURCEIDSTRING( IDS_HEADER_P_MODE ),
  1065. LVCFMT_LEFT,
  1066. 75 );
  1067. portList.InsertColumn( 5,
  1068. GETRESOURCEIDSTRING( IDS_HEADER_P_PRIORITY ),
  1069. LVCFMT_LEFT,
  1070. 75 );
  1071. portList.InsertColumn( 6,
  1072. GETRESOURCEIDSTRING( IDS_HEADER_P_LOAD ),
  1073. LVCFMT_LEFT,
  1074. 75 );
  1075. portList.InsertColumn( 7,
  1076. GETRESOURCEIDSTRING( IDS_HEADER_P_AFFINITY ),
  1077. LVCFMT_LEFT,
  1078. 75 );
  1079. }
  1080. portList.SetExtendedStyle( portList.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
  1081. wStat = CfgUtilGetPortRules(&pNlbCfg->NlbParams, &pRules, &NumRules);
  1082. if (FAILED(wStat))
  1083. {
  1084. pRules = NULL;
  1085. TRACE_CRIT("%!FUNC! error 0x%08lx extracting port rules!", wStat);
  1086. goto end;
  1087. }
  1088. for (UINT index = 0; index<NumRules; index++)
  1089. {
  1090. WLBS_PORT_RULE *pRule = &pRules[index];
  1091. LPCWSTR szPriority = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY);
  1092. LPCWSTR szAffinity = szPriority; // empty
  1093. LPCWSTR szLoad = szPriority; // empty
  1094. LPCWSTR szMode = szPriority; // empty
  1095. wchar_t buf[Common::BUF_SIZE];
  1096. wchar_t rgPriority[Common::BUF_SIZE];
  1097. wchar_t rgLoad[Common::BUF_SIZE];
  1098. // vip
  1099. LVITEM item;
  1100. /* Convert "255.255.255.255" to "All" for display purposes. */
  1101. if (!lstrcmpi(pRule->virtual_ip_addr, CVY_DEF_ALL_VIP))
  1102. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_VIP_ALL);
  1103. else {
  1104. ARRAYSTRCPY(buf, pRule->virtual_ip_addr);
  1105. item.pszText = buf;
  1106. }
  1107. item.mask = LVIF_TEXT | LVIF_PARAM;
  1108. item.iItem = index;
  1109. item.iSubItem = 0;
  1110. item.lParam = pRule->start_port;
  1111. item.cchTextMax = Common::BUF_SIZE;
  1112. portList.InsertItem( &item );
  1113. // start port
  1114. StringCbPrintf( buf, sizeof(buf), L"%d", pRule->start_port);
  1115. item.mask = LVIF_TEXT;
  1116. item.iItem = index;
  1117. item.iSubItem = 1;
  1118. item.pszText = buf;
  1119. item.cchTextMax = Common::BUF_SIZE;
  1120. portList.SetItem( &item );
  1121. // end port
  1122. StringCbPrintf( buf, sizeof(buf), L"%d", pRule->end_port);
  1123. item.mask = LVIF_TEXT;
  1124. item.iItem = index;
  1125. item.iSubItem = 2;
  1126. item.pszText = buf;
  1127. item.cchTextMax = Common::BUF_SIZE;
  1128. portList.SetItem( &item );
  1129. // protocol
  1130. item.mask = LVIF_TEXT;
  1131. item.iItem = index;
  1132. item.iSubItem = 3;
  1133. switch(pRule->protocol)
  1134. {
  1135. case CVY_TCP :
  1136. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  1137. break;
  1138. case CVY_UDP :
  1139. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  1140. break;
  1141. default:
  1142. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  1143. break;
  1144. }
  1145. item.cchTextMax = Common::BUF_SIZE;
  1146. portList.SetItem( &item );
  1147. // mode
  1148. switch(pRule->mode)
  1149. {
  1150. case CVY_SINGLE:
  1151. szMode = GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE );
  1152. if (!isClusterLevel)
  1153. {
  1154. StringCbPrintf( rgPriority, sizeof(rgPriority), L"%d", pRule->mode_data.single.priority );
  1155. szPriority = rgPriority;
  1156. }
  1157. break;
  1158. case CVY_NEVER:
  1159. szMode = GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED );
  1160. break;
  1161. default: // assume multi
  1162. szMode = GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE );
  1163. if (isClusterLevel)
  1164. {
  1165. szLoad = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY);
  1166. }
  1167. else
  1168. {
  1169. if (pRule->mode_data.multi.equal_load)
  1170. {
  1171. szLoad = GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL);
  1172. }
  1173. else
  1174. {
  1175. UINT load = pRule->mode_data.multi.load;
  1176. StringCbPrintf(rgLoad, sizeof(rgLoad), L"%d", load);
  1177. szLoad = rgLoad;
  1178. }
  1179. }
  1180. switch (pRule->mode_data.multi.affinity)
  1181. {
  1182. case CVY_AFFINITY_SINGLE:
  1183. szAffinity =GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE);
  1184. break;
  1185. case CVY_AFFINITY_CLASSC:
  1186. szAffinity =GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_CLASSC);
  1187. break;
  1188. default: // assume no affinity
  1189. szAffinity =GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_NONE);
  1190. break;
  1191. }
  1192. break;
  1193. }
  1194. // mode
  1195. item.mask = LVIF_TEXT;
  1196. item.iItem = index;
  1197. item.iSubItem = 4;
  1198. item.pszText = (LPWSTR) szMode;
  1199. item.cchTextMax = Common::BUF_SIZE;
  1200. portList.SetItem( &item );
  1201. // priority
  1202. item.mask = LVIF_TEXT;
  1203. item.iItem = index;
  1204. item.iSubItem = 5;
  1205. item.pszText = (LPWSTR) szPriority;
  1206. item.cchTextMax = Common::BUF_SIZE;
  1207. portList.SetItem( &item );
  1208. // load
  1209. item.mask = LVIF_TEXT;
  1210. item.iItem = index;
  1211. item.iSubItem = 6;
  1212. item.pszText = (LPWSTR) szLoad;
  1213. item.cchTextMax = Common::BUF_SIZE;
  1214. portList.SetItem( &item );
  1215. // affinity
  1216. item.mask = LVIF_TEXT;
  1217. item.iItem = index;
  1218. item.iSubItem = 7;
  1219. item.pszText = (LPWSTR) szAffinity;
  1220. item.cchTextMax = Common::BUF_SIZE;
  1221. portList.SetItem( &item );
  1222. }
  1223. end:
  1224. delete pRules; // can be NULL
  1225. TRACE_INFO("%!FUNC! <-");
  1226. }
  1227. void
  1228. PortsPage::mfn_SaveToNlbCfg(void)
  1229. {
  1230. // get present port rules
  1231. vector<PortData> ports;
  1232. PortListUtils::getPresentPorts(m_portList, &ports );
  1233. UINT NumRules = ports.size();
  1234. WLBS_PORT_RULE PortRules[CVY_MAX_USABLE_RULES];
  1235. TRACE_INFO("%!FUNC! ->");
  1236. if (NumRules > CVY_MAX_USABLE_RULES)
  1237. {
  1238. // should't get here, but anyway...
  1239. NumRules = CVY_MAX_USABLE_RULES;
  1240. }
  1241. for( int i = 0; i < NumRules; ++i )
  1242. {
  1243. WLBS_PORT_RULE PortRule;
  1244. DWORD dwMode;
  1245. ZeroMemory(&PortRule, sizeof(PortRule));
  1246. //
  1247. // mode (multiple/single/disabled)
  1248. //
  1249. {
  1250. if( ports[i].mode == GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE))
  1251. {
  1252. dwMode = CVY_MULTI;
  1253. }
  1254. else if(ports[i].mode==GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE))
  1255. {
  1256. dwMode = CVY_SINGLE;
  1257. }
  1258. else // assume disabled.
  1259. {
  1260. dwMode = CVY_NEVER;
  1261. }
  1262. PortRule.mode = dwMode;
  1263. }
  1264. //
  1265. // Start and end ports
  1266. //
  1267. {
  1268. PortRule.start_port = _wtoi( ports[i].start_port );
  1269. PortRule.end_port = _wtoi( ports[i].end_port );
  1270. }
  1271. //
  1272. // Protocol
  1273. //
  1274. if (ports[i].protocol==GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_TCP))
  1275. {
  1276. PortRule.protocol = CVY_TCP;
  1277. }
  1278. else if(ports[i].protocol==GETRESOURCEIDSTRING(IDS_REPORT_PROTOCOL_UDP))
  1279. {
  1280. PortRule.protocol = CVY_UDP;
  1281. }
  1282. else // assume both
  1283. {
  1284. PortRule.protocol = CVY_TCP_UDP;
  1285. }
  1286. // Virtual IP address. Convert "All" back to an IP address - 255.255.255.255. */
  1287. if (!lstrcmpi(ports[i].virtual_ip_addr, GETRESOURCEIDSTRING(IDS_REPORT_VIP_ALL)))
  1288. ARRAYSTRCPY(PortRule.virtual_ip_addr, CVY_DEF_ALL_VIP);
  1289. else
  1290. ARRAYSTRCPY(PortRule.virtual_ip_addr, ports[i].virtual_ip_addr);
  1291. //
  1292. // mode-specific data.
  1293. //
  1294. if (dwMode == CVY_SINGLE)
  1295. {
  1296. if (m_isClusterLevel)
  1297. {
  1298. //
  1299. // CfgUtilsSetPortRules needs valid port rules, so we fill
  1300. // in an arbitrary but valid value.
  1301. //
  1302. PortRule.mode_data.single.priority = 1;
  1303. }
  1304. else
  1305. {
  1306. PortRule.mode_data.single.priority = _wtoi(ports[i].priority);
  1307. }
  1308. }
  1309. else if (dwMode == CVY_MULTI)
  1310. {
  1311. if (m_isClusterLevel)
  1312. {
  1313. //
  1314. // Set the defaults here ...
  1315. //
  1316. PortRule.mode_data.multi.equal_load = TRUE;
  1317. PortRule.mode_data.multi.load = CVY_DEF_LOAD;
  1318. }
  1319. else
  1320. {
  1321. if (ports[i].load == GETRESOURCEIDSTRING(IDS_REPORT_LOAD_EQUAL))
  1322. {
  1323. PortRule.mode_data.multi.equal_load = TRUE;
  1324. PortRule.mode_data.multi.load = 50;
  1325. }
  1326. else
  1327. {
  1328. PortRule.mode_data.multi.equal_load = FALSE;
  1329. PortRule.mode_data.multi.load = _wtoi(ports[i].load);
  1330. }
  1331. }
  1332. if (ports[i].affinity==GETRESOURCEIDSTRING(IDS_REPORT_AFFINITY_SINGLE))
  1333. {
  1334. PortRule.mode_data.multi.affinity = CVY_AFFINITY_SINGLE;
  1335. }
  1336. else if (ports[i].affinity == GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_CLASSC))
  1337. {
  1338. PortRule.mode_data.multi.affinity = CVY_AFFINITY_CLASSC;
  1339. }
  1340. else // assume no affinity...
  1341. {
  1342. PortRule.mode_data.multi.affinity = CVY_AFFINITY_NONE;
  1343. }
  1344. }
  1345. PortRules[i] = PortRule; // struct copy
  1346. }
  1347. WBEMSTATUS wStat;
  1348. wStat = CfgUtilSetPortRules(PortRules, NumRules, &m_pNlbCfg->NlbParams);
  1349. if (FAILED(wStat))
  1350. {
  1351. TRACE_CRIT("%!FUNC!: Could not set port rules -- err=0x%lx!", wStat);
  1352. }
  1353. TRACE_INFO("%!FUNC! <-");
  1354. }