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.

796 lines
16 KiB

  1. /*++
  2. Copyright (c) 2000-2000 Microsoft Corporation
  3. Module Name:
  4. DrvProcs.c
  5. Abstract:
  6. This file contains the function prototypes in the Driver.
  7. Author:
  8. Mohammad Shabbir Alam (MAlam) 3-30-2000
  9. Revision History:
  10. --*/
  11. #ifndef _DRVPROCS_H_
  12. #define _DRVPROCS_H_
  13. //
  14. // In Data.c
  15. //
  16. NTSTATUS
  17. FilterAndAddNaksToList(
  18. IN tSEND_SESSION *pSend,
  19. IN tNAKS_LIST *pNaksList
  20. );
  21. NTSTATUS
  22. InitRDataInfo(
  23. IN tADDRESS_CONTEXT *pAddress,
  24. IN tSEND_SESSION *pSend
  25. );
  26. VOID
  27. DestroyRDataInfo(
  28. IN tSEND_SESSION *pSend
  29. );
  30. BOOLEAN
  31. AnyMoreNaks(
  32. IN tSEND_RDATA_CONTEXT *pRData
  33. );
  34. BOOLEAN
  35. GetNextNakIndex(
  36. IN tSEND_RDATA_CONTEXT *pRData,
  37. OUT UCHAR *pNakIndex
  38. );
  39. PSEND_RDATA_CONTEXT
  40. AnyRequestPending(
  41. IN tRDATA_INFO *pRDataInfo
  42. );
  43. VOID
  44. UpdateRDataTrailingEdge(
  45. IN tRDATA_INFO *pRDataInfo,
  46. IN SEQ_TYPE SeqNum
  47. );
  48. PSEND_RDATA_CONTEXT
  49. FindFirstEntry(
  50. IN tSEND_SESSION *pSend,
  51. IN tSEND_RDATA_CONTEXT **ppRDataLast,
  52. IN BOOLEAN fIgnoreWaitTime
  53. );
  54. ULONG
  55. RemoveAllEntries(
  56. IN tSEND_SESSION *pSend,
  57. IN BOOLEAN fForceRemoveAll
  58. );
  59. VOID
  60. RemoveEntry(
  61. IN tRDATA_INFO *pRDataInfo,
  62. IN tSEND_RDATA_CONTEXT *pRData
  63. );
  64. VOID
  65. DestroyEntry(
  66. IN tRDATA_INFO *pRDataInfo,
  67. IN tSEND_RDATA_CONTEXT *pRData
  68. );
  69. LIST_ENTRY *
  70. InitReceiverData(
  71. IN tRECEIVE_SESSION *pReceive
  72. );
  73. tNAK_FORWARD_DATA *
  74. FindReceiverEntry(
  75. IN tRECEIVE_CONTEXT *pReceiver,
  76. IN SEQ_TYPE SeqNum
  77. );
  78. VOID
  79. AppendPendingReceiverEntry(
  80. IN tRECEIVE_CONTEXT *pReceiver,
  81. IN tNAK_FORWARD_DATA *pNak
  82. );
  83. VOID
  84. RemovePendingReceiverEntry(
  85. IN tNAK_FORWARD_DATA *pNak
  86. );
  87. VOID
  88. RemoveAllPendingReceiverEntries(
  89. IN tRECEIVE_CONTEXT *pReceiver
  90. );
  91. //
  92. // In Driver.c
  93. //
  94. NTSTATUS
  95. DriverEntry(
  96. IN PDRIVER_OBJECT DriverObject,
  97. IN PUNICODE_STRING RegistryPath
  98. );
  99. VOID
  100. PgmUnload(
  101. IN PDRIVER_OBJECT DriverObject
  102. );
  103. VOID
  104. PgmIoComplete(
  105. IN PIRP pIrp,
  106. IN NTSTATUS Status,
  107. IN ULONG SentLength
  108. );
  109. NTSTATUS
  110. PgmCheckSetCancelRoutine(
  111. IN PIRP pIrp,
  112. IN PVOID CancelRoutine,
  113. IN BOOLEAN fLocked
  114. );
  115. NTSTATUS
  116. PgmCancelCancelRoutine(
  117. IN PIRP pIrp
  118. );
  119. //
  120. // In Init.c
  121. //
  122. BOOLEAN
  123. PgmFipsInitialize(
  124. VOID
  125. );
  126. NTSTATUS
  127. InitPgm(
  128. IN PDRIVER_OBJECT DriverObject,
  129. IN PUNICODE_STRING RegistryPath
  130. );
  131. VOID
  132. CleanupInit(
  133. enum eCLEANUP_STAGE CleanupStage
  134. );
  135. NTSTATUS
  136. InitStaticPgmConfig(
  137. IN PDRIVER_OBJECT DriverObject,
  138. IN PUNICODE_STRING RegistryPath
  139. );
  140. NTSTATUS
  141. InitDynamicPgmConfig(
  142. );
  143. NTSTATUS
  144. PgmReadRegistryParameters(
  145. IN PUNICODE_STRING RegistryPath,
  146. OUT tPGM_REGISTRY_CONFIG **pPgmDynamic
  147. );
  148. NTSTATUS
  149. AllocateInitialPgmStructures(
  150. );
  151. NTSTATUS
  152. PgmCreateDevice(
  153. );
  154. VOID
  155. PgmDereferenceDevice(
  156. IN OUT tPGM_DEVICE **ppPgmDevice,
  157. IN ULONG RefContext
  158. );
  159. //
  160. // In TdiPnP.c
  161. //
  162. BOOLEAN
  163. SrcIsUs(
  164. tIPADDRESS IpAddress
  165. );
  166. BOOLEAN
  167. SrcIsOnLocalSubnet(
  168. tIPADDRESS IpAddress
  169. );
  170. NTSTATUS
  171. SetTdiHandlers(
  172. );
  173. NTSTATUS
  174. GetIpInterfaceIndexFromAddress(
  175. IN tIPADDRESS NetIpAddr,
  176. OUT ULONG *pIPInterfaceIndex
  177. );
  178. NTSTATUS
  179. ListenOnAllInterfaces(
  180. IN tADDRESS_CONTEXT *pAddress,
  181. IN PGMLockHandle *pOldIrqDynamicConfig,
  182. IN PGMLockHandle *pOldIrqAddress
  183. );
  184. VOID
  185. StopListeningOnAllInterfacesExcept(
  186. IN tADDRESS_CONTEXT *pAddress,
  187. IN PVOID Data1,
  188. IN PVOID Unused
  189. );
  190. //
  191. // In Tdi.c
  192. //
  193. NTSTATUS
  194. TdiOpenAddressHandle(
  195. IN tPGM_DEVICE *pPgmDevice,
  196. IN PVOID HandlerContext,
  197. IN ULONG IpAddress,
  198. IN USHORT PortNumber,
  199. OUT HANDLE *pFileHandle,
  200. OUT PFILE_OBJECT *ppFileObject,
  201. OUT PDEVICE_OBJECT *ppDeviceObject
  202. );
  203. NTSTATUS
  204. CloseAddressHandles(
  205. IN HANDLE FileHandle,
  206. IN PFILE_OBJECT pFileObject
  207. );
  208. NTSTATUS
  209. PgmTdiOpenControl(
  210. IN tPGM_DEVICE *pPgmDevice
  211. );
  212. NTSTATUS
  213. PgmSetTcpInfo(
  214. IN HANDLE FileHandle,
  215. IN ULONG ToiId,
  216. IN PVOID pData,
  217. IN ULONG DataLength
  218. );
  219. NTSTATUS
  220. PgmQueryTcpInfo(
  221. IN HANDLE FileHandle,
  222. IN ULONG ToiId,
  223. IN PVOID pDataIn,
  224. IN ULONG DataInLength,
  225. OUT PVOID *ppDataOut,
  226. OUT ULONG *pDataOutLength
  227. );
  228. VOID
  229. PgmDereferenceControl(
  230. IN tCONTROL_CONTEXT *pControlContext,
  231. IN ULONG RefContext
  232. );
  233. NTSTATUS
  234. TdiSendDatagram(
  235. IN PFILE_OBJECT pTdiFileObject,
  236. IN PDEVICE_OBJECT pTdiDeviceObject,
  237. IN PVOID pBuffer,
  238. IN ULONG BufferLength,
  239. IN pCLIENT_COMPLETION_ROUTINE pClientCompletionRoutine,
  240. IN PVOID ClientCompletionContext1,
  241. IN PVOID ClientCompletionContext2,
  242. IN tIPADDRESS DestIpAddress,
  243. IN USHORT DestPort,
  244. IN BOOLEAN fPagedBuffer
  245. );
  246. NTSTATUS
  247. PgmProcessIPRequest(
  248. IN ULONG IOControlCode,
  249. IN PVOID pInBuffer,
  250. IN ULONG InBufferLen,
  251. OUT PVOID *pOutBuffer,
  252. IN OUT ULONG *pOutBufferLen
  253. );
  254. //
  255. // In Address.c
  256. //
  257. BOOLEAN
  258. GetIpAddress(
  259. IN TRANSPORT_ADDRESS UNALIGNED *pTransportAddr,
  260. IN ULONG BufferLength, // Total Buffer length
  261. OUT tIPADDRESS *pIpAddress,
  262. OUT USHORT *pPort
  263. );
  264. NTSTATUS
  265. PgmCreateAddress(
  266. IN tPGM_DEVICE *pPgmDevice,
  267. IN PIRP pIrp,
  268. IN PIO_STACK_LOCATION pIrpSp,
  269. IN PFILE_FULL_EA_INFORMATION TargetEA
  270. );
  271. VOID
  272. PgmDestroyAddress(
  273. IN tADDRESS_CONTEXT *pAddress,
  274. IN PVOID Unused1,
  275. IN PVOID Unused2
  276. );
  277. VOID
  278. PgmDereferenceAddress(
  279. IN tADDRESS_CONTEXT *pAddress,
  280. IN ULONG RefContext
  281. );
  282. NTSTATUS
  283. PgmCleanupAddress(
  284. IN tADDRESS_CONTEXT *pAddress,
  285. IN PIRP pIrp
  286. );
  287. NTSTATUS
  288. PgmCloseAddress(
  289. IN PIRP pIrp,
  290. IN PIO_STACK_LOCATION pIrpSp
  291. );
  292. NTSTATUS
  293. PgmAssociateAddress(
  294. IN tPGM_DEVICE *pPgmDevice,
  295. IN PIRP pIrp,
  296. IN PIO_STACK_LOCATION pIrpSp
  297. );
  298. NTSTATUS
  299. PgmDisassociateAddress(
  300. IN PIRP pIrp,
  301. IN PIO_STACK_LOCATION pIrpSp
  302. );
  303. NTSTATUS
  304. PgmSetEventHandler(
  305. IN tPGM_DEVICE *pPgmDevice,
  306. IN PIRP pIrp,
  307. IN PIO_STACK_LOCATION pIrpSp
  308. );
  309. NTSTATUS
  310. PgmSetMCastOutIf(
  311. IN PIRP pIrp,
  312. IN PIO_STACK_LOCATION pIrpSp
  313. );
  314. NTSTATUS
  315. SetSenderMCastOutIf(
  316. IN tADDRESS_CONTEXT *pAddress,
  317. IN tIPADDRESS IpAddress // Net format
  318. );
  319. NTSTATUS
  320. ReceiverAddMCastIf(
  321. IN tADDRESS_CONTEXT *pAddress,
  322. IN tIPADDRESS IpAddress, // In host format
  323. IN PGMLockHandle *pOldIrqDynamicConfig,
  324. IN PGMLockHandle *pOldIrqAddress
  325. );
  326. NTSTATUS
  327. PgmAddMCastReceiveIf(
  328. IN PIRP pIrp,
  329. IN PIO_STACK_LOCATION pIrpSp
  330. );
  331. NTSTATUS
  332. PgmDelMCastReceiveIf(
  333. IN PIRP pIrp,
  334. IN PIO_STACK_LOCATION pIrpSp
  335. );
  336. NTSTATUS
  337. PgmSetWindowSizeAndSendRate(
  338. IN PIRP pIrp,
  339. IN PIO_STACK_LOCATION pIrpSp
  340. );
  341. NTSTATUS
  342. PgmQueryWindowSizeAndSendRate(
  343. IN PIRP pIrp,
  344. IN PIO_STACK_LOCATION pIrpSp
  345. );
  346. NTSTATUS
  347. PgmSetWindowAdvanceRate(
  348. IN PIRP pIrp,
  349. IN PIO_STACK_LOCATION pIrpSp
  350. );
  351. NTSTATUS
  352. PgmQueryWindowAdvanceRate(
  353. IN PIRP pIrp,
  354. IN PIO_STACK_LOCATION pIrpSp
  355. );
  356. NTSTATUS
  357. PgmSetLateJoinerPercentage(
  358. IN PIRP pIrp,
  359. IN PIO_STACK_LOCATION pIrpSp
  360. );
  361. NTSTATUS
  362. PgmQueryLateJoinerPercentage(
  363. IN PIRP pIrp,
  364. IN PIO_STACK_LOCATION pIrpSp
  365. );
  366. NTSTATUS
  367. PgmSetWindowAdvanceMethod(
  368. IN PIRP pIrp,
  369. IN PIO_STACK_LOCATION pIrpSp
  370. );
  371. NTSTATUS
  372. PgmQueryWindowAdvanceMethod(
  373. IN PIRP pIrp,
  374. IN PIO_STACK_LOCATION pIrpSp
  375. );
  376. NTSTATUS
  377. PgmSetNextMessageBoundary(
  378. IN PIRP pIrp,
  379. IN PIO_STACK_LOCATION pIrpSp
  380. );
  381. NTSTATUS
  382. PgmSetMCastTtl(
  383. IN PIRP pIrp,
  384. IN PIO_STACK_LOCATION pIrpSp
  385. );
  386. NTSTATUS
  387. PgmSetFECInfo(
  388. IN PIRP pIrp,
  389. IN PIO_STACK_LOCATION pIrpSp
  390. );
  391. NTSTATUS
  392. PgmQueryFecInfo(
  393. IN PIRP pIrp,
  394. IN PIO_STACK_LOCATION pIrpSp
  395. );
  396. NTSTATUS
  397. PgmQueryHighSpeedOptimization(
  398. IN PIRP pIrp,
  399. IN PIO_STACK_LOCATION pIrpSp
  400. );
  401. NTSTATUS
  402. PgmSetHighSpeedOptimization(
  403. IN PIRP pIrp,
  404. IN PIO_STACK_LOCATION pIrpSp
  405. );
  406. NTSTATUS
  407. PgmQuerySenderStats(
  408. IN PIRP pIrp,
  409. IN PIO_STACK_LOCATION pIrpSp
  410. );
  411. NTSTATUS
  412. PgmQueryReceiverStats(
  413. IN PIRP pIrp,
  414. IN PIO_STACK_LOCATION pIrpSp
  415. );
  416. //
  417. // In Connect.c
  418. //
  419. NTSTATUS
  420. PgmCreateConnection(
  421. IN tPGM_DEVICE *pPgmDevice,
  422. IN PIRP pIrp,
  423. IN PIO_STACK_LOCATION pIrpSp,
  424. IN PFILE_FULL_EA_INFORMATION TargetEA
  425. );
  426. VOID
  427. PgmDereferenceSessionCommon(
  428. IN tSEND_SESSION *pSend,
  429. IN ULONG Verify,
  430. IN ULONG RefContext
  431. );
  432. NTSTATUS
  433. PgmCleanupConnection(
  434. IN tCOMMON_SESSION_CONTEXT *pConnect,
  435. IN PIRP pIrp
  436. );
  437. NTSTATUS
  438. PgmCloseConnection(
  439. IN PIRP pIrp,
  440. IN PIO_STACK_LOCATION pIrpSp
  441. );
  442. NTSTATUS
  443. PgmConnect(
  444. IN tPGM_DEVICE *pPgmDevice,
  445. IN PIRP pIrp,
  446. IN PIO_STACK_LOCATION pIrpSp
  447. );
  448. NTSTATUS
  449. PgmDisconnect(
  450. IN tPGM_DEVICE *pPgmDevice,
  451. IN PIRP pIrp,
  452. IN PIO_STACK_LOCATION pIrpSp
  453. );
  454. NTSTATUS
  455. PgmSetRcvBufferLength(
  456. IN PIRP pIrp,
  457. IN PIO_STACK_LOCATION pIrpSp
  458. );
  459. //
  460. // In Receive.c
  461. //
  462. VOID
  463. RemovePendingIrps(
  464. IN tRECEIVE_SESSION *pReceive,
  465. IN LIST_ENTRY *pIrpsList
  466. );
  467. NTSTATUS
  468. ProcessOptions(
  469. IN tPACKET_OPTION_LENGTH UNALIGNED *pPacketExtension,
  470. IN ULONG BytesAvailable,
  471. IN ULONG PacketType,
  472. OUT tPACKET_OPTIONS *pPacketOptions,
  473. OUT tNAKS_LIST *pNaksList
  474. );
  475. VOID
  476. CleanupPendingNaks(
  477. IN tRECEIVE_SESSION *pReceive,
  478. IN PVOID fDerefReceive,
  479. IN PVOID fReceiveLockHeld
  480. );
  481. NTSTATUS
  482. ExtractNakNcfSequences(
  483. IN tBASIC_NAK_NCF_PACKET_HEADER UNALIGNED *pNakNcfPacket,
  484. IN ULONG BytesAvailable,
  485. OUT tNAKS_LIST *pNakNcfList,
  486. OUT SEQ_TYPE *pLastSequenceNumber,
  487. IN UCHAR FECGroupSize
  488. );
  489. NTSTATUS
  490. TdiRcvDatagramHandler(
  491. IN PVOID pDgramEventContext,
  492. IN INT SourceAddressLength,
  493. IN PVOID pSourceAddress,
  494. IN INT OptionsLength,
  495. IN PVOID pOptions,
  496. IN ULONG ReceiveDatagramFlags,
  497. IN ULONG BytesIndicated,
  498. IN ULONG BytesAvailable,
  499. OUT ULONG *pBytesTaken,
  500. IN PVOID pTsdu,
  501. OUT PIRP *ppIrp
  502. );
  503. VOID
  504. ReceiveTimerTimeout(
  505. IN PKDPC Dpc,
  506. IN PVOID DeferredContext,
  507. IN PVOID SystemArg1,
  508. IN PVOID SystemArg2
  509. );
  510. VOID
  511. PgmCancelReceiveIrp(
  512. IN PDEVICE_OBJECT DeviceContext,
  513. IN PIRP pIrp
  514. );
  515. NTSTATUS
  516. PgmReceive(
  517. IN tPGM_DEVICE *pPgmDevice,
  518. IN PIRP pIrp,
  519. IN PIO_STACK_LOCATION pIrpSp
  520. );
  521. //
  522. // In Send.c
  523. //
  524. VOID
  525. PgmDereferenceSendContext(
  526. IN tCLIENT_SEND_REQUEST *pSendDataContext
  527. );
  528. NTSTATUS
  529. PgmBuildSenderPacketHeaders(
  530. IN tSEND_SESSION *pSend
  531. );
  532. VOID
  533. SendSessionTimeout(
  534. IN PKDPC Dpc,
  535. IN PVOID DeferredContext,
  536. IN PVOID SystemArg1,
  537. IN PVOID SystemArg2
  538. );
  539. NTSTATUS
  540. PgmSendRequestFromClient(
  541. IN tPGM_DEVICE *pPgmDevice,
  542. IN PIRP pIrp,
  543. IN PIO_STACK_LOCATION pIrpSp
  544. );
  545. NTSTATUS
  546. SenderProcessNakPacket(
  547. IN tADDRESS_CONTEXT *pAddress,
  548. IN tSEND_SESSION *pSend,
  549. IN ULONG BytesIndicated,
  550. IN tBASIC_NAK_NCF_PACKET_HEADER UNALIGNED *pNakPacket
  551. );
  552. //
  553. // In Query.c
  554. //
  555. NTSTATUS
  556. PgmQueryInformation(
  557. IN tPGM_DEVICE *pPgmDevice,
  558. IN PIRP pIrp,
  559. IN PIO_STACK_LOCATION pIrpSp
  560. );
  561. //
  562. // In Utils.c
  563. //
  564. VOID
  565. GetRandomData(
  566. IN PUCHAR pBuffer,
  567. IN ULONG BufferSize
  568. );
  569. ULONG
  570. GetRandomInteger(
  571. IN ULONG StartRange,
  572. IN ULONG EndRange
  573. );
  574. NTSTATUS
  575. PgmQueueForDelayedExecution(
  576. IN PVOID DelayedWorkerRoutine,
  577. IN PVOID Context1,
  578. IN PVOID Context2,
  579. IN PVOID Context3,
  580. IN BOOLEAN fConfigLockHeld
  581. );
  582. typedef
  583. VOID
  584. (*PPGM_WORKER_ROUTINE) (PVOID Context1,
  585. PVOID Context2,
  586. PVOID Context3);
  587. #ifdef OLD_LOGGING
  588. NTSTATUS
  589. PgmLog(
  590. IN enum eSEVERITY_LEVEL Severity,
  591. IN ULONG Path,
  592. IN PUCHAR pszFunctionName,
  593. IN PUCHAR Format,
  594. ...
  595. );
  596. #endif // OLD_LOGGING
  597. //
  598. // In FileIo.c
  599. //
  600. NTSTATUS
  601. PgmCreateDataFileAndMapSection(
  602. IN tADDRESS_CONTEXT *pAddress,
  603. IN tSEND_SESSION *pSend
  604. );
  605. NTSTATUS
  606. PgmCopyDataToBuffer(
  607. IN tSEND_SESSION *pSend,
  608. IN PMDL pMdlChain,
  609. IN ULONG DataSize,
  610. OUT ULONG *pNumDataPackets,
  611. OUT ULONG *pStartOffset
  612. );
  613. NTSTATUS
  614. PgmUnmapAndCloseDataFile(
  615. IN tSEND_SESSION *pSend
  616. );
  617. //
  618. // In FEC.c
  619. //
  620. NTSTATUS
  621. FECInitGlobals(
  622. );
  623. NTSTATUS
  624. CreateFECContext(
  625. IN tFEC_CONTEXT *pFec,
  626. IN LONG k,
  627. IN LONG n,
  628. IN BOOLEAN fFECDecoder
  629. );
  630. VOID
  631. DestroyFECContext(
  632. tFEC_CONTEXT *pFec
  633. );
  634. NTSTATUS
  635. FECEncode(
  636. IN tFEC_CONTEXT *pFec,
  637. IN PUCHAR pBlocks[],
  638. IN LONG GroupSize,
  639. IN LONG BlockSize,
  640. IN LONG Index,
  641. OUT PUCHAR pEncoded
  642. );
  643. NTSTATUS
  644. FECDecode(
  645. IN tFEC_CONTEXT *pFec,
  646. IN OUT tPENDING_DATA *pDataBlocks,
  647. IN LONG BlockSize,
  648. IN LONG k
  649. );
  650. //
  651. // In Security.c
  652. //
  653. NTSTATUS
  654. PgmBuildAdminSecurityDescriptor(
  655. OUT SECURITY_DESCRIPTOR **ppSecurityDescriptor
  656. );
  657. NTSTATUS
  658. PgmGetUserInfo(
  659. IN PIRP pIrp,
  660. IN PIO_STACK_LOCATION pIrpSp,
  661. OUT TOKEN_USER **ppUserId,
  662. OUT BOOLEAN *pfUserIsAdmin
  663. );
  664. //
  665. // In xsum.<arch>
  666. //
  667. ULONG
  668. tcpxsum(
  669. ULONG Seed,
  670. CHAR *Ptr,
  671. ULONG Length
  672. );
  673. #endif // _DRVPROCS_H_