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.

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