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.

1972 lines
48 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. afdprocs.h
  5. Abstract:
  6. This module contains routine prototypes for AFD.
  7. Author:
  8. David Treadwell (davidtr) 21-Feb-1992
  9. Revision History:
  10. --*/
  11. #ifndef _AFDPROCS_
  12. #define _AFDPROCS_
  13. NTSTATUS
  14. DriverEntry (
  15. IN PDRIVER_OBJECT DriverObject,
  16. IN PUNICODE_STRING RegistryPath
  17. );
  18. NTSTATUS
  19. FASTCALL
  20. AfdAccept (
  21. IN PIRP Irp,
  22. IN PIO_STACK_LOCATION IrpSp
  23. );
  24. NTSTATUS
  25. FASTCALL
  26. AfdSuperAccept (
  27. IN PIRP Irp,
  28. IN PIO_STACK_LOCATION IrpSp
  29. );
  30. NTSTATUS
  31. FASTCALL
  32. AfdDeferAccept (
  33. IN PIRP Irp,
  34. IN PIO_STACK_LOCATION IrpSp
  35. );
  36. NTSTATUS
  37. AfdRestartSuperAccept (
  38. IN PDEVICE_OBJECT DeviceObject,
  39. IN PIRP Irp,
  40. IN PVOID Context
  41. );
  42. VOID
  43. AfdCancelSuperAccept (
  44. IN PDEVICE_OBJECT DeviceObject,
  45. IN PIRP Irp
  46. );
  47. VOID
  48. AfdCleanupSuperAccept (
  49. IN PIRP Irp,
  50. IN NTSTATUS Status
  51. );
  52. BOOLEAN
  53. AfdServiceSuperAccept (
  54. IN PAFD_ENDPOINT Endpoint,
  55. IN PAFD_CONNECTION Connection,
  56. IN PAFD_LOCK_QUEUE_HANDLE LockHandle,
  57. OUT PLIST_ENTRY AcceptIrpList
  58. );
  59. NTSTATUS
  60. AfdAcceptCore (
  61. IN PIRP AcceptIrp,
  62. IN PAFD_ENDPOINT AcceptEndpoint,
  63. IN PAFD_CONNECTION Connection
  64. );
  65. NTSTATUS
  66. AfdSetupAcceptEndpoint (
  67. PAFD_ENDPOINT ListenEndpoint,
  68. PAFD_ENDPOINT AcceptEndpoint,
  69. PAFD_CONNECTION Connection
  70. );
  71. VOID
  72. AfdRestartSuperAcceptListen (
  73. IN PIRP Irp,
  74. IN PAFD_CONNECTION Connection
  75. );
  76. NTSTATUS
  77. AfdRestartDelayedSuperAccept (
  78. IN PDEVICE_OBJECT DeviceObject,
  79. IN PIRP Irp,
  80. IN PVOID Context
  81. );
  82. PMDL
  83. AfdAdvanceMdlChain(
  84. IN PMDL Mdl,
  85. IN ULONG Offset
  86. );
  87. #ifdef _WIN64
  88. NTSTATUS
  89. AfdAllocateMdlChain32(
  90. IN PIRP Irp,
  91. IN LPWSABUF32 BufferArray,
  92. IN ULONG BufferCount,
  93. IN LOCK_OPERATION Operation,
  94. OUT PULONG TotalByteCount
  95. );
  96. #endif
  97. NTSTATUS
  98. AfdAllocateMdlChain(
  99. IN PIRP Irp,
  100. IN LPWSABUF BufferArray,
  101. IN ULONG BufferCount,
  102. IN LOCK_OPERATION Operation,
  103. OUT PULONG TotalByteCount
  104. );
  105. BOOLEAN
  106. AfdAreTransportAddressesEqual (
  107. IN PTRANSPORT_ADDRESS EndpointAddress,
  108. IN ULONG EndpointAddressLength,
  109. IN PTRANSPORT_ADDRESS RequestAddress,
  110. IN ULONG RequestAddressLength,
  111. IN BOOLEAN HonorWildcardIpPortInEndpointAddress
  112. );
  113. NTSTATUS
  114. AfdBeginAbort (
  115. IN PAFD_CONNECTION Connection
  116. );
  117. NTSTATUS
  118. AfdBeginDisconnect (
  119. IN PAFD_ENDPOINT Endpoint,
  120. IN PLARGE_INTEGER Timeout OPTIONAL,
  121. OUT PIRP *DisconnectIrp OPTIONAL
  122. );
  123. NTSTATUS
  124. FASTCALL
  125. AfdBind (
  126. IN PIRP Irp,
  127. IN PIO_STACK_LOCATION IrpSp
  128. );
  129. ULONG
  130. AfdCalcBufferArrayByteLength(
  131. IN LPWSABUF BufferArray,
  132. IN ULONG BufferCount
  133. );
  134. VOID
  135. AfdCancelReceiveDatagram (
  136. IN PDEVICE_OBJECT DeviceObject,
  137. IN PIRP Irp
  138. );
  139. NTSTATUS
  140. FASTCALL
  141. AfdCleanup (
  142. IN PIRP Irp,
  143. IN PIO_STACK_LOCATION IrpSp
  144. );
  145. NTSTATUS
  146. FASTCALL
  147. AfdClose (
  148. IN PIRP Irp,
  149. IN PIO_STACK_LOCATION IrpSp
  150. );
  151. VOID
  152. AfdCompleteIrpList (
  153. IN PLIST_ENTRY IrpListHead,
  154. IN PAFD_ENDPOINT Endpoint,
  155. IN NTSTATUS Status,
  156. IN PAFD_IRP_CLEANUP_ROUTINE CleanupRoutine OPTIONAL
  157. );
  158. VOID
  159. AfdCompleteClosePendedTransmit (
  160. IN PVOID Context
  161. );
  162. NTSTATUS
  163. FASTCALL
  164. AfdConnect (
  165. IN PIRP Irp,
  166. IN PIO_STACK_LOCATION IrpSp
  167. );
  168. NTSTATUS
  169. FASTCALL
  170. AfdJoinLeaf (
  171. IN PIRP Irp,
  172. IN PIO_STACK_LOCATION IrpSp
  173. );
  174. NTSTATUS
  175. FASTCALL
  176. AfdSuperConnect (
  177. IN PIRP Irp,
  178. IN PIO_STACK_LOCATION IrpSp
  179. );
  180. NTSTATUS
  181. AfdConnectEventHandler (
  182. IN PVOID TdiEventContext,
  183. IN int RemoteAddressLength,
  184. IN PVOID RemoteAddress,
  185. IN int UserDataLength,
  186. IN PVOID UserData,
  187. IN int OptionsLength,
  188. IN PVOID Options,
  189. OUT CONNECTION_CONTEXT *ConnectionContext,
  190. OUT PIRP *AcceptIrp
  191. );
  192. #ifdef _WIN64
  193. ULONG
  194. AfdComputeCMSGLength32 (
  195. PVOID ControlBuffer,
  196. ULONG ControlLength
  197. );
  198. VOID
  199. AfdCopyCMSGBuffer32 (
  200. PVOID Dst,
  201. PVOID ControlBuffer,
  202. ULONG CopyLength
  203. );
  204. #endif //_WIN64
  205. ULONG
  206. AfdCopyBufferArrayToBuffer(
  207. IN PVOID Destination,
  208. IN ULONG DestinationLength,
  209. IN LPWSABUF BufferArray,
  210. IN ULONG BufferCount
  211. );
  212. ULONG
  213. AfdCopyBufferToBufferArray(
  214. IN LPWSABUF BufferArray,
  215. IN ULONG Offset,
  216. IN ULONG BufferCount,
  217. IN PVOID Source,
  218. IN ULONG SourceLength
  219. );
  220. ULONG
  221. AfdCopyMdlChainToBufferArray(
  222. IN LPWSABUF BufferArray,
  223. IN ULONG BufferOffset,
  224. IN ULONG BufferCount,
  225. IN PMDL Source,
  226. IN ULONG SourceOffset,
  227. IN ULONG SourceLength
  228. );
  229. NTSTATUS
  230. AfdCopyMdlChainToMdlChain (
  231. PMDL Destination,
  232. ULONG DestinationOffset,
  233. PMDL Source,
  234. ULONG SourceOffset,
  235. ULONG SourceLength,
  236. PULONG BytesCopied
  237. );
  238. NTSTATUS
  239. AfdCopyMdlChainToBufferAvoidMapping(
  240. IN PMDL SourceMdl,
  241. IN ULONG SourceOffset,
  242. IN ULONG SourceLength,
  243. IN PUCHAR Buffer,
  244. IN ULONG BufferSize
  245. );
  246. NTSTATUS
  247. AfdMapMdlChain (
  248. PMDL MdlChain
  249. );
  250. NTSTATUS
  251. FASTCALL
  252. AfdCreate (
  253. IN PIRP Irp,
  254. IN PIO_STACK_LOCATION IrpSp
  255. );
  256. NTSTATUS
  257. AfdDelayedAcceptListen (
  258. PAFD_ENDPOINT Endpoint,
  259. PAFD_CONNECTION Connection
  260. );
  261. VOID
  262. AfdDestroyMdlChain (
  263. IN PIRP Irp
  264. );
  265. NTSTATUS
  266. AfdDisconnectEventHandler (
  267. IN PVOID TdiEventContext,
  268. IN CONNECTION_CONTEXT ConnectionContext,
  269. IN int DisconnectDataLength,
  270. IN PVOID DisconnectData,
  271. IN int DisconnectInformationLength,
  272. IN PVOID DisconnectInformation,
  273. IN ULONG DisconnectFlags
  274. );
  275. NTSTATUS
  276. AfdDispatch (
  277. IN PDEVICE_OBJECT DeviceObject,
  278. IN PIRP Irp
  279. );
  280. NTSTATUS
  281. AfdDispatchDeviceControl (
  282. IN PDEVICE_OBJECT DeviceObject,
  283. IN PIRP Irp
  284. );
  285. NTSTATUS
  286. FASTCALL
  287. AfdDispatchImmediateIrp(
  288. IN PIRP Irp,
  289. IN PIO_STACK_LOCATION IrpSp
  290. );
  291. NTSTATUS
  292. AfdEnumNetworkEvents (
  293. IN PFILE_OBJECT FileObject,
  294. IN ULONG IoctlCode,
  295. IN KPROCESSOR_MODE RequestorMode,
  296. IN PVOID InputBuffer,
  297. IN ULONG InputBufferLength,
  298. IN PVOID OutputBuffer,
  299. IN ULONG OutputBufferLength,
  300. OUT PUINT_PTR Information
  301. );
  302. NTSTATUS
  303. AfdErrorEventHandler (
  304. IN PVOID TdiEventContext,
  305. IN NTSTATUS Status
  306. );
  307. NTSTATUS
  308. AfdErrorExEventHandler (
  309. IN PVOID TdiEventContext,
  310. IN NTSTATUS Status,
  311. IN PVOID Context
  312. );
  313. NTSTATUS
  314. AfdEventSelect (
  315. IN PFILE_OBJECT FileObject,
  316. IN ULONG IoctlCode,
  317. IN KPROCESSOR_MODE RequestorMode,
  318. IN PVOID InputBuffer,
  319. IN ULONG InputBufferLength,
  320. IN PVOID OutputBuffer,
  321. IN ULONG OutputBufferLength,
  322. OUT PUINT_PTR Information
  323. );
  324. LONG
  325. AfdExceptionFilter(
  326. #if DBG
  327. PCHAR SourceFile,
  328. LONG LineNumber,
  329. #endif
  330. PEXCEPTION_POINTERS ExceptionPointers,
  331. PNTSTATUS ExceptionCode
  332. );
  333. BOOLEAN
  334. AfdFastTransmitFile (
  335. IN PAFD_ENDPOINT endpoint,
  336. IN PAFD_TRANSMIT_FILE_INFO transmitInfo,
  337. OUT PIO_STATUS_BLOCK IoStatus
  338. );
  339. VOID
  340. AfdFreeConnectDataBuffers (
  341. IN PAFD_CONNECT_DATA_BUFFERS ConnectDataBuffers
  342. );
  343. VOID
  344. AfdFreeQueuedConnections (
  345. IN PAFD_ENDPOINT Endpoint
  346. );
  347. NTSTATUS
  348. FASTCALL
  349. AfdGetAddress (
  350. IN PIRP Irp,
  351. IN PIO_STACK_LOCATION IrpSp
  352. );
  353. NTSTATUS
  354. AfdGetRemoteAddress (
  355. IN PFILE_OBJECT FileObject,
  356. IN ULONG IoctlCode,
  357. IN KPROCESSOR_MODE RequestorMode,
  358. IN PVOID InputBuffer,
  359. IN ULONG InputBufferLength,
  360. IN PVOID OutputBuffer,
  361. IN ULONG OutputBufferLength,
  362. OUT PUINT_PTR Information
  363. );
  364. NTSTATUS
  365. AfdGetContext (
  366. IN PFILE_OBJECT FileObject,
  367. IN ULONG IoctlCode,
  368. IN KPROCESSOR_MODE RequestorMode,
  369. IN PVOID InputBuffer,
  370. IN ULONG InputBufferLength,
  371. IN PVOID OutputBuffer,
  372. IN ULONG OutputBufferLength,
  373. OUT PUINT_PTR Information
  374. );
  375. NTSTATUS
  376. AfdGetInformation (
  377. IN PFILE_OBJECT FileObject,
  378. IN ULONG IoctlCode,
  379. IN KPROCESSOR_MODE RequestorMode,
  380. IN PVOID InputBuffer,
  381. IN ULONG InputBufferLength,
  382. IN PVOID OutputBuffer,
  383. IN ULONG OutputBufferLength,
  384. OUT PUINT_PTR Information
  385. );
  386. NTSTATUS
  387. AfdGetTransportInfo (
  388. IN PUNICODE_STRING TransportDeviceName,
  389. IN OUT PAFD_TRANSPORT_INFO *TransportInfo
  390. );
  391. NTSTATUS
  392. AfdQueryProviderInfo (
  393. IN PUNICODE_STRING TransportDeviceName,
  394. OUT PTDI_PROVIDER_INFO ProviderInfo
  395. );
  396. VOID
  397. AfdIndicateEventSelectEvent (
  398. IN PAFD_ENDPOINT Endpoint,
  399. IN ULONG PollEventMask,
  400. IN NTSTATUS Status
  401. );
  402. VOID
  403. AfdIndicatePollEventReal (
  404. IN PAFD_ENDPOINT Endpoint,
  405. IN ULONG PollEventMask,
  406. IN NTSTATUS Status
  407. );
  408. #define AfdIndicatePollEvent(_e,_m,_s) \
  409. ((_e)->PollCalled ? (AfdIndicatePollEventReal((_e),(_m),(_s)), TRUE) : FALSE)
  410. VOID
  411. AfdInitiateListenBacklogReplenish (
  412. IN PAFD_ENDPOINT Endpoint
  413. );
  414. VOID
  415. AfdInitializeData (
  416. VOID
  417. );
  418. NTSTATUS
  419. AfdIssueDeviceControl (
  420. IN PFILE_OBJECT FileObject,
  421. IN PVOID IrpParameters,
  422. IN ULONG IrpParametersLength,
  423. IN PVOID MdlBuffer,
  424. IN ULONG MdlBufferLength,
  425. IN UCHAR MinorFunction
  426. );
  427. VOID
  428. AfdIncrementLockCount (
  429. VOID
  430. );
  431. VOID
  432. AfdDecrementLockCount (
  433. VOID
  434. );
  435. VOID
  436. AfdInsertNewEndpointInList (
  437. IN PAFD_ENDPOINT Endpoint
  438. );
  439. VOID
  440. AfdRemoveEndpointFromList (
  441. IN PAFD_ENDPOINT Endpoint
  442. );
  443. PVOID
  444. AfdLockEndpointContext (
  445. PAFD_ENDPOINT Endpoint
  446. );
  447. VOID
  448. AfdUnlockEndpointContext (
  449. PAFD_ENDPOINT Endpoint,
  450. PVOID Context
  451. );
  452. NTSTATUS
  453. AfdPartialDisconnect (
  454. IN PFILE_OBJECT FileObject,
  455. IN ULONG IoctlCode,
  456. IN KPROCESSOR_MODE RequestorMode,
  457. IN PVOID InputBuffer,
  458. IN ULONG InputBufferLength,
  459. IN PVOID OutputBuffer,
  460. IN ULONG OutputBufferLength,
  461. OUT PUINT_PTR Information
  462. );
  463. NTSTATUS
  464. FASTCALL
  465. AfdPoll (
  466. IN PIRP Irp,
  467. IN PIO_STACK_LOCATION IrpSp
  468. );
  469. VOID
  470. AfdQueueWorkItem (
  471. IN PWORKER_THREAD_ROUTINE AfdWorkerRoutine,
  472. IN PAFD_WORK_ITEM AfdWorkItem
  473. );
  474. PAFD_WORK_ITEM
  475. AfdGetWorkerByRoutine (
  476. PWORKER_THREAD_ROUTINE Routine
  477. );
  478. NTSTATUS
  479. AfdQueryHandles (
  480. IN PFILE_OBJECT FileObject,
  481. IN ULONG IoctlCode,
  482. IN KPROCESSOR_MODE RequestorMode,
  483. IN PVOID InputBuffer,
  484. IN ULONG InputBufferLength,
  485. IN PVOID OutputBuffer,
  486. IN ULONG OutputBufferLength,
  487. OUT PUINT_PTR Information
  488. );
  489. NTSTATUS
  490. AfdQueryReceiveInformation (
  491. IN PFILE_OBJECT FileObject,
  492. IN ULONG IoctlCode,
  493. IN KPROCESSOR_MODE RequestorMode,
  494. IN PVOID InputBuffer,
  495. IN ULONG InputBufferLength,
  496. IN PVOID OutputBuffer,
  497. IN ULONG OutputBufferLength,
  498. OUT PUINT_PTR Information
  499. );
  500. NTSTATUS
  501. AfdSetContext (
  502. IN PFILE_OBJECT FileObject,
  503. IN ULONG IoctlCode,
  504. IN KPROCESSOR_MODE RequestorMode,
  505. IN PVOID InputBuffer,
  506. IN ULONG InputBufferLength,
  507. IN PVOID OutputBuffer,
  508. IN ULONG OutputBufferLength,
  509. OUT PUINT_PTR Information
  510. );
  511. NTSTATUS
  512. AfdSetEventHandler (
  513. IN PFILE_OBJECT FileObject,
  514. IN ULONG EventType,
  515. IN PVOID EventHandler,
  516. IN PVOID EventContext
  517. );
  518. NTSTATUS
  519. AfdSetInLineMode (
  520. IN PAFD_CONNECTION Connection,
  521. IN BOOLEAN InLine
  522. );
  523. NTSTATUS
  524. FASTCALL
  525. AfdReceive (
  526. IN PIRP Irp,
  527. IN PIO_STACK_LOCATION IrpSp
  528. );
  529. NTSTATUS
  530. AfdBReceive (
  531. IN PIRP Irp,
  532. IN PIO_STACK_LOCATION IrpSp,
  533. IN ULONG RecvFlags,
  534. IN ULONG AfdFlags,
  535. IN ULONG RecvLength
  536. );
  537. NTSTATUS
  538. FASTCALL
  539. AfdReceiveDatagram (
  540. IN PIRP Irp,
  541. IN PIO_STACK_LOCATION IrpSp
  542. );
  543. NTSTATUS
  544. AfdSetupReceiveDatagramIrp (
  545. IN PIRP Irp,
  546. IN PVOID DatagramBuffer OPTIONAL,
  547. IN ULONG DatagramLength,
  548. IN PVOID OptionsBuffer OPTIONAL,
  549. IN ULONG OptionsLength,
  550. IN PVOID SourceAddress OPTIONAL,
  551. IN ULONG SourceAddressLength,
  552. IN ULONG TdiFlags
  553. );
  554. BOOLEAN
  555. AfdCleanupReceiveDatagramIrp(
  556. IN PIRP Irp
  557. );
  558. BOOLEAN
  559. AfdCleanupSendIrp (
  560. PIRP Irp
  561. );
  562. NTSTATUS
  563. AfdReceiveEventHandler (
  564. IN PVOID TdiEventContext,
  565. IN CONNECTION_CONTEXT ConnectionContext,
  566. IN ULONG ReceiveFlags,
  567. IN ULONG BytesIndicated,
  568. IN ULONG BytesAvailable,
  569. OUT ULONG *BytesTaken,
  570. IN PVOID Tsdu,
  571. OUT PIRP *IoRequestPacket
  572. );
  573. NTSTATUS
  574. AfdBChainedReceiveEventHandler(
  575. IN PVOID TdiEventContext,
  576. IN CONNECTION_CONTEXT ConnectionContext,
  577. IN ULONG ReceiveFlags,
  578. IN ULONG ReceiveLength,
  579. IN ULONG StartingOffset,
  580. IN PMDL Tsdu,
  581. IN PVOID TsduDescriptor
  582. );
  583. NTSTATUS
  584. AfdBReceiveEventHandler (
  585. IN PVOID TdiEventContext,
  586. IN CONNECTION_CONTEXT ConnectionContext,
  587. IN ULONG ReceiveFlags,
  588. IN ULONG BytesIndicated,
  589. IN ULONG BytesAvailable,
  590. OUT ULONG *BytesTaken,
  591. IN PVOID Tsdu,
  592. OUT PIRP *IoRequestPacket
  593. );
  594. NTSTATUS
  595. AfdReceiveDatagramEventHandler (
  596. IN PVOID TdiEventContext,
  597. IN int SourceAddressLength,
  598. IN PVOID SourceAddress,
  599. IN int OptionsLength,
  600. IN PVOID Options,
  601. IN ULONG ReceiveDatagramFlags,
  602. IN ULONG BytesIndicated,
  603. IN ULONG BytesAvailable,
  604. OUT ULONG *BytesTaken,
  605. IN PVOID Tsdu,
  606. OUT PIRP *IoRequestPacket
  607. );
  608. NTSTATUS
  609. AfdReceiveExpeditedEventHandler (
  610. IN PVOID TdiEventContext,
  611. IN CONNECTION_CONTEXT ConnectionContext,
  612. IN ULONG ReceiveFlags,
  613. IN ULONG BytesIndicated,
  614. IN ULONG BytesAvailable,
  615. OUT ULONG *BytesTaken,
  616. IN PVOID Tsdu,
  617. OUT PIRP *IoRequestPacket
  618. );
  619. NTSTATUS
  620. AfdBReceiveExpeditedEventHandler (
  621. IN PVOID TdiEventContext,
  622. IN CONNECTION_CONTEXT ConnectionContext,
  623. IN ULONG ReceiveFlags,
  624. IN ULONG BytesIndicated,
  625. IN ULONG BytesAvailable,
  626. OUT ULONG *BytesTaken,
  627. IN PVOID Tsdu,
  628. OUT PIRP *IoRequestPacket
  629. );
  630. NTSTATUS
  631. AfdRestartBufferReceive (
  632. IN PDEVICE_OBJECT DeviceObject,
  633. IN PIRP Irp,
  634. IN PVOID Context
  635. );
  636. NTSTATUS
  637. AfdRestartAbort (
  638. IN PDEVICE_OBJECT DeviceObject,
  639. IN PIRP Irp,
  640. IN PVOID Context
  641. );
  642. NTSTATUS
  643. FASTCALL
  644. AfdSend (
  645. IN PIRP Irp,
  646. IN PIO_STACK_LOCATION IrpSp
  647. );
  648. NTSTATUS
  649. FASTCALL
  650. AfdSendDatagram (
  651. IN PIRP Irp,
  652. IN PIO_STACK_LOCATION IrpSp
  653. );
  654. NTSTATUS
  655. AfdSendPossibleEventHandler (
  656. IN PVOID TdiEventContext,
  657. IN PVOID ConnectionContext,
  658. IN ULONG BytesAvailable
  659. );
  660. NTSTATUS
  661. AfdRestartBufferSend (
  662. IN PDEVICE_OBJECT DeviceObject,
  663. IN PIRP Irp,
  664. IN PVOID Context
  665. );
  666. VOID
  667. AfdProcessBufferSend (
  668. IN PAFD_CONNECTION Connection,
  669. IN PIRP Irp
  670. );
  671. NTSTATUS
  672. AfdSetInformation (
  673. IN PFILE_OBJECT FileObject,
  674. IN ULONG IoctlCode,
  675. IN KPROCESSOR_MODE RequestorMode,
  676. IN PVOID InputBuffer,
  677. IN ULONG InputBufferLength,
  678. IN PVOID OutputBuffer,
  679. IN ULONG OutputBufferLength,
  680. OUT PUINT_PTR Information
  681. );
  682. BOOLEAN
  683. AfdShouldSendBlock (
  684. IN PAFD_ENDPOINT Endpoint,
  685. IN PAFD_CONNECTION Connection,
  686. IN ULONG SendLength
  687. );
  688. NTSTATUS
  689. AfdStartListen (
  690. IN PFILE_OBJECT FileObject,
  691. IN ULONG IoctlCode,
  692. IN KPROCESSOR_MODE RequestorMode,
  693. IN PVOID InputBuffer,
  694. IN ULONG InputBufferLength,
  695. IN PVOID OutputBuffer,
  696. IN ULONG OutputBufferLength,
  697. OUT PUINT_PTR Information
  698. );
  699. NTSTATUS
  700. FASTCALL
  701. AfdTransmitFile (
  702. IN PIRP Irp,
  703. IN PIO_STACK_LOCATION IrpSp
  704. );
  705. NTSTATUS
  706. FASTCALL
  707. AfdWaitForListen (
  708. IN PIRP Irp,
  709. IN PIO_STACK_LOCATION IrpSp
  710. );
  711. NTSTATUS
  712. FASTCALL
  713. AfdSetQos (
  714. IN PIRP Irp,
  715. IN PIO_STACK_LOCATION IrpSp
  716. );
  717. NTSTATUS
  718. FASTCALL
  719. AfdGetQos (
  720. IN PIRP Irp,
  721. IN PIO_STACK_LOCATION IrpSp
  722. );
  723. NTSTATUS
  724. FASTCALL
  725. AfdNoOperation (
  726. IN PIRP Irp,
  727. IN PIO_STACK_LOCATION IrpSp
  728. );
  729. NTSTATUS
  730. FASTCALL
  731. AfdValidateGroup (
  732. IN PIRP Irp,
  733. IN PIO_STACK_LOCATION IrpSp
  734. );
  735. NTSTATUS
  736. AfdGetUnacceptedConnectData (
  737. IN PFILE_OBJECT FileObject,
  738. IN ULONG IoctlCode,
  739. IN KPROCESSOR_MODE RequestorMode,
  740. IN PVOID InputBuffer,
  741. IN ULONG InputBufferLength,
  742. IN PVOID OutputBuffer,
  743. IN ULONG OutputBufferLength,
  744. OUT PUINT_PTR Information
  745. );
  746. #define AfdReferenceEventObjectByHandle(Handle, AccessMode, Object) \
  747. ObReferenceObjectByHandle( \
  748. (Handle), \
  749. EVENT_MODIFY_STATE, \
  750. *(POBJECT_TYPE *)ExEventObjectType, \
  751. (AccessMode), \
  752. (Object), \
  753. NULL \
  754. )
  755. //
  756. // Endpoint handling routines.
  757. //
  758. NTSTATUS
  759. AfdAllocateEndpoint (
  760. OUT PAFD_ENDPOINT * NewEndpoint,
  761. IN PUNICODE_STRING TransportDeviceName,
  762. IN LONG GroupID
  763. );
  764. #if REFERENCE_DEBUG
  765. VOID
  766. AfdReferenceEndpoint (
  767. IN PAFD_ENDPOINT Endpoint,
  768. IN LONG LocationId,
  769. IN ULONG Param
  770. );
  771. BOOLEAN
  772. AfdCheckAndReferenceEndpoint (
  773. IN PAFD_ENDPOINT Endpoint,
  774. IN LONG LocationId,
  775. IN ULONG Param
  776. );
  777. VOID
  778. AfdDereferenceEndpoint (
  779. IN PAFD_ENDPOINT Endpoint,
  780. IN LONG LocationId,
  781. IN ULONG Param
  782. );
  783. VOID
  784. AfdUpdateEndpoint (
  785. IN PAFD_ENDPOINT Endpoint,
  786. IN LONG LocationId,
  787. IN ULONG Param
  788. );
  789. #define REFERENCE_ENDPOINT(_e) { \
  790. static LONG _arl; \
  791. AfdReferenceEndpoint((_e),AFD_GET_ARL(__FILE__"(%d)+"),__LINE__); \
  792. }
  793. #define REFERENCE_ENDPOINT2(_e,_s,_p) { \
  794. static LONG _arl; \
  795. AfdReferenceEndpoint((_e),AFD_GET_ARL(_s"+"),(_p)); \
  796. }
  797. #define CHECK_REFERENCE_ENDPOINT(_e,_r) { \
  798. static LONG _arl; \
  799. _r = AfdCheckAndReferenceEndpoint((_e),AFD_GET_ARL(__FILE__"(%d)*"),\
  800. __LINE__); \
  801. }
  802. #define DEREFERENCE_ENDPOINT(_e) { \
  803. static LONG _arl; \
  804. AfdDereferenceEndpoint((_e),AFD_GET_ARL(__FILE__"(%d)-"),__LINE__); \
  805. }
  806. #define DEREFERENCE_ENDPOINT2(_e,_s,_p) { \
  807. static LONG _arl; \
  808. AfdDereferenceEndpoint((_e),AFD_GET_ARL(_s"-"),(_p)); \
  809. }
  810. #define UPDATE_ENDPOINT(_e) { \
  811. static LONG _arl; \
  812. AfdUpdateEndpoint((_e),AFD_GET_ARL(__FILE__"(%d)="),__LINE__); \
  813. }
  814. #define UPDATE_ENDPOINT2(_e,_s,_p) { \
  815. static LONG _arl; \
  816. AfdUpdateEndpoint((_e),AFD_GET_ARL(_s"="),(_p)); \
  817. }
  818. #else
  819. BOOLEAN
  820. AfdCheckAndReferenceEndpoint (
  821. IN PAFD_ENDPOINT Endpoint
  822. );
  823. VOID
  824. AfdDereferenceEndpoint (
  825. IN PAFD_ENDPOINT Endpoint
  826. );
  827. #define REFERENCE_ENDPOINT(_e) (VOID)InterlockedIncrement( (PLONG)&(_e)->ReferenceCount )
  828. #define REFERENCE_ENDPOINT2(_e,_s,_p) InterlockedIncrement( (PLONG)&(_e)->ReferenceCount )
  829. #define CHECK_REFERENCE_ENDPOINT(_e,_r) _r=AfdCheckAndReferenceEndpoint((_e))
  830. #define DEREFERENCE_ENDPOINT(_e) AfdDereferenceEndpoint((_e))
  831. #define DEREFERENCE_ENDPOINT2(_e,_s,_p) AfdDereferenceEndpoint((_e))
  832. #define UPDATE_ENDPOINT(_e)
  833. #define UPDATE_ENDPOINT2(_e,_s,_p)
  834. #endif
  835. VOID
  836. AfdRefreshEndpoint (
  837. IN PAFD_ENDPOINT Endpoint
  838. );
  839. //
  840. // Connection handling routines.
  841. //
  842. VOID
  843. AfdAbortConnection (
  844. IN PAFD_CONNECTION Connection
  845. );
  846. NTSTATUS
  847. AfdAddFreeConnection (
  848. IN PAFD_ENDPOINT Endpoint
  849. );
  850. PAFD_CONNECTION
  851. AfdAllocateConnection (
  852. VOID
  853. );
  854. NTSTATUS
  855. AfdCreateConnection (
  856. IN PUNICODE_STRING TransportDeviceName,
  857. IN HANDLE AddressHandle OPTIONAL,
  858. IN BOOLEAN TdiBufferring,
  859. IN LOGICAL InLine,
  860. IN PEPROCESS ProcessToCharge,
  861. OUT PAFD_CONNECTION *Connection
  862. );
  863. PAFD_CONNECTION
  864. AfdGetFreeConnection (
  865. IN PAFD_ENDPOINT Endpoint,
  866. OUT PIRP *Irp
  867. );
  868. PAFD_CONNECTION
  869. AfdGetReturnedConnection (
  870. IN PAFD_ENDPOINT Endpoint,
  871. IN LONG Sequence
  872. );
  873. PAFD_CONNECTION
  874. AfdFindReturnedConnection(
  875. IN PAFD_ENDPOINT Endpoint,
  876. IN LONG Sequence
  877. );
  878. PAFD_CONNECTION
  879. AfdGetUnacceptedConnection (
  880. IN PAFD_ENDPOINT Endpoint
  881. );
  882. PAFD_CONNECTION
  883. AfdGetConnectionReferenceFromEndpoint (
  884. PAFD_ENDPOINT Endpoint
  885. );
  886. #if REFERENCE_DEBUG
  887. VOID
  888. AfdReferenceConnection (
  889. IN PAFD_CONNECTION Connection,
  890. IN LONG LocationId,
  891. IN ULONG Param
  892. );
  893. BOOLEAN
  894. AfdCheckAndReferenceConnection (
  895. PAFD_CONNECTION Connection,
  896. IN LONG LocationId,
  897. IN ULONG Param
  898. );
  899. VOID
  900. AfdDereferenceConnection (
  901. IN PAFD_CONNECTION Connection,
  902. IN LONG LocationId,
  903. IN ULONG Param
  904. );
  905. #define REFERENCE_CONNECTION(_c) { \
  906. static LONG _arl; \
  907. AfdReferenceConnection((_c),AFD_GET_ARL(__FILE__"(%d)+"),__LINE__); \
  908. }
  909. #define REFERENCE_CONNECTION2(_c,_s,_p) { \
  910. static LONG _arl; \
  911. AfdReferenceConnection((_c),AFD_GET_ARL(_s"+"),(_p)); \
  912. }
  913. #define CHECK_REFERENCE_CONNECTION(_c,_r) { \
  914. static LONG _arl; \
  915. _r=AfdCheckAndReferenceConnection((_c),AFD_GET_ARL(__FILE__"(%d)*"),\
  916. __LINE__); \
  917. }
  918. #define CHECK_REFERENCE_CONNECTION2(_c,_s,_p,_r) { \
  919. static LONG _arl; \
  920. _r = AfdCheckAndReferenceConnection((_c),AFD_GET_ARL(_s"*"),(_p)); \
  921. }
  922. #define DEREFERENCE_CONNECTION(_c) { \
  923. static LONG _arl; \
  924. AfdDereferenceConnection((_c),AFD_GET_ARL(__FILE__"(%d)-"),__LINE__);\
  925. }
  926. #define DEREFERENCE_CONNECTION2(_c,_s,_p) { \
  927. static LONG _arl; \
  928. AfdDereferenceConnection((_c),AFD_GET_ARL(_s"-"),(_p)); \
  929. }
  930. VOID
  931. AfdUpdateConnectionTrack (
  932. IN PAFD_CONNECTION Connection,
  933. IN LONG LocationId,
  934. IN ULONG Param
  935. );
  936. #define UPDATE_CONN(_c) \
  937. if( (_c) != NULL ) { \
  938. static LONG _arl; \
  939. AfdUpdateConnectionTrack( \
  940. (_c), \
  941. AFD_GET_ARL(__FILE__"(%d)="), \
  942. __LINE__ \
  943. ); \
  944. } else
  945. #define UPDATE_CONN2(_c,_s,_p) \
  946. if( (_c) != NULL ) { \
  947. static LONG _arl; \
  948. AfdUpdateConnectionTrack((_c),AFD_GET_ARL(_s"="),(_p)); \
  949. } else
  950. #else
  951. VOID
  952. AfdCloseConnection (
  953. IN PAFD_CONNECTION Connection
  954. );
  955. BOOLEAN
  956. AfdCheckAndReferenceConnection (
  957. PAFD_CONNECTION Connection
  958. );
  959. #define REFERENCE_CONNECTION(_c) (VOID)InterlockedIncrement( (PLONG)&(_c)->ReferenceCount )
  960. #define REFERENCE_CONNECTION2(_c,_s,_p) (VOID)InterlockedIncrement( (PLONG)&(_c)->ReferenceCount )
  961. #define CHECK_REFERENCE_CONNECTION(_c,_r) _r=AfdCheckAndReferenceConnection((_c))
  962. #define CHECK_REFERENCE_CONNECTION2(_c,_s,_p,_r) _r=AfdCheckAndReferenceConnection((_c))
  963. #define DEREFERENCE_CONNECTION(_c) \
  964. if (InterlockedDecrement((PLONG)&(_c)->ReferenceCount)==0) { \
  965. AfdCloseConnection (_c); \
  966. } \
  967. #define DEREFERENCE_CONNECTION2(_c,_s,_p) \
  968. if (InterlockedDecrement((PLONG)&(_c)->ReferenceCount)==0) { \
  969. AfdCloseConnection (_c); \
  970. } \
  971. #define UPDATE_CONN(_c)
  972. #define UPDATE_CONN2(_c,_s,_p)
  973. #endif
  974. VOID
  975. AfdAddConnectedReference (
  976. IN PAFD_CONNECTION Connection
  977. );
  978. VOID
  979. AfdDeleteConnectedReference (
  980. IN PAFD_CONNECTION Connection,
  981. IN BOOLEAN EndpointLockHeld
  982. );
  983. //
  984. // Routines to handle fast IO.
  985. //
  986. BOOLEAN
  987. AfdFastIoRead (
  988. IN struct _FILE_OBJECT *FileObject,
  989. IN PLARGE_INTEGER FileOffset,
  990. IN ULONG Length,
  991. IN BOOLEAN Wait,
  992. IN ULONG LockKey,
  993. OUT PVOID Buffer,
  994. OUT PIO_STATUS_BLOCK IoStatus,
  995. IN struct _DEVICE_OBJECT *DeviceObject
  996. );
  997. BOOLEAN
  998. AfdFastIoWrite (
  999. IN struct _FILE_OBJECT *FileObject,
  1000. IN PLARGE_INTEGER FileOffset,
  1001. IN ULONG Length,
  1002. IN BOOLEAN Wait,
  1003. IN ULONG LockKey,
  1004. IN PVOID Buffer,
  1005. OUT PIO_STATUS_BLOCK IoStatus,
  1006. IN struct _DEVICE_OBJECT *DeviceObject
  1007. );
  1008. BOOLEAN
  1009. AfdFastIoDeviceControl (
  1010. IN struct _FILE_OBJECT *FileObject,
  1011. IN BOOLEAN Wait,
  1012. IN PVOID InputBuffer OPTIONAL,
  1013. IN ULONG InputBufferLength,
  1014. OUT PVOID OutputBuffer OPTIONAL,
  1015. IN ULONG OutputBufferLength,
  1016. IN ULONG IoControlCode,
  1017. OUT PIO_STATUS_BLOCK IoStatus,
  1018. IN struct _DEVICE_OBJECT *DeviceObject
  1019. );
  1020. //
  1021. // Routines to handle getting and setting connect data.
  1022. //
  1023. NTSTATUS
  1024. AfdGetConnectData (
  1025. IN PFILE_OBJECT FileObject,
  1026. IN ULONG IoctlCode,
  1027. IN KPROCESSOR_MODE RequestorMode,
  1028. IN PVOID InputBuffer,
  1029. IN ULONG InputBufferLength,
  1030. IN PVOID OutputBuffer,
  1031. IN ULONG OutputBufferLength,
  1032. OUT PUINT_PTR Information
  1033. );
  1034. NTSTATUS
  1035. AfdSetConnectData (
  1036. IN PFILE_OBJECT FileObject,
  1037. IN ULONG IoctlCode,
  1038. IN KPROCESSOR_MODE RequestorMode,
  1039. IN PVOID InputBuffer,
  1040. IN ULONG InputBufferLength,
  1041. IN PVOID OutputBuffer,
  1042. IN ULONG OutputBufferLength,
  1043. OUT PUINT_PTR Information
  1044. );
  1045. NTSTATUS
  1046. AfdSaveReceivedConnectData (
  1047. IN OUT PAFD_CONNECT_DATA_BUFFERS * DataBuffers,
  1048. IN ULONG IoControlCode,
  1049. IN PVOID Buffer,
  1050. IN ULONG BufferLength
  1051. );
  1052. //
  1053. // Buffer management routines.
  1054. //
  1055. PVOID
  1056. AfdAllocateBuffer (
  1057. IN POOL_TYPE PoolType,
  1058. IN SIZE_T NumberOfBytes,
  1059. IN ULONG Tag
  1060. );
  1061. PVOID
  1062. AfdAllocateBufferTag (
  1063. IN POOL_TYPE PoolType,
  1064. IN SIZE_T NumberOfBytes,
  1065. IN ULONG Tag
  1066. );
  1067. VOID
  1068. NTAPI
  1069. AfdFreeBufferTag(
  1070. IN PVOID AfdBufferTag
  1071. );
  1072. PVOID
  1073. AfdAllocateRemoteAddress (
  1074. IN POOL_TYPE PoolType,
  1075. IN SIZE_T NumberOfBytes,
  1076. IN ULONG Tag
  1077. );
  1078. VOID
  1079. NTAPI
  1080. AfdFreeRemoteAddress(
  1081. IN PVOID AfdBufferTag
  1082. );
  1083. VOID
  1084. AfdInitializeBufferTag (
  1085. IN PAFD_BUFFER_TAG AfdBufferTag,
  1086. IN ULONG AddressSize
  1087. );
  1088. #define AFDB_RAISE_ON_FAILURE ((ULONG_PTR)1)
  1089. PAFD_BUFFER_TAG
  1090. AfdGetBufferTag (
  1091. IN ULONG AddressSize,
  1092. IN PEPROCESS Process
  1093. );
  1094. #define AfdGetBufferTagRaiseOnFailure(_as,_pr) \
  1095. AfdGetBufferTag((_as),((PEPROCESS)((ULONG_PTR)(_pr)|AFDB_RAISE_ON_FAILURE)))
  1096. ULONG
  1097. AfdCalculateBufferSize (
  1098. IN ULONG BufferDataSize,
  1099. IN ULONG AddressSize
  1100. );
  1101. PAFD_BUFFER
  1102. AfdGetBuffer (
  1103. IN ULONG BufferDataSize,
  1104. IN ULONG AddressSize,
  1105. IN PEPROCESS Process
  1106. );
  1107. #define AfdGetBufferRaiseOnFailure(_ds,_as,_pr) \
  1108. AfdGetBuffer((_ds),(_as),((PEPROCESS)((ULONG_PTR)(_pr)|AFDB_RAISE_ON_FAILURE)))
  1109. VOID
  1110. AfdReturnBuffer (
  1111. IN PAFD_BUFFER_HEADER AfdBufferHeader,
  1112. IN PEPROCESS Process
  1113. );
  1114. VOID
  1115. NTAPI
  1116. AfdFreeBuffer(
  1117. IN PVOID AfdBuffer
  1118. );
  1119. VOID
  1120. AfdInitializeBufferManager (
  1121. VOID
  1122. );
  1123. //
  1124. // Group ID managment routines.
  1125. //
  1126. BOOLEAN
  1127. AfdInitializeGroup(
  1128. VOID
  1129. );
  1130. VOID
  1131. AfdTerminateGroup(
  1132. VOID
  1133. );
  1134. BOOLEAN
  1135. AfdReferenceGroup(
  1136. IN LONG Group,
  1137. OUT PAFD_GROUP_TYPE GroupType
  1138. );
  1139. BOOLEAN
  1140. AfdDereferenceGroup(
  1141. IN LONG Group
  1142. );
  1143. BOOLEAN
  1144. AfdGetGroup(
  1145. IN OUT PLONG Group,
  1146. OUT PAFD_GROUP_TYPE GroupType
  1147. );
  1148. BOOLEAN
  1149. AfdCancelIrp (
  1150. IN PIRP Irp
  1151. );
  1152. // PnP and PM routines
  1153. NTSTATUS
  1154. FASTCALL
  1155. AfdPnpPower (
  1156. IN PIRP Irp,
  1157. IN PIO_STACK_LOCATION IrpSp
  1158. );
  1159. NTSTATUS
  1160. AfdRoutingInterfaceQuery (
  1161. IN PFILE_OBJECT FileObject,
  1162. IN ULONG IoctlCode,
  1163. IN KPROCESSOR_MODE RequestorMode,
  1164. IN PVOID InputBuffer,
  1165. IN ULONG InputBufferLength,
  1166. IN PVOID OutputBuffer,
  1167. IN ULONG OutputBufferLength,
  1168. OUT PUINT_PTR Information
  1169. );
  1170. NTSTATUS
  1171. FASTCALL
  1172. AfdRoutingInterfaceChange (
  1173. IN PIRP Irp,
  1174. IN PIO_STACK_LOCATION IrpSp
  1175. );
  1176. NTSTATUS
  1177. AfdAddressListQuery (
  1178. IN PFILE_OBJECT FileObject,
  1179. IN ULONG IoctlCode,
  1180. IN KPROCESSOR_MODE RequestorMode,
  1181. IN PVOID InputBuffer,
  1182. IN ULONG InputBufferLength,
  1183. IN PVOID OutputBuffer,
  1184. IN ULONG OutputBufferLength,
  1185. OUT PUINT_PTR Information
  1186. );
  1187. NTSTATUS
  1188. FASTCALL
  1189. AfdAddressListChange (
  1190. IN PIRP Irp,
  1191. IN PIO_STACK_LOCATION IrpSp
  1192. );
  1193. VOID
  1194. AfdDeregisterPnPHandlers (
  1195. PVOID Param
  1196. );
  1197. VOID
  1198. AfdDereferenceRoutingQuery (
  1199. IN USHORT AddressType
  1200. );
  1201. NTSTATUS
  1202. FASTCALL
  1203. AfdDoTransportIoctl (
  1204. IN PIRP Irp,
  1205. IN PIO_STACK_LOCATION IrpSp
  1206. );
  1207. BOOLEAN
  1208. AfdLRRepostReceive (
  1209. PAFD_LR_LIST_ITEM ListEntry
  1210. );
  1211. VOID
  1212. AfdLRListAddItem (
  1213. PAFD_LR_LIST_ITEM Item,
  1214. PAFD_LR_LIST_ROUTINE Routine
  1215. );
  1216. VOID
  1217. AfdCheckLookasideLists (
  1218. IN PKDPC Dpc,
  1219. IN PVOID DeferredContext,
  1220. IN PVOID SystemArgument1,
  1221. IN PVOID SystemArgument2
  1222. );
  1223. ULONG
  1224. AfdComputeTpInfoSize (
  1225. ULONG ElementCount,
  1226. LONG IrpCount,
  1227. CCHAR IrpStackCount
  1228. );
  1229. NTSTATUS
  1230. FASTCALL
  1231. AfdTransmitPackets (
  1232. IN PIRP Irp,
  1233. IN PIO_STACK_LOCATION IrpSp
  1234. );
  1235. NTSTATUS
  1236. FASTCALL
  1237. AfdSuperDisconnect (
  1238. IN PIRP Irp,
  1239. IN PIO_STACK_LOCATION IrpSp
  1240. );
  1241. VOID
  1242. AfdCompleteClosePendedTPackets (
  1243. PAFD_ENDPOINT Endpoint
  1244. );
  1245. PVOID
  1246. AfdAllocateTpInfo (
  1247. IN POOL_TYPE PoolType,
  1248. IN SIZE_T NumberOfBytes,
  1249. IN ULONG Tag
  1250. );
  1251. VOID
  1252. NTAPI
  1253. AfdFreeTpInfo (
  1254. PVOID TpInfo
  1255. );
  1256. //
  1257. // SAN prototypes
  1258. //
  1259. NTSTATUS
  1260. AfdServiceWaitForListen (
  1261. PIRP Irp,
  1262. PAFD_CONNECTION Connection,
  1263. PAFD_LOCK_QUEUE_HANDLE LockHandle
  1264. );
  1265. VOID
  1266. AfdSanCancelAccept (
  1267. IN PDEVICE_OBJECT DeviceObject,
  1268. IN PIRP Irp
  1269. );
  1270. NTSTATUS
  1271. AfdSanAcceptCore (
  1272. PIRP AcceptIrp,
  1273. PFILE_OBJECT AcceptFileObject,
  1274. PAFD_CONNECTION Connection,
  1275. PAFD_LOCK_QUEUE_HANDLE LockHandle
  1276. );
  1277. NTSTATUS
  1278. AfdSanCreateHelper (
  1279. PIRP Irp,
  1280. PFILE_FULL_EA_INFORMATION EaBuffer,
  1281. PAFD_ENDPOINT *Endpoint
  1282. );
  1283. VOID
  1284. AfdSanCleanupHelper (
  1285. PAFD_ENDPOINT Endpoint
  1286. );
  1287. VOID
  1288. AfdSanCleanupEndpoint (
  1289. PAFD_ENDPOINT Endpoint
  1290. );
  1291. NTSTATUS
  1292. AfdSanFastCementEndpoint (
  1293. IN PFILE_OBJECT FileObject,
  1294. IN ULONG IoctlCode,
  1295. IN KPROCESSOR_MODE RequestorMode,
  1296. IN PVOID InputBuffer,
  1297. IN ULONG InputBufferLength,
  1298. IN PVOID OutputBuffer,
  1299. IN ULONG OutputBufferLength,
  1300. OUT PUINT_PTR Information
  1301. );
  1302. NTSTATUS
  1303. AfdSanFastSetEvents (
  1304. IN PFILE_OBJECT FileObject,
  1305. IN ULONG IoctlCode,
  1306. IN KPROCESSOR_MODE RequestorMode,
  1307. IN PVOID InputBuffer,
  1308. IN ULONG InputBufferLength,
  1309. IN PVOID OutputBuffer,
  1310. IN ULONG OutputBufferLength,
  1311. OUT PUINT_PTR Information
  1312. );
  1313. NTSTATUS
  1314. AfdSanFastResetEvents (
  1315. IN PFILE_OBJECT FileObject,
  1316. IN ULONG IoctlCode,
  1317. IN KPROCESSOR_MODE RequestorMode,
  1318. IN PVOID InputBuffer,
  1319. IN ULONG InputBufferLength,
  1320. IN PVOID OutputBuffer,
  1321. IN ULONG OutputBufferLength,
  1322. OUT PUINT_PTR Information
  1323. );
  1324. NTSTATUS
  1325. FASTCALL
  1326. AfdSanConnectHandler (
  1327. PIRP Irp,
  1328. PIO_STACK_LOCATION IrpSp
  1329. );
  1330. NTSTATUS
  1331. AfdSanFastCompleteAccept (
  1332. IN PFILE_OBJECT FileObject,
  1333. IN ULONG IoctlCode,
  1334. IN KPROCESSOR_MODE RequestorMode,
  1335. IN PVOID InputBuffer,
  1336. IN ULONG InputBufferLength,
  1337. IN PVOID OutputBuffer,
  1338. IN ULONG OutputBufferLength,
  1339. OUT PUINT_PTR Information
  1340. );
  1341. NTSTATUS
  1342. FASTCALL
  1343. AfdSanRedirectRequest (
  1344. PIRP Irp,
  1345. PIO_STACK_LOCATION IrpSp
  1346. );
  1347. NTSTATUS
  1348. AfdSanFastCompleteRequest (
  1349. IN PFILE_OBJECT FileObject,
  1350. IN ULONG IoctlCode,
  1351. IN KPROCESSOR_MODE RequestorMode,
  1352. IN PVOID InputBuffer,
  1353. IN ULONG InputBufferLength,
  1354. IN PVOID OutputBuffer,
  1355. IN ULONG OutputBufferLength,
  1356. OUT PUINT_PTR Information
  1357. );
  1358. NTSTATUS
  1359. AfdSanFastCompleteIo (
  1360. IN PFILE_OBJECT FileObject,
  1361. IN ULONG IoctlCode,
  1362. IN KPROCESSOR_MODE RequestorMode,
  1363. IN PVOID InputBuffer,
  1364. IN ULONG InputBufferLength,
  1365. IN PVOID OutputBuffer,
  1366. IN ULONG OutputBufferLength,
  1367. OUT PUINT_PTR Information
  1368. );
  1369. NTSTATUS
  1370. AfdSanFastRefreshEndpoint (
  1371. IN PFILE_OBJECT FileObject,
  1372. IN ULONG IoctlCode,
  1373. IN KPROCESSOR_MODE RequestorMode,
  1374. IN PVOID InputBuffer,
  1375. IN ULONG InputBufferLength,
  1376. IN PVOID OutputBuffer,
  1377. IN ULONG OutputBufferLength,
  1378. OUT PUINT_PTR Information
  1379. );
  1380. NTSTATUS
  1381. AfdSanFastGetPhysicalAddr (
  1382. IN PFILE_OBJECT FileObject,
  1383. IN ULONG IoctlCode,
  1384. IN KPROCESSOR_MODE RequestorMode,
  1385. IN PVOID InputBuffer,
  1386. IN ULONG InputBufferLength,
  1387. IN PVOID OutputBuffer,
  1388. IN ULONG OutputBufferLength,
  1389. OUT PUINT_PTR Information
  1390. );
  1391. NTSTATUS
  1392. AfdSanPollBegin (
  1393. PAFD_ENDPOINT Endpoint,
  1394. ULONG EventMask
  1395. );
  1396. VOID
  1397. AfdSanPollEnd (
  1398. PAFD_ENDPOINT Endpoint,
  1399. ULONG EventMask
  1400. );
  1401. VOID
  1402. AfdSanPollUpdate (
  1403. PAFD_ENDPOINT Endpoint,
  1404. ULONG EventMask
  1405. );
  1406. NTSTATUS
  1407. AfdSanPollMerge (
  1408. PAFD_ENDPOINT Endpoint,
  1409. PAFD_SWITCH_CONTEXT Context
  1410. );
  1411. NTSTATUS
  1412. AfdSanFastTransferCtx (
  1413. IN PFILE_OBJECT FileObject,
  1414. IN ULONG IoctlCode,
  1415. IN KPROCESSOR_MODE RequestorMode,
  1416. IN PVOID InputBuffer,
  1417. IN ULONG InputBufferLength,
  1418. IN PVOID OutputBuffer,
  1419. IN ULONG OutputBufferLength,
  1420. OUT PUINT_PTR Information
  1421. );
  1422. NTSTATUS
  1423. AfdSanFastGetServicePid (
  1424. IN PFILE_OBJECT FileObject,
  1425. IN ULONG IoctlCode,
  1426. IN KPROCESSOR_MODE RequestorMode,
  1427. IN PVOID InputBuffer,
  1428. IN ULONG InputBufferLength,
  1429. IN PVOID OutputBuffer,
  1430. IN ULONG OutputBufferLength,
  1431. OUT PUINT_PTR Information
  1432. );
  1433. NTSTATUS
  1434. AfdSanFastSetServiceProcess (
  1435. IN PFILE_OBJECT FileObject,
  1436. IN ULONG IoctlCode,
  1437. IN KPROCESSOR_MODE RequestorMode,
  1438. IN PVOID InputBuffer,
  1439. IN ULONG InputBufferLength,
  1440. IN PVOID OutputBuffer,
  1441. IN ULONG OutputBufferLength,
  1442. OUT PUINT_PTR Information
  1443. );
  1444. NTSTATUS
  1445. AfdSanFastProviderChange (
  1446. IN PFILE_OBJECT FileObject,
  1447. IN ULONG IoctlCode,
  1448. IN KPROCESSOR_MODE RequestorMode,
  1449. IN PVOID InputBuffer,
  1450. IN ULONG InputBufferLength,
  1451. IN PVOID OutputBuffer,
  1452. IN ULONG OutputBufferLength,
  1453. OUT PUINT_PTR Information
  1454. );
  1455. NTSTATUS
  1456. FASTCALL
  1457. AfdSanAddrListChange (
  1458. PIRP Irp,
  1459. PIO_STACK_LOCATION IrpSp
  1460. );
  1461. NTSTATUS
  1462. FASTCALL
  1463. AfdSanAcquireContext (
  1464. PIRP Irp,
  1465. PIO_STACK_LOCATION IrpSp
  1466. );
  1467. BOOLEAN
  1468. AfdSanFastUnlockAll (
  1469. IN PFILE_OBJECT FileObject,
  1470. IN PEPROCESS Process,
  1471. OUT PIO_STATUS_BLOCK IoStatus,
  1472. IN PDEVICE_OBJECT DeviceObject
  1473. );
  1474. VOID
  1475. AfdSanReleaseConnection (
  1476. PAFD_ENDPOINT ListenEndpoint,
  1477. PAFD_CONNECTION Connection,
  1478. BOOLEAN CheckBacklog
  1479. );
  1480. VOID
  1481. AfdSanAbortConnection (
  1482. PAFD_CONNECTION Connection
  1483. );
  1484. NTSTATUS
  1485. AfdValidateStatus (
  1486. NTSTATUS Status
  1487. );
  1488. //
  1489. // Check if datagram part of the union is valid
  1490. //
  1491. #define IS_DGRAM_ENDPOINT(endp) \
  1492. ((endp)->Type==AfdBlockTypeDatagram)
  1493. //
  1494. // Check if Vc part of the union is valid
  1495. //
  1496. #define IS_VC_ENDPOINT(endp) \
  1497. ( ((endp)->Type==AfdBlockTypeEndpoint) || \
  1498. ((endp)->Type==AfdBlockTypeVcConnecting) || \
  1499. ((endp)->Type==AfdBlockTypeVcListening) || \
  1500. ((endp)->Type==AfdBlockTypeVcBoth) )
  1501. #define IS_SAN_ENDPOINT(endp) \
  1502. ((endp)->Type==AfdBlockTypeSanEndpoint)
  1503. #define IS_SAN_HELPER(endp) \
  1504. ((endp)->Type==AfdBlockTypeSanHelper)
  1505. #define IS_MESSAGE_ENDPOINT(endp) \
  1506. ((endp)->afdMessageMode)
  1507. #define IS_RAW_ENDPOINT(endp) \
  1508. ((endp)->afdRaw)
  1509. #define IS_CROOT_ENDPOINT(endp) \
  1510. ((endp)->afdMultipoint && (endp)->afdC_Root)
  1511. #define IS_DELAYED_ACCEPTANCE_ENDPOINT(endp) \
  1512. ((endp)->DelayedAcceptance)
  1513. #define IS_TDI_MESSAGE_MODE(endp) \
  1514. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_MESSAGE_MODE)!=0))
  1515. #define IS_TDI_BUFFERRING(endp) \
  1516. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_INTERNAL_BUFFERING)!=0))
  1517. #define IS_TDI_EXPEDITED(endp) \
  1518. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_EXPEDITED_DATA)!=0))
  1519. #define IS_TDI_ORDERLY_RELEASE(endp) \
  1520. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_ORDERLY_RELEASE)!=0))
  1521. #define IS_TDI_DGRAM_CONNECTION(endp) \
  1522. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_DGRAM_CONNECTION)!=0))
  1523. #define IS_TDI_FORCE_ACCESS_CHECK(endp) \
  1524. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_FORCE_ACCESS_CHECK)!=0))
  1525. #define IS_TDI_DELAYED_ACCEPTANCE(endp) \
  1526. ((BOOLEAN)(((endp)->TdiServiceFlags&TDI_SERVICE_DELAYED_ACCEPTANCE)!=0))
  1527. #define IS_DATA_ON_CONNECTION_B(conn) \
  1528. ((conn)->Common.Bufferring.ReceiveBytesIndicated.QuadPart > \
  1529. ((conn)->Common.Bufferring.ReceiveBytesTaken.QuadPart + \
  1530. (conn)->Common.Bufferring.ReceiveBytesOutstanding.QuadPart )\
  1531. || \
  1532. (conn)->VcZeroByteReceiveIndicated)
  1533. #define IS_EXPEDITED_DATA_ON_CONNECTION_B(conn) \
  1534. ((conn)->Common.Bufferring.ReceiveExpeditedBytesIndicated.QuadPart > \
  1535. ((conn)->Common.Bufferring.ReceiveExpeditedBytesTaken.QuadPart + \
  1536. (conn)->Common.Bufferring.ReceiveExpeditedBytesOutstanding.QuadPart) )
  1537. #define IS_DATA_ON_CONNECTION_NB(conn) \
  1538. ( (conn)->VcBufferredReceiveCount != 0 )
  1539. #define IS_EXPEDITED_DATA_ON_CONNECTION_NB(conn) \
  1540. ( (conn)->VcBufferredExpeditedCount != 0 )
  1541. #define IS_DATA_ON_CONNECTION(conn) \
  1542. ((conn)->TdiBufferring ? \
  1543. IS_DATA_ON_CONNECTION_B(conn) : \
  1544. IS_DATA_ON_CONNECTION_NB(conn) )
  1545. #define IS_EXPEDITED_DATA_ON_CONNECTION(conn) \
  1546. ((conn)->TdiBufferring ? \
  1547. IS_EXPEDITED_DATA_ON_CONNECTION_B(conn) : \
  1548. IS_EXPEDITED_DATA_ON_CONNECTION_NB(conn) )
  1549. #define ARE_DATAGRAMS_ON_ENDPOINT(endp) \
  1550. ( (endp)->DgBufferredReceiveCount != 0 )
  1551. #define AFD_START_STATE_CHANGE(endp,newState) \
  1552. (InterlockedCompareExchange( \
  1553. &(endp)->StateChangeInProgress, \
  1554. newState, \
  1555. 0)==0)
  1556. #if DBG
  1557. #define AFD_END_STATE_CHANGE(endp) \
  1558. ASSERT (InterlockedExchange(&(endp)->StateChangeInProgress,0)!=0)
  1559. #else
  1560. #define AFD_END_STATE_CHANGE(endp) \
  1561. (endp)->StateChangeInProgress = 0;
  1562. #endif
  1563. #define AFD_ALLOCATE_REMOTE_ADDRESS(_l) \
  1564. (((ULONG)(_l)<=AfdStandardAddressLength) \
  1565. ? ExAllocateFromNPagedLookasideList( \
  1566. &AfdLookasideLists->RemoteAddrList )\
  1567. : AFD_ALLOCATE_POOL(NonPagedPool, \
  1568. (_l), AFD_REMOTE_ADDRESS_POOL_TAG) \
  1569. )
  1570. #define AFD_RETURN_REMOTE_ADDRESS(_a,_l) \
  1571. (((ULONG)(_l)<=AfdStandardAddressLength) \
  1572. ? ExFreeToNPagedLookasideList( \
  1573. &AfdLookasideLists->RemoteAddrList, \
  1574. (_a)) \
  1575. : AFD_FREE_POOL((_a), AFD_REMOTE_ADDRESS_POOL_TAG) \
  1576. )
  1577. #if DBG
  1578. LONG
  1579. AfdApcExceptionFilter(
  1580. PEXCEPTION_POINTERS ExceptionPointers,
  1581. PCHAR SourceFile,
  1582. LONG LineNumber
  1583. );
  1584. #endif
  1585. //
  1586. // Debug statistic manipulators. On checked builds these macros update
  1587. // their corresponding statistic counter. On retail builds, these macros
  1588. // evaluate to nothing.
  1589. //
  1590. #if AFD_KEEP_STATS
  1591. #define AfdRecordPoolQuotaCharged( b ) \
  1592. ExInterlockedAddLargeStatistic( \
  1593. &AfdQuotaStats.Charged, \
  1594. (b) \
  1595. )
  1596. #define AfdRecordPoolQuotaReturned( b ) \
  1597. ExInterlockedAddLargeStatistic( \
  1598. &AfdQuotaStats.Returned, \
  1599. (b) \
  1600. )
  1601. #define AfdRecordAddrOpened() InterlockedIncrement( &AfdHandleStats.AddrOpened )
  1602. #define AfdRecordAddrClosed() InterlockedIncrement( &AfdHandleStats.AddrClosed )
  1603. #define AfdRecordAddrRef() InterlockedIncrement( &AfdHandleStats.AddrRef )
  1604. #define AfdRecordAddrDeref() InterlockedIncrement( &AfdHandleStats.AddrDeref )
  1605. #define AfdRecordConnOpened() InterlockedIncrement( &AfdHandleStats.ConnOpened )
  1606. #define AfdRecordConnClosed() InterlockedIncrement( &AfdHandleStats.ConnClosed )
  1607. #define AfdRecordConnRef() InterlockedIncrement( &AfdHandleStats.ConnRef )
  1608. #define AfdRecordConnDeref() InterlockedIncrement( &AfdHandleStats.ConnDeref )
  1609. #define AfdRecordFileRef() InterlockedIncrement( &AfdHandleStats.FileRef )
  1610. #define AfdRecordFileDeref() InterlockedIncrement( &AfdHandleStats.FileDeref )
  1611. #define AfdRecordAfdWorkItemsQueued() InterlockedIncrement( &AfdQueueStats.AfdWorkItemsQueued )
  1612. #define AfdRecordExWorkItemsQueued() InterlockedIncrement( &AfdQueueStats.ExWorkItemsQueued )
  1613. #define AfdRecordWorkerEnter() InterlockedIncrement( &AfdQueueStats.WorkerEnter )
  1614. #define AfdRecordWorkerLeave() InterlockedIncrement( &AfdQueueStats.WorkerLeave )
  1615. #define AfdRecordAfdWorkItemsProcessed() InterlockedIncrement( &AfdQueueStats.AfdWorkItemsProcessed )
  1616. #define AfdRecordAfdWorkerThread(t) \
  1617. if( 1 ) { \
  1618. ASSERT( AfdQueueStats.AfdWorkerThread == NULL || \
  1619. (t) == NULL ); \
  1620. AfdQueueStats.AfdWorkerThread = (t); \
  1621. } else
  1622. #define AfdRecordConnectedReferencesAdded() InterlockedIncrement( &AfdConnectionStats.ConnectedReferencesAdded )
  1623. #define AfdRecordConnectedReferencesDeleted() InterlockedIncrement( &AfdConnectionStats.ConnectedReferencesDeleted )
  1624. #define AfdRecordGracefulDisconnectsInitiated() InterlockedIncrement( &AfdConnectionStats.GracefulDisconnectsInitiated )
  1625. #define AfdRecordGracefulDisconnectsCompleted() InterlockedIncrement( &AfdConnectionStats.GracefulDisconnectsCompleted )
  1626. #define AfdRecordGracefulDisconnectIndications() InterlockedIncrement( &AfdConnectionStats.GracefulDisconnectIndications )
  1627. #define AfdRecordAbortiveDisconnectsInitiated() InterlockedIncrement( &AfdConnectionStats.AbortiveDisconnectsInitiated )
  1628. #define AfdRecordAbortiveDisconnectsCompleted() InterlockedIncrement( &AfdConnectionStats.AbortiveDisconnectsCompleted )
  1629. #define AfdRecordAbortiveDisconnectIndications() InterlockedIncrement( &AfdConnectionStats.AbortiveDisconnectIndications )
  1630. #define AfdRecordConnectionIndications() InterlockedIncrement( &AfdConnectionStats.ConnectionIndications )
  1631. #define AfdRecordConnectionsDropped() InterlockedIncrement( &AfdConnectionStats.ConnectionsDropped )
  1632. #define AfdRecordConnectionsAccepted() InterlockedIncrement( &AfdConnectionStats.ConnectionsAccepted )
  1633. #define AfdRecordConnectionsPreaccepted() InterlockedIncrement( &AfdConnectionStats.ConnectionsPreaccepted )
  1634. #define AfdRecordConnectionsReused() InterlockedIncrement( &AfdConnectionStats.ConnectionsReused )
  1635. #define AfdRecordEndpointsReused() InterlockedIncrement( &AfdConnectionStats.EndpointsReused )
  1636. #else // !AFD_KEEP_STATS
  1637. #define AfdRecordPoolQuotaCharged(b)
  1638. #define AfdRecordPoolQuotaReturned(b)
  1639. #define AfdRecordAddrOpened()
  1640. #define AfdRecordAddrClosed()
  1641. #define AfdRecordAddrRef()
  1642. #define AfdRecordAddrDeref()
  1643. #define AfdRecordConnOpened()
  1644. #define AfdRecordConnClosed()
  1645. #define AfdRecordConnRef()
  1646. #define AfdRecordConnDeref()
  1647. #define AfdRecordFileRef()
  1648. #define AfdRecordFileDeref()
  1649. #define AfdRecordAfdWorkItemsQueued()
  1650. #define AfdRecordExWorkItemsQueued()
  1651. #define AfdRecordWorkerEnter()
  1652. #define AfdRecordWorkerLeave()
  1653. #define AfdRecordAfdWorkItemsProcessed()
  1654. #define AfdRecordAfdWorkerThread(t)
  1655. #define AfdRecordConnectedReferencesAdded()
  1656. #define AfdRecordConnectedReferencesDeleted()
  1657. #define AfdRecordGracefulDisconnectsInitiated()
  1658. #define AfdRecordGracefulDisconnectsCompleted()
  1659. #define AfdRecordGracefulDisconnectIndications()
  1660. #define AfdRecordAbortiveDisconnectsInitiated()
  1661. #define AfdRecordAbortiveDisconnectsCompleted()
  1662. #define AfdRecordAbortiveDisconnectIndications()
  1663. #define AfdRecordConnectionIndications()
  1664. #define AfdRecordConnectionsDropped()
  1665. #define AfdRecordConnectionsAccepted()
  1666. #define AfdRecordConnectionsPreaccepted()
  1667. #define AfdRecordConnectionsReused()
  1668. #define AfdRecordEndpointsReused()
  1669. #endif // if AFD_KEEP_STATS
  1670. #endif // ndef _AFDPROCS_