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 "ripstats.h"
  19. #include "resource.h"
  20. /*---------------------------------------------------------------------------
  21. RIPParamsStatistics implementation
  22. ---------------------------------------------------------------------------*/
  23. extern const ContainerColumnInfo s_rgRIPParamsStatsColumnInfo[];
  24. const ContainerColumnInfo s_rgRIPParamsStatsColumnInfo[] =
  25. {
  26. { IDS_STATS_RIPPARAMS_OPER_STATE, 0, TRUE, COL_STATUS },
  27. { IDS_STATS_RIPPARAMS_SENT_PACKETS, 0, TRUE, COL_LARGE_NUM },
  28. { IDS_STATS_RIPPARAMS_RCVD_PACKETS, 0, TRUE, COL_LARGE_NUM },
  29. };
  30. RIPParamsStatistics::RIPParamsStatistics()
  31. : IPXStatisticsDialog(STATSDLG_VERTICAL |
  32. STATSDLG_FULLWINDOW |
  33. STATSDLG_CONTEXTMENU |
  34. STATSDLG_SELECT_COLUMNS)
  35. {
  36. SetColumnInfo(s_rgRIPParamsStatsColumnInfo,
  37. DimensionOf(s_rgRIPParamsStatsColumnInfo));
  38. }
  39. HRESULT RIPParamsStatistics::RefreshData(BOOL fGrabNewData)
  40. {
  41. HRESULT hr = hrOK;
  42. CString st;
  43. ULONG iPos;
  44. TCHAR szNumber[32];
  45. RIP_MIB_GET_INPUT_DATA MibGetInputData;
  46. PRIPMIB_BASE pRipBase = NULL;
  47. DWORD cbRipBase;
  48. SPMprMibBuffer spMib;
  49. PRIP_INTERFACE pRipIf = NULL;
  50. DWORD cbRipIf;
  51. DWORD cSent = 0;
  52. DWORD cRcvd = 0;
  53. DWORD dwErr;
  54. Assert(m_pIPXConn);
  55. MibGetInputData.TableId = RIP_BASE_ENTRY;
  56. dwErr = ::MprAdminMIBEntryGet(m_pIPXConn->GetMibHandle(),
  57. PID_IPX,
  58. IPX_PROTOCOL_RIP,
  59. &MibGetInputData,
  60. sizeof(MibGetInputData),
  61. (LPVOID *) &pRipBase,
  62. &cbRipBase);
  63. spMib = (LPBYTE) pRipBase;
  64. hr = HRESULT_FROM_WIN32(dwErr);
  65. CORg( hr );
  66. if (IsSubitemVisible(MVR_RIPPARAMS_OPER_STATE))
  67. {
  68. st = IpxOperStateToCString(pRipBase->RIPOperState);
  69. iPos = MapSubitemToColumn(MVR_RIPPARAMS_OPER_STATE);
  70. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) st);
  71. }
  72. spMib.Free();
  73. MibGetInputData.TableId = RIP_INTERFACE_TABLE;
  74. dwErr = MprAdminMIBEntryGetFirst(m_pIPXConn->GetMibHandle(),
  75. PID_IPX,
  76. IPX_PROTOCOL_RIP,
  77. &MibGetInputData,
  78. sizeof(MibGetInputData),
  79. (LPVOID *) &pRipIf,
  80. &cbRipIf);
  81. hr = HRESULT_FROM_WIN32(dwErr);
  82. spMib = (LPBYTE) pRipIf;
  83. while (FHrSucceeded(hr))
  84. {
  85. if (pRipIf->InterfaceIndex)
  86. {
  87. cSent += pRipIf->RipIfStats.RipIfOutputPackets;
  88. cRcvd += pRipIf->RipIfStats.RipIfInputPackets;
  89. }
  90. MibGetInputData.InterfaceIndex = pRipIf->InterfaceIndex;
  91. spMib.Free();
  92. pRipIf = NULL;
  93. dwErr = MprAdminMIBEntryGetNext(m_pIPXConn->GetMibHandle(),
  94. PID_IPX,
  95. IPX_PROTOCOL_RIP,
  96. &MibGetInputData,
  97. sizeof(MibGetInputData),
  98. (LPVOID *) &pRipIf,
  99. &cbRipIf);
  100. hr = HRESULT_FROM_WIN32(dwErr);
  101. spMib = (LPBYTE) pRipIf;
  102. }
  103. if (IsSubitemVisible(MVR_RIPPARAMS_SENT_PKTS))
  104. {
  105. FormatNumber(cSent, szNumber, DimensionOf(szNumber), FALSE);
  106. iPos = MapSubitemToColumn(MVR_RIPPARAMS_SENT_PKTS);
  107. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) szNumber);
  108. }
  109. if (IsSubitemVisible(MVR_RIPPARAMS_RCVD_PKTS))
  110. {
  111. FormatNumber(cRcvd, szNumber, DimensionOf(szNumber), FALSE);
  112. iPos = MapSubitemToColumn(MVR_RIPPARAMS_RCVD_PKTS);
  113. m_listCtrl.SetItemText(iPos, 1, (LPCTSTR) szNumber);
  114. }
  115. Error:
  116. return hr;
  117. }
  118. BOOL RIPParamsStatistics::OnInitDialog()
  119. {
  120. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  121. CString st;
  122. st.LoadString(IDS_STATS_RIPPARAMS_TITLE);
  123. SetWindowText((LPCTSTR) st);
  124. return IPXStatisticsDialog::OnInitDialog();
  125. }
  126. void RIPParamsStatistics::Sort(UINT)
  127. {
  128. }