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.

364 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. rxmsg.c
  5. Abstract:
  6. Routines in this module implement the functionality required to remote the
  7. NetMessage APIs to down-level servers
  8. Contains RxNetMessage routines:
  9. RxNetMessageBufferSend
  10. RxNetMessageNameAdd
  11. RxNetMessageNameDel
  12. RxNetMessageNameEnum
  13. RxNetMessageNameGetInfo
  14. Author:
  15. Richard L Firth (rfirth) 20-May-1991
  16. Environment:
  17. Win-32/flat address space
  18. Notes:
  19. Routines in this module assume that caller-supplied parameters have
  20. already been verified. No effort is made to further check the veracity
  21. of parms. Any actions causing exceptions must be trapped at a higher
  22. level. This applies to ALL parameters - strings, pointers, buffers, etc.
  23. Revision History:
  24. 20-May-1991 rfirth
  25. Created
  26. 16-Sep-1991 JohnRo
  27. Made changes as suggested by PC-LINT.
  28. 25-Sep-1991 JohnRo
  29. Fixed MIPS build problems.
  30. 05-Dec-1991 RFirth
  31. Enum returns in TotalEntries (or EntriesLeft) the number of items to
  32. be enumerated BEFORE this call. Used to be number left after this call
  33. 01-Apr-1992 JohnRo
  34. Use NetApiBufferAllocate() instead of private version.
  35. --*/
  36. #include "downlevl.h"
  37. #include <rxmsg.h>
  38. #include <lmmsg.h>
  39. NET_API_STATUS
  40. RxNetMessageBufferSend(
  41. IN LPTSTR ServerName,
  42. IN LPTSTR Recipient,
  43. IN LPTSTR Sender OPTIONAL,
  44. IN LPBYTE Buffer,
  45. IN DWORD BufLen
  46. )
  47. /*++
  48. Routine Description:
  49. Allows a down-level server to send a message buffer to a registered message
  50. recipient
  51. Arguments:
  52. ServerName - Which down-level server to run this API on
  53. Recipient - Message name to send buffer to
  54. Sender - Optional name used to supply computer name, not logged on user
  55. Buffer - Pointer to buffer containing message to send
  56. BufLen - size of buffer being sent (bytes)
  57. Return Value:
  58. NET_API_STATUS
  59. Success - NERR_Success
  60. Failure - (Return code from down-level NetMessageBufferSend)
  61. --*/
  62. {
  63. UNREFERENCED_PARAMETER(Sender);
  64. return RxRemoteApi(API_WMessageBufferSend, // API #
  65. ServerName, // where to do it
  66. REMSmb_NetMessageBufferSend_P, // parameter descriptor
  67. NULL, NULL, NULL, // no primary data descriptors
  68. NULL, NULL, NULL, // or secondaries
  69. FALSE, // can't use NULL session
  70. Recipient, // API params start here
  71. Buffer,
  72. BufLen
  73. );
  74. }
  75. NET_API_STATUS
  76. RxNetMessageNameAdd(
  77. IN LPTSTR ServerName,
  78. IN LPTSTR MessageName
  79. )
  80. /*++
  81. Routine Description:
  82. Adds a messaging name at a down-level server
  83. Arguments:
  84. ServerName - Which down-level server to run this API on
  85. MessageName - to add
  86. Return Value:
  87. NET_API_STATUS
  88. Success - NERR_Success
  89. Failure - (Return code from down-level NetMessageNameAdd)
  90. --*/
  91. {
  92. return RxRemoteApi(API_WMessageNameAdd, // API #
  93. ServerName, // where to do it
  94. REMSmb_NetMessageNameAdd_P, // parameter descriptor
  95. NULL, NULL, NULL, // no primary data descriptors
  96. NULL, NULL, NULL, // or secondaries
  97. FALSE, // can't use NULL session
  98. MessageName, // API params start here
  99. 0 // error if name forwarded
  100. );
  101. }
  102. NET_API_STATUS
  103. RxNetMessageNameDel(
  104. IN LPTSTR ServerName,
  105. IN LPTSTR MessageName
  106. )
  107. /*++
  108. Routine Description:
  109. Deletes a messaging name at a down-level server
  110. Arguments:
  111. ServerName - Which down-level server to run this API on
  112. MessageName - to delete
  113. Return Value:
  114. NET_API_STATUS
  115. Success - NERR_Success
  116. Failure - (Return code from down-level NetMessageNameDel)
  117. --*/
  118. {
  119. return RxRemoteApi(API_WMessageNameDel, // API #
  120. ServerName, // where to do it
  121. REMSmb_NetMessageNameDel_P, // parameter descriptor
  122. NULL, NULL, NULL, // no primary data descriptors
  123. NULL, NULL, NULL, // or secondaries
  124. FALSE, // can't use NULL session
  125. MessageName, // API params start here
  126. 0 // error if name forwarded
  127. );
  128. }
  129. NET_API_STATUS
  130. RxNetMessageNameEnum(
  131. IN LPTSTR ServerName,
  132. IN DWORD Level,
  133. OUT LPBYTE* Buffer,
  134. IN DWORD PrefMaxLen,
  135. OUT LPDWORD EntriesRead,
  136. OUT LPDWORD EntriesLeft,
  137. IN OUT LPDWORD ResumeHandle OPTIONAL
  138. )
  139. /*++
  140. Routine Description:
  141. description-of-function.
  142. Arguments:
  143. ServerName - Which down-level server to run this API on
  144. Level - Of info to return - 0 or 1
  145. Buffer - Pointer to returned buffer
  146. PrefMaxLen - Caller's preferred maximum size of Buffer
  147. EntriesRead - Number of entries returned in Buffer
  148. EntriesLeft - Number of entries left to enumerate
  149. ResumeHandle- Where to resume if all entries not returned. IGNORED
  150. Return Value:
  151. NET_API_STATUS
  152. Success - NERR_Success
  153. Failure - ERROR_INVALID_LEVEL
  154. (return code from down-level NetMessageNameEnum)
  155. --*/
  156. {
  157. NET_API_STATUS rc;
  158. LPBYTE bufptr;
  159. LPDESC pDesc16, pDesc32, pDescSmb;
  160. DWORD entries_read, total_entries;
  161. UNREFERENCED_PARAMETER(PrefMaxLen);
  162. UNREFERENCED_PARAMETER(ResumeHandle);
  163. *Buffer = NULL;
  164. *EntriesRead = *EntriesLeft = 0;
  165. switch (Level) {
  166. case 0:
  167. pDesc16 = REM16_msg_info_0;
  168. pDesc32 = REM32_msg_info_0;
  169. pDescSmb = REMSmb_msg_info_0;
  170. break;
  171. case 1:
  172. pDesc16 = REM16_msg_info_1;
  173. pDesc32 = REM32_msg_info_1;
  174. pDescSmb = REMSmb_msg_info_1;
  175. break;
  176. default:
  177. return ERROR_INVALID_LEVEL;
  178. }
  179. bufptr = NULL;
  180. rc = RxRemoteApi(API_WMessageNameEnum, // API #
  181. ServerName, // where to do it
  182. REMSmb_NetMessageNameEnum_P, // parameter descriptor
  183. pDesc16, // 16-bit data descriptor
  184. pDesc32, // 32-bit data descriptor
  185. pDescSmb, // SMB data descriptor
  186. NULL, NULL, NULL, // no secondary structures
  187. ALLOCATE_RESPONSE,
  188. Level, // API params start here
  189. &bufptr,
  190. 65535,
  191. &entries_read,
  192. &total_entries
  193. );
  194. if (rc) {
  195. if (bufptr) {
  196. (void) NetApiBufferFree(bufptr);
  197. }
  198. } else {
  199. *Buffer = bufptr;
  200. *EntriesLeft = total_entries;
  201. *EntriesRead = entries_read;
  202. }
  203. return rc;
  204. }
  205. NET_API_STATUS
  206. RxNetMessageNameGetInfo(
  207. IN LPTSTR ServerName,
  208. IN LPTSTR MessageName,
  209. IN DWORD Level,
  210. OUT LPBYTE* Buffer
  211. )
  212. /*++
  213. Routine Description:
  214. Retrieves information about a specific message name from a down-level
  215. server
  216. Arguments:
  217. ServerName - Which down-level server to run this API on
  218. MessageName - Name to get info for
  219. Level - Of info required - 0 or 1
  220. Buffer - Where to return buffer containing info
  221. Return Value:
  222. NET_API_STATUS
  223. Success - NERR_Success
  224. Failure - ERROR_INVALID_LEVEL
  225. (return code from down-level NetMessageNameGetInfo API)
  226. --*/
  227. {
  228. NET_API_STATUS rc;
  229. LPDESC pDesc16, pDesc32, pDescSmb;
  230. LPBYTE bufptr;
  231. DWORD buflen, total_avail;
  232. *Buffer = NULL;
  233. switch (Level) {
  234. case 0:
  235. pDesc16 = REM16_msg_info_0;
  236. pDesc32 = REM32_msg_info_0;
  237. pDescSmb = REMSmb_msg_info_0;
  238. buflen = sizeof(MSG_INFO_0) + STRING_SPACE_REQD(UNLEN);
  239. break;
  240. case 1:
  241. pDesc16 = REM16_msg_info_1;
  242. pDesc32 = REM32_msg_info_1;
  243. pDescSmb = REMSmb_msg_info_1;
  244. buflen = sizeof(MSG_INFO_1) + STRING_SPACE_REQD(2 * UNLEN);
  245. break;
  246. default:
  247. return ERROR_INVALID_LEVEL;
  248. }
  249. if (rc = NetApiBufferAllocate(buflen, (LPVOID *) &bufptr)) {
  250. return rc;
  251. }
  252. rc = RxRemoteApi(API_WMessageNameGetInfo, // API #
  253. ServerName, // where to do it
  254. REMSmb_NetMessageNameGetInfo_P, // parameter descriptor
  255. pDesc16, // 16-bit data descriptor
  256. pDesc32, // 32-bit data descriptor
  257. pDescSmb, // SMB data descriptor
  258. NULL, NULL, NULL, // no secondary structures
  259. FALSE, // can't use NULL session
  260. MessageName, // first parameter
  261. Level,
  262. bufptr,
  263. buflen,
  264. &total_avail // not used in 32-bit side
  265. );
  266. if (rc) {
  267. (void) NetApiBufferFree(bufptr);
  268. } else {
  269. *Buffer = bufptr;
  270. }
  271. return rc;
  272. }