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.

1714 lines
49 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 2002 **/
  4. /**********************************************************************/
  5. /*
  6. provider.cpp
  7. Main Mode Policy node handler
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "server.h"
  12. #include "Stats.h"
  13. UINT QmStatsItems1[] = {
  14. IDS_STATS_QM_ACTIVE_SA,
  15. IDS_STATS_QM_OFFLOAD_SA,
  16. IDS_STATS_QM_PENDING_KEY_OPS,
  17. IDS_STATS_QM_KEY_ADDITION,
  18. IDS_STATS_QM_KEY_DELETION,
  19. IDS_STATS_QM_REKEYS,
  20. IDS_STATS_QM_ACTIVE_TNL,
  21. IDS_STATS_QM_BAD_SPI,
  22. IDS_STATS_QM_PKT_NOT_DECRYPT,
  23. IDS_STATS_QM_PKT_NOT_AUTH,
  24. IDS_STATS_QM_PKT_REPLAY,
  25. IDS_STATS_QM_ESP_BYTE_SENT,
  26. IDS_STATS_QM_ESP_BYTE_RCV,
  27. IDS_STATS_QM_AUTH_BYTE_SENT,
  28. IDS_STATS_QM_ATTH_BYTE_RCV,
  29. IDS_STATS_QM_XPORT_BYTE_SENT,
  30. IDS_STATS_QM_XPORT_BYTE_RCV,
  31. IDS_STATS_QM_TNL_BYTE_SENT,
  32. IDS_STATS_QM_TNL_BYTE_RCV,
  33. IDS_STATS_QM_OFFLOAD_BYTE_SENT,
  34. IDS_STATS_QM_OFFLOAD_BYTE_RCV
  35. };
  36. UINT MmStatsItems1[] = {
  37. IDS_STATS_MM_ACTIVE_ACQUIRE,
  38. IDS_STATS_MM_ACTIVE_RCV,
  39. IDS_STATS_MM_ACQUIRE_FAIL,
  40. IDS_STATS_MM_RCV_FAIL,
  41. IDS_STATS_MM_SEND_FAIL,
  42. IDS_STATS_MM_ACQUIRE_HEAP_SIZE,
  43. IDS_STATS_MM_RCV_HEAP_SIZE,
  44. IDS_STATS_MM_ATTH_FAILURE,
  45. IDS_STATS_MM_NEG_FAIL,
  46. IDS_STATS_MM_INVALID_COOKIE,
  47. IDS_STATS_MM_TOTAL_ACQUIRE,
  48. IDS_STATS_MM_TOTAL_GETSPI,
  49. IDS_STATS_MM_TOTAL_KEY_ADD,
  50. IDS_STATS_MM_TOTAL_KEY_UPDATE,
  51. IDS_STATS_MM_GET_SPI_FAIL,
  52. IDS_STATS_MM_KEY_ADD_FAIL,
  53. IDS_STATS_MM_KEY_UPDATE_FAIL,
  54. IDS_STATS_MM_ISADB_LIST_SIZE,
  55. IDS_STATS_MM_CONN_LIST_SIZE,
  56. IDS_STATS_MM_OAKLEY_MM,
  57. IDS_STATS_MM_OAKLEY_QM,
  58. IDS_STATS_MM_SOFT_ASSOCIATIONS,
  59. IDS_STATS_MM_INVALID_PACKETS
  60. };
  61. /*---------------------------------------------------------------------------
  62. Class CIkeStatsHandler implementation
  63. ---------------------------------------------------------------------------*/
  64. /*---------------------------------------------------------------------------
  65. Constructor and destructor
  66. Description
  67. Author: NSun
  68. ---------------------------------------------------------------------------*/
  69. CIkeStatsHandler::CIkeStatsHandler
  70. (
  71. ITFSComponentData * pComponentData
  72. ) : CIpsmHandler(pComponentData)
  73. {
  74. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  75. }
  76. CIkeStatsHandler::~CIkeStatsHandler()
  77. {
  78. }
  79. /*!--------------------------------------------------------------------------
  80. CIkeStatsHandler::InitializeNode
  81. Initializes node specific data
  82. Author: NSun
  83. ---------------------------------------------------------------------------*/
  84. HRESULT
  85. CIkeStatsHandler::InitializeNode
  86. (
  87. ITFSNode * pNode
  88. )
  89. {
  90. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  91. CString strTemp;
  92. strTemp.LoadString(IDS_STATS_DATA);
  93. SetDisplayName(strTemp);
  94. // Make the node immediately visible
  95. pNode->SetVisibilityState(TFS_VIS_SHOW);
  96. pNode->SetData(TFS_DATA_COOKIE, (LPARAM) pNode);
  97. pNode->SetData(TFS_DATA_IMAGEINDEX, ICON_IDX_FOLDER_CLOSED);
  98. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, ICON_IDX_FOLDER_OPEN);
  99. pNode->SetData(TFS_DATA_USER, (LPARAM) this);
  100. pNode->SetData(TFS_DATA_TYPE, IPSECMON_MM_IKESTATS);
  101. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  102. SetColumnStringIDs(&aColumns[IPSECMON_MM_IKESTATS][0]);
  103. SetColumnWidths(&aColumnWidths[IPSECMON_MM_IKESTATS][0]);
  104. return hrOK;
  105. }
  106. /*---------------------------------------------------------------------------
  107. CIkeStatsHandler::GetImageIndex
  108. -
  109. Author: NSun
  110. ---------------------------------------------------------------------------*/
  111. int
  112. CIkeStatsHandler::GetImageIndex(BOOL bOpenImage)
  113. {
  114. int nIndex = -1;
  115. return nIndex;
  116. }
  117. /*---------------------------------------------------------------------------
  118. Overridden base handler functions
  119. ---------------------------------------------------------------------------*/
  120. /*---------------------------------------------------------------------------
  121. CIkeStatsHandler::OnAddMenuItems
  122. Adds context menu items for the SA scope pane node
  123. Author: NSun
  124. ---------------------------------------------------------------------------*/
  125. STDMETHODIMP
  126. CIkeStatsHandler::OnAddMenuItems
  127. (
  128. ITFSNode * pNode,
  129. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  130. LPDATAOBJECT lpDataObject,
  131. DATA_OBJECT_TYPES type,
  132. DWORD dwType,
  133. long * pInsertionAllowed
  134. )
  135. {
  136. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  137. LONG fFlags = 0, fLoadingFlags = 0;
  138. HRESULT hr = S_OK;
  139. if (type == CCT_SCOPE)
  140. {
  141. //load scope node context menu items here
  142. // these menu items go in the new menu,
  143. // only visible from scope pane
  144. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  145. {
  146. }
  147. }
  148. return hr;
  149. }
  150. /*!--------------------------------------------------------------------------
  151. CIkeStatsHandler::AddMenuItems
  152. Adds context menu items for virtual list box (result pane) items
  153. Author: NSun
  154. ---------------------------------------------------------------------------*/
  155. STDMETHODIMP
  156. CIkeStatsHandler::AddMenuItems
  157. (
  158. ITFSComponent * pComponent,
  159. MMC_COOKIE cookie,
  160. LPDATAOBJECT pDataObject,
  161. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  162. long * pInsertionAllowed
  163. )
  164. {
  165. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  166. HRESULT hr = hrOK;
  167. CString strMenuItem;
  168. SPINTERNAL spInternal;
  169. LONG fFlags = 0;
  170. spInternal = ExtractInternalFormat(pDataObject);
  171. // virtual listbox notifications come to the handler of the node that is selected.
  172. // check to see if this notification is for a virtual listbox item or this SA
  173. // node itself.
  174. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
  175. {
  176. //load and view menu items here
  177. }
  178. return hr;
  179. }
  180. /*!--------------------------------------------------------------------------
  181. CIkeStatsHandler::OnRefresh
  182. Default implementation for the refresh functionality
  183. Author: NSun
  184. ---------------------------------------------------------------------------*/
  185. HRESULT
  186. CIkeStatsHandler::OnRefresh
  187. (
  188. ITFSNode * pNode,
  189. LPDATAOBJECT pDataObject,
  190. DWORD dwType,
  191. LPARAM arg,
  192. LPARAM param
  193. )
  194. {
  195. HRESULT hr = S_OK;
  196. int i = 0;
  197. SPIConsole spConsole;
  198. CORg(CHandler::OnRefresh(pNode, pDataObject, dwType, arg, param));
  199. CORg(m_spSpdInfo->LoadStatistics());
  200. m_spSpdInfo->GetLoadedStatistics(&m_IkeStats, NULL);
  201. i = sizeof(MmStatsItems1)/sizeof(UINT);
  202. // now notify the virtual listbox
  203. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  204. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE));
  205. Error:
  206. return hr;
  207. }
  208. /*---------------------------------------------------------------------------
  209. CIkeStatsHandler::OnCommand
  210. Handles context menu commands for SA scope pane node
  211. Author: NSun
  212. ---------------------------------------------------------------------------*/
  213. STDMETHODIMP
  214. CIkeStatsHandler::OnCommand
  215. (
  216. ITFSNode * pNode,
  217. long nCommandId,
  218. DATA_OBJECT_TYPES type,
  219. LPDATAOBJECT pDataObject,
  220. DWORD dwType
  221. )
  222. {
  223. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  224. return S_OK;
  225. }
  226. /*!--------------------------------------------------------------------------
  227. CIkeStatsHandler::Command
  228. Handles context menu commands for virtual listbox items
  229. Author: NSun
  230. ---------------------------------------------------------------------------*/
  231. STDMETHODIMP
  232. CIkeStatsHandler::Command
  233. (
  234. ITFSComponent * pComponent,
  235. MMC_COOKIE cookie,
  236. int nCommandID,
  237. LPDATAOBJECT pDataObject
  238. )
  239. {
  240. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  241. HRESULT hr = S_OK;
  242. SPITFSNode spNode;
  243. m_spResultNodeMgr->FindNode(cookie, &spNode);
  244. // handle result context menu and view menus here
  245. return hr;
  246. }
  247. /*!--------------------------------------------------------------------------
  248. CIkeStatsHandler::HasPropertyPages
  249. Implementation of ITFSNodeHandler::HasPropertyPages
  250. NOTE: the root node handler has to over-ride this function to
  251. handle the snapin manager property page (wizard) case!!!
  252. Author: KennT
  253. ---------------------------------------------------------------------------*/
  254. STDMETHODIMP
  255. CIkeStatsHandler::HasPropertyPages
  256. (
  257. ITFSNode * pNode,
  258. LPDATAOBJECT pDataObject,
  259. DATA_OBJECT_TYPES type,
  260. DWORD dwType
  261. )
  262. {
  263. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  264. return hrFalse;
  265. }
  266. /*---------------------------------------------------------------------------
  267. CIkeStatsHandler::CreatePropertyPages
  268. Description
  269. Author: NSun
  270. ---------------------------------------------------------------------------*/
  271. STDMETHODIMP
  272. CIkeStatsHandler::CreatePropertyPages
  273. (
  274. ITFSNode * pNode,
  275. LPPROPERTYSHEETCALLBACK lpSA,
  276. LPDATAOBJECT pDataObject,
  277. LONG_PTR handle,
  278. DWORD dwType
  279. )
  280. {
  281. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  282. return hrFalse;
  283. }
  284. /*---------------------------------------------------------------------------
  285. CIkeStatsHandler::OnPropertyChange
  286. Description
  287. Author: NSun
  288. ---------------------------------------------------------------------------*/
  289. HRESULT
  290. CIkeStatsHandler::OnPropertyChange
  291. (
  292. ITFSNode * pNode,
  293. LPDATAOBJECT pDataobject,
  294. DWORD dwType,
  295. LPARAM arg,
  296. LPARAM lParam
  297. )
  298. {
  299. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  300. //CServerProperties * pServerProp = reinterpret_cast<CServerProperties *>(lParam);
  301. LONG_PTR changeMask = 0;
  302. // tell the property page to do whatever now that we are back on the
  303. // main thread
  304. //pServerProp->OnPropertyChange(TRUE, &changeMask);
  305. //pServerProp->AcknowledgeNotify();
  306. if (changeMask)
  307. pNode->ChangeNode(changeMask);
  308. return hrOK;
  309. }
  310. /*---------------------------------------------------------------------------
  311. CIkeStatsHandler::OnExpand
  312. Handles enumeration of a scope item
  313. Author: NSun
  314. ---------------------------------------------------------------------------*/
  315. HRESULT
  316. CIkeStatsHandler::OnExpand
  317. (
  318. ITFSNode * pNode,
  319. LPDATAOBJECT pDataObject,
  320. DWORD dwType,
  321. LPARAM arg,
  322. LPARAM param
  323. )
  324. {
  325. HRESULT hr = hrOK;
  326. if (m_bExpanded)
  327. return hr;
  328. // do the default handling
  329. CORg (CIpsmHandler::OnExpand(pNode, pDataObject, dwType, arg, param));
  330. Error:
  331. return hr;
  332. }
  333. /*!--------------------------------------------------------------------------
  334. CIkeStatsHandler::OnResultSelect
  335. Handles the MMCN_SELECT notifcation
  336. Author: NSun
  337. ---------------------------------------------------------------------------*/
  338. HRESULT
  339. CIkeStatsHandler::OnResultSelect
  340. (
  341. ITFSComponent * pComponent,
  342. LPDATAOBJECT pDataObject,
  343. MMC_COOKIE cookie,
  344. LPARAM arg,
  345. LPARAM lParam
  346. )
  347. {
  348. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  349. HRESULT hr = hrOK;
  350. SPINTERNAL spInternal;
  351. SPIConsole spConsole;
  352. SPIConsoleVerb spConsoleVerb;
  353. SPITFSNode spNode;
  354. BOOL bStates[ARRAYLEN(g_ConsoleVerbs)];
  355. int i;
  356. LONG_PTR dwNodeType;
  357. BOOL fSelect = HIWORD(arg);
  358. // virtual listbox notifications come to the handler of the node that is selected.
  359. // check to see if this notification is for a virtual listbox item or the active
  360. // registrations node itself.
  361. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  362. m_verbDefault = MMC_VERB_OPEN;
  363. if (!fSelect)
  364. {
  365. return hr;
  366. }
  367. // Get the current count
  368. i = sizeof(MmStatsItems1)/sizeof(UINT);
  369. // now notify the virtual listbox
  370. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  371. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE) );
  372. // now update the verbs...
  373. spInternal = ExtractInternalFormat(pDataObject);
  374. Assert(spInternal);
  375. if (spInternal->HasVirtualIndex())
  376. {
  377. //TODO add to here if we want to have some result console verbs
  378. // we gotta do special stuff for the virtual index items
  379. dwNodeType = IPSECMON_MM_IKESTATS_ITEM;
  380. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = FALSE);
  381. m_verbDefault = MMC_VERB_PROPERTIES;
  382. }
  383. else
  384. {
  385. // enable/disable delete depending if the node supports it
  386. CORg (m_spNodeMgr->FindNode(cookie, &spNode));
  387. dwNodeType = spNode->GetData(TFS_DATA_TYPE);
  388. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = TRUE);
  389. //hide "delete" context menu
  390. bStates[MMC_VERB_DELETE & 0x000F] = FALSE;
  391. }
  392. EnableVerbs(spConsoleVerb, g_ConsoleVerbStates[dwNodeType], bStates);
  393. COM_PROTECT_ERROR_LABEL;
  394. return hr;
  395. }
  396. /*!--------------------------------------------------------------------------
  397. CIkeStatsHandler::OnDelete
  398. The base handler calls this when MMC sends a MMCN_DELETE for a
  399. scope pane item. We just call our delete command handler.
  400. Author: NSun
  401. ---------------------------------------------------------------------------*/
  402. HRESULT
  403. CIkeStatsHandler::OnDelete
  404. (
  405. ITFSNode * pNode,
  406. LPARAM arg,
  407. LPARAM lParam
  408. )
  409. {
  410. return S_FALSE;
  411. }
  412. /*!--------------------------------------------------------------------------
  413. CIkeStatsHandler::HasPropertyPages
  414. Handle the result notification
  415. Author: NSun
  416. ---------------------------------------------------------------------------*/
  417. STDMETHODIMP
  418. CIkeStatsHandler::HasPropertyPages(
  419. ITFSComponent *pComponent,
  420. MMC_COOKIE cookie,
  421. LPDATAOBJECT pDataObject)
  422. {
  423. return hrFalse;
  424. }
  425. /*!--------------------------------------------------------------------------
  426. CIkeStatsHandler::HasPropertyPages
  427. Handle the result notification. Create the filter property sheet
  428. Author: NSun
  429. ---------------------------------------------------------------------------*/
  430. STDMETHODIMP CIkeStatsHandler::CreatePropertyPages
  431. (
  432. ITFSComponent * pComponent,
  433. MMC_COOKIE cookie,
  434. LPPROPERTYSHEETCALLBACK lpProvider,
  435. LPDATAOBJECT pDataObject,
  436. LONG_PTR handle
  437. )
  438. {
  439. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  440. return hrFalse;
  441. }
  442. /*---------------------------------------------------------------------------
  443. CIkeStatsHandler::OnGetResultViewType
  444. Return the result view that this node is going to support
  445. Author: NSun
  446. ---------------------------------------------------------------------------*/
  447. HRESULT
  448. CIkeStatsHandler::OnGetResultViewType
  449. (
  450. ITFSComponent * pComponent,
  451. MMC_COOKIE cookie,
  452. LPOLESTR * ppViewType,
  453. long * pViewOptions
  454. )
  455. {
  456. if (cookie != NULL)
  457. {
  458. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  459. }
  460. return S_FALSE;
  461. }
  462. /*---------------------------------------------------------------------------
  463. CIkeStatsHandler::GetVirtualImage
  464. Returns the image index for virtual listbox items
  465. Author: NSun
  466. ---------------------------------------------------------------------------*/
  467. int
  468. CIkeStatsHandler::GetVirtualImage
  469. (
  470. int nIndex
  471. )
  472. {
  473. return ICON_IDX_POLICY;
  474. }
  475. /*---------------------------------------------------------------------------
  476. CIkeStatsHandler::GetVirtualString
  477. returns a pointer to the string for virtual listbox items
  478. Author: NSun
  479. ---------------------------------------------------------------------------*/
  480. LPCWSTR
  481. CIkeStatsHandler::GetVirtualString
  482. (
  483. int nIndex,
  484. int nCol
  485. )
  486. {
  487. HRESULT hr = S_OK;
  488. static CString strTemp;
  489. strTemp.Empty();
  490. if (nCol >= DimensionOf(aColumns[IPSECMON_MM_IKESTATS]))
  491. return NULL;
  492. switch (aColumns[IPSECMON_MM_IKESTATS][nCol])
  493. {
  494. case IDS_STATS_NAME:
  495. strTemp.LoadString(MmStatsItems1[nIndex]);
  496. return strTemp;
  497. break;
  498. case IDS_STATS_DATA:
  499. switch (MmStatsItems1[nIndex])
  500. {
  501. case IDS_STATS_MM_ACTIVE_ACQUIRE:
  502. strTemp.Format(_T("%u"), m_IkeStats.m_dwActiveAcquire);
  503. break;
  504. case IDS_STATS_MM_ACTIVE_RCV:
  505. strTemp.Format(_T("%u"), m_IkeStats.m_dwActiveReceive);
  506. break;
  507. case IDS_STATS_MM_ACQUIRE_FAIL:
  508. strTemp.Format(_T("%u"), m_IkeStats.m_dwAcquireFail);
  509. break;
  510. case IDS_STATS_MM_RCV_FAIL:
  511. strTemp.Format(_T("%u"), m_IkeStats.m_dwReceiveFail);
  512. break;
  513. case IDS_STATS_MM_SEND_FAIL:
  514. strTemp.Format(_T("%u"), m_IkeStats.m_dwSendFail);
  515. break;
  516. case IDS_STATS_MM_ACQUIRE_HEAP_SIZE:
  517. strTemp.Format(_T("%u"), m_IkeStats.m_dwAcquireHeapSize);
  518. break;
  519. case IDS_STATS_MM_RCV_HEAP_SIZE:
  520. strTemp.Format(_T("%u"), m_IkeStats.m_dwReceiveHeapSize);
  521. break;
  522. case IDS_STATS_MM_NEG_FAIL:
  523. strTemp.Format(_T("%u"), m_IkeStats.m_dwNegotiationFailures);
  524. break;
  525. case IDS_STATS_MM_ATTH_FAILURE:
  526. strTemp.Format(_T("%u"), m_IkeStats.m_dwAuthenticationFailures);
  527. break;
  528. case IDS_STATS_MM_INVALID_COOKIE:
  529. strTemp.Format(_T("%u"), m_IkeStats.m_dwInvalidCookiesReceived);
  530. break;
  531. case IDS_STATS_MM_TOTAL_ACQUIRE:
  532. strTemp.Format(_T("%u"), m_IkeStats.m_dwTotalAcquire);
  533. break;
  534. case IDS_STATS_MM_TOTAL_GETSPI:
  535. strTemp.Format(_T("%u"), m_IkeStats.m_dwTotalGetSpi);
  536. break;
  537. case IDS_STATS_MM_TOTAL_KEY_ADD:
  538. strTemp.Format(_T("%u"), m_IkeStats.m_dwTotalKeyAdd);
  539. break;
  540. case IDS_STATS_MM_TOTAL_KEY_UPDATE:
  541. strTemp.Format(_T("%u"), m_IkeStats.m_dwTotalKeyUpdate);
  542. break;
  543. case IDS_STATS_MM_GET_SPI_FAIL:
  544. strTemp.Format(_T("%u"), m_IkeStats.m_dwGetSpiFail);
  545. break;
  546. case IDS_STATS_MM_KEY_ADD_FAIL:
  547. strTemp.Format(_T("%u"), m_IkeStats.m_dwKeyAddFail);
  548. break;
  549. case IDS_STATS_MM_KEY_UPDATE_FAIL:
  550. strTemp.Format(_T("%u"), m_IkeStats.m_dwKeyUpdateFail);
  551. break;
  552. case IDS_STATS_MM_ISADB_LIST_SIZE:
  553. strTemp.Format(_T("%u"), m_IkeStats.m_dwIsadbListSize);
  554. break;
  555. case IDS_STATS_MM_CONN_LIST_SIZE:
  556. strTemp.Format(_T("%u"), m_IkeStats.m_dwConnListSize);
  557. break;
  558. case IDS_STATS_MM_OAKLEY_MM:
  559. strTemp.Format(_T("%u"), m_IkeStats.m_dwOakleyMainModes);
  560. break;
  561. case IDS_STATS_MM_OAKLEY_QM:
  562. strTemp.Format(_T("%u"), m_IkeStats.m_dwOakleyQuickModes);
  563. break;
  564. case IDS_STATS_MM_SOFT_ASSOCIATIONS:
  565. strTemp.Format(_T("%u"), m_IkeStats.m_dwSoftAssociations);
  566. break;
  567. case IDS_STATS_MM_INVALID_PACKETS:
  568. strTemp.Format(_T("%u"), m_IkeStats.m_dwInvalidPacketsReceived);
  569. break;
  570. }
  571. //strTemp.Format(_T("%d"), 10);
  572. return strTemp;
  573. break;
  574. default:
  575. Panic0("CIkeStatsHandler::GetVirtualString - Unknown column!\n");
  576. break;
  577. }
  578. return NULL;
  579. }
  580. /*---------------------------------------------------------------------------
  581. CIkeStatsHandler::CacheHint
  582. MMC tells us which items it will need before it requests things
  583. Author: NSun
  584. ---------------------------------------------------------------------------*/
  585. STDMETHODIMP
  586. CIkeStatsHandler::CacheHint
  587. (
  588. int nStartIndex,
  589. int nEndIndex
  590. )
  591. {
  592. HRESULT hr = hrOK;;
  593. Trace2("CacheHint - Start %d, End %d\n", nStartIndex, nEndIndex);
  594. return hr;
  595. }
  596. /*---------------------------------------------------------------------------
  597. CIkeStatsHandler::SortItems
  598. We are responsible for sorting of virtual listbox items
  599. Author: NSun
  600. ---------------------------------------------------------------------------*/
  601. /*STDMETHODIMP
  602. CIkeStatsHandler::SortItems
  603. (
  604. int nColumn,
  605. DWORD dwSortOptions,
  606. LPARAM lUserParam
  607. )
  608. {
  609. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  610. HRESULT hr = S_OK;
  611. if (nColumn >= DimensionOf(aColumns[IPSECMON_MM_POLICY]))
  612. return E_INVALIDARG;
  613. BEGIN_WAIT_CURSOR
  614. DWORD dwIndexType = aColumns[IPSECMON_MM_POLICY][nColumn];
  615. hr = m_spSpdInfo->SortMmPolicies(dwIndexType, dwSortOptions);
  616. END_WAIT_CURSOR
  617. return hr;
  618. }*/
  619. /*!--------------------------------------------------------------------------
  620. CIkeStatsHandler::OnResultUpdateView
  621. Implementation of ITFSResultHandler::OnResultUpdateView
  622. Author: NSun
  623. ---------------------------------------------------------------------------*/
  624. HRESULT CIkeStatsHandler::OnResultUpdateView
  625. (
  626. ITFSComponent *pComponent,
  627. LPDATAOBJECT pDataObject,
  628. LPARAM data,
  629. LONG_PTR hint
  630. )
  631. {
  632. HRESULT hr = hrOK;
  633. SPITFSNode spSelectedNode;
  634. pComponent->GetSelectedNode(&spSelectedNode);
  635. if (spSelectedNode == NULL)
  636. return S_OK; // no selection for our IComponentData
  637. if ( hint == IPSECMON_UPDATE_STATUS )
  638. {
  639. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  640. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  641. SPITFSNode spSelectedNode;
  642. pComponent->GetSelectedNode(&spSelectedNode);
  643. if (pNode == spSelectedNode)
  644. {
  645. // if we are the selected node, then we need to update
  646. SPIResultData spResultData;
  647. CORg (pComponent->GetResultData(&spResultData));
  648. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOSCROLL));
  649. }
  650. }
  651. else
  652. {
  653. // we don't handle this message, let the base class do it.
  654. return CIpsmHandler::OnResultUpdateView(pComponent, pDataObject, data, hint);
  655. }
  656. COM_PROTECT_ERROR_LABEL;
  657. return hr;
  658. }
  659. /*!--------------------------------------------------------------------------
  660. CIkeStatsHandler::LoadColumns
  661. Set the correct column header and then call the base class
  662. Author: NSun
  663. ---------------------------------------------------------------------------*/
  664. HRESULT
  665. CIkeStatsHandler::LoadColumns
  666. (
  667. ITFSComponent * pComponent,
  668. MMC_COOKIE cookie,
  669. LPARAM arg,
  670. LPARAM lParam
  671. )
  672. {
  673. //set column info
  674. return CIpsmHandler::LoadColumns(pComponent, cookie, arg, lParam);
  675. }
  676. /*---------------------------------------------------------------------------
  677. Command handlers
  678. ---------------------------------------------------------------------------*/
  679. /*---------------------------------------------------------------------------
  680. CIkeStatsHandler::OnDelete
  681. Removes a service SA
  682. Author: NSun
  683. ---------------------------------------------------------------------------*/
  684. HRESULT
  685. CIkeStatsHandler::OnDelete
  686. (
  687. ITFSNode * pNode
  688. )
  689. {
  690. HRESULT hr = S_FALSE;
  691. return hr;
  692. }
  693. /*---------------------------------------------------------------------------
  694. CIkeStatsHandler::UpdateStatus
  695. -
  696. Author: NSun
  697. ---------------------------------------------------------------------------*/
  698. HRESULT
  699. CIkeStatsHandler::UpdateStatus
  700. (
  701. ITFSNode * pNode
  702. )
  703. {
  704. HRESULT hr = hrOK;
  705. SPIComponentData spComponentData;
  706. SPIConsole spConsole;
  707. IDataObject * pDataObject;
  708. SPIDataObject spDataObject;
  709. int i = 0;
  710. Trace0("CIkeStatsHandler::UpdateStatus - Updating status for Filter");
  711. // force the listbox to update. We do this by setting the count and
  712. // telling it to invalidate the data
  713. CORg(m_spNodeMgr->GetComponentData(&spComponentData));
  714. CORg(m_spNodeMgr->GetConsole(&spConsole));
  715. // grab a data object to use
  716. CORg(spComponentData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  717. spDataObject = pDataObject;
  718. CORg(m_spSpdInfo->LoadStatistics());
  719. m_spSpdInfo->GetLoadedStatistics(&m_IkeStats, NULL);
  720. i = sizeof(MmStatsItems1)/sizeof(UINT);
  721. CORg(spConsole->UpdateAllViews(pDataObject, i, IPSECMON_UPDATE_STATUS));
  722. COM_PROTECT_ERROR_LABEL;
  723. return hr;
  724. }
  725. /*---------------------------------------------------------------------------
  726. Misc functions
  727. ---------------------------------------------------------------------------*/
  728. /*---------------------------------------------------------------------------
  729. CIkeStatsHandler::InitData
  730. Initializes data for this node
  731. Author: NSun
  732. ---------------------------------------------------------------------------*/
  733. HRESULT
  734. CIkeStatsHandler::InitData
  735. (
  736. ISpdInfo * pSpdInfo
  737. )
  738. {
  739. HRESULT hr = hrOK;
  740. m_spSpdInfo.Set(pSpdInfo);
  741. CORg(m_spSpdInfo->LoadStatistics());
  742. m_spSpdInfo->GetLoadedStatistics(&m_IkeStats, NULL);
  743. return hr;
  744. Error:
  745. if (FAILED(hr))
  746. {
  747. //TODO bring up a error pop up here
  748. }
  749. return hr;
  750. }
  751. /*---------------------------------------------------------------------------
  752. Class CIpsecStatsHandler implementation
  753. ---------------------------------------------------------------------------*/
  754. /*---------------------------------------------------------------------------
  755. Constructor and destructor
  756. Description
  757. Author: NSun
  758. ---------------------------------------------------------------------------*/
  759. CIpsecStatsHandler::CIpsecStatsHandler
  760. (
  761. ITFSComponentData * pComponentData
  762. ) : CIpsmHandler(pComponentData)
  763. {
  764. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  765. }
  766. CIpsecStatsHandler::~CIpsecStatsHandler()
  767. {
  768. }
  769. /*!--------------------------------------------------------------------------
  770. CIpsecStatsHandler::InitializeNode
  771. Initializes node specific data
  772. Author: NSun
  773. ---------------------------------------------------------------------------*/
  774. HRESULT
  775. CIpsecStatsHandler::InitializeNode
  776. (
  777. ITFSNode * pNode
  778. )
  779. {
  780. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  781. CString strTemp;
  782. strTemp.LoadString(IDS_STATS_DATA);
  783. SetDisplayName(strTemp);
  784. // Make the node immediately visible
  785. pNode->SetVisibilityState(TFS_VIS_SHOW);
  786. pNode->SetData(TFS_DATA_COOKIE, (LPARAM) pNode);
  787. pNode->SetData(TFS_DATA_IMAGEINDEX, ICON_IDX_FOLDER_CLOSED);
  788. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, ICON_IDX_FOLDER_OPEN);
  789. pNode->SetData(TFS_DATA_USER, (LPARAM) this);
  790. pNode->SetData(TFS_DATA_TYPE, IPSECMON_QM_IPSECSTATS);
  791. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  792. SetColumnStringIDs(&aColumns[IPSECMON_QM_IPSECSTATS][0]);
  793. SetColumnWidths(&aColumnWidths[IPSECMON_QM_IPSECSTATS][0]);
  794. return hrOK;
  795. }
  796. /*---------------------------------------------------------------------------
  797. CIpsecStatsHandler::GetImageIndex
  798. -
  799. Author: NSun
  800. ---------------------------------------------------------------------------*/
  801. int
  802. CIpsecStatsHandler::GetImageIndex(BOOL bOpenImage)
  803. {
  804. int nIndex = -1;
  805. return nIndex;
  806. }
  807. /*---------------------------------------------------------------------------
  808. Overridden base handler functions
  809. ---------------------------------------------------------------------------*/
  810. /*---------------------------------------------------------------------------
  811. CIpsecStatsHandler::OnAddMenuItems
  812. Adds context menu items for the SA scope pane node
  813. Author: NSun
  814. ---------------------------------------------------------------------------*/
  815. STDMETHODIMP
  816. CIpsecStatsHandler::OnAddMenuItems
  817. (
  818. ITFSNode * pNode,
  819. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  820. LPDATAOBJECT lpDataObject,
  821. DATA_OBJECT_TYPES type,
  822. DWORD dwType,
  823. long * pInsertionAllowed
  824. )
  825. {
  826. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  827. LONG fFlags = 0, fLoadingFlags = 0;
  828. HRESULT hr = S_OK;
  829. CString strMenuItem;
  830. if (type == CCT_SCOPE)
  831. {
  832. //load scope node context menu items here
  833. // these menu items go in the new menu,
  834. // only visible from scope pane
  835. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  836. {
  837. }
  838. }
  839. return hr;
  840. }
  841. /*!--------------------------------------------------------------------------
  842. CIpsecStatsHandler::AddMenuItems
  843. Adds context menu items for virtual list box (result pane) items
  844. Author: NSun
  845. ---------------------------------------------------------------------------*/
  846. STDMETHODIMP
  847. CIpsecStatsHandler::AddMenuItems
  848. (
  849. ITFSComponent * pComponent,
  850. MMC_COOKIE cookie,
  851. LPDATAOBJECT pDataObject,
  852. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  853. long * pInsertionAllowed
  854. )
  855. {
  856. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  857. HRESULT hr = hrOK;
  858. CString strMenuItem;
  859. SPINTERNAL spInternal;
  860. LONG fFlags = 0;
  861. spInternal = ExtractInternalFormat(pDataObject);
  862. // virtual listbox notifications come to the handler of the node that is selected.
  863. // check to see if this notification is for a virtual listbox item or this SA
  864. // node itself.
  865. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
  866. {
  867. //load and view menu items here
  868. }
  869. return hr;
  870. }
  871. /*!--------------------------------------------------------------------------
  872. CIpsecStatsHandler::OnRefresh
  873. Default implementation for the refresh functionality
  874. Author: NSun
  875. ---------------------------------------------------------------------------*/
  876. HRESULT
  877. CIpsecStatsHandler::OnRefresh
  878. (
  879. ITFSNode * pNode,
  880. LPDATAOBJECT pDataObject,
  881. DWORD dwType,
  882. LPARAM arg,
  883. LPARAM param
  884. )
  885. {
  886. HRESULT hr = S_OK;
  887. int i = 0;
  888. SPIConsole spConsole;
  889. CORg(CHandler::OnRefresh(pNode, pDataObject, dwType, arg, param));
  890. CORg(m_spSpdInfo->LoadStatistics());
  891. m_spSpdInfo->GetLoadedStatistics(NULL, &m_IpsecStats);
  892. i = sizeof(QmStatsItems1)/sizeof(UINT);
  893. // now notify the virtual listbox
  894. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  895. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE));
  896. Error:
  897. return hr;
  898. }
  899. /*---------------------------------------------------------------------------
  900. CIpsecStatsHandler::OnCommand
  901. Handles context menu commands for SA scope pane node
  902. Author: NSun
  903. ---------------------------------------------------------------------------*/
  904. STDMETHODIMP
  905. CIpsecStatsHandler::OnCommand
  906. (
  907. ITFSNode * pNode,
  908. long nCommandId,
  909. DATA_OBJECT_TYPES type,
  910. LPDATAOBJECT pDataObject,
  911. DWORD dwType
  912. )
  913. {
  914. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  915. return S_OK;
  916. }
  917. /*!--------------------------------------------------------------------------
  918. CIpsecStatsHandler::Command
  919. Handles context menu commands for virtual listbox items
  920. Author: NSun
  921. ---------------------------------------------------------------------------*/
  922. STDMETHODIMP
  923. CIpsecStatsHandler::Command
  924. (
  925. ITFSComponent * pComponent,
  926. MMC_COOKIE cookie,
  927. int nCommandID,
  928. LPDATAOBJECT pDataObject
  929. )
  930. {
  931. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  932. HRESULT hr = S_OK;
  933. SPITFSNode spNode;
  934. m_spResultNodeMgr->FindNode(cookie, &spNode);
  935. // handle result context menu and view menus here
  936. return hr;
  937. }
  938. /*!--------------------------------------------------------------------------
  939. CIpsecStatsHandler::HasPropertyPages
  940. Implementation of ITFSNodeHandler::HasPropertyPages
  941. NOTE: the root node handler has to over-ride this function to
  942. handle the snapin manager property page (wizard) case!!!
  943. Author: KennT
  944. ---------------------------------------------------------------------------*/
  945. STDMETHODIMP
  946. CIpsecStatsHandler::HasPropertyPages
  947. (
  948. ITFSNode * pNode,
  949. LPDATAOBJECT pDataObject,
  950. DATA_OBJECT_TYPES type,
  951. DWORD dwType
  952. )
  953. {
  954. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  955. return hrFalse;
  956. }
  957. /*---------------------------------------------------------------------------
  958. CIpsecStatsHandler::CreatePropertyPages
  959. Description
  960. Author: NSun
  961. ---------------------------------------------------------------------------*/
  962. STDMETHODIMP
  963. CIpsecStatsHandler::CreatePropertyPages
  964. (
  965. ITFSNode * pNode,
  966. LPPROPERTYSHEETCALLBACK lpSA,
  967. LPDATAOBJECT pDataObject,
  968. LONG_PTR handle,
  969. DWORD dwType
  970. )
  971. {
  972. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  973. return hrFalse;
  974. }
  975. /*---------------------------------------------------------------------------
  976. CIpsecStatsHandler::OnPropertyChange
  977. Description
  978. Author: NSun
  979. ---------------------------------------------------------------------------*/
  980. HRESULT
  981. CIpsecStatsHandler::OnPropertyChange
  982. (
  983. ITFSNode * pNode,
  984. LPDATAOBJECT pDataobject,
  985. DWORD dwType,
  986. LPARAM arg,
  987. LPARAM lParam
  988. )
  989. {
  990. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  991. //CServerProperties * pServerProp = reinterpret_cast<CServerProperties *>(lParam);
  992. LONG_PTR changeMask = 0;
  993. // tell the property page to do whatever now that we are back on the
  994. // main thread
  995. //pServerProp->OnPropertyChange(TRUE, &changeMask);
  996. //pServerProp->AcknowledgeNotify();
  997. if (changeMask)
  998. pNode->ChangeNode(changeMask);
  999. return hrOK;
  1000. }
  1001. /*---------------------------------------------------------------------------
  1002. CIpsecStatsHandler::OnExpand
  1003. Handles enumeration of a scope item
  1004. Author: NSun
  1005. ---------------------------------------------------------------------------*/
  1006. HRESULT
  1007. CIpsecStatsHandler::OnExpand
  1008. (
  1009. ITFSNode * pNode,
  1010. LPDATAOBJECT pDataObject,
  1011. DWORD dwType,
  1012. LPARAM arg,
  1013. LPARAM param
  1014. )
  1015. {
  1016. HRESULT hr = hrOK;
  1017. if (m_bExpanded)
  1018. return hr;
  1019. // do the default handling
  1020. CORg (CIpsmHandler::OnExpand(pNode, pDataObject, dwType, arg, param));
  1021. Error:
  1022. return hr;
  1023. }
  1024. /*!--------------------------------------------------------------------------
  1025. CIpsecStatsHandler::OnResultSelect
  1026. Handles the MMCN_SELECT notifcation
  1027. Author: NSun
  1028. ---------------------------------------------------------------------------*/
  1029. HRESULT
  1030. CIpsecStatsHandler::OnResultSelect
  1031. (
  1032. ITFSComponent * pComponent,
  1033. LPDATAOBJECT pDataObject,
  1034. MMC_COOKIE cookie,
  1035. LPARAM arg,
  1036. LPARAM lParam
  1037. )
  1038. {
  1039. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  1040. HRESULT hr = hrOK;
  1041. SPINTERNAL spInternal;
  1042. SPIConsole spConsole;
  1043. SPIConsoleVerb spConsoleVerb;
  1044. SPITFSNode spNode;
  1045. BOOL bStates[ARRAYLEN(g_ConsoleVerbs)];
  1046. int i;
  1047. LONG_PTR dwNodeType;
  1048. BOOL fSelect = HIWORD(arg);
  1049. // virtual listbox notifications come to the handler of the node that is selected.
  1050. // check to see if this notification is for a virtual listbox item or the active
  1051. // registrations node itself.
  1052. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  1053. m_verbDefault = MMC_VERB_OPEN;
  1054. if (!fSelect)
  1055. {
  1056. return hr;
  1057. }
  1058. // Get the current count
  1059. i = sizeof(QmStatsItems1)/sizeof(UINT);
  1060. // now notify the virtual listbox
  1061. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  1062. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE) );
  1063. // now update the verbs...
  1064. spInternal = ExtractInternalFormat(pDataObject);
  1065. Assert(spInternal);
  1066. if (spInternal->HasVirtualIndex())
  1067. {
  1068. //TODO add to here if we want to have some result console verbs
  1069. // we gotta do special stuff for the virtual index items
  1070. dwNodeType = IPSECMON_QM_IPSECSTATS_ITEM;
  1071. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = FALSE);
  1072. m_verbDefault = MMC_VERB_PROPERTIES;
  1073. }
  1074. else
  1075. {
  1076. // enable/disable delete depending if the node supports it
  1077. CORg (m_spNodeMgr->FindNode(cookie, &spNode));
  1078. dwNodeType = spNode->GetData(TFS_DATA_TYPE);
  1079. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = TRUE);
  1080. //hide "delete" context menu
  1081. bStates[MMC_VERB_DELETE & 0x000F] = FALSE;
  1082. }
  1083. EnableVerbs(spConsoleVerb, g_ConsoleVerbStates[dwNodeType], bStates);
  1084. COM_PROTECT_ERROR_LABEL;
  1085. return hr;
  1086. }
  1087. /*!--------------------------------------------------------------------------
  1088. CIpsecStatsHandler::OnDelete
  1089. The base handler calls this when MMC sends a MMCN_DELETE for a
  1090. scope pane item. We just call our delete command handler.
  1091. Author: NSun
  1092. ---------------------------------------------------------------------------*/
  1093. HRESULT
  1094. CIpsecStatsHandler::OnDelete
  1095. (
  1096. ITFSNode * pNode,
  1097. LPARAM arg,
  1098. LPARAM lParam
  1099. )
  1100. {
  1101. return S_FALSE;
  1102. }
  1103. /*!--------------------------------------------------------------------------
  1104. CIpsecStatsHandler::HasPropertyPages
  1105. Handle the result notification
  1106. Author: NSun
  1107. ---------------------------------------------------------------------------*/
  1108. STDMETHODIMP
  1109. CIpsecStatsHandler::HasPropertyPages(
  1110. ITFSComponent *pComponent,
  1111. MMC_COOKIE cookie,
  1112. LPDATAOBJECT pDataObject)
  1113. {
  1114. return hrFalse;
  1115. }
  1116. /*!--------------------------------------------------------------------------
  1117. CIpsecStatsHandler::HasPropertyPages
  1118. Handle the result notification. Create the filter property sheet
  1119. Author: NSun
  1120. ---------------------------------------------------------------------------*/
  1121. STDMETHODIMP CIpsecStatsHandler::CreatePropertyPages
  1122. (
  1123. ITFSComponent * pComponent,
  1124. MMC_COOKIE cookie,
  1125. LPPROPERTYSHEETCALLBACK lpProvider,
  1126. LPDATAOBJECT pDataObject,
  1127. LONG_PTR handle
  1128. )
  1129. {
  1130. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1131. return hrFalse;
  1132. }
  1133. /*---------------------------------------------------------------------------
  1134. CIpsecStatsHandler::OnGetResultViewType
  1135. Return the result view that this node is going to support
  1136. Author: NSun
  1137. ---------------------------------------------------------------------------*/
  1138. HRESULT
  1139. CIpsecStatsHandler::OnGetResultViewType
  1140. (
  1141. ITFSComponent * pComponent,
  1142. MMC_COOKIE cookie,
  1143. LPOLESTR * ppViewType,
  1144. long * pViewOptions
  1145. )
  1146. {
  1147. if (cookie != NULL)
  1148. {
  1149. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  1150. }
  1151. return S_FALSE;
  1152. }
  1153. /*---------------------------------------------------------------------------
  1154. CIpsecStatsHandler::GetVirtualImage
  1155. Returns the image index for virtual listbox items
  1156. Author: NSun
  1157. ---------------------------------------------------------------------------*/
  1158. int
  1159. CIpsecStatsHandler::GetVirtualImage
  1160. (
  1161. int nIndex
  1162. )
  1163. {
  1164. return ICON_IDX_POLICY;
  1165. }
  1166. /*---------------------------------------------------------------------------
  1167. CIpsecStatsHandler::GetVirtualString
  1168. returns a pointer to the string for virtual listbox items
  1169. Author: NSun
  1170. ---------------------------------------------------------------------------*/
  1171. LPCWSTR
  1172. CIpsecStatsHandler::GetVirtualString
  1173. (
  1174. int nIndex,
  1175. int nCol
  1176. )
  1177. {
  1178. HRESULT hr = S_OK;
  1179. static CString strTemp;
  1180. strTemp.Empty();
  1181. if (nCol >= DimensionOf(aColumns[IPSECMON_QM_IPSECSTATS]))
  1182. return NULL;
  1183. switch (aColumns[IPSECMON_MM_IKESTATS][nCol])
  1184. {
  1185. case IDS_STATS_NAME:
  1186. strTemp.LoadString(QmStatsItems1[nIndex]);
  1187. return strTemp;
  1188. break;
  1189. case IDS_STATS_DATA:
  1190. switch(QmStatsItems1[nIndex])
  1191. {
  1192. case IDS_STATS_QM_ACTIVE_SA:
  1193. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumActiveAssociations);
  1194. break;
  1195. case IDS_STATS_QM_OFFLOAD_SA:
  1196. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumOffloadedSAs);
  1197. break;
  1198. case IDS_STATS_QM_PENDING_KEY_OPS:
  1199. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumPendingKeyOps);
  1200. break;
  1201. case IDS_STATS_QM_KEY_ADDITION:
  1202. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumKeyAdditions);
  1203. break;
  1204. case IDS_STATS_QM_KEY_DELETION:
  1205. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumKeyDeletions);
  1206. break;
  1207. case IDS_STATS_QM_REKEYS:
  1208. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumReKeys);
  1209. break;
  1210. case IDS_STATS_QM_ACTIVE_TNL:
  1211. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumActiveTunnels);
  1212. break;
  1213. case IDS_STATS_QM_BAD_SPI:
  1214. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumBadSPIPackets);
  1215. break;
  1216. case IDS_STATS_QM_PKT_NOT_DECRYPT:
  1217. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumPacketsNotDecrypted);
  1218. break;
  1219. case IDS_STATS_QM_PKT_NOT_AUTH:
  1220. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumPacketsNotAuthenticated);
  1221. break;
  1222. case IDS_STATS_QM_PKT_REPLAY:
  1223. strTemp.Format(_T("%u"), m_IpsecStats.m_dwNumPacketsWithReplayDetection);
  1224. break;
  1225. case IDS_STATS_QM_ESP_BYTE_SENT:
  1226. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uConfidentialBytesSent);
  1227. break;
  1228. case IDS_STATS_QM_ESP_BYTE_RCV:
  1229. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uConfidentialBytesReceived);
  1230. break;
  1231. case IDS_STATS_QM_AUTH_BYTE_SENT:
  1232. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uAuthenticatedBytesSent);
  1233. break;
  1234. case IDS_STATS_QM_ATTH_BYTE_RCV:
  1235. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uAuthenticatedBytesReceived);
  1236. break;
  1237. case IDS_STATS_QM_XPORT_BYTE_SENT:
  1238. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uTransportBytesSent);
  1239. break;
  1240. case IDS_STATS_QM_XPORT_BYTE_RCV:
  1241. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uTransportBytesReceived);
  1242. break;
  1243. case IDS_STATS_QM_TNL_BYTE_SENT:
  1244. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uBytesSentInTunnels);
  1245. break;
  1246. case IDS_STATS_QM_TNL_BYTE_RCV:
  1247. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uBytesReceivedInTunnels);
  1248. break;
  1249. case IDS_STATS_QM_OFFLOAD_BYTE_SENT:
  1250. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uOffloadedBytesSent);
  1251. break;
  1252. case IDS_STATS_QM_OFFLOAD_BYTE_RCV:
  1253. strTemp.Format(_T("%I64u"), m_IpsecStats.m_uOffloadedBytesReceived);
  1254. break;
  1255. }
  1256. return strTemp;
  1257. break;
  1258. default:
  1259. Panic0("CIpsecStatsHandler::GetVirtualString - Unknown column!\n");
  1260. break;
  1261. }
  1262. return NULL;
  1263. }
  1264. /*---------------------------------------------------------------------------
  1265. CIpsecStatsHandler::CacheHint
  1266. MMC tells us which items it will need before it requests things
  1267. Author: NSun
  1268. ---------------------------------------------------------------------------*/
  1269. STDMETHODIMP
  1270. CIpsecStatsHandler::CacheHint
  1271. (
  1272. int nStartIndex,
  1273. int nEndIndex
  1274. )
  1275. {
  1276. HRESULT hr = hrOK;;
  1277. Trace2("CacheHint - Start %d, End %d\n", nStartIndex, nEndIndex);
  1278. return hr;
  1279. }
  1280. /*---------------------------------------------------------------------------
  1281. CIpsecStatsHandler::SortItems
  1282. We are responsible for sorting of virtual listbox items
  1283. Author: NSun
  1284. ---------------------------------------------------------------------------*/
  1285. /*STDMETHODIMP
  1286. CIpsecStatsHandler::SortItems
  1287. (
  1288. int nColumn,
  1289. DWORD dwSortOptions,
  1290. LPARAM lUserParam
  1291. )
  1292. {
  1293. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1294. HRESULT hr = S_OK;
  1295. if (nColumn >= DimensionOf(aColumns[IPSECMON_MM_POLICY]))
  1296. return E_INVALIDARG;
  1297. BEGIN_WAIT_CURSOR
  1298. DWORD dwIndexType = aColumns[IPSECMON_MM_POLICY][nColumn];
  1299. hr = m_spSpdInfo->SortMmPolicies(dwIndexType, dwSortOptions);
  1300. END_WAIT_CURSOR
  1301. return hr;
  1302. }*/
  1303. /*!--------------------------------------------------------------------------
  1304. CIpsecStatsHandler::OnResultUpdateView
  1305. Implementation of ITFSResultHandler::OnResultUpdateView
  1306. Author: NSun
  1307. ---------------------------------------------------------------------------*/
  1308. HRESULT CIpsecStatsHandler::OnResultUpdateView
  1309. (
  1310. ITFSComponent *pComponent,
  1311. LPDATAOBJECT pDataObject,
  1312. LPARAM data,
  1313. LONG_PTR hint
  1314. )
  1315. {
  1316. HRESULT hr = hrOK;
  1317. SPITFSNode spSelectedNode;
  1318. pComponent->GetSelectedNode(&spSelectedNode);
  1319. if (spSelectedNode == NULL)
  1320. return S_OK; // no selection for our IComponentData
  1321. if ( hint == IPSECMON_UPDATE_STATUS )
  1322. {
  1323. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  1324. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  1325. SPITFSNode spSelectedNode;
  1326. pComponent->GetSelectedNode(&spSelectedNode);
  1327. if (pNode == spSelectedNode)
  1328. {
  1329. // if we are the selected node, then we need to update
  1330. SPIResultData spResultData;
  1331. CORg (pComponent->GetResultData(&spResultData));
  1332. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOSCROLL));
  1333. }
  1334. }
  1335. else
  1336. {
  1337. // we don't handle this message, let the base class do it.
  1338. return CIpsmHandler::OnResultUpdateView(pComponent, pDataObject, data, hint);
  1339. }
  1340. COM_PROTECT_ERROR_LABEL;
  1341. return hr;
  1342. }
  1343. /*!--------------------------------------------------------------------------
  1344. CIpsecStatsHandler::LoadColumns
  1345. Set the correct column header and then call the base class
  1346. Author: NSun
  1347. ---------------------------------------------------------------------------*/
  1348. HRESULT
  1349. CIpsecStatsHandler::LoadColumns
  1350. (
  1351. ITFSComponent * pComponent,
  1352. MMC_COOKIE cookie,
  1353. LPARAM arg,
  1354. LPARAM lParam
  1355. )
  1356. {
  1357. //set column info
  1358. return CIpsmHandler::LoadColumns(pComponent, cookie, arg, lParam);
  1359. }
  1360. /*---------------------------------------------------------------------------
  1361. Command handlers
  1362. ---------------------------------------------------------------------------*/
  1363. /*---------------------------------------------------------------------------
  1364. CIpsecStatsHandler::OnDelete
  1365. Removes a service SA
  1366. Author: NSun
  1367. ---------------------------------------------------------------------------*/
  1368. HRESULT
  1369. CIpsecStatsHandler::OnDelete
  1370. (
  1371. ITFSNode * pNode
  1372. )
  1373. {
  1374. HRESULT hr = S_FALSE;
  1375. return hr;
  1376. }
  1377. /*---------------------------------------------------------------------------
  1378. CIpsecStatsHandler::UpdateStatus
  1379. -
  1380. Author: NSun
  1381. ---------------------------------------------------------------------------*/
  1382. HRESULT
  1383. CIpsecStatsHandler::UpdateStatus
  1384. (
  1385. ITFSNode * pNode
  1386. )
  1387. {
  1388. HRESULT hr = hrOK;
  1389. SPIComponentData spComponentData;
  1390. SPIConsole spConsole;
  1391. IDataObject * pDataObject;
  1392. SPIDataObject spDataObject;
  1393. int i = 0;
  1394. Trace0("CIpsecStatsHandler::UpdateStatus - Updating status for Filter");
  1395. // force the listbox to update. We do this by setting the count and
  1396. // telling it to invalidate the data
  1397. CORg(m_spNodeMgr->GetComponentData(&spComponentData));
  1398. CORg(m_spNodeMgr->GetConsole(&spConsole));
  1399. // grab a data object to use
  1400. CORg(spComponentData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  1401. spDataObject = pDataObject;
  1402. CORg(m_spSpdInfo->LoadStatistics());
  1403. m_spSpdInfo->GetLoadedStatistics(NULL, &m_IpsecStats);
  1404. i = sizeof(QmStatsItems1)/sizeof(UINT);
  1405. CORg(spConsole->UpdateAllViews(pDataObject, i, IPSECMON_UPDATE_STATUS));
  1406. COM_PROTECT_ERROR_LABEL;
  1407. return hr;
  1408. }
  1409. /*---------------------------------------------------------------------------
  1410. Misc functions
  1411. ---------------------------------------------------------------------------*/
  1412. /*---------------------------------------------------------------------------
  1413. CIpsecStatsHandler::InitData
  1414. Initializes data for this node
  1415. Author: NSun
  1416. ---------------------------------------------------------------------------*/
  1417. HRESULT
  1418. CIpsecStatsHandler::InitData
  1419. (
  1420. ISpdInfo * pSpdInfo
  1421. )
  1422. {
  1423. HRESULT hr = hrOK;
  1424. m_spSpdInfo.Set(pSpdInfo);
  1425. CORg(m_spSpdInfo->LoadStatistics());
  1426. m_spSpdInfo->GetLoadedStatistics(NULL, &m_IpsecStats);
  1427. return hr;
  1428. Error:
  1429. if (FAILED(hr))
  1430. {
  1431. //TODO bring up a error pop up here
  1432. }
  1433. return hr;
  1434. }