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.

155 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. rxstats.c
  5. Abstract:
  6. Contains NetStatistics APIs:
  7. RxNetStatisticsGet
  8. Author:
  9. Richard Firth (rfirth) 20-May-1991
  10. Environment:
  11. Win-32/flat address space
  12. Revision History:
  13. 20-May-1991 RFirth
  14. Created
  15. 13-Sep-1991 JohnRo
  16. Made changes suggested by PC-LINT.
  17. 25-Sep-1991 JohnRo
  18. Fixed MIPS build problems.
  19. 01-Apr-1992 JohnRo
  20. Use NetApiBufferAllocate() instead of private version.
  21. --*/
  22. #include "downlevl.h"
  23. #include <rxstats.h>
  24. #include <lmstats.h>
  25. #include <lmsvc.h>
  26. NET_API_STATUS
  27. RxNetStatisticsGet(
  28. IN LPTSTR ServerName,
  29. IN LPTSTR ServiceName,
  30. IN DWORD Level,
  31. IN DWORD Options,
  32. OUT LPBYTE* Buffer
  33. )
  34. /*++
  35. Routine Description:
  36. Retrieves statistics from a designated service running at a down-level
  37. server. Currently, the only services recognised are:
  38. SERVER
  39. WORKSTATION
  40. Arguments:
  41. ServerName - Where to run the API
  42. ServiceName - Pointer to string designating service to get stats for
  43. Level - At which to get info. Allowable levels are: 0
  44. Options - Flags. Currently defined bits are:
  45. 0 Clear Statistics
  46. 1-31 Reserved. MBZ
  47. Buffer - Pointer to pointer to returned buffer containing stats
  48. Return Value:
  49. NET_API_STATUS
  50. Success - NERR_Success
  51. Failure - ERROR_NOT_SUPPORTED
  52. ServiceName was not "WORKSTATION" or "SERVER"
  53. --*/
  54. {
  55. LPDESC pDesc16, pDesc32, pDescSmb;
  56. LPBYTE bufptr;
  57. DWORD buflen, total_avail;
  58. NET_API_STATUS rc;
  59. UNREFERENCED_PARAMETER(Level);
  60. *Buffer = NULL;
  61. //
  62. // If there are any other options set other than the CLEAR bit, return an
  63. // error - we may allow extra options in NT, but down-level only knows
  64. // about this one
  65. //
  66. if (Options & ~STATSOPT_CLR) {
  67. return ERROR_INVALID_PARAMETER;
  68. }
  69. //
  70. // get the data descriptor strings and size of the returned buffer based
  71. // on the service name string. If statistics for new services are made
  72. // available then this code must be extended to use the correct, new,
  73. // descriptor strings. Hence we return an error here if the string is not
  74. // recognised, although it may be valid under NT
  75. //
  76. if (!STRCMP(ServiceName, (LPTSTR) SERVICE_SERVER)) {
  77. pDesc16 = REM16_stat_server_0;
  78. pDesc32 = REM32_stat_server_0;
  79. pDescSmb = REMSmb_stat_server_0;
  80. buflen = sizeof(STAT_SERVER_0);
  81. ServiceName = SERVICE_LM20_SERVER;
  82. } else if (!STRCMP(ServiceName, (LPTSTR) SERVICE_WORKSTATION)) {
  83. pDesc16 = REM16_stat_workstation_0;
  84. pDesc32 = REM32_stat_workstation_0;
  85. pDescSmb = REMSmb_stat_workstation_0;
  86. buflen = sizeof(STAT_WORKSTATION_0);
  87. ServiceName = SERVICE_LM20_WORKSTATION;
  88. } else {
  89. return ERROR_NOT_SUPPORTED;
  90. }
  91. //
  92. // standard retrieve buffer from down-level server type of thing: alloc
  93. // buffer, do RxRemoteApi call, return buffer or throw away if error
  94. //
  95. if (rc = NetApiBufferAllocate(buflen, (LPVOID *) &bufptr)) {
  96. return rc;
  97. }
  98. rc = RxRemoteApi(API_WStatisticsGet2, // API #
  99. ServerName, // where to do it
  100. REM16_NetStatisticsGet2_P, // parameter string
  101. pDesc16, // 16-bit data descriptor
  102. pDesc32, // 32-bit data descriptor
  103. pDescSmb, // SMB data descriptor
  104. NULL, NULL, NULL, // no aux structures
  105. FALSE, // user must be logged on
  106. ServiceName, // first API parameter after ServerName
  107. 0, // RESERVED
  108. 0, // Level MBZ
  109. Options, // whatever caller supplied
  110. bufptr, // locally allocated stats buffer
  111. buflen, // size of stats buffer
  112. &total_avail // not used on 32-bit side
  113. );
  114. if (rc) {
  115. (void) NetApiBufferFree(bufptr);
  116. } else {
  117. *Buffer = bufptr;
  118. }
  119. return rc;
  120. }