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.

806 lines
24 KiB

  1. /////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // rcvdgram
  7. //
  8. // Abstract:
  9. // This module contains code which deals with receiving datagrams
  10. //
  11. //////////////////////////////////////////////////////////
  12. #include "sysvars.h"
  13. //////////////////////////////////////////////////////////////
  14. // private constants, types, and prototypes
  15. //////////////////////////////////////////////////////////////
  16. const PCHAR strFunc1 = "TSReceiveDatagram";
  17. const PCHAR strFunc2 = "TSRcvDatagramHandler";
  18. const PCHAR strFunc3 = "TSChainedRcvDatagramHandler";
  19. const PCHAR strFuncP1 = "TSReceiveDgramComplete";
  20. const PCHAR strFuncP2 = "TSGetRestOfDgram";
  21. const PCHAR strFuncP3 = "TSShowDgramInfo";
  22. //
  23. // completion information structure
  24. //
  25. struct RECEIVE_CONTEXT
  26. {
  27. PMDL pLowerMdl; // mdl from lower irp
  28. PRECEIVE_DATA pReceiveData; // above structure
  29. PADDRESS_OBJECT pAddressObject; // associate address object
  30. PIRP_POOL pIrpPool;
  31. };
  32. typedef RECEIVE_CONTEXT *PRECEIVE_CONTEXT;
  33. //
  34. // completion function
  35. //
  36. TDI_STATUS
  37. TSReceiveDgramComplete(
  38. PDEVICE_OBJECT DeviceObject,
  39. PIRP Irp,
  40. PVOID Context
  41. );
  42. PIRP
  43. TSGetRestOfDgram(
  44. PADDRESS_OBJECT pAddressObject,
  45. PRECEIVE_DATA pReceiveData
  46. );
  47. VOID
  48. TSShowDgramInfo(
  49. PVOID pvTdiEventContext,
  50. LONG lSourceAddressLength,
  51. PVOID pvSourceAddress,
  52. LONG lOptionsLength,
  53. PVOID pvOptions,
  54. ULONG ulReceiveDatagramFlags
  55. );
  56. //////////////////////////////////////////////////////////////
  57. // public functions
  58. //////////////////////////////////////////////////////////////
  59. // -----------------------------------------------------------------
  60. //
  61. // Function: TSReceiveDatagram
  62. //
  63. // Arguments: pAddressObject -- address object
  64. // pSendBuffer -- arguments from user dll
  65. // pIrp -- completion information
  66. //
  67. // Returns: STATUS_SUCCESS
  68. //
  69. // Descript: This function checks to see if a datagram has been received
  70. // on this address object. If so, and if it matches certain
  71. // criteria, it returns it. Otherwise it returns with no data.
  72. //
  73. // ----------------------------------------------------------------------------
  74. NTSTATUS
  75. TSReceiveDatagram(PADDRESS_OBJECT pAddressObject,
  76. PSEND_BUFFER pSendBuffer,
  77. PRECEIVE_BUFFER pReceiveBuffer)
  78. {
  79. PTRANSPORT_ADDRESS pTransportAddress
  80. = (PTRANSPORT_ADDRESS)&pSendBuffer->COMMAND_ARGS.SendArgs.TransAddr;
  81. BOOLEAN fMatchAddress
  82. = (BOOLEAN)(pTransportAddress->TAAddressCount > 0);
  83. PRECEIVE_DATA pReceiveData = NULL;
  84. //
  85. // if need to match to address, return the first packet in the queue
  86. // that was sent from the specified address.
  87. //
  88. if (fMatchAddress)
  89. {
  90. ULONG ulCompareLength
  91. = FIELD_OFFSET(TRANSPORT_ADDRESS, Address)
  92. + FIELD_OFFSET(TA_ADDRESS, Address)
  93. + pTransportAddress->Address[0].AddressLength;
  94. if (pTransportAddress->Address[0].AddressType == TDI_ADDRESS_TYPE_IP)
  95. {
  96. ulCompareLength -= 8; // ignore sin_zero[8]
  97. }
  98. TSAcquireSpinLock(&pAddressObject->TdiSpinLock);
  99. pReceiveData = pAddressObject->pHeadReceiveData;
  100. while(pReceiveData)
  101. {
  102. if (RtlEqualMemory(pTransportAddress,
  103. &pReceiveData->TransAddr,
  104. ulCompareLength))
  105. {
  106. break;
  107. }
  108. pReceiveData = pReceiveData->pNextReceiveData;
  109. }
  110. //
  111. // did we find anything?
  112. //
  113. if (pReceiveData)
  114. {
  115. //
  116. // fix up the lists as necessary
  117. //
  118. if (pReceiveData->pPrevReceiveData)
  119. {
  120. pReceiveData->pPrevReceiveData->pNextReceiveData
  121. = pReceiveData->pNextReceiveData;
  122. }
  123. else
  124. {
  125. pAddressObject->pHeadReceiveData = pReceiveData->pNextReceiveData;
  126. }
  127. if (pReceiveData->pNextReceiveData)
  128. {
  129. pReceiveData->pNextReceiveData->pPrevReceiveData
  130. = pReceiveData->pPrevReceiveData;
  131. }
  132. else
  133. {
  134. pAddressObject->pTailReceiveData = pReceiveData->pPrevReceiveData;
  135. }
  136. }
  137. TSReleaseSpinLock(&pAddressObject->TdiSpinLock);
  138. }
  139. //
  140. // if not matching address, just get the first packet from the queue
  141. //
  142. else
  143. {
  144. TSAcquireSpinLock(&pAddressObject->TdiSpinLock);
  145. pReceiveData = pAddressObject->pHeadReceiveData;
  146. if (pReceiveData)
  147. {
  148. //
  149. // fix up the lists as necessary
  150. //
  151. if (pReceiveData->pNextReceiveData)
  152. {
  153. pReceiveData->pNextReceiveData->pPrevReceiveData = NULL;
  154. }
  155. else
  156. {
  157. pAddressObject->pTailReceiveData = NULL;
  158. }
  159. pAddressObject->pHeadReceiveData = pReceiveData->pNextReceiveData;
  160. }
  161. TSReleaseSpinLock(&pAddressObject->TdiSpinLock);
  162. }
  163. //
  164. // if we got a packet to return, then lets return it..
  165. // and release its memory
  166. //
  167. if (pReceiveData)
  168. {
  169. //
  170. // we are only showing debug if we actually return a packet
  171. //
  172. if (ulDebugLevel & ulDebugShowCommand)
  173. {
  174. DebugPrint1("\nCommand = ulRECEIVEDATAGRAM\n"
  175. "FileObject = %p\n",
  176. pAddressObject);
  177. if (pTransportAddress->TAAddressCount)
  178. {
  179. TSPrintTaAddress(pTransportAddress->Address);
  180. }
  181. }
  182. if (pReceiveData->ulBufferLength > pSendBuffer->COMMAND_ARGS.SendArgs.ulBufferLength)
  183. {
  184. pReceiveData->ulBufferLength = pSendBuffer->COMMAND_ARGS.SendArgs.ulBufferLength;
  185. }
  186. //
  187. // attempt to lock down the memory
  188. //
  189. PMDL pMdl = TSMakeMdlForUserBuffer(pSendBuffer->COMMAND_ARGS.SendArgs.pucUserModeBuffer,
  190. pReceiveData->ulBufferLength,
  191. IoModifyAccess);
  192. if (pMdl)
  193. {
  194. RtlCopyMemory(&pReceiveBuffer->RESULTS.RecvDgramRet.TransAddr,
  195. &pReceiveData->TransAddr,
  196. sizeof(TRANSADDR));
  197. RtlCopyMemory(MmGetSystemAddressForMdl(pMdl),
  198. pReceiveData->pucDataBuffer,
  199. pReceiveData->ulBufferLength);
  200. TSFreeUserBuffer(pMdl);
  201. }
  202. else
  203. {
  204. pReceiveData->ulBufferLength = 0;
  205. }
  206. pReceiveBuffer->RESULTS.RecvDgramRet.ulBufferLength = pReceiveData->ulBufferLength;
  207. TSFreeMemory(pReceiveData->pucDataBuffer);
  208. TSFreeMemory(pReceiveData);
  209. }
  210. else
  211. {
  212. pReceiveBuffer->RESULTS.RecvDgramRet.ulBufferLength = 0;
  213. }
  214. return STATUS_SUCCESS;
  215. }
  216. // -----------------------------------------------
  217. //
  218. // Function: TSRcvDatagramHandler
  219. //
  220. // Arguments: pvTdiEventContext -- really pointer to our AddressObject
  221. // lSourceAddressLength -- #bytes of source address
  222. // pvSourceAddress -- TransportAddress
  223. // lOptionsLength -- #bytes of transport-specific options
  224. // pvOptions -- options string
  225. // ulReceiveDatagramFlags -- nature of datagram received
  226. // ulBytesIndicated --- length of data in buffer
  227. // ulBytesTotal -- total length of datagram
  228. // pulBytesTaken -- stuff with bytes used by this driver
  229. // pvTsdu -- data buffer
  230. // pIoRequestPacket -- pIrp in case not all data received
  231. //
  232. // Returns: STATUS_DATA_NOT_ACCEPTED (we didn't want data)
  233. // STATUS_SUCCESS (we used all data & are done with it)
  234. // STATUS_MORE_PROCESSING_REQUIRED -- we supplied an IRP for rest
  235. //
  236. // Descript: Event handler for incoming datagrams
  237. //
  238. // -----------------------------------------------
  239. TDI_STATUS
  240. TSRcvDatagramHandler(PVOID pvTdiEventContext,
  241. LONG lSourceAddressLength,
  242. PVOID pvSourceAddress,
  243. LONG lOptionsLength,
  244. PVOID pvOptions,
  245. ULONG ulReceiveDatagramFlags,
  246. ULONG ulBytesIndicated,
  247. ULONG ulBytesTotal,
  248. PULONG pulBytesTaken,
  249. PVOID pvTsdu,
  250. PIRP *pIoRequestPacket)
  251. {
  252. //
  253. // show debug information
  254. //
  255. if (ulDebugLevel & ulDebugShowHandlers)
  256. {
  257. DebugPrint1("\n >>>> %s\n", strFunc2);
  258. TSShowDgramInfo(pvTdiEventContext,
  259. lSourceAddressLength,
  260. pvSourceAddress,
  261. lOptionsLength,
  262. pvOptions,
  263. ulReceiveDatagramFlags);
  264. DebugPrint3("BytesIndicated = %u\n"
  265. "BytesTotal = %u\n"
  266. "pTSDU = %p\n",
  267. ulBytesIndicated,
  268. ulBytesTotal,
  269. pvTsdu);
  270. }
  271. //
  272. // bad situation if more bytes are indicated than the total in the packet
  273. //
  274. if (ulBytesIndicated > ulBytesTotal)
  275. {
  276. DebugPrint2("%d bytes indicated > %u bytes total\n",
  277. ulBytesIndicated,
  278. ulBytesTotal);
  279. }
  280. //
  281. // now start doing the work...
  282. //
  283. PADDRESS_OBJECT pAddressObject = (PADDRESS_OBJECT)pvTdiEventContext;
  284. PRECEIVE_DATA pReceiveData;
  285. TDI_STATUS TdiStatus = TDI_SUCCESS; // default -- we are done with packet
  286. // (also returned in case of error)
  287. if ((TSAllocateMemory((PVOID *)&pReceiveData,
  288. sizeof(RECEIVE_DATA),
  289. strFunc2,
  290. "ReceiveData")) == STATUS_SUCCESS)
  291. {
  292. PUCHAR pucDataBuffer = NULL;
  293. if ((TSAllocateMemory((PVOID *)&pucDataBuffer,
  294. ulBytesTotal,
  295. strFunc2,
  296. "DataBuffer")) == STATUS_SUCCESS)
  297. {
  298. RtlCopyMemory(&pReceiveData->TransAddr,
  299. pvSourceAddress,
  300. lSourceAddressLength);
  301. pReceiveData->pucDataBuffer = pucDataBuffer;
  302. pReceiveData->ulBufferLength = ulBytesTotal;
  303. TdiCopyLookaheadData(pucDataBuffer,
  304. pvTsdu,
  305. ulBytesIndicated,
  306. ulReceiveDatagramFlags);
  307. pReceiveData->ulBufferUsed = ulBytesIndicated;
  308. if (ulBytesIndicated == ulBytesTotal) // note: should never be >
  309. {
  310. TSPacketReceived(pAddressObject,
  311. pReceiveData,
  312. FALSE);
  313. *pulBytesTaken = ulBytesTotal;
  314. *pIoRequestPacket = NULL;
  315. }
  316. else // not all data is present!!
  317. {
  318. PIRP pLowerIrp = TSGetRestOfDgram(pAddressObject,
  319. pReceiveData);
  320. if (pLowerIrp)
  321. {
  322. //
  323. // need to do this since we are bypassing IoCallDriver
  324. //
  325. IoSetNextIrpStackLocation(pLowerIrp);
  326. *pulBytesTaken = ulBytesIndicated;
  327. *pIoRequestPacket = pLowerIrp;
  328. TdiStatus = TDI_MORE_PROCESSING;
  329. }
  330. else
  331. {
  332. TSFreeMemory(pReceiveData->pucDataBuffer);
  333. TSFreeMemory(pReceiveData);
  334. }
  335. }
  336. }
  337. else // unable to allocate pucDataBuffer
  338. {
  339. TSFreeMemory(pReceiveData);
  340. }
  341. }
  342. return TdiStatus;
  343. }
  344. // ----------------------------------------------
  345. //
  346. // Function: TSChainedRcvDatagramHandler
  347. //
  348. // Arguments: pvTdiEventContext -- really pointer to our AddressObject
  349. // lSourceAddressLength -- #bytes of source address
  350. // pvSourceAddress -- TransportAddress
  351. // lOptionsLength -- #bytes of transport-specific options
  352. // pvOptions -- options string
  353. // ulReceiveDatagramFlags -- nature of datagram received
  354. // ulReceiveDatagramLength -- bytes in received datagram
  355. // ulStartingOffset -- starting offset of data within MDL
  356. // pTsdu -- data buffer (as an mdl)
  357. // pvTsduDescriptor -- handle to use when completing if pend
  358. //
  359. // Returns: STATUS_DATA_NOT_ACCEPTED or STATUS_SUCCESS
  360. //
  361. // Descript: Deals with receiving chained datagrams (where the
  362. // entire datagram is always available)
  363. //
  364. // -----------------------------------------------
  365. #pragma warning(disable: UNREFERENCED_PARAM)
  366. TDI_STATUS
  367. TSChainedRcvDatagramHandler(PVOID pvTdiEventContext,
  368. LONG lSourceAddressLength,
  369. PVOID pvSourceAddress,
  370. LONG lOptionsLength,
  371. PVOID pvOptions,
  372. ULONG ulReceiveDatagramFlags,
  373. ULONG ulReceiveDatagramLength,
  374. ULONG ulStartingOffset,
  375. PMDL pMdl,
  376. PVOID pvTsduDescriptor)
  377. {
  378. if (ulDebugLevel & ulDebugShowHandlers)
  379. {
  380. DebugPrint1("\n >>>> %s\n", strFunc3);
  381. TSShowDgramInfo(pvTdiEventContext,
  382. lSourceAddressLength,
  383. pvSourceAddress,
  384. lOptionsLength,
  385. pvOptions,
  386. ulReceiveDatagramFlags);
  387. DebugPrint3("DataLength = %u\n"
  388. "StartingOffset = %u\n"
  389. "pTSDU = %p\n",
  390. ulReceiveDatagramLength,
  391. ulStartingOffset,
  392. pMdl);
  393. }
  394. //
  395. // now do the work..
  396. //
  397. PRECEIVE_DATA pReceiveData;
  398. PADDRESS_OBJECT pAddressObject = (PADDRESS_OBJECT)pvTdiEventContext;
  399. if ((TSAllocateMemory((PVOID *)&pReceiveData,
  400. sizeof(RECEIVE_DATA),
  401. strFunc3,
  402. "ReceiveData")) == STATUS_SUCCESS)
  403. {
  404. PUCHAR pucDataBuffer = NULL;
  405. if ((TSAllocateMemory((PVOID *)&pucDataBuffer,
  406. ulReceiveDatagramLength,
  407. strFunc3,
  408. "DataBuffer")) == STATUS_SUCCESS)
  409. {
  410. ULONG ulBytesCopied;
  411. RtlCopyMemory(&pReceiveData->TransAddr,
  412. pvSourceAddress,
  413. lSourceAddressLength);
  414. TdiCopyMdlToBuffer(pMdl,
  415. ulStartingOffset,
  416. pucDataBuffer,
  417. 0,
  418. ulReceiveDatagramLength,
  419. &ulBytesCopied);
  420. //
  421. // if successfully copied all data
  422. //
  423. if (ulBytesCopied == ulReceiveDatagramLength)
  424. {
  425. UCHAR ucFirstChar = *pucDataBuffer;
  426. pReceiveData->pucDataBuffer = pucDataBuffer;
  427. pReceiveData->ulBufferLength = ulReceiveDatagramLength;
  428. pReceiveData->ulBufferUsed = ulReceiveDatagramLength;
  429. TSPacketReceived(pAddressObject,
  430. pReceiveData,
  431. FALSE);
  432. }
  433. //
  434. // error in copying data!
  435. //
  436. else
  437. {
  438. DebugPrint1("%s: error copying data\n", strFunc3);
  439. TSFreeMemory(pucDataBuffer);
  440. TSFreeMemory(pReceiveData);
  441. }
  442. }
  443. else // unable to allocate pucDataBuffer
  444. {
  445. TSFreeMemory(pReceiveData);
  446. }
  447. }
  448. return TDI_SUCCESS; // we are done with packet
  449. }
  450. #pragma warning(default: UNREFERENCED_PARAM)
  451. /////////////////////////////////////////////////////////////
  452. // private functions
  453. /////////////////////////////////////////////////////////////
  454. // ---------------------------------------------------------
  455. //
  456. // Function: TSReceiveDgramComplete
  457. //
  458. // Arguments: pDeviceObject -- device object that called ReceiveDatagram
  459. // pIrp -- IRP used in the call
  460. // pContext -- context used for the call
  461. //
  462. // Returns: status of operation (STATUS_MORE_PROCESSING_REQUIRED)
  463. //
  464. // Descript: Gets the result of the receive and adds the packet
  465. // to the receive queue of the address object. Then
  466. // cleans up
  467. //
  468. // ---------------------------------------------------------
  469. #pragma warning(disable: UNREFERENCED_PARAM)
  470. TDI_STATUS
  471. TSReceiveDgramComplete(PDEVICE_OBJECT pDeviceObject,
  472. PIRP pLowerIrp,
  473. PVOID pvContext)
  474. {
  475. PRECEIVE_CONTEXT pReceiveContext = (PRECEIVE_CONTEXT)pvContext;
  476. NTSTATUS lStatus = pLowerIrp->IoStatus.Status;
  477. ULONG ulBytesCopied = (ULONG)pLowerIrp->IoStatus.Information;
  478. PADDRESS_OBJECT pAddressObject = pReceiveContext->pAddressObject;
  479. PRECEIVE_DATA pReceiveData = pReceiveContext->pReceiveData;
  480. if (NT_SUCCESS(lStatus))
  481. {
  482. if (ulDebugLevel & ulDebugShowCommand)
  483. {
  484. DebugPrint2("%s: %u BytesCopied\n",
  485. strFuncP1,
  486. ulBytesCopied);
  487. }
  488. pReceiveData->ulBufferUsed += ulBytesCopied;
  489. if (pReceiveData->ulBufferUsed >= pReceiveData->ulBufferLength)
  490. {
  491. TSPacketReceived(pAddressObject,
  492. pReceiveData,
  493. FALSE);
  494. }
  495. else
  496. {
  497. DebugPrint1("%s: Data Incomplete\n", strFuncP1);
  498. TSFreeMemory(pReceiveData->pucDataBuffer);
  499. TSFreeMemory(pReceiveData);
  500. }
  501. }
  502. else
  503. {
  504. DebugPrint2("%s: Completed with status 0x%08x\n",
  505. strFuncP1,
  506. lStatus);
  507. TSFreeMemory(pReceiveData->pucDataBuffer);
  508. TSFreeMemory(pReceiveData);
  509. }
  510. //
  511. // now cleanup
  512. //
  513. TSFreeIrp(pLowerIrp, pReceiveContext->pIrpPool);
  514. TSFreeBuffer(pReceiveContext->pLowerMdl);
  515. TSFreeMemory(pReceiveContext);
  516. return STATUS_MORE_PROCESSING_REQUIRED;
  517. }
  518. #pragma warning(default: UNREFERENCED_PARAM)
  519. // ------------------------------------------------------
  520. //
  521. // Function: TSGetRestOfDgram
  522. //
  523. // Arguments: pAddressObject -- address object we are receiving on
  524. // pReceiveData -- what we have received so far..
  525. //
  526. // Returns: Irp to return to transport, to get rest of data (NULL if error)
  527. //
  528. // Descript: This function sets up the IRP to get the rest of a datagram
  529. // that was only partially delivered via the event handler
  530. //
  531. // -------------------------------------------------
  532. PIRP
  533. TSGetRestOfDgram(PADDRESS_OBJECT pAddressObject,
  534. PRECEIVE_DATA pReceiveData)
  535. {
  536. PUCHAR pucDataBuffer = pReceiveData->pucDataBuffer + pReceiveData->ulBufferUsed;
  537. ULONG ulBufferLength = pReceiveData->ulBufferLength - pReceiveData->ulBufferUsed;
  538. PRECEIVE_CONTEXT pReceiveContext = NULL;
  539. PMDL pReceiveMdl = NULL;
  540. //
  541. // allocate all the necessary structures
  542. // our context
  543. //
  544. if ((TSAllocateMemory((PVOID *)&pReceiveContext,
  545. sizeof(RECEIVE_CONTEXT),
  546. strFuncP2,
  547. "ReceiveContext")) != STATUS_SUCCESS)
  548. {
  549. goto cleanup;
  550. }
  551. //
  552. // then the actual mdl
  553. //
  554. pReceiveMdl = TSAllocateBuffer(pucDataBuffer,
  555. ulBufferLength);
  556. if (pReceiveMdl)
  557. {
  558. //
  559. // set up the completion context
  560. //
  561. pReceiveContext->pLowerMdl = pReceiveMdl;
  562. pReceiveContext->pReceiveData = pReceiveData;
  563. pReceiveContext->pAddressObject = pAddressObject;
  564. //
  565. // finally, the irp itself
  566. //
  567. PIRP pLowerIrp = TSAllocateIrp(pAddressObject->GenHead.pDeviceObject,
  568. pAddressObject->pIrpPool);
  569. if (pLowerIrp)
  570. {
  571. pReceiveContext->pIrpPool = pAddressObject->pIrpPool;
  572. //
  573. // if made it to here, everything is correctly allocated
  574. // set up the irp for the call
  575. //
  576. #pragma warning(disable: CONSTANT_CONDITIONAL)
  577. TdiBuildReceiveDatagram(pLowerIrp,
  578. pAddressObject->GenHead.pDeviceObject,
  579. pAddressObject->GenHead.pFileObject,
  580. TSReceiveDgramComplete,
  581. pReceiveContext,
  582. pReceiveMdl,
  583. 0, /// ulBufferLength, // 0 doesn't work with ipx
  584. NULL,
  585. NULL,
  586. TDI_RECEIVE_NORMAL);
  587. #pragma warning(default: CONSTANT_CONDITIONAL)
  588. //
  589. // mark it pending before returning control to transport
  590. //
  591. return pLowerIrp;
  592. }
  593. }
  594. //
  595. // get here if there was an allocation failure
  596. // need to clean up everything else...
  597. //
  598. cleanup:
  599. if (pReceiveContext)
  600. {
  601. TSFreeMemory(pReceiveContext);
  602. }
  603. if (pReceiveMdl)
  604. {
  605. TSFreeBuffer(pReceiveMdl);
  606. }
  607. return NULL;
  608. }
  609. // ---------------------------------
  610. //
  611. // Function: TSShowDgramInfo
  612. //
  613. // Arguments: pvTdiEventContext -- really pointer to our AddressObject
  614. // lSourceAddressLength -- #bytes of source address
  615. // pvSourceAddress -- TransportAddress
  616. // lOptionsLength -- #bytes of transport-specific options
  617. // pvOptions -- options string
  618. // ulReceiveDatagramFlags -- nature of datagram received
  619. //
  620. // Returns: none
  621. //
  622. // Descript: shows info passed to the dgram handlers
  623. //
  624. // --------------------------------
  625. VOID
  626. TSShowDgramInfo(PVOID pvTdiEventContext,
  627. LONG lSourceAddressLength,
  628. PVOID pvSourceAddress,
  629. LONG lOptionsLength,
  630. PVOID pvOptions,
  631. ULONG ulReceiveDatagramFlags)
  632. {
  633. DebugPrint2("pAddressObject = %p\n"
  634. "SourceAddressLength = %d\n",
  635. pvTdiEventContext,
  636. lSourceAddressLength);
  637. if (lSourceAddressLength)
  638. {
  639. PTRANSPORT_ADDRESS pTransportAddress = (PTRANSPORT_ADDRESS)pvSourceAddress;
  640. DebugPrint0("SourceAddress: ");
  641. TSPrintTaAddress(&pTransportAddress->Address[0]);
  642. }
  643. DebugPrint1("OptionsLength = %d\n", lOptionsLength);
  644. if (lOptionsLength)
  645. {
  646. PUCHAR pucTemp = (PUCHAR)pvOptions;
  647. DebugPrint0("Options: ");
  648. for (LONG lCount = 0; lCount < lOptionsLength; lCount++)
  649. {
  650. DebugPrint1("%02x ", *pucTemp);
  651. ++pucTemp;
  652. }
  653. DebugPrint0("\n");
  654. }
  655. DebugPrint1("ReceiveDatagramFlags: 0x%08x\n", ulReceiveDatagramFlags);
  656. if (ulReceiveDatagramFlags & TDI_RECEIVE_BROADCAST)
  657. {
  658. DebugPrint0("TDI_RECEIVE_BROADCAST\n");
  659. }
  660. if (ulReceiveDatagramFlags & TDI_RECEIVE_MULTICAST)
  661. {
  662. DebugPrint0("TDI_RECEIVE_MULTICAST\n");
  663. }
  664. if (ulReceiveDatagramFlags & TDI_RECEIVE_PARTIAL)
  665. {
  666. DebugPrint0("TDI_RECEIVE_PARTIAL (legacy)\n");
  667. }
  668. if (ulReceiveDatagramFlags & TDI_RECEIVE_NORMAL) // shouldn't see for datagram
  669. {
  670. DebugPrint0("TDI_RECEIVE_NORMAL\n");
  671. }
  672. if (ulReceiveDatagramFlags & TDI_RECEIVE_EXPEDITED) // shouldn't see for datagram
  673. {
  674. DebugPrint0("TDI_RECEIVE_EXPEDITED\n");
  675. }
  676. if (ulReceiveDatagramFlags & TDI_RECEIVE_PEEK)
  677. {
  678. DebugPrint0("TDI_RECEIVE_PEEK\n");
  679. }
  680. if (ulReceiveDatagramFlags & TDI_RECEIVE_NO_RESPONSE_EXP) // not for datagrams
  681. {
  682. DebugPrint0("TDI_RECEIVE_NO_RESPONSE_EXP\n");
  683. }
  684. if (ulReceiveDatagramFlags & TDI_RECEIVE_COPY_LOOKAHEAD)
  685. {
  686. DebugPrint0("TDI_RECEIVE_COPY_LOOKAHEAD\n");
  687. }
  688. if (ulReceiveDatagramFlags & TDI_RECEIVE_ENTIRE_MESSAGE)
  689. {
  690. DebugPrint0("TDI_RECEIVE_ENTIRE_MESSAGE\n");
  691. }
  692. if (ulReceiveDatagramFlags & TDI_RECEIVE_AT_DISPATCH_LEVEL)
  693. {
  694. DebugPrint0("TDI_RECEIVE_AT_DISPATCH_LEVEL\n");
  695. }
  696. }
  697. ///////////////////////////////////////////////////////////////////////////////
  698. // end of file rcvdgram.cpp
  699. ///////////////////////////////////////////////////////////////////////////////