Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

449 lines
13 KiB

  1. #include "stdafx.h"
  2. #include "HostPortsPage.h"
  3. #include "Document.h"
  4. #include "ResourceString.h"
  5. HostPortsPage::HostPortsPage( const _bstr_t& myMachineName,
  6. ClusterData* p_clusterData,
  7. UINT ID)
  8. : CPropertyPage(ID),
  9. m_clusterData( p_clusterData ),
  10. machine( myMachineName )
  11. {}
  12. HostPortsPage:: ~HostPortsPage()
  13. {}
  14. void HostPortsPage::DoDataExchange(CDataExchange* pDX)
  15. {
  16. CPropertyPage::DoDataExchange(pDX);
  17. DDX_Control(pDX, IDC_LIST_PORT_RULE, m_portList);
  18. }
  19. BEGIN_MESSAGE_MAP(HostPortsPage, CPropertyPage)
  20. END_MESSAGE_MAP()
  21. BOOL
  22. HostPortsPage::OnInitDialog()
  23. {
  24. CPropertyPage::OnInitDialog();
  25. m_portList.InsertColumn( 0,
  26. GETRESOURCEIDSTRING( IDS_HEADER_P_START ) ,
  27. LVCFMT_LEFT,
  28. Document::LV_COLUMN_SMALL );
  29. m_portList.InsertColumn( 1,
  30. GETRESOURCEIDSTRING( IDS_HEADER_P_END ),
  31. LVCFMT_LEFT,
  32. Document::LV_COLUMN_SMALL );
  33. m_portList.InsertColumn( 2,
  34. GETRESOURCEIDSTRING( IDS_HEADER_P_PROTOCOL ),
  35. LVCFMT_LEFT,
  36. Document::LV_COLUMN_SMALL );
  37. m_portList.InsertColumn( 3,
  38. GETRESOURCEIDSTRING( IDS_HEADER_P_MODE ),
  39. LVCFMT_LEFT,
  40. Document::LV_COLUMN_SMALL );
  41. m_portList.InsertColumn( 4,
  42. GETRESOURCEIDSTRING( IDS_HEADER_P_PRIORITY ),
  43. LVCFMT_LEFT,
  44. Document::LV_COLUMN_SMALL );
  45. m_portList.InsertColumn( 5,
  46. GETRESOURCEIDSTRING( IDS_HEADER_P_LOAD ),
  47. LVCFMT_LEFT,
  48. Document::LV_COLUMN_SMALL );
  49. m_portList.InsertColumn( 6,
  50. GETRESOURCEIDSTRING( IDS_HEADER_P_AFFINITY ),
  51. LVCFMT_LEFT,
  52. Document::LV_COLUMN_SMALL );
  53. m_portList.SetExtendedStyle( m_portList.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
  54. SetControlData();
  55. int numItems = m_portList.GetItemCount();
  56. if( numItems > 0 )
  57. {
  58. m_portList.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  59. }
  60. return TRUE;
  61. }
  62. void
  63. HostPortsPage::SetControlData()
  64. {
  65. int index = 0;
  66. map< long, PortDataELB>::iterator topELB;
  67. for( topELB = m_clusterData->portELB.begin();
  68. topELB != m_clusterData->portELB.end();
  69. ++topELB )
  70. {
  71. wchar_t buf[100];
  72. // start port
  73. swprintf( buf, L"%d", (*topELB).second._startPort );
  74. LVITEM item;
  75. item.mask = LVIF_TEXT | LVIF_IMAGE;
  76. item.iItem = index;
  77. item.iSubItem = 0;
  78. item.iImage = 2;
  79. item.pszText = buf;
  80. item.cchTextMax = 100;
  81. m_portList.InsertItem( &item );
  82. // end port
  83. swprintf( buf, L"%d", (*topELB).second._endPort );
  84. item.mask = LVIF_TEXT;
  85. item.iItem = index;
  86. item.iSubItem = 1;
  87. item.pszText = buf;
  88. item.cchTextMax = 100;
  89. m_portList.SetItem( &item );
  90. // protocol
  91. item.mask = LVIF_TEXT;
  92. item.iItem = index;
  93. item.iSubItem = 2;
  94. switch( (*topELB).second._trafficToHandle )
  95. {
  96. case MNLBPortRule::both :
  97. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  98. break;
  99. case MNLBPortRule::tcp :
  100. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  101. break;
  102. case MNLBPortRule::udp :
  103. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  104. break;
  105. }
  106. item.cchTextMax = 100;
  107. m_portList.SetItem( &item );
  108. // mode
  109. item.mask = LVIF_TEXT;
  110. item.iItem = index;
  111. item.iSubItem = 3;
  112. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE );
  113. item.cchTextMax = 100;
  114. m_portList.SetItem( &item );
  115. // priority
  116. item.mask = LVIF_TEXT;
  117. item.iItem = index;
  118. item.iSubItem = 4;
  119. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  120. item.cchTextMax = 100;
  121. m_portList.SetItem( &item );
  122. // load
  123. item.mask = LVIF_TEXT;
  124. item.iItem = index;
  125. item.iSubItem = 5;
  126. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_LOAD_EQUAL );
  127. item.cchTextMax = 100;
  128. m_portList.SetItem( &item );
  129. // affinity
  130. item.mask = LVIF_TEXT;
  131. item.iItem = index;
  132. item.iSubItem = 6;
  133. switch( (*topELB).second._affinity )
  134. {
  135. case MNLBPortRule::none :
  136. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_NONE );
  137. break;
  138. case MNLBPortRule::single :
  139. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_SINGLE );
  140. break;
  141. case MNLBPortRule::classC :
  142. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_CLASSC );
  143. break;
  144. }
  145. item.cchTextMax = 100;
  146. m_portList.SetItem( &item );
  147. ++index;
  148. }
  149. index = 0;
  150. map< long, PortDataULB>::iterator topULB;
  151. for( topULB = m_clusterData->portULB.begin();
  152. topULB != m_clusterData->portULB.end();
  153. ++topULB )
  154. {
  155. wchar_t buf[100];
  156. // start port
  157. swprintf( buf, L"%d", (*topULB).second._startPort );
  158. LVITEM item;
  159. item.mask = LVIF_TEXT | LVIF_IMAGE;
  160. item.iItem = index;
  161. item.iSubItem = 0;
  162. item.iImage = 2;
  163. item.pszText = buf;
  164. item.cchTextMax = 100;
  165. m_portList.InsertItem( &item );
  166. // end port
  167. swprintf( buf, L"%d", (*topULB).second._endPort );
  168. item.mask = LVIF_TEXT;
  169. item.iItem = index;
  170. item.iSubItem = 1;
  171. item.pszText = buf;
  172. item.cchTextMax = 100;
  173. m_portList.SetItem( &item );
  174. // protocol
  175. item.mask = LVIF_TEXT;
  176. item.iItem = index;
  177. item.iSubItem = 2;
  178. switch( (*topULB).second._trafficToHandle )
  179. {
  180. case MNLBPortRule::both :
  181. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  182. break;
  183. case MNLBPortRule::tcp :
  184. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  185. break;
  186. case MNLBPortRule::udp :
  187. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  188. break;
  189. }
  190. item.cchTextMax = 100;
  191. m_portList.SetItem( &item );
  192. // mode
  193. item.mask = LVIF_TEXT;
  194. item.iItem = index;
  195. item.iSubItem = 3;
  196. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE );
  197. item.cchTextMax = 100;
  198. m_portList.SetItem( &item );
  199. // priority
  200. item.mask = LVIF_TEXT;
  201. item.iItem = index;
  202. item.iSubItem = 4;
  203. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  204. item.cchTextMax = 100;
  205. m_portList.SetItem( &item );
  206. // load
  207. item.mask = LVIF_TEXT;
  208. item.iItem = index;
  209. item.iSubItem = 5;
  210. swprintf( buf, L"%d", (*topULB).second.machineMapToLoadWeight[machine] );
  211. item.pszText = buf;
  212. item.cchTextMax = 100;
  213. m_portList.SetItem( &item );
  214. // affinity
  215. item.mask = LVIF_TEXT;
  216. item.iItem = index;
  217. item.iSubItem = 6;
  218. switch( (*topULB).second._affinity )
  219. {
  220. case MNLBPortRule::none :
  221. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_NONE );
  222. break;
  223. case MNLBPortRule::single :
  224. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_SINGLE );
  225. break;
  226. case MNLBPortRule::classC :
  227. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_CLASSC );
  228. break;
  229. }
  230. item.cchTextMax = 100;
  231. m_portList.SetItem( &item );
  232. ++index;
  233. }
  234. index = 0;
  235. map< long, PortDataF>::iterator topF;
  236. for( topF = m_clusterData->portF.begin();
  237. topF != m_clusterData->portF.end();
  238. ++topF )
  239. {
  240. wchar_t buf[100];
  241. // start port
  242. swprintf( buf, L"%d", (*topF).second._startPort );
  243. LVITEM item;
  244. item.mask = LVIF_TEXT | LVIF_IMAGE;
  245. item.iItem = index;
  246. item.iSubItem = 0;
  247. item.iImage = 2;
  248. item.pszText = buf;
  249. item.cchTextMax = 100;
  250. m_portList.InsertItem( &item );
  251. // end port
  252. swprintf( buf, L"%d", (*topF).second._endPort );
  253. item.mask = LVIF_TEXT;
  254. item.iItem = index;
  255. item.iSubItem = 1;
  256. item.pszText = buf;
  257. item.cchTextMax = 100;
  258. m_portList.SetItem( &item );
  259. // protocol
  260. item.mask = LVIF_TEXT;
  261. item.iItem = index;
  262. item.iSubItem = 2;
  263. switch( (*topF).second._trafficToHandle )
  264. {
  265. case MNLBPortRule::both :
  266. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  267. break;
  268. case MNLBPortRule::tcp :
  269. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  270. break;
  271. case MNLBPortRule::udp :
  272. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  273. break;
  274. }
  275. item.cchTextMax = 100;
  276. m_portList.SetItem( &item );
  277. // mode
  278. item.mask = LVIF_TEXT;
  279. item.iItem = index;
  280. item.iSubItem = 3;
  281. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE );
  282. item.cchTextMax = 100;
  283. m_portList.SetItem( &item );
  284. // priority
  285. item.mask = LVIF_TEXT;
  286. item.iItem = index;
  287. item.iSubItem = 4;
  288. swprintf( buf, L"%d", (*topF).second.machineMapToPriority[machine] );
  289. item.pszText = buf;
  290. item.cchTextMax = 100;
  291. m_portList.SetItem( &item );
  292. // load
  293. item.mask = LVIF_TEXT;
  294. item.iItem = index;
  295. item.iSubItem = 5;
  296. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  297. item.cchTextMax = 100;
  298. m_portList.SetItem( &item );
  299. // affinity
  300. item.mask = LVIF_TEXT;
  301. item.iItem = index;
  302. item.iSubItem = 6;
  303. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  304. item.cchTextMax = 100;
  305. m_portList.SetItem( &item );
  306. ++index;
  307. }
  308. index = 0;
  309. map< long, PortDataD>::iterator topD;
  310. for( topD = m_clusterData->portD.begin();
  311. topD != m_clusterData->portD.end();
  312. ++topD )
  313. {
  314. wchar_t buf[100];
  315. // start port
  316. swprintf( buf, L"%d", (*topD).second._startPort );
  317. LVITEM item;
  318. item.mask = LVIF_TEXT | LVIF_IMAGE;
  319. item.iItem = index;
  320. item.iSubItem = 0;
  321. item.iImage = 2;
  322. item.pszText = buf;
  323. item.cchTextMax = 100;
  324. m_portList.InsertItem( &item );
  325. // end port
  326. swprintf( buf, L"%d", (*topD).second._endPort );
  327. item.mask = LVIF_TEXT;
  328. item.iItem = index;
  329. item.iSubItem = 1;
  330. item.pszText = buf;
  331. item.cchTextMax = 100;
  332. m_portList.SetItem( &item );
  333. // protocol
  334. item.mask = LVIF_TEXT;
  335. item.iItem = index;
  336. item.iSubItem = 2;
  337. switch( (*topD).second._trafficToHandle )
  338. {
  339. case MNLBPortRule::both :
  340. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  341. break;
  342. case MNLBPortRule::tcp :
  343. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  344. break;
  345. case MNLBPortRule::udp :
  346. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  347. break;
  348. }
  349. item.cchTextMax = 100;
  350. m_portList.SetItem( &item );
  351. // mode
  352. item.mask = LVIF_TEXT;
  353. item.iItem = index;
  354. item.iSubItem = 3;
  355. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED );
  356. item.cchTextMax = 100;
  357. m_portList.SetItem( &item );
  358. // priority
  359. item.mask = LVIF_TEXT;
  360. item.iItem = index;
  361. item.iSubItem = 4;
  362. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  363. item.cchTextMax = 100;
  364. m_portList.SetItem( &item );
  365. // load
  366. item.mask = LVIF_TEXT;
  367. item.iItem = index;
  368. item.iSubItem = 5;
  369. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_EMPTY );
  370. item.cchTextMax = 100;
  371. m_portList.SetItem( &item );
  372. // affinity
  373. item.mask = LVIF_TEXT;
  374. item.iItem = index;
  375. item.iSubItem = 6;
  376. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_EMPTY );
  377. item.cchTextMax = 100;
  378. m_portList.SetItem( &item );
  379. ++index;
  380. }
  381. }