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.

951 lines
22 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1994-1997 **/
  4. /**********************************************************************/
  5. /*
  6. atq.h
  7. This module contains async thread queue (atq) for async IO and thread
  8. pool sharing among various services.
  9. Brief Description of ATQ:
  10. For description, please see iis\spec\isatq.doc
  11. */
  12. #ifndef _ATQ_H_
  13. #define _ATQ_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // Include Standard headers
  18. # include <nt.h>
  19. # include <ntrtl.h>
  20. # include <nturtl.h>
  21. # include <windows.h>
  22. # include <winsock2.h>
  23. # include <mswsock.h>
  24. # include <uspud.h>
  25. # include <iscaptrc.h>
  26. #ifndef dllexp
  27. #define dllexp __declspec( dllexport )
  28. #endif
  29. /*++
  30. ATQ API Overview:
  31. Global per module:
  32. AtqInitialize()
  33. AtqTerminate()
  34. AtqGetCompletionPort()
  35. AtqGetInfo()
  36. AtqSetInfo()
  37. ATQ Endpoint functions:
  38. AtqCreateEndpoint()
  39. AtqStartEndpoint()
  40. AtqEndpointGetInfo()
  41. AtqEndpointSetInfo()
  42. AtqStopCloseEndpoint()
  43. AtqCloseCloseEndpoint()
  44. AtqStopAndCloseEndpoint() <-- soon to be killed
  45. Per ATQ Context Functions:
  46. AtqAddAsyncHandle() <-- for non AcceptEx() sockets
  47. AtqGetAcceptExAddrs() <-- for AcceptEx() sockets
  48. AtqContextSetInfo()
  49. AtqCloseFileHandle()
  50. AtqCloseSocket()
  51. AtqFreeContext()
  52. Bandwidth Throttler Functions:
  53. AtqCreateBandwidthInfo()
  54. AtqFreeBandwidthInfo()
  55. AtqBandwidthSetInfo()
  56. AtqBandwidthGetInfo()
  57. IO Functions:
  58. AtqReadFile()
  59. AtqWriteFile()
  60. AtqReadSocket()
  61. AtqWriteSocket()
  62. AtqTransmitFile()
  63. AtqTransmitFileAndRecv()
  64. AtqSendAndRecv()
  65. Utility Functions:
  66. AtqCreateFileW()
  67. AtqSpudInitialized()
  68. AtqReadDirChanges()
  69. AtqPostCompletionStatus()
  70. --*/
  71. /*----------------------------------------------------------
  72. Registry Parameters used by ATQ during AtqInitialize()
  73. ATQ loads some of the parameters from
  74. HKLM\System\CurrentControlSet\Services\InetInfo\Parameters
  75. Most of these parameters are for INTERNAL ANALYSIS and
  76. development/testing. Setup should not install values
  77. for the same. Setup can include values for items marked SETUP.
  78. ------------------------------------------------------------*/
  79. // Names
  80. #define ATQ_REG_PER_PROCESSOR_ATQ_THREADS TEXT("MaxPoolThreads")
  81. #define ATQ_REG_POOL_THREAD_LIMIT TEXT("PoolThreadLimit") // SETUP
  82. #define ATQ_REG_PER_PROCESSOR_CONCURRENCY TEXT("MaxConcurrency")
  83. #define ATQ_REG_THREAD_TIMEOUT TEXT("ThreadTimeout")
  84. #define ATQ_REG_USE_ACCEPTEX TEXT("UseAcceptEx")
  85. #define ATQ_REG_USE_KERNEL_APC TEXT("UseKernelApc")
  86. #define ATQ_REG_MIN_KB_SEC TEXT("MinFileKbSec") // SETUP
  87. #define ATQ_REG_LISTEN_BACKLOG TEXT("ListenBacklog") // SETUP
  88. #define ATQ_REG_ENABLE_DEBUG_THREADS TEXT("EnableDebugThreads")
  89. #define ATQ_REG_DISABLE_BACKLOG_MONITOR TEXT("DisableBacklogMonitor")
  90. #define ATQ_REG_FORCE_TIMEOUT TEXT("ForceTimeout")
  91. // Default Values
  92. #define ATQ_REG_DEF_PER_PROCESSOR_ATQ_THREADS (4)
  93. // special value of 0 means that system will determine this dynamically.
  94. #define ATQ_REG_DEF_PER_PROCESSOR_CONCURRENCY (0)
  95. #define ATQ_REG_DEF_USE_KERNEL_APC (1)
  96. #define ATQ_REG_DEF_MAX_UNCONNECTED_ACCEPTEX (1024)
  97. //
  98. // thread limit settings
  99. //
  100. #define ATQ_REG_MIN_POOL_THREAD_LIMIT (64)
  101. #define ATQ_REG_DEF_POOL_THREAD_LIMIT (128)
  102. #define ATQ_REG_MAX_POOL_THREAD_LIMIT (256)
  103. //
  104. // THREAD_TIMEOUTs are high to prevent async ios from being cancelled
  105. // when the thread goes away.
  106. //
  107. #define ATQ_REG_DEF_THREAD_TIMEOUT (30 * 60) // thirty minutes
  108. #define ATQ_REG_DEF_USE_ACCEPTEX (TRUE)
  109. #define ATQ_REG_DEF_MIN_KB_SEC (1000) // 1000 bytes
  110. #define ATQ_REG_DEF_LISTEN_BACKLOG (25)
  111. //
  112. // fake xmit file buffer size
  113. //
  114. #define ATQ_REG_DEF_NONTF_BUFFER_SIZE (4096)
  115. /*----------------------------------------------------------
  116. Global Functions of ATQ module
  117. -----------------------------------------------------------*/
  118. // Flags for AtqInitialize()
  119. # define ATQ_INIT_SPUD_FLAG (0x00000001)
  120. BOOL
  121. AtqInitialize(
  122. IN DWORD dwFlags
  123. );
  124. BOOL
  125. AtqTerminate(
  126. VOID
  127. );
  128. dllexp
  129. HANDLE
  130. AtqGetCompletionPort();
  131. /*
  132. * Sets various context information in Atq Module for global modifications
  133. *
  134. *
  135. * Bandwidth Throttle: Sets the throttle level in Bytes/Second.
  136. * If INFINITE, then it is assumed that
  137. * there is no throttle value (default)
  138. *
  139. * Max Pool Threads: Sets the maximum number of pool threads Atq will allow
  140. * to be created per processor
  141. *
  142. * MaxConcurrency: tells how many threads to permit per processor
  143. *
  144. * Thread Timeout: Indicates how long a thread should be kep alive
  145. * waiting on GetQueuedCompletionStatus() before commiting suicide
  146. * (in seconds)
  147. *
  148. * Inc/Dec max pool threads: If a server will be doing extended processing
  149. * in an ATQ pool thread, they should increase the max pool threads
  150. * while the extended processing is occurring. This prevents starvation
  151. * of other requests
  152. *
  153. * AtqMinKbSec: set the assumed minimum KB per second for AtqTransmitFile()
  154. * This value is used in calculating the timeout for file transfer
  155. * operation
  156. *
  157. */
  158. typedef enum _ATQ_INFO {
  159. AtqBandwidthThrottle = 0,
  160. AtqExitThreadCallback,
  161. AtqMaxPoolThreads, // per processor values
  162. AtqMaxConcurrency, // per processor concurrency value
  163. AtqThreadTimeout,
  164. AtqUseAcceptEx, // Use AcceptEx if available
  165. AtqIncMaxPoolThreads, // Up the max thread count
  166. AtqDecMaxPoolThreads, // Decrease the max thread count
  167. AtqMinKbSec, // Minimum assumed transfer rate for AtqTransmitFile
  168. AtqBandwidthThrottleMaxBlocked, // Max number of blocked requests
  169. AtqMaxThreadLimit, // absolute maximum number of threads
  170. AtqAvailableThreads // Number of available threads
  171. } ATQ_INFO;
  172. //
  173. // ATQ_THREAD_EXIT_CALLBACK
  174. // Type of callback function to be called when an ATQ thread exits so
  175. // that the user of ATQ may clen up thread specific data.
  176. //
  177. typedef
  178. VOID
  179. (*ATQ_THREAD_EXIT_CALLBACK) ( VOID );
  180. dllexp
  181. ULONG_PTR
  182. AtqSetInfo(
  183. IN ATQ_INFO atqInfo,
  184. IN ULONG_PTR Data
  185. );
  186. dllexp
  187. ULONG_PTR
  188. AtqGetInfo(
  189. IN ATQ_INFO atqInfo
  190. );
  191. typedef struct _ATQ_STATISTICS {
  192. DWORD cAllowedRequests;
  193. DWORD cBlockedRequests;
  194. DWORD cRejectedRequests;
  195. DWORD cCurrentBlockedRequests;
  196. DWORD MeasuredBandwidth;
  197. } ATQ_STATISTICS;
  198. dllexp
  199. BOOL AtqGetStatistics( IN OUT ATQ_STATISTICS * pAtqStats);
  200. dllexp
  201. BOOL AtqClearStatistics(VOID);
  202. /*----------------------------------------------------------
  203. ATQ Endpoint functions
  204. -----------------------------------------------------------*/
  205. //
  206. // endpoint data
  207. //
  208. typedef enum _ATQ_ENDPOINT_INFO {
  209. EndpointInfoListenPort,
  210. EndpointInfoListenSocket,
  211. EndpointInfoAcceptExOutstanding
  212. } ATQ_ENDPOINT_INFO;
  213. //
  214. // ATQ_COMPLETION
  215. // This is the routine that is called upon IO completion (on
  216. // error or success).
  217. //
  218. // Context is the context passed to AtqAddAsyncHandle
  219. // BytesWritten is the number of bytes written to the file or
  220. // bytes written to the client's buffer
  221. // CompletionStatus is the WinError completion code
  222. // lpOverLapped is the filled in overlap structure
  223. //
  224. // If the timeout thread times out an IO request, the completion routine
  225. // will be called by the timeout thread with IOCompletion FALSE and
  226. // CompletionStatus == ERROR_SEM_TIMEOUT. The IO request is *still*
  227. // outstanding in this instance. Generally it will be completed when
  228. // the file handle is closed.
  229. //
  230. typedef
  231. VOID
  232. (*ATQ_COMPLETION)(
  233. IN PVOID Context,
  234. IN DWORD BytesWritten,
  235. IN DWORD CompletionStatus, // Win32 Error code
  236. IN OVERLAPPED * lpo
  237. );
  238. //
  239. // Type of callback function to be called when a new connection is established.
  240. // This function should be defined before including conninfo.hxx
  241. //
  242. typedef
  243. VOID
  244. (*ATQ_CONNECT_CALLBACK) (
  245. IN SOCKET sNew,
  246. IN LPSOCKADDR_IN pSockAddr,
  247. IN PVOID EndpointContext,
  248. IN PVOID EndpointObject
  249. );
  250. typedef struct _ATQ_ENDPOINT_CONFIGURATION {
  251. //
  252. // Port to listen on. If 0, system will assign
  253. //
  254. USHORT ListenPort;
  255. //
  256. // IP address to bind to. 0 (INADDR_ANY) == wildcard.
  257. //
  258. DWORD IpAddress;
  259. DWORD cbAcceptExRecvBuffer;
  260. DWORD nAcceptExOutstanding;
  261. DWORD AcceptExTimeout;
  262. //
  263. // Callbacks
  264. //
  265. ATQ_CONNECT_CALLBACK pfnConnect;
  266. ATQ_COMPLETION pfnConnectEx;
  267. ATQ_COMPLETION pfnIoCompletion;
  268. } ATQ_ENDPOINT_CONFIGURATION, *PATQ_ENDPOINT_CONFIGURATION;
  269. dllexp
  270. PVOID
  271. AtqCreateEndpoint(
  272. IN PATQ_ENDPOINT_CONFIGURATION Configuration,
  273. IN PVOID EndpointContext
  274. );
  275. dllexp
  276. BOOL
  277. AtqStartEndpoint(
  278. IN PVOID Endpoint
  279. );
  280. dllexp
  281. ULONG_PTR
  282. AtqEndpointGetInfo(
  283. IN PVOID Endpoint,
  284. IN ATQ_ENDPOINT_INFO EndpointInfo
  285. );
  286. dllexp
  287. ULONG_PTR
  288. AtqEndpointSetInfo(
  289. IN PVOID Endpoint,
  290. IN ATQ_ENDPOINT_INFO EndpointInfo,
  291. IN ULONG_PTR Info
  292. );
  293. dllexp
  294. BOOL
  295. AtqStopEndpoint(
  296. IN PVOID Endpoint
  297. );
  298. dllexp
  299. BOOL
  300. AtqCloseEndpoint(
  301. IN PVOID Endpoint
  302. );
  303. dllexp
  304. BOOL
  305. AtqStopAndCloseEndpoint(
  306. IN PVOID Endpoint,
  307. IN LPTHREAD_START_ROUTINE lpCompletion,
  308. IN PVOID lpCompletionContext
  309. );
  310. /*----------------------------------------------------------
  311. ATQ CONTEXT functions
  312. -----------------------------------------------------------*/
  313. //
  314. // This is the public portion of an ATQ Context. It should be treated
  315. // as read only
  316. //
  317. // !!! Changes made to this structure should also be made to
  318. // ATQ_CONTEXT in atqtypes.hxx !!!
  319. //
  320. typedef struct _ATQ_CONTEXT_PUBLIC {
  321. HANDLE hAsyncIO; // handle for async i/o object: socket/file
  322. OVERLAPPED Overlapped; // Overlapped structure used for IO
  323. } ATQ_CONTEXT_PUBLIC, *PATQ_CONTEXT;
  324. dllexp
  325. BOOL
  326. AtqAddAsyncHandle(
  327. OUT PATQ_CONTEXT * ppatqContext,
  328. IN PVOID EndpointObject,
  329. IN PVOID ClientContext,
  330. IN ATQ_COMPLETION pfnCompletion,
  331. IN DWORD TimeOut,
  332. IN HANDLE hAsyncIO
  333. );
  334. dllexp
  335. VOID
  336. AtqGetAcceptExAddrs(
  337. IN PATQ_CONTEXT patqContext,
  338. OUT SOCKET * pSock,
  339. OUT PVOID * ppvBuff,
  340. OUT PVOID * pEndpointContext,
  341. OUT SOCKADDR * * ppsockaddrLocal,
  342. OUT SOCKADDR * * ppsockaddrRemote
  343. );
  344. /*++
  345. AtqCloseSocket()
  346. Routine Description:
  347. Closes the socket in this atq structure if it wasn't
  348. closed by transmitfile. This function should be called only
  349. if the embedded handle in AtqContext is a Socket.
  350. Arguments:
  351. patqContext - Context whose socket should be closed.
  352. fShutdown - If TRUE, means we call shutdown and always close the socket.
  353. Note that if TransmitFile closed the socket, it will have done the
  354. shutdown for us
  355. Returns:
  356. TRUE on success and FALSE if there is a failure.
  357. --*/
  358. dllexp
  359. BOOL
  360. AtqCloseSocket(
  361. PATQ_CONTEXT patqContext,
  362. BOOL fShutdown
  363. );
  364. /*++
  365. AtqCloseFileHandle()
  366. Routine Description:
  367. Closes the file handle in this atq structure.
  368. This function should be called only if the embedded handle
  369. in AtqContext is a file handle.
  370. Arguments:
  371. patqContext - Context whose file handle should be closed.
  372. Returns:
  373. TRUE on success and FALSE if there is a failure.
  374. --*/
  375. dllexp
  376. BOOL
  377. AtqCloseFileHandle(
  378. PATQ_CONTEXT patqContext
  379. );
  380. /*++
  381. AtqFreeContext()
  382. Routine Description:
  383. Frees the context created in AtqAddAsyncHandle.
  384. Call this after the async handle has been closed and all outstanding
  385. IO operations have been completed. The context is invalid after this call.
  386. Call AtqFreeContext() for same context only ONCE.
  387. Arguments:
  388. patqContext - Context to free
  389. fReuseContext - TRUE if this can context can be reused in the context of
  390. the calling thread. Should be FALSE if the calling thread will exit
  391. soon (i.e., isn't an AtqPoolThread).
  392. Returns:
  393. None
  394. --*/
  395. dllexp
  396. VOID
  397. AtqFreeContext(
  398. IN PATQ_CONTEXT patqContext,
  399. BOOL fReuseContext
  400. );
  401. enum ATQ_CONTEXT_INFO
  402. {
  403. ATQ_INFO_TIMEOUT = 0, // Timeout rounded up to ATQ timeout interval
  404. ATQ_INFO_RESUME_IO, // resumes IO as is after Timeout
  405. ATQ_INFO_COMPLETION, // Completion routine
  406. ATQ_INFO_COMPLETION_CONTEXT,// Completion context
  407. ATQ_INFO_BANDWIDTH_INFO, // Bandwidth Throttling Descriptor
  408. ATQ_INFO_ABORTIVE_CLOSE, // do abortive close on closesocket
  409. ATQ_INFO_FORCE_CLOSE // Always close the socket in AtqCloseSocket()
  410. };
  411. /*++
  412. AtqContextSetInfo()
  413. Routine Description:
  414. Sets various bits of information for this context
  415. Arguments:
  416. patqContext - pointer to ATQ context
  417. atqInfo - Data item to set
  418. data - New value for item
  419. Return Value:
  420. The old value of the parameter
  421. --*/
  422. dllexp
  423. ULONG_PTR
  424. AtqContextSetInfo(
  425. IN PATQ_CONTEXT patqContext,
  426. IN enum ATQ_CONTEXT_INFO atqInfo,
  427. IN ULONG_PTR data
  428. );
  429. /*----------------------------------------------------------
  430. ATQ Context IO functions
  431. -----------------------------------------------------------*/
  432. /*++
  433. Routine Description:
  434. Atq<Operation><Target>()
  435. <Operation> := Read | Write | Transmit
  436. <Target> := File | Socket
  437. These functions just setup ATQ context and then call the corresponding
  438. Win32/WinSock function for submitting an asynchronous IO operation. By
  439. default the Socket functions support scatter/gather using WSABUF
  440. These functions are wrappers and should be called instead of the
  441. correpsonding Win32 API. The one difference from the Win32 API is TRUE
  442. is returned if the error ERROR_IO_PENDING occurred, thus clients do not
  443. need to check for this case.
  444. The timeout time for the request is calculated by taking the maximum of
  445. the context's timeout time and bytes transferred based on 1k/second.
  446. Arguments:
  447. patqContext - pointer to ATQ context
  448. Everything else as in the Win32 API/WinSock APIs
  449. NOTES: AtqTransmitFile takes an additional DWORD flags which may contain
  450. the winsock constants TF_DISCONNECT and TF_REUSE_SOCKET
  451. AtqReadFile and AtqWriteFile take an optional overlapped structure if
  452. clients want to have multiple outstanding reads or writes. If the value
  453. is NULL, then the overlapped structure from the Atq context is used.
  454. Return Value:
  455. TRUE if successful, FALSE on error (call GetLastError)
  456. sets ERROR_NETWORK_BUSY as error when the request needs to be rejected.
  457. --*/
  458. dllexp
  459. BOOL
  460. AtqReadFile(
  461. IN PATQ_CONTEXT patqContext,
  462. IN LPVOID lpBuffer,
  463. IN DWORD BytesToRead,
  464. IN OVERLAPPED * lpo OPTIONAL
  465. );
  466. dllexp
  467. BOOL
  468. AtqReadSocket(
  469. IN PATQ_CONTEXT patqContext,
  470. IN LPWSABUF pwsaBuffers,
  471. IN DWORD dwBufferCount,
  472. IN OVERLAPPED * lpo OPTIONAL
  473. );
  474. /*
  475. * Code for reading into single buffer will look like the following.
  476. * {
  477. * WSABUF wsaBuf = { (BytesToRead), (lpBuffer)};
  478. * fRet = AtqReadSocket( patqContext, &wsaBuf, 1, lpo);
  479. * }
  480. */
  481. dllexp
  482. BOOL
  483. AtqWriteFile(
  484. IN PATQ_CONTEXT patqContext,
  485. IN LPCVOID lpBuffer,
  486. IN DWORD BytesToWrite,
  487. IN OVERLAPPED * lpo OPTIONAL
  488. );
  489. dllexp
  490. BOOL
  491. AtqWriteSocket(
  492. IN PATQ_CONTEXT patqContext,
  493. IN LPWSABUF pwsaBuffers,
  494. IN DWORD dwBufferCount,
  495. IN OVERLAPPED * lpo OPTIONAL
  496. );
  497. dllexp
  498. BOOL
  499. AtqSyncWsaSend(
  500. IN PATQ_CONTEXT patqContext,
  501. IN LPWSABUF pwsaBuffers,
  502. IN DWORD dwBufferCount,
  503. OUT LPDWORD pcbWritten
  504. );
  505. // Note: This API always causes the complete file to be sent.
  506. // If you want to change the behaviour store the appropriate offsets
  507. // in the ATQ_CONTEXT::Overlapped object. Or use AtqTransmitFileEx
  508. dllexp
  509. BOOL
  510. AtqTransmitFile(
  511. IN PATQ_CONTEXT patqContext,
  512. IN HANDLE hFile, // File data comes from
  513. IN DWORD dwBytesInFile, // what is the size of file?
  514. IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  515. IN DWORD dwFlags // TF_DISCONNECT, TF_REUSE_SOCKET
  516. );
  517. dllexp
  518. BOOL
  519. AtqTransmitFileEx(
  520. IN PATQ_CONTEXT patqContext,
  521. IN HANDLE hFile, // File data comes from
  522. IN DWORD dwBytesInFile, // what is the size of file?
  523. IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  524. IN DWORD dwFlags, // TF_DISCONNECT, TF_REUSE_SOCKET
  525. IN OVERLAPPED * lpo
  526. );
  527. dllexp
  528. BOOL
  529. AtqTransmitFileAndRecv(
  530. IN PATQ_CONTEXT patqContext, // pointer to ATQ context
  531. IN HANDLE hFile, // handle of file to read
  532. IN DWORD dwBytesInFile, // Bytes to transmit
  533. IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, // transmit buffer structure
  534. IN DWORD dwTFFlags, // TF Flags
  535. IN LPWSABUF pwsaBuffers, // Buffers for recv
  536. IN DWORD dwBufferCount
  537. );
  538. dllexp
  539. BOOL
  540. AtqSendAndRecv(
  541. IN PATQ_CONTEXT patqContext, // pointer to ATQ context
  542. IN LPWSABUF pwsaSendBuffers, // buffers for send
  543. IN DWORD dwSendBufferCount, // count of buffers for send
  544. IN LPWSABUF pwsaRecvBuffers, // Buffers for recv
  545. IN DWORD dwRecvBufferCount // count of buffers for recv
  546. );
  547. /*----------------------------------------------------------
  548. ATQ Utility Functions
  549. -----------------------------------------------------------*/
  550. typedef
  551. VOID
  552. (*ATQ_OPLOCK_COMPLETION)(
  553. IN PVOID Context,
  554. IN DWORD Status
  555. );
  556. dllexp
  557. HANDLE
  558. AtqCreateFileW(
  559. LPCWSTR lpFileName,
  560. DWORD dwShareMode,
  561. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  562. DWORD dwFlagsAndAttributes,
  563. SECURITY_INFORMATION si,
  564. PSECURITY_DESCRIPTOR sd,
  565. ULONG Length,
  566. PULONG LengthNeeded,
  567. PSPUD_FILE_INFORMATION pFileInfo
  568. );
  569. dllexp
  570. BOOL
  571. AtqSpudInitialized(
  572. VOID
  573. );
  574. dllexp
  575. BOOL
  576. AtqReadDirChanges(PATQ_CONTEXT patqContext,
  577. LPVOID lpBuffer,
  578. DWORD BytesToRead,
  579. BOOL fWatchSubDir,
  580. DWORD dwNotifyFilter,
  581. OVERLAPPED * lpo );
  582. /*++
  583. AtqPostCompletionStatus()
  584. Routine Description:
  585. Posts a completion status on the completion port queue
  586. An IO pending error code is treated as a success error code
  587. Arguments:
  588. patqContext - pointer to ATQ context
  589. Everything else as in the Win32 API
  590. NOTES:
  591. Return Value:
  592. TRUE if successful, FALSE on error (call GetLastError)
  593. --*/
  594. dllexp
  595. BOOL
  596. AtqPostCompletionStatus(
  597. IN PATQ_CONTEXT patqContext,
  598. IN DWORD BytesTransferred
  599. );
  600. /*----------------------------------------------------------
  601. ATQ Utility Functions
  602. -----------------------------------------------------------*/
  603. /*++
  604. Bandwidth Throttling Support
  605. The following items are used in the support for bandwidth throttling
  606. --*/
  607. enum ATQ_BANDWIDTH_INFO
  608. {
  609. ATQ_BW_BANDWIDTH_LEVEL = 0,
  610. ATQ_BW_MAX_BLOCKED,
  611. ATQ_BW_STATISTICS,
  612. ATQ_BW_DESCRIPTION,
  613. };
  614. /*++
  615. AtqCreateBandwidthInfo()
  616. Routine Description:
  617. Allocate and opaque bandwidth descriptor
  618. Arguments:
  619. None
  620. Return Value:
  621. Pointer to descriptor. NULL if failed.
  622. --*/
  623. dllexp
  624. PVOID
  625. AtqCreateBandwidthInfo(
  626. VOID
  627. );
  628. /*++
  629. AtqFreeBandwidthInfo()
  630. Routine Description:
  631. Triggers the destruction of a bandwidth descriptor
  632. Arguments:
  633. pvBandwidthInfo - pointer to valid descriptor
  634. Return Value:
  635. TRUE if successful, else FALSE
  636. --*/
  637. dllexp
  638. BOOL
  639. AtqFreeBandwidthInfo(
  640. IN PVOID pvBandwidthInfo
  641. );
  642. /*++
  643. AtqBandwidthSetInfo()
  644. Routine Description:
  645. Set properties of bandwidth descriptor
  646. Arguments:
  647. pvBandwidthInfo - pointer to descriptor
  648. BWInfo - property to change
  649. Data - value of property
  650. Return Value:
  651. Old value of property
  652. --*/
  653. dllexp
  654. ULONG_PTR
  655. AtqBandwidthSetInfo(
  656. IN PVOID pvBandwidthInfo,
  657. IN ATQ_BANDWIDTH_INFO BwInfo,
  658. IN ULONG_PTR Data
  659. );
  660. /*++
  661. AtqBandwidthGetInfo()
  662. Routine Description:
  663. Get properties of bandwidth descriptor
  664. Arguments:
  665. pvBandwidthInfo - pointer to descriptor
  666. BWInfo - property to change
  667. pData - filled in with value of property
  668. Return Value:
  669. TRUE if successful, else FALSE
  670. --*/
  671. dllexp
  672. BOOL
  673. AtqBandwidthGetInfo(
  674. IN PVOID pvBandwidthInfo,
  675. IN ATQ_BANDWIDTH_INFO BwInfo,
  676. OUT ULONG_PTR * pData
  677. );
  678. /*++
  679. AtqSetSocketOption()
  680. Routine Description:
  681. Set socket options. Presently only handles TCP_NODELAY
  682. Arguments:
  683. patqContext - pointer to ATQ context
  684. optName - name of property to change
  685. optValue - value of property to set
  686. Return Value:
  687. TRUE if successful, else FALSE
  688. --*/
  689. dllexp
  690. BOOL
  691. AtqSetSocketOption(
  692. IN PATQ_CONTEXT patqContext,
  693. IN INT optName,
  694. IN INT optValue
  695. );
  696. dllexp
  697. PIIS_CAP_TRACE_INFO
  698. AtqGetCapTraceInfo(
  699. IN PATQ_CONTEXT patqContext
  700. );
  701. #ifdef __cplusplus
  702. }
  703. #endif
  704. #endif // !_ATQ_H_