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.

292 lines
11 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. SrvEquiv.c
  5. Abstract:
  6. This file contains support code to convert between old and new server
  7. info levels.
  8. Author:
  9. John Rogers (JohnRo) 02-May-1991
  10. Environment:
  11. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  12. Requires ANSI C extensions: slash-slash comments, long external names.
  13. Revision History:
  14. 02-May-1991 JohnRo
  15. Created.
  16. 09-May-1991 JohnRo
  17. Made some LINT-suggested changes.
  18. 28-May-1991 JohnRo
  19. Added incomplete output parm to RxGetServerInfoLevelEquivalent.
  20. 14-Jun-1991 JohnRo
  21. Correct IncompleteOutput values.
  22. 17-Jul-1991 JohnRo
  23. Extracted RxpDebug.h from Rxp.h.
  24. 21-Nov-1991 JohnRo
  25. Removed NT dependencies to reduce recompiles.
  26. 26-Aug-1992 JohnRo
  27. RAID 4463: NetServerGetInfo(level 3) to downlevel: assert in convert.c.
  28. Use PREFIX_ equates.
  29. --*/
  30. // These must be included first:
  31. #include <windef.h> // IN, LPVOID, etc.
  32. #include <lmcons.h> // NET_API_STATUS.
  33. // These may be included in any order:
  34. #include <dlserver.h> // Old info levels, MAX_ stuff, my prototype.
  35. #include <lmerr.h> // NERR_ and ERROR_ equates.
  36. #include <lmserver.h> // New info level structures.
  37. #include <netdebug.h> // NetpKdPrint(()), FORMAT_ equates, etc.
  38. #include <netlib.h> // NetpPointerPlusSomeBytes(), etc.
  39. #include <prefix.h> // PREFIX_ equates.
  40. #include <rap.h> // LPDESC, etc.
  41. #include <remdef.h> // REM16_ REM32_, and REMSmb_ equates.
  42. #include <rxpdebug.h> // IF_DEBUG().
  43. #include <rxserver.h> // My prototype.
  44. NET_API_STATUS
  45. RxGetServerInfoLevelEquivalent (
  46. IN DWORD FromLevel,
  47. IN BOOL FromNative,
  48. IN BOOL ToNative,
  49. OUT LPDWORD ToLevel,
  50. OUT LPDESC * ToDataDesc16 OPTIONAL,
  51. OUT LPDESC * ToDataDesc32 OPTIONAL,
  52. OUT LPDESC * ToDataDescSmb OPTIONAL,
  53. OUT LPDWORD FromMaxSize OPTIONAL,
  54. OUT LPDWORD FromFixedSize OPTIONAL,
  55. OUT LPDWORD FromStringSize OPTIONAL,
  56. OUT LPDWORD ToMaxSize OPTIONAL,
  57. OUT LPDWORD ToFixedSize OPTIONAL,
  58. OUT LPDWORD ToStringSize OPTIONAL,
  59. OUT LPBOOL IncompleteOutput OPTIONAL // incomplete (except platform ID)
  60. )
  61. /*++
  62. Routine Description:
  63. Arguments:
  64. Return Value:
  65. NET_API_STATUS - NERR_Success or ERROR_INVALID_LEVEL.
  66. --*/
  67. {
  68. // LPDESC FromDataDesc; // Desc for data we've got.
  69. // LPBYTE ToStringArea;
  70. NetpAssert(FromNative == TRUE);
  71. UNREFERENCED_PARAMETER(FromNative);
  72. NetpAssert(ToNative == TRUE);
  73. UNREFERENCED_PARAMETER(ToNative);
  74. IF_DEBUG(SERVER) {
  75. NetpKdPrint(( PREFIX_NETAPI
  76. "RxGetServerInfoLevelEquivalent: starting, "
  77. "FromLevel=" FORMAT_DWORD ".\n", FromLevel));
  78. }
  79. //
  80. // Decide what to do based on the info level. Note that normally we'd
  81. // be using REM16_, REM32_, and REMSmb_ descriptors here. However,
  82. // the REM16_ and REM32_ ones have been modified to reflect a nonexistant
  83. // field (svX_platform_id). This messes up the automatic conversions
  84. // done by RxRemoteApi. So, we use "downlevel" descriptors (DL_REM16_
  85. // and DL_REM32_) which are defined in DlServer.h.
  86. //
  87. switch (FromLevel) {
  88. case 0 :
  89. // 0 is equivalent to level 100 (minus the platform ID).
  90. NetpSetOptionalArg(ToLevel, 100);
  91. NetpSetOptionalArg(ToDataDesc16, NULL);
  92. NetpSetOptionalArg(ToDataDesc32, REM32_server_info_100);
  93. NetpSetOptionalArg(ToDataDescSmb, NULL);
  94. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_0_TOTAL_SIZE);
  95. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_0));
  96. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_0_STRING_SIZE);
  97. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_0_TOTAL_SIZE);
  98. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_100_TOTAL_SIZE);
  99. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_100));
  100. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_100_STRING_SIZE);
  101. NetpSetOptionalArg(IncompleteOutput, FALSE); // all but platform ID
  102. // FromDataDesc = REM32_server_info_0;
  103. // ToDataDesc = REM32_server_info_100;
  104. break;
  105. case 1 :
  106. // 1 is equivalent to level 101 (minus the platform ID).
  107. NetpSetOptionalArg(ToLevel, 101);
  108. NetpSetOptionalArg(ToDataDesc16, NULL);
  109. NetpSetOptionalArg(ToDataDesc32, REM32_server_info_101);
  110. NetpSetOptionalArg(ToDataDescSmb, NULL);
  111. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_1_TOTAL_SIZE);
  112. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_1));
  113. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_1_STRING_SIZE);
  114. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_101_TOTAL_SIZE);
  115. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_101));
  116. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_101_STRING_SIZE);
  117. NetpSetOptionalArg(IncompleteOutput, FALSE); // all but platform ID
  118. break;
  119. case 100 :
  120. // 100 is superset of level 0.
  121. NetpSetOptionalArg(ToLevel, 0);
  122. NetpSetOptionalArg(ToDataDesc16, DL_REM16_server_info_0);
  123. NetpSetOptionalArg(ToDataDesc32, DL_REM32_server_info_0);
  124. NetpSetOptionalArg(ToDataDescSmb, REMSmb_server_info_0);
  125. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_100_TOTAL_SIZE);
  126. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_100));
  127. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_100_STRING_SIZE);
  128. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_0_TOTAL_SIZE);
  129. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_0));
  130. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_0_STRING_SIZE);
  131. NetpSetOptionalArg(IncompleteOutput, FALSE);
  132. // FromDataDesc = REM32_server_info_100;
  133. // ToDataDesc = REM32_server_info_0;
  134. break;
  135. case 101 :
  136. // 101 is superset of 1.
  137. NetpSetOptionalArg(ToLevel, 1);
  138. NetpSetOptionalArg(ToDataDesc16, DL_REM16_server_info_1);
  139. NetpSetOptionalArg(ToDataDesc32, DL_REM32_server_info_1);
  140. NetpSetOptionalArg(ToDataDescSmb, REMSmb_server_info_1);
  141. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_101_TOTAL_SIZE);
  142. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_101));
  143. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_101_STRING_SIZE);
  144. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_1_TOTAL_SIZE);
  145. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_1));
  146. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_1_STRING_SIZE);
  147. NetpSetOptionalArg(IncompleteOutput, FALSE);
  148. // FromDataDesc = REM32_server_info_101;
  149. // ToDataDesc = REM32_server_info_1;
  150. break;
  151. case 102 :
  152. // Level 102 is a subset of old level 2.
  153. NetpSetOptionalArg(ToLevel, 2);
  154. NetpSetOptionalArg(ToDataDesc16, DL_REM16_server_info_2);
  155. NetpSetOptionalArg(ToDataDesc32, DL_REM32_server_info_2);
  156. NetpSetOptionalArg(ToDataDescSmb, REMSmb_server_info_2);
  157. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_102_TOTAL_SIZE);
  158. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_102));
  159. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_102_STRING_SIZE);
  160. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_2_TOTAL_SIZE);
  161. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_2));
  162. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_2_STRING_SIZE);
  163. NetpSetOptionalArg(IncompleteOutput, TRUE);
  164. // FromDataDesc = REM32_server_info_102;
  165. // ToDataDesc = REM32_server_info_2;
  166. break;
  167. case 402 :
  168. // Level 402 is a subset of old level 2.
  169. NetpSetOptionalArg(ToLevel, 2);
  170. NetpSetOptionalArg(ToDataDesc16, DL_REM16_server_info_2);
  171. NetpSetOptionalArg(ToDataDesc32, DL_REM32_server_info_2);
  172. NetpSetOptionalArg(ToDataDescSmb, REMSmb_server_info_2);
  173. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_402_TOTAL_SIZE);
  174. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_402));
  175. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_402_STRING_SIZE);
  176. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_2_TOTAL_SIZE);
  177. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_2));
  178. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_2_STRING_SIZE);
  179. NetpSetOptionalArg(IncompleteOutput, TRUE);
  180. // FromDataDesc = REM32_server_info_402;
  181. // ToDataDesc = REM32_server_info_2;
  182. break;
  183. case 403 :
  184. // Level 403 is a subset of old level 3.
  185. NetpSetOptionalArg(ToLevel, 3);
  186. NetpSetOptionalArg(ToDataDesc16, DL_REM16_server_info_3);
  187. NetpSetOptionalArg(ToDataDesc32, DL_REM32_server_info_3);
  188. NetpSetOptionalArg(ToDataDescSmb, REMSmb_server_info_3);
  189. NetpSetOptionalArg(FromMaxSize, MAX_LEVEL_403_TOTAL_SIZE);
  190. NetpSetOptionalArg(FromFixedSize, sizeof(SERVER_INFO_403));
  191. NetpSetOptionalArg(FromStringSize, MAX_LEVEL_403_STRING_SIZE);
  192. NetpSetOptionalArg(ToMaxSize, MAX_LEVEL_3_TOTAL_SIZE);
  193. NetpSetOptionalArg(ToFixedSize, sizeof(SERVER_INFO_3));
  194. NetpSetOptionalArg(ToStringSize, MAX_LEVEL_3_STRING_SIZE);
  195. NetpSetOptionalArg(IncompleteOutput, TRUE);
  196. // FromDataDesc = REM32_server_info_403;
  197. // ToDataDesc = REM32_server_info_3;
  198. break;
  199. default :
  200. return (ERROR_INVALID_LEVEL);
  201. }
  202. IF_DEBUG(SERVER) {
  203. NetpKdPrint(( PREFIX_NETAPI
  204. "RxGetServerInfoLevelEquivalent: returning:\n"));
  205. if ( ToLevel != NULL ) {
  206. NetpKdPrint((" ToLevel=" FORMAT_DWORD "\n", *ToLevel));
  207. }
  208. if (ToDataDesc16 != NULL) {
  209. NetpKdPrint((" ToDataDesc16=" FORMAT_LPDESC "\n", *ToDataDesc16));
  210. }
  211. if (ToDataDesc32 != NULL) {
  212. NetpKdPrint((" ToDataDesc32=" FORMAT_LPDESC "\n", *ToDataDesc32));
  213. }
  214. if (ToDataDescSmb != NULL) {
  215. NetpKdPrint((" ToDataDescSmb=" FORMAT_LPDESC "\n", *ToDataDescSmb));
  216. }
  217. if (FromMaxSize != NULL) {
  218. NetpKdPrint((" FromMaxSize=" FORMAT_DWORD "\n", *FromMaxSize));
  219. }
  220. if (FromFixedSize != NULL) {
  221. NetpKdPrint((" FromFixedSize=" FORMAT_DWORD "\n", *FromFixedSize));
  222. }
  223. if (FromStringSize != NULL) {
  224. NetpKdPrint((" FromStringSize=" FORMAT_DWORD "\n", *FromStringSize));
  225. }
  226. if (ToMaxSize != NULL) {
  227. NetpKdPrint((" ToMaxSize=" FORMAT_DWORD "\n", *ToMaxSize));
  228. }
  229. if (ToFixedSize != NULL) {
  230. NetpKdPrint((" ToFixedSize=" FORMAT_DWORD "\n", *ToFixedSize));
  231. }
  232. if (ToStringSize != NULL) {
  233. NetpKdPrint((" ToStringSize=" FORMAT_DWORD "\n", *ToStringSize));
  234. }
  235. if (IncompleteOutput != NULL) {
  236. if (*IncompleteOutput) {
  237. NetpKdPrint((" IncompleteOutput=TRUE.\n" ));
  238. } else {
  239. NetpKdPrint((" IncompleteOutput=FALSE.\n" ));
  240. }
  241. }
  242. }
  243. return (NERR_Success);
  244. } // RxGetServerInfoLevelEquivalent