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.

275 lines
7.3 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: stats.c
  7. //
  8. // Description: This module contains support routines for the statistics
  9. // category API's for the AFP server service. These routines
  10. // are called by the RPC runtime.
  11. //
  12. // History:
  13. // July 21,1992. NarenG Created original version.
  14. //
  15. #include "afpsvcp.h"
  16. //**
  17. //
  18. // Call: AfpAdminrStatisticsGet
  19. //
  20. // Returns: NO_ERROR
  21. // ERROR_ACCESS_DENIED
  22. // non-zero returns from AfpServerIOCtrlGetInfo
  23. //
  24. // Description: This routine communicates with the AFP FSD to implement
  25. // the AfpAdminStatisticsGet function.
  26. //
  27. DWORD
  28. AfpAdminrStatisticsGet(
  29. IN AFP_SERVER_HANDLE hServer,
  30. OUT PAFP_STATISTICS_INFO* ppAfpStatisticsInfo
  31. )
  32. {
  33. AFP_REQUEST_PACKET AfpSrp;
  34. DWORD dwRetCode=0;
  35. DWORD dwAccessStatus=0;
  36. AFP_STATISTICS_INFO afpStats;
  37. // Check if caller has access
  38. //
  39. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  40. {
  41. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsGet, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  42. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  43. dwRetCode, EVENTLOG_ERROR_TYPE );
  44. return( ERROR_ACCESS_DENIED );
  45. }
  46. if ( dwAccessStatus )
  47. {
  48. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsGet, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  49. return( ERROR_ACCESS_DENIED );
  50. }
  51. // Set up request packet and make IOCTL to the FSD
  52. //
  53. AfpSrp.dwRequestCode = OP_GET_STATISTICS;
  54. AfpSrp.dwApiType = AFP_API_TYPE_GETINFO;
  55. AfpSrp.Type.GetInfo.pInputBuf = &afpStats;
  56. AfpSrp.Type.GetInfo.cbInputBufSize = sizeof( afpStats );
  57. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  58. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  59. return( dwRetCode );
  60. *ppAfpStatisticsInfo = (PAFP_STATISTICS_INFO)AfpSrp.Type.GetInfo.pOutputBuf;
  61. return( dwRetCode );
  62. }
  63. //**
  64. //
  65. // Call: AfpAdminrStatisticsGetEx
  66. //
  67. // Returns: NO_ERROR
  68. // ERROR_ACCESS_DENIED
  69. // non-zero returns from AfpServerIOCtrlGetInfo
  70. //
  71. // Description: This routine communicates with the AFP FSD to implement
  72. // the AfpAdminStatisticsGet function.
  73. //
  74. DWORD
  75. AfpAdminrStatisticsGetEx(
  76. IN AFP_SERVER_HANDLE hServer,
  77. OUT PAFP_STATISTICS_INFO_EX* ppAfpStatisticsInfo
  78. )
  79. {
  80. AFP_REQUEST_PACKET AfpSrp;
  81. DWORD dwRetCode=0;
  82. DWORD dwAccessStatus=0;
  83. AFP_STATISTICS_INFO_EX afpStats;
  84. // Check if caller has access
  85. //
  86. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  87. {
  88. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsGetEx, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  89. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  90. dwRetCode, EVENTLOG_ERROR_TYPE );
  91. return( ERROR_ACCESS_DENIED );
  92. }
  93. if ( dwAccessStatus )
  94. {
  95. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsGetEx, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  96. return( ERROR_ACCESS_DENIED );
  97. }
  98. // Set up request packet and make IOCTL to the FSD
  99. //
  100. AfpSrp.dwRequestCode = OP_GET_STATISTICS_EX;
  101. AfpSrp.dwApiType = AFP_API_TYPE_GETINFO;
  102. AfpSrp.Type.GetInfo.pInputBuf = &afpStats;
  103. AfpSrp.Type.GetInfo.cbInputBufSize = sizeof( afpStats );
  104. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  105. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  106. return( dwRetCode );
  107. *ppAfpStatisticsInfo = (PAFP_STATISTICS_INFO_EX)AfpSrp.Type.GetInfo.pOutputBuf;
  108. return( dwRetCode );
  109. }
  110. //**
  111. //
  112. // Call: AfpAdminrStatisticsClear
  113. //
  114. // Returns: NO_ERROR
  115. // ERROR_ACCESS_DENIED
  116. // non-zero returns from AfpServerIOCtrlGetInfo
  117. //
  118. // Description: This routine communicates with the AFP FSD to implement
  119. // the AfpAdminFileClose function.
  120. //
  121. DWORD
  122. AfpAdminrStatisticsClear(
  123. IN AFP_SERVER_HANDLE hServer
  124. )
  125. {
  126. AFP_REQUEST_PACKET AfpSrp;
  127. DWORD dwAccessStatus=0;
  128. DWORD dwRetCode=0;
  129. // Check if caller has access
  130. //
  131. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  132. {
  133. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsClear, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  134. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  135. dwRetCode, EVENTLOG_ERROR_TYPE );
  136. return( ERROR_ACCESS_DENIED );
  137. }
  138. if ( dwAccessStatus )
  139. {
  140. AFP_PRINT(( "SFMSVC: AfpAdminrStatisticsClear, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  141. return( ERROR_ACCESS_DENIED );
  142. }
  143. // IOCTL the FSD to clear the statistics
  144. //
  145. AfpSrp.dwRequestCode = OP_CLEAR_STATISTICS;
  146. AfpSrp.dwApiType = AFP_API_TYPE_COMMAND;
  147. return ( AfpServerIOCtrl( &AfpSrp ) );
  148. }
  149. //**
  150. //
  151. // Call: AfpAdminrProfileGet
  152. //
  153. // Returns: NO_ERROR
  154. // ERROR_ACCESS_DENIED
  155. // non-zero returns from AfpServerIOCtrlGetInfo
  156. //
  157. // Description: This routine communicates with the AFP FSD to implement
  158. // the AfpAdminProfileGet function.
  159. //
  160. DWORD
  161. AfpAdminrProfileGet(
  162. IN AFP_SERVER_HANDLE hServer,
  163. OUT PAFP_PROFILE_INFO * ppAfpProfileInfo
  164. )
  165. {
  166. AFP_REQUEST_PACKET AfpSrp;
  167. DWORD dwRetCode=0;
  168. DWORD dwAccessStatus=0;
  169. AFP_PROFILE_INFO afpProfs;
  170. // Check if caller has access
  171. //
  172. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  173. {
  174. AFP_PRINT(( "SFMSVC: AfpAdminrProfileGet, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  175. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  176. dwRetCode, EVENTLOG_ERROR_TYPE );
  177. return( ERROR_ACCESS_DENIED );
  178. }
  179. if ( dwAccessStatus )
  180. {
  181. AFP_PRINT(( "SFMSVC: AfpAdminrProfileGet, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  182. return( ERROR_ACCESS_DENIED );
  183. }
  184. // Set up request packet and make IOCTL to the FSD
  185. //
  186. AfpSrp.dwRequestCode = OP_GET_PROF_COUNTERS;
  187. AfpSrp.dwApiType = AFP_API_TYPE_GETINFO;
  188. AfpSrp.Type.GetInfo.pInputBuf = &afpProfs;
  189. AfpSrp.Type.GetInfo.cbInputBufSize = sizeof( afpProfs );
  190. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  191. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  192. return( dwRetCode );
  193. *ppAfpProfileInfo = (PAFP_PROFILE_INFO)AfpSrp.Type.GetInfo.pOutputBuf;
  194. return( dwRetCode );
  195. }
  196. //**
  197. //
  198. // Call: AfpAdminrProfileClear
  199. //
  200. // Returns: NO_ERROR
  201. // ERROR_ACCESS_DENIED
  202. // non-zero returns from AfpServerIOCtrlGetInfo
  203. //
  204. // Description: This routine communicates with the AFP FSD to implement
  205. // the AfpAdminProfileClear function.
  206. //
  207. DWORD
  208. AfpAdminrProfileClear(
  209. IN AFP_SERVER_HANDLE hServer
  210. )
  211. {
  212. AFP_REQUEST_PACKET AfpSrp;
  213. DWORD dwAccessStatus=0;
  214. DWORD dwRetCode=0;
  215. // Check if caller has access
  216. //
  217. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  218. {
  219. AFP_PRINT(( "SFMSVC: AfpAdminrProfileClear, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  220. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  221. dwRetCode, EVENTLOG_ERROR_TYPE );
  222. return( ERROR_ACCESS_DENIED );
  223. }
  224. if ( dwAccessStatus )
  225. {
  226. AFP_PRINT(( "SFMSVC: AfpAdminrProfileClear, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  227. return( ERROR_ACCESS_DENIED );
  228. }
  229. // IOCTL the FSD to clear the statistics
  230. //
  231. AfpSrp.dwRequestCode = OP_CLEAR_PROF_COUNTERS;
  232. AfpSrp.dwApiType = AFP_API_TYPE_COMMAND;
  233. return ( AfpServerIOCtrl( &AfpSrp ) );
  234. }