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.

1180 lines
28 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ApiChDev.c
  5. Abstract:
  6. This module contains individual API handlers for the NetCharDev
  7. and NetCharDevQ APIs. Supported APIs are NetCharDevControl,
  8. NetCharDevEnum, NetCharDevGetInfo, NetCharDevQEnum, NetCharDevQGetInfo,
  9. NetCharDevQPurge, NetCharDevQPurgeSelf, and NetCharDevQSetInfo.
  10. SUPPORTED: NetCharDevControl, NetCharDevEnum, NetCharDevGetInfo,
  11. NetCharDevQEnum, NetCharDevQGetInfo, NetCharDevQPurge,
  12. NetCharDevQPurgeSelf, NetCharDevQSetInfo.
  13. !!! Remove handlers for unsupported APIs when done.
  14. Author:
  15. Shanku Niyogi (w-shanku) 06-Mar-1991
  16. Revision History:
  17. --*/
  18. #include "XactSrvP.h"
  19. //
  20. // Declaration of descriptor strings.
  21. //
  22. #if 0
  23. STATIC const LPDESC Desc16_chardev_info_0 = REM16_chardev_info_0;
  24. STATIC const LPDESC Desc32_chardev_info_0 = REM32_chardev_info_0;
  25. STATIC const LPDESC Desc16_chardev_info_1 = REM16_chardev_info_1;
  26. STATIC const LPDESC Desc32_chardev_info_1 = REM32_chardev_info_1;
  27. STATIC const LPDESC Desc16_chardevQ_info_0 = REM16_chardevQ_info_0;
  28. STATIC const LPDESC Desc32_chardevQ_info_0 = REM32_chardevQ_info_0;
  29. STATIC const LPDESC Desc16_chardevQ_info_1 = REM16_chardevQ_info_1;
  30. STATIC const LPDESC Desc32_chardevQ_info_1 = REM32_chardevQ_info_1;
  31. STATIC const LPDESC Desc16_chardevQ_info_1_setinfo
  32. = REM16_chardevQ_info_1_setinfo;
  33. STATIC const LPDESC Desc32_chardevQ_info_1_setinfo
  34. = REM32_chardevQ_info_1_setinfo;
  35. #endif
  36. #define RETURN_CHARDEV_NOT_SUPPORTED \
  37. API_HANDLER_PARAMETERS_REFERENCE; \
  38. Header->Status = ERROR_NOT_SUPPORTED;
  39. NTSTATUS
  40. XsNetCharDevControl (
  41. API_HANDLER_PARAMETERS
  42. )
  43. /*++
  44. Routine Description:
  45. This routine handles a call to NetCharDevControl.
  46. Arguments:
  47. API_HANDLER_PARAMETERS - information about the API call. See
  48. XsTypes.h for details.
  49. Return Value:
  50. NTSTATUS - STATUS_SUCCESS or reason for failure.
  51. --*/
  52. {
  53. #if 0
  54. NET_API_STATUS status;
  55. PXS_NET_CHAR_DEV_CONTROL parameters = Parameters;
  56. LPTSTR nativeDevName = NULL; // Native parameters
  57. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  58. //
  59. // Translate parameters, check for errors.
  60. //
  61. XsConvertTextParameter(
  62. nativeDevName,
  63. (LPSTR)SmbGetUlong( &parameters->DevName )
  64. );
  65. //
  66. // Make the local call.
  67. //
  68. status = NetCharDevControl(
  69. NULL,
  70. nativeDevName,
  71. (DWORD)SmbGetUshort( &parameters->OpCode )
  72. );
  73. if ( !XsApiSuccess( status )) {
  74. IF_DEBUG(ERRORS) {
  75. NetpKdPrint(( "XsNetCharDevControl: "
  76. "NetCharDevControl failed: %X\n", status ));
  77. }
  78. }
  79. cleanup:
  80. NetpMemoryFree( nativeDevName );
  81. //
  82. // No return data.
  83. //
  84. Header->Status = (WORD)status;
  85. #else
  86. RETURN_CHARDEV_NOT_SUPPORTED;
  87. #endif
  88. return STATUS_SUCCESS;
  89. } // XsNetCharDevControl
  90. NTSTATUS
  91. XsNetCharDevEnum (
  92. API_HANDLER_PARAMETERS
  93. )
  94. /*++
  95. Routine Description:
  96. This routine handles a call to NetCharDevEnum.
  97. Arguments:
  98. API_HANDLER_PARAMETERS - information about the API call. See
  99. XsTypes.h for details.
  100. Return Value:
  101. NTSTATUS - STATUS_SUCCESS or reason for failure.
  102. --*/
  103. {
  104. PXS_NET_CHAR_DEV_ENUM parameters = Parameters;
  105. DWORD entriesFilled = 0;
  106. #if 0
  107. NET_API_STATUS status;
  108. LPVOID outBuffer = NULL; // Native parameters
  109. DWORD entriesRead;
  110. DWORD totalEntries;
  111. DWORD bytesRequired = 0; // Conversion variables
  112. LPDESC nativeStructureDesc;
  113. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  114. IF_DEBUG(CHAR_DEV) {
  115. NetpKdPrint(( "XsNetCharDevEnum: header at %lx, params at %lx, "
  116. "level %ld, buf size %ld\n",
  117. Header, parameters, SmbGetUshort( &parameters->Level ),
  118. SmbGetUshort( &parameters->BufLen )));
  119. }
  120. //
  121. // Check for errors.
  122. //
  123. if ( XsWordParamOutOfRange( parameters->Level, 0, 1 )) {
  124. Header->Status = (WORD)ERROR_INVALID_LEVEL;
  125. goto cleanup;
  126. }
  127. //
  128. // Make the local call.
  129. //
  130. status = NetCharDevEnum(
  131. NULL,
  132. (DWORD)SmbGetUshort( &parameters->Level ),
  133. (LPBYTE *)&outBuffer,
  134. XsNativeBufferSize( SmbGetUshort( &parameters->BufLen )),
  135. &entriesRead,
  136. &totalEntries,
  137. NULL
  138. );
  139. if ( !XsApiSuccess( status )) {
  140. IF_DEBUG(API_ERRORS) {
  141. NetpKdPrint(( "XsNetCharDevEnum: NetCharDevEnum failed: %X\n",
  142. status ));
  143. }
  144. Header->Status = (WORD)status;
  145. goto cleanup;
  146. }
  147. IF_DEBUG(CHAR_DEV) {
  148. NetpKdPrint(( "XsNetCharDevEnum: received %ld entries at %lx\n",
  149. entriesRead, outBuffer ));
  150. }
  151. //
  152. // Use the requested level to determine the format of the
  153. // data structure.
  154. //
  155. switch ( SmbGetUshort( &parameters->Level ) ) {
  156. case 0:
  157. nativeStructureDesc = Desc32_chardev_info_0;
  158. StructureDesc = Desc16_chardev_info_0;
  159. break;
  160. case 1:
  161. nativeStructureDesc = Desc32_chardev_info_1;
  162. StructureDesc = Desc16_chardev_info_1;
  163. break;
  164. }
  165. //
  166. // Do the actual conversion from the 32-bit structures to 16-bit
  167. // structures.
  168. //
  169. XsFillEnumBuffer(
  170. outBuffer,
  171. entriesRead,
  172. nativeStructureDesc,
  173. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  174. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  175. SmbGetUshort( &parameters->BufLen ),
  176. StructureDesc,
  177. NULL, // verify function
  178. &bytesRequired,
  179. &entriesFilled,
  180. NULL
  181. );
  182. IF_DEBUG(CHAR_DEV) {
  183. NetpKdPrint(( "32-bit data at %lx, 16-bit data at %lx, %ld BR,"
  184. " Entries %ld of %ld\n",
  185. outBuffer, SmbGetUlong( &parameters->Buffer ),
  186. bytesRequired, entriesFilled, totalEntries ));
  187. }
  188. //
  189. // The 16-bit chardev_info structures do not contain any variable
  190. // data. Therefore, there is no need to pack any data - the converter
  191. // is already set to 0.
  192. //
  193. if ( entriesFilled < totalEntries ) {
  194. Header->Status = ERROR_MORE_DATA;
  195. }
  196. //
  197. // Set up the response parameters.
  198. //
  199. SmbPutUshort( &parameters->EntriesRead, (WORD)entriesFilled );
  200. SmbPutUshort( &parameters->TotalAvail, (WORD)totalEntries );
  201. cleanup:
  202. NetApiBufferFree( outBuffer );
  203. #else
  204. RETURN_CHARDEV_NOT_SUPPORTED;
  205. #endif
  206. //
  207. // Determine return buffer size.
  208. //
  209. XsSetDataCount(
  210. &parameters->BufLen,
  211. StructureDesc,
  212. Header->Converter,
  213. entriesFilled,
  214. Header->Status
  215. );
  216. return STATUS_SUCCESS;
  217. } // XsNetCharDevEnum
  218. NTSTATUS
  219. XsNetCharDevGetInfo (
  220. API_HANDLER_PARAMETERS
  221. )
  222. /*++
  223. Routine Description:
  224. This routine handles a call to NetCharDevGetInfo.
  225. Arguments:
  226. API_HANDLER_PARAMETERS - information about the API call. See
  227. XsTypes.h for details.
  228. Return Value:
  229. NTSTATUS - STATUS_SUCCESS or reason for failure.
  230. --*/
  231. {
  232. PXS_NET_CHAR_DEV_GET_INFO parameters = Parameters;
  233. #if 0
  234. NET_API_STATUS status;
  235. LPTSTR nativeDevName = NULL; // Native parameters
  236. LPVOID outBuffer = NULL;
  237. LPBYTE stringLocation = NULL; // Conversion variables
  238. DWORD bytesRequired = 0;
  239. LPDESC nativeStructureDesc;
  240. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  241. IF_DEBUG(CHAR_DEV) {
  242. NetpKdPrint(( "XsNetCharDevGetInfo: header at %lx, "
  243. "params at %lx, level %ld\n",
  244. Header, parameters, SmbGetUshort( &parameters->Level ) ));
  245. }
  246. //
  247. // Translate parameters, check for errors.
  248. //
  249. if ( XsWordParamOutOfRange( parameters->Level, 0, 1 )) {
  250. Header->Status = (WORD)ERROR_INVALID_LEVEL;
  251. goto cleanup;
  252. }
  253. XsConvertTextParameter(
  254. nativeDevName,
  255. (LPSTR)SmbGetUlong( &parameters->DevName )
  256. );
  257. //
  258. //
  259. // Make the local call.
  260. //
  261. status = NetCharDevGetInfo(
  262. NULL,
  263. nativeDevName,
  264. (DWORD)SmbGetUshort( &parameters->Level ),
  265. (LPBYTE *)&outBuffer
  266. );
  267. if ( !XsApiSuccess( status )) {
  268. IF_DEBUG(API_ERRORS) {
  269. NetpKdPrint(( "XsNetCharDevGetInfo: NetCharDevGetInfo failed: "
  270. "%X\n", status ));
  271. }
  272. Header->Status = (WORD)status;
  273. goto cleanup;
  274. }
  275. //
  276. // Use the requested level to determine the format of the
  277. // data structure.
  278. //
  279. switch ( SmbGetUshort( &parameters->Level ) ) {
  280. case 0:
  281. nativeStructureDesc = Desc32_chardev_info_0;
  282. StructureDesc = Desc16_chardev_info_0;
  283. break;
  284. case 1:
  285. nativeStructureDesc = Desc32_chardev_info_1;
  286. StructureDesc = Desc16_chardev_info_1;
  287. break;
  288. }
  289. //
  290. // Convert the structure returned by the 32-bit call to a 16-bit
  291. // structure. The last possible location for variable data is
  292. // calculated from buffer location and length.
  293. //
  294. stringLocation = (LPBYTE)( SmbGetUlong( &parameters->Buffer )
  295. + SmbGetUshort( &parameters->BufLen ) );
  296. status = RapConvertSingleEntry(
  297. outBuffer,
  298. nativeStructureDesc,
  299. FALSE,
  300. (LPBYTE)SmbGetUlong( &parameters->Buffer ),
  301. (LPBYTE)SmbGetUlong( &parameters->Buffer ),
  302. StructureDesc,
  303. TRUE,
  304. &stringLocation,
  305. &bytesRequired,
  306. Response,
  307. NativeToRap
  308. );
  309. if ( status != NERR_Success ) {
  310. IF_DEBUG(ERRORS) {
  311. NetpKdPrint(( "XsNetCharDevGetInfo: RapConvertSingleEntry failed: "
  312. "%X\n", status ));
  313. }
  314. Header->Status = NERR_InternalError;
  315. goto cleanup;
  316. }
  317. IF_DEBUG(CHAR_DEV) {
  318. NetpKdPrint(( "32-bit data at %lx, 16-bit data at %lx, %ld BR\n",
  319. outBuffer, SmbGetUlong( &parameters->Buffer ),
  320. bytesRequired ));
  321. }
  322. //
  323. // Determine return code based on the size of the buffer. The 16-bit
  324. // chardev_info structures do not have any variable data to pack.
  325. //
  326. if ( !XsCheckBufferSize(
  327. SmbGetUshort( &parameters->BufLen ),
  328. StructureDesc,
  329. FALSE // not in native format
  330. )) {
  331. IF_DEBUG(ERRORS) {
  332. NetpKdPrint(( "XsNetCharDevGetInfo: Buffer too small.\n" ));
  333. }
  334. Header->Status = NERR_BufTooSmall;
  335. } else if ( bytesRequired > SmbGetUshort( &parameters-> BufLen )) {
  336. IF_DEBUG(ERRORS) {
  337. NetpKdPrint(( "NetCharDevGetInfo: More data available.\n" ));
  338. }
  339. Header->Status = ERROR_MORE_DATA;
  340. }
  341. //
  342. // Set up the response parameters.
  343. //
  344. SmbPutUshort( &parameters->TotalAvail, (WORD)bytesRequired );
  345. cleanup:
  346. NetApiBufferFree( outBuffer );
  347. NetpMemoryFree( nativeDevName );
  348. #else
  349. RETURN_CHARDEV_NOT_SUPPORTED;
  350. #endif
  351. //
  352. // Determine return buffer size.
  353. //
  354. XsSetDataCount(
  355. &parameters->BufLen,
  356. StructureDesc,
  357. Header->Converter,
  358. 1,
  359. Header->Status
  360. );
  361. return STATUS_SUCCESS;
  362. } // XsNetCharDevGetInfo
  363. NTSTATUS
  364. XsNetCharDevQEnum (
  365. API_HANDLER_PARAMETERS
  366. )
  367. /*++
  368. Routine Description:
  369. This routine handles a call to NetCharDevQEnum.
  370. Arguments:
  371. API_HANDLER_PARAMETERS - information about the API call. See
  372. XsTypes.h for details.
  373. Return Value:
  374. NTSTATUS - STATUS_SUCCESS or reason for failure.
  375. --*/
  376. {
  377. PXS_NET_CHAR_DEV_Q_ENUM parameters = Parameters;
  378. DWORD entriesFilled = 0;
  379. #if 0
  380. NET_API_STATUS status;
  381. LPTSTR nativeUserName = NULL; // Native parameters
  382. LPVOID outBuffer = NULL;
  383. DWORD entriesRead;
  384. DWORD totalEntries;
  385. DWORD bytesRequired = 0;
  386. LPDESC nativeStructureDesc;
  387. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  388. IF_DEBUG(CHAR_DEV) {
  389. NetpKdPrint(( "XsNetCharDevQEnum: header at %lx, params at %lx, "
  390. "level %ld, buf size %ld\n",
  391. Header, parameters, SmbGetUshort( &parameters->Level ),
  392. SmbGetUshort( &parameters->BufLen )));
  393. }
  394. //
  395. // Translate parameters, check for errors.
  396. //
  397. if ( XsWordParamOutOfRange( parameters->Level, 0, 1 )) {
  398. Header->Status = (WORD)ERROR_INVALID_LEVEL;
  399. goto cleanup;
  400. }
  401. XsConvertTextParameter(
  402. nativeUserName,
  403. (LPSTR)SmbGetUlong( &parameters->UserName )
  404. );
  405. //
  406. // Make the local call.
  407. //
  408. status = NetCharDevQEnum(
  409. NULL,
  410. nativeUserName,
  411. (DWORD)SmbGetUshort( &parameters->Level ),
  412. (LPBYTE *)&outBuffer,
  413. XsNativeBufferSize( SmbGetUshort( &parameters->BufLen )),
  414. &entriesRead,
  415. &totalEntries,
  416. NULL
  417. );
  418. if ( !XsApiSuccess( status )) {
  419. IF_DEBUG(API_ERRORS) {
  420. NetpKdPrint(( "XsNetCharDevQEnum: NetCharDevQEnum failed: %X\n",
  421. status ));
  422. }
  423. Header->Status = (WORD)status;
  424. goto cleanup;
  425. }
  426. IF_DEBUG(CHAR_DEV) {
  427. NetpKdPrint(( "XsNetCharDevQEnum: received %ld entries at %lx\n",
  428. entriesRead, outBuffer ));
  429. }
  430. //
  431. // Use the requested level to determine the format of the
  432. // data structure.
  433. //
  434. switch ( SmbGetUshort( &parameters->Level ) ) {
  435. case 0:
  436. nativeStructureDesc = Desc32_chardevQ_info_0;
  437. StructureDesc = Desc16_chardevQ_info_0;
  438. break;
  439. case 1:
  440. nativeStructureDesc = Desc32_chardevQ_info_1;
  441. StructureDesc = Desc16_chardevQ_info_1;
  442. break;
  443. }
  444. //
  445. // Do the actual conversion from the 32-bit structures to 16-bit
  446. // structures.
  447. //
  448. XsFillEnumBuffer(
  449. outBuffer,
  450. entriesRead,
  451. nativeStructureDesc,
  452. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  453. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  454. SmbGetUshort( &parameters->BufLen ),
  455. StructureDesc,
  456. NULL, // verify function
  457. &bytesRequired,
  458. &entriesFilled,
  459. NULL
  460. );
  461. IF_DEBUG(CHAR_DEV) {
  462. NetpKdPrint(( "32-bit data at %lx, 16-bit data at %lx, %ld BR,"
  463. " Entries %ld of %ld\n",
  464. outBuffer, SmbGetUlong( &parameters->Buffer ),
  465. bytesRequired, entriesFilled, totalEntries ));
  466. }
  467. //
  468. // If all the data was returned, try to pack the data so that we
  469. // don't send empty bytes back.
  470. //
  471. if ( entriesFilled < totalEntries ) {
  472. Header->Status = ERROR_MORE_DATA;
  473. } else {
  474. Header->Converter = XsPackReturnData(
  475. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  476. SmbGetUshort( &parameters->BufLen ),
  477. StructureDesc,
  478. entriesFilled
  479. );
  480. }
  481. //
  482. // Set up the response parameters.
  483. //
  484. SmbPutUshort( &parameters->EntriesRead, (WORD)entriesFilled );
  485. SmbPutUshort( &parameters->TotalAvail, (WORD)totalEntries );
  486. cleanup:
  487. NetApiBufferFree( outBuffer );
  488. NetpMemoryFree( nativeUserName );
  489. #else
  490. RETURN_CHARDEV_NOT_SUPPORTED;
  491. #endif
  492. //
  493. // Determine return buffer size.
  494. //
  495. XsSetDataCount(
  496. &parameters->BufLen,
  497. StructureDesc,
  498. Header->Converter,
  499. entriesFilled,
  500. Header->Status
  501. );
  502. return STATUS_SUCCESS;
  503. } // XsNetCharDevQEnum
  504. NTSTATUS
  505. XsNetCharDevQGetInfo (
  506. API_HANDLER_PARAMETERS
  507. )
  508. /*++
  509. Routine Description:
  510. This routine handles a call to NetCharDevQGetInfo.
  511. Arguments:
  512. API_HANDLER_PARAMETERS - information about the API call. See
  513. XsTypes.h for details.
  514. Return Value:
  515. NTSTATUS - STATUS_SUCCESS or reason for failure.
  516. --*/
  517. {
  518. PXS_NET_CHAR_DEV_Q_GET_INFO parameters = Parameters;
  519. #if 0
  520. NET_API_STATUS status;
  521. LPTSTR nativeQueueName = NULL; // Native parameters
  522. LPTSTR nativeUserName = NULL;
  523. LPVOID outBuffer = NULL;
  524. LPBYTE stringLocation = NULL; // Conversion variables
  525. DWORD bytesRequired = 0;
  526. LPDESC nativeStructureDesc;
  527. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  528. //
  529. // Translate parameters, check for errors.
  530. //
  531. if ( XsWordParamOutOfRange( parameters->Level, 0, 1 )) {
  532. Header->Status = (WORD)ERROR_INVALID_LEVEL;
  533. goto cleanup;
  534. }
  535. XsConvertTextParameter(
  536. nativeQueueName,
  537. (LPSTR)SmbGetUlong( &parameters->QueueName )
  538. );
  539. XsConvertTextParameter(
  540. nativeUserName,
  541. (LPSTR)SmbGetUlong( &parameters->UserName )
  542. );
  543. IF_DEBUG(CHAR_DEV) {
  544. NetpKdPrint(( "XsNetCharDevQGetInfo: header at %lx, "
  545. "params at %lx, level %ld\n",
  546. Header, parameters, SmbGetUshort( &parameters->Level ) ));
  547. }
  548. //
  549. // Make the local call.
  550. //
  551. status = NetCharDevQGetInfo(
  552. NULL,
  553. nativeQueueName,
  554. nativeUserName,
  555. (DWORD)SmbGetUshort( &parameters->Level ),
  556. (LPBYTE *)&outBuffer
  557. );
  558. if ( !XsApiSuccess( status )) {
  559. IF_DEBUG(API_ERRORS) {
  560. NetpKdPrint(( "XsNetCharDevQGetInfo: NetCharDevQGetInfo failed: "
  561. "%X\n", status ));
  562. }
  563. Header->Status = (WORD)status;
  564. goto cleanup;
  565. }
  566. //
  567. // Use the requested level to determine the format of the
  568. // data structure.
  569. //
  570. switch ( SmbGetUshort( &parameters->Level ) ) {
  571. case 0:
  572. nativeStructureDesc = Desc32_chardevQ_info_0;
  573. StructureDesc = Desc16_chardevQ_info_0;
  574. break;
  575. case 1:
  576. nativeStructureDesc = Desc32_chardevQ_info_1;
  577. StructureDesc = Desc16_chardevQ_info_1;
  578. break;
  579. }
  580. //
  581. // Convert the structure returned by the 32-bit call to a 16-bit
  582. // structure. The last possible location for variable data is
  583. // calculated from buffer location and length.
  584. //
  585. stringLocation = (LPBYTE)( SmbGetUlong( &parameters->Buffer )
  586. + SmbGetUshort( &parameters->BufLen ) );
  587. status = RapConvertSingleEntry(
  588. outBuffer,
  589. nativeStructureDesc,
  590. FALSE,
  591. (LPBYTE)SmbGetUlong( &parameters->Buffer ),
  592. (LPBYTE)SmbGetUlong( &parameters->Buffer ),
  593. StructureDesc,
  594. TRUE,
  595. &stringLocation,
  596. &bytesRequired,
  597. Response,
  598. NativeToRap
  599. );
  600. if ( status != NERR_Success ) {
  601. IF_DEBUG(ERRORS) {
  602. NetpKdPrint(( "XsCharDevQGetInfo: RapConvertSingleEntry failed: "
  603. "%X\n", status ));
  604. }
  605. Header->Status = NERR_InternalError;
  606. goto cleanup;
  607. }
  608. IF_DEBUG(CHAR_DEV) {
  609. NetpKdPrint(( "32-bit data at %lx, 16-bit data at %lx, %ld BR\n",
  610. outBuffer, SmbGetUlong( &parameters->Buffer ),
  611. bytesRequired ));
  612. }
  613. //
  614. // Determine return code based on the size of the buffer. If all data
  615. // has fit, try to pack it.
  616. //
  617. if ( !XsCheckBufferSize(
  618. SmbGetUshort( &parameters->BufLen ),
  619. StructureDesc,
  620. FALSE // not in native format
  621. )) {
  622. IF_DEBUG(ERRORS) {
  623. NetpKdPrint(( "XsNetCharDevQGetInfo: Buffer too small.\n" ));
  624. }
  625. Header->Status = NERR_BufTooSmall;
  626. } else if ( bytesRequired > SmbGetUshort( &parameters-> BufLen )) {
  627. IF_DEBUG(ERRORS) {
  628. NetpKdPrint(( "NetCharDevQGetInfo: More data available.\n" ));
  629. }
  630. Header->Status = ERROR_MORE_DATA;
  631. } else {
  632. Header->Converter = XsPackReturnData(
  633. (LPVOID)SmbGetUlong( &parameters->Buffer ),
  634. SmbGetUshort( &parameters->BufLen ),
  635. StructureDesc,
  636. 1
  637. );
  638. }
  639. //
  640. // Set up the response parameters.
  641. //
  642. SmbPutUshort( &parameters->TotalAvail, (WORD)bytesRequired );
  643. cleanup:
  644. NetApiBufferFree( outBuffer );
  645. NetpMemoryFree( nativeQueueName );
  646. NetpMemoryFree( nativeUserName );
  647. #else
  648. RETURN_CHARDEV_NOT_SUPPORTED;
  649. #endif
  650. //
  651. // Determine return buffer size.
  652. //
  653. XsSetDataCount(
  654. &parameters->BufLen,
  655. StructureDesc,
  656. Header->Converter,
  657. 1,
  658. Header->Status
  659. );
  660. return STATUS_SUCCESS;
  661. } // XsNetCharDevQGetInfo
  662. NTSTATUS
  663. XsNetCharDevQPurge (
  664. API_HANDLER_PARAMETERS
  665. )
  666. /*++
  667. Routine Description:
  668. This routine handles a call to NetCharDevQPurge.
  669. Arguments:
  670. API_HANDLER_PARAMETERS - information about the API call. See
  671. XsTypes.h for details.
  672. Return Value:
  673. NTSTATUS - STATUS_SUCCESS or reason for failure.
  674. --*/
  675. {
  676. #if 0
  677. NET_API_STATUS status;
  678. PXS_NET_CHAR_DEV_Q_PURGE parameters = Parameters;
  679. LPTSTR nativeQueueName = NULL; // Native parameters
  680. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  681. //
  682. // Translate parameters, check for errors.
  683. //
  684. XsConvertTextParameter(
  685. nativeQueueName,
  686. (LPSTR)SmbGetUlong( &parameters->QueueName )
  687. );
  688. //
  689. // Make the local call.
  690. //
  691. status = NetCharDevQPurge(
  692. NULL,
  693. nativeQueueName
  694. );
  695. if ( !XsApiSuccess( status )) {
  696. IF_DEBUG(ERRORS) {
  697. NetpKdPrint(( "XsNetCharDevQPurge: "
  698. "NetCharDevQPurge failed: %X\n", status ));
  699. }
  700. }
  701. cleanup:
  702. NetpMemoryFree( nativeQueueName );
  703. //
  704. // No return data.
  705. //
  706. Header->Status = (WORD)status;
  707. #else
  708. RETURN_CHARDEV_NOT_SUPPORTED;
  709. #endif
  710. return STATUS_SUCCESS;
  711. } // XsNetCharDevQPurge
  712. NTSTATUS
  713. XsNetCharDevQPurgeSelf (
  714. API_HANDLER_PARAMETERS
  715. )
  716. /*++
  717. Routine Description:
  718. This routine handles a call to NetCharDevQPurgeSelf.
  719. Arguments:
  720. API_HANDLER_PARAMETERS - information about the API call. See
  721. XsTypes.h for details.
  722. Return Value:
  723. NTSTATUS - STATUS_SUCCESS or reason for failure.
  724. --*/
  725. {
  726. #if 0
  727. NET_API_STATUS status;
  728. PXS_NET_CHAR_DEV_Q_PURGE_SELF parameters = Parameters;
  729. LPTSTR nativeQueueName = NULL; // Native parameters
  730. LPTSTR nativeComputerName = NULL;
  731. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  732. //
  733. // Translate parameters, check for errors.
  734. //
  735. XsConvertTextParameter(
  736. nativeQueueName,
  737. (LPSTR)SmbGetUlong( &parameters->QueueName )
  738. );
  739. XsConvertTextParameter(
  740. nativeComputerName,
  741. (LPSTR)SmbGetUlong( &parameters->ComputerName )
  742. );
  743. //
  744. // Make the local call.
  745. //
  746. status = NetCharDevQPurgeSelf(
  747. NULL,
  748. nativeQueueName,
  749. nativeComputerName
  750. );
  751. if ( !XsApiSuccess( status )) {
  752. IF_DEBUG(ERRORS) {
  753. NetpKdPrint(( "XsNetCharDevQPurgeSelf: "
  754. "NetCharDevQPurgeSelf failed: %X\n", status ));
  755. }
  756. }
  757. cleanup:
  758. NetpMemoryFree( nativeQueueName );
  759. NetpMemoryFree( nativeComputerName );
  760. //
  761. // No return data.
  762. //
  763. Header->Status = (WORD)status;
  764. #else
  765. RETURN_CHARDEV_NOT_SUPPORTED;
  766. #endif
  767. return STATUS_SUCCESS;
  768. } // XsNetCharDevQPurgeSelf
  769. NTSTATUS
  770. XsNetCharDevQSetInfo (
  771. API_HANDLER_PARAMETERS
  772. )
  773. /*++
  774. Routine Description:
  775. This routine handles a call to NetCharDevQSetInfo.
  776. Arguments:
  777. API_HANDLER_PARAMETERS - information about the API call. See
  778. XsTypes.h for details.
  779. Return Value:
  780. NTSTATUS - STATUS_SUCCESS or reason for failure.
  781. --*/
  782. {
  783. #if 0
  784. NET_API_STATUS status;
  785. PXS_NET_CHAR_DEV_Q_SET_INFO parameters = Parameters;
  786. LPTSTR nativeQueueName = NULL; // Native parameters
  787. LPVOID buffer = NULL;
  788. DWORD level;
  789. API_HANDLER_PARAMETERS_REFERENCE; // Avoid warnings
  790. //
  791. // Translate parameters, check for errors.
  792. //
  793. if ( SmbGetUshort( &parameters->Level ) != 1 ) {
  794. Header->Status = (WORD)ERROR_INVALID_LEVEL;
  795. goto cleanup;
  796. }
  797. XsConvertTextParameter(
  798. nativeQueueName,
  799. (LPSTR)SmbGetUlong( &parameters->QueueName )
  800. );
  801. StructureDesc = Desc16_chardevQ_info_1;
  802. status = XsConvertSetInfoBuffer(
  803. (LPBYTE)SmbGetUlong( &parameters->Buffer ),
  804. SmbGetUshort( &parameters->BufLen ),
  805. SmbGetUshort( &parameters->ParmNum ),
  806. FALSE,
  807. TRUE,
  808. StructureDesc,
  809. Desc32_chardevQ_info_1,
  810. Desc16_chardevQ_info_1_setinfo,
  811. Desc32_chardevQ_info_1_setinfo,
  812. (LPBYTE *)&buffer,
  813. NULL
  814. );
  815. if ( status != NERR_Success ) {
  816. IF_DEBUG(ERRORS) {
  817. NetpKdPrint(( "XsNetCharDevQSetInfo: Problem with conversion: "
  818. "%X\n", status ));
  819. }
  820. Header->Status = (WORD)status;
  821. goto cleanup;
  822. }
  823. //
  824. // Make the local call.
  825. //
  826. level = SmbGetUshort( &parameters->ParmNum );
  827. if ( level != 0 ) {
  828. level = level + PARMNUM_BASE_INFOLEVEL;
  829. } else {
  830. level = SmbGetUshort( &parameters->Level );
  831. }
  832. status = NetCharDevQSetInfo(
  833. NULL,
  834. nativeQueueName,
  835. level,
  836. buffer,
  837. NULL
  838. );
  839. if ( !XsApiSuccess( status )) {
  840. IF_DEBUG(ERRORS) {
  841. NetpKdPrint(( "XsNetCharDevQSetInfo: NetCharDevQSetInfo failed: "
  842. "%X\n", status ));
  843. }
  844. Header->Status = (WORD)status;
  845. goto cleanup;
  846. }
  847. //
  848. // No return information for this API.
  849. //
  850. cleanup:
  851. //
  852. // If there is a native 32-bit buffer, free it.
  853. //
  854. NetpMemoryFree( buffer );
  855. NetpMemoryFree( nativeQueueName );
  856. #else
  857. RETURN_CHARDEV_NOT_SUPPORTED;
  858. #endif
  859. return STATUS_SUCCESS;
  860. } // XsNetCharDevQSetInfo