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.

157 lines
4.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ipstats.cpp
  7. IP Statistics implementation.
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "rtrutil.h" // smart MPR handle pointers
  12. #include "format.h" // FormatNumber function
  13. #include "column.h" // containercolumninfo
  14. #include "ipxconn.h" // IPXConnection
  15. #include "routprot.h"
  16. #include "ipxutil.h"
  17. #include "statsdlg.h"
  18. #include "sapstats.h"
  19. #include "resource.h"
  20. /*---------------------------------------------------------------------------
  21. SAPParamsStatistics implementation
  22. ---------------------------------------------------------------------------*/
  23. extern const ContainerColumnInfo s_rgSAPParamsStatsColumnInfo[];
  24. const ContainerColumnInfo s_rgSAPParamsStatsColumnInfo[] =
  25. {
  26. { IDS_STATS_SAPPARAMS_OPER_STATE, 0, TRUE, COL_STATUS },
  27. { IDS_STATS_SAPPARAMS_SENT_PACKETS, 0, TRUE, COL_LARGE_NUM },
  28. { IDS_STATS_SAPPARAMS_RCVD_PACKETS, 0, TRUE, COL_LARGE_NUM },
  29. };
  30. SAPParamsStatistics::SAPParamsStatistics()
  31. : IPXStatisticsDialog(STATSDLG_VERTICAL |
  32. STATSDLG_FULLWINDOW |
  33. STATSDLG_CONTEXTMENU |
  34. STATSDLG_SELECT_COLUMNS)
  35. {
  36. SetColumnInfo(s_rgSAPParamsStatsColumnInfo,
  37. DimensionOf(s_rgSAPParamsStatsColumnInfo));
  38. }
  39. HRESULT SAPParamsStatistics::RefreshData(BOOL fGrabNewData)
  40. {
  41. HRESULT hr = hrOK;
  42. CString st;
  43. ULONG iPos;
  44. TCHAR szNumber[32];
  45. SAP_MIB_GET_INPUT_DATA MibGetInputData;
  46. PSAP_MIB_BASE pSapBase = NULL;
  47. DWORD cbSapBase;
  48. SPMprMibBuffer spMib;
  49. PSAP_INTERFACE pSapIf = NULL;
  50. DWORD cbSapIf;
  51. DWORD cSent = 0;
  52. DWORD cRcvd = 0;
  53. DWORD dwErr;
  54. Assert(m_pIPXConn);
  55. MibGetInputData.TableId = SAP_BASE_ENTRY;
  56. dwErr = ::MprAdminMIBEntryGet(m_pIPXConn->GetMibHandle(),
  57. PID_IPX,
  58. IPX_PROTOCOL_SAP,
  59. &MibGetInputData,
  60. sizeof(MibGetInputData),
  61. (LPVOID *) &pSapBase,
  62. &cbSapBase);
  63. spMib = (LPBYTE) pSapBase;
  64. hr = HRESULT_FROM_WIN32(dwErr);
  65. CORg( hr );
  66. if (IsSubitemVisible(MVR_SAPPARAMS_OPER_STATE))
  67. {
  68. st = IpxOperStateToCString(pSapBase->SapOperState);
  69. iPos = MapSubitemToColumn(MVR_SAPPARAMS_OPER_STATE);
  70. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) st);
  71. }
  72. spMib.Free();
  73. MibGetInputData.TableId = SAP_INTERFACE_TABLE;
  74. dwErr = MprAdminMIBEntryGetFirst(m_pIPXConn->GetMibHandle(),
  75. PID_IPX,
  76. IPX_PROTOCOL_SAP,
  77. &MibGetInputData,
  78. sizeof(MibGetInputData),
  79. (LPVOID *) &pSapIf,
  80. &cbSapIf);
  81. hr = HRESULT_FROM_WIN32(dwErr);
  82. spMib = (LPBYTE) pSapIf;
  83. while (FHrSucceeded(hr))
  84. {
  85. if (pSapIf->InterfaceIndex)
  86. {
  87. cSent += pSapIf->SapIfStats.SapIfOutputPackets;
  88. cRcvd += pSapIf->SapIfStats.SapIfInputPackets;
  89. }
  90. MibGetInputData.InterfaceIndex = pSapIf->InterfaceIndex;
  91. spMib.Free();
  92. pSapIf = NULL;
  93. dwErr = MprAdminMIBEntryGetNext(m_pIPXConn->GetMibHandle(),
  94. PID_IPX,
  95. IPX_PROTOCOL_SAP,
  96. &MibGetInputData,
  97. sizeof(MibGetInputData),
  98. (LPVOID *) &pSapIf,
  99. &cbSapIf);
  100. hr = HRESULT_FROM_WIN32(dwErr);
  101. spMib = (LPBYTE) pSapIf;
  102. }
  103. if (IsSubitemVisible(MVR_SAPPARAMS_SENT_PKTS))
  104. {
  105. FormatNumber(cSent, szNumber, DimensionOf(szNumber), FALSE);
  106. iPos = MapSubitemToColumn(MVR_SAPPARAMS_SENT_PKTS);
  107. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) szNumber);
  108. }
  109. if (IsSubitemVisible(MVR_SAPPARAMS_RCVD_PKTS))
  110. {
  111. FormatNumber(cRcvd, szNumber, DimensionOf(szNumber), FALSE);
  112. iPos = MapSubitemToColumn(MVR_SAPPARAMS_RCVD_PKTS);
  113. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) szNumber);
  114. }
  115. Error:
  116. return hr;
  117. }
  118. BOOL SAPParamsStatistics::OnInitDialog()
  119. {
  120. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  121. CString st;
  122. st.LoadString(IDS_STATS_SAPPARAMS_TITLE);
  123. SetWindowText((LPCTSTR) st);
  124. return IPXStatisticsDialog::OnInitDialog();
  125. }
  126. void SAPParamsStatistics::Sort(UINT)
  127. {
  128. }