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.

259 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. spxquery.c
  5. Abstract:
  6. This module contains code which performs the following TDI services:
  7. o TdiQueryInformation
  8. Author:
  9. Adam Barr (adamba) Initial Version
  10. Nikhil Kamkolkar (nikhilk) 11-November-1993
  11. Environment:
  12. Kernel mode
  13. Revision History:
  14. --*/
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. // Discardable code after Init time
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text(INIT, SpxQueryInitProviderInfo)
  20. #endif
  21. // Define module number for event logging entries
  22. #define FILENUM SPXQUERY
  23. // Useful macro to obtain the total length of an MDL chain.
  24. #define SpxGetMdlChainLength(Mdl, Length) { \
  25. PMDL _Mdl = (Mdl); \
  26. *(Length) = 0; \
  27. while (_Mdl) { \
  28. *(Length) += MmGetMdlByteCount(_Mdl); \
  29. _Mdl = _Mdl->Next; \
  30. } \
  31. }
  32. VOID
  33. SpxQueryInitProviderInfo(
  34. PTDI_PROVIDER_INFO ProviderInfo
  35. )
  36. {
  37. // Initialize to defaults first
  38. RtlZeroMemory((PVOID)ProviderInfo, sizeof(TDI_PROVIDER_INFO));
  39. ProviderInfo->Version = SPX_TDI_PROVIDERINFO_VERSION;
  40. KeQuerySystemTime (&ProviderInfo->StartTime);
  41. ProviderInfo->MinimumLookaheadData = SPX_PINFOMINMAXLOOKAHEAD;
  42. ProviderInfo->MaximumLookaheadData = IpxLineInfo.MaximumPacketSize;
  43. ProviderInfo->MaxSendSize = SPX_PINFOSENDSIZE;
  44. ProviderInfo->ServiceFlags = SPX_PINFOSERVICEFLAGS;
  45. return;
  46. }
  47. NTSTATUS
  48. SpxTdiQueryInformation(
  49. IN PDEVICE Device,
  50. IN PREQUEST Request
  51. )
  52. /*++
  53. Routine Description:
  54. This routine performs the TdiQueryInformation request for the transport
  55. provider.
  56. Arguments:
  57. Request - the request for the operation.
  58. Return Value:
  59. NTSTATUS - status of operation.
  60. --*/
  61. {
  62. NTSTATUS status;
  63. PSPX_ADDR_FILE AddressFile;
  64. PSPX_CONN_FILE ConnectionFile;
  65. PTDI_REQUEST_KERNEL_QUERY_INFORMATION query;
  66. struct {
  67. ULONG ActivityCount;
  68. TA_IPX_ADDRESS SpxAddress;
  69. } AddressInfo;
  70. // what type of status do we want?
  71. query = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)REQUEST_PARAMETERS(Request);
  72. switch (query->QueryType)
  73. {
  74. case TDI_QUERY_CONNECTION_INFO:
  75. status = STATUS_NOT_IMPLEMENTED;
  76. break;
  77. case TDI_QUERY_ADDRESS_INFO:
  78. // The caller wants the exact address value.
  79. ConnectionFile = (PSPX_CONN_FILE)REQUEST_OPEN_CONTEXT(Request);
  80. status = SpxConnFileVerify(ConnectionFile);
  81. if (status == STATUS_SUCCESS) {
  82. AddressFile = ConnectionFile->scf_AddrFile;
  83. SpxConnFileDereference(ConnectionFile, CFREF_VERIFY);
  84. } else {
  85. AddressFile = (PSPX_ADDR_FILE)REQUEST_OPEN_CONTEXT(Request);
  86. }
  87. status = SpxAddrFileVerify(AddressFile);
  88. if (status == STATUS_SUCCESS)
  89. {
  90. DBGPRINT(RECEIVE, INFO,
  91. ("SpxTdiQuery: Net.Socket %lx.%lx\n",
  92. *(PULONG)Device->dev_Network,
  93. AddressFile->saf_Addr->sa_Socket));
  94. AddressInfo.ActivityCount = 0;
  95. (VOID)SpxBuildTdiAddress(
  96. &AddressInfo.SpxAddress,
  97. sizeof(TA_IPX_ADDRESS),
  98. Device->dev_Network,
  99. Device->dev_Node,
  100. AddressFile->saf_Addr->sa_Socket);
  101. status = TdiCopyBufferToMdl(
  102. &AddressInfo,
  103. 0,
  104. sizeof(AddressInfo),
  105. REQUEST_NDIS_BUFFER(Request),
  106. 0,
  107. (PULONG)&REQUEST_INFORMATION(Request));
  108. SpxAddrFileDereference(AddressFile, AFREF_VERIFY);
  109. }
  110. break;
  111. case TDI_QUERY_PROVIDER_INFO: {
  112. BYTE socketType;
  113. TDI_PROVIDER_INFO providerInfo = Device->dev_ProviderInfo;
  114. //
  115. // The device name extension comes down in the Irp
  116. //
  117. if (!NT_SUCCESS(status = SpxUtilGetSocketType(
  118. REQUEST_OPEN_NAME(Request),
  119. &socketType))) {
  120. DBGPRINT(RECEIVE, ERR, ("TDI_QUERY_PROVIDER_INFO: SpxUtilGetSocketType failed: %lx\n", status));
  121. return(status);
  122. }
  123. //
  124. // The Catapult folks had a problem where AFD was discarding buffered sends on the NT box when it got a
  125. // local disconnect on SPX1. This was because the Orderly release flag was always set in the provider
  126. // info. AFD queries this once per device type. We detect the device above and OR in the orderly release
  127. // flag if this query came down on an SPX2 endpoint.
  128. // This is to make sure that AFD follows the correct disconnect semantics for SPX1 and SPX2 (SPX1 does
  129. // only abortive; SPX2 does both abortive and orderly).
  130. //
  131. // this will still not solve the problem completely since a connection that starts off as an SPX2
  132. // one can still be negotiated to SPX1 if the remote supports only SPX1.
  133. //
  134. if ((socketType == SOCKET2_TYPE_SEQPKT) ||
  135. (socketType == SOCKET2_TYPE_STREAM)) {
  136. DBGPRINT(RECEIVE, INFO, ("TDI_QUERY_PROVIDER_INFO: SPX2 socket\n"));
  137. providerInfo.ServiceFlags |= TDI_SERVICE_ORDERLY_RELEASE;
  138. } else {
  139. DBGPRINT(RECEIVE, INFO, ("TDI_QUERY_PROVIDER_INFO: SPX1 socket\n"));
  140. }
  141. status = TdiCopyBufferToMdl (
  142. &providerInfo,
  143. 0,
  144. sizeof (TDI_PROVIDER_INFO),
  145. REQUEST_TDI_BUFFER(Request),
  146. 0,
  147. (PULONG)&REQUEST_INFORMATION(Request));
  148. break;
  149. }
  150. case TDI_QUERY_PROVIDER_STATISTICS:
  151. status = TdiCopyBufferToMdl (
  152. &Device->dev_Stat,
  153. 0,
  154. FIELD_OFFSET (TDI_PROVIDER_STATISTICS, ResourceStats[0]),
  155. REQUEST_TDI_BUFFER(Request),
  156. 0,
  157. (PULONG)&REQUEST_INFORMATION(Request));
  158. break;
  159. default:
  160. status = STATUS_INVALID_DEVICE_REQUEST;
  161. break;
  162. }
  163. return status;
  164. } // SpxTdiQueryInformation
  165. NTSTATUS
  166. SpxTdiSetInformation(
  167. IN PDEVICE Device,
  168. IN PREQUEST Request
  169. )
  170. /*++
  171. Routine Description:
  172. This routine performs the TdiSetInformation request for the transport
  173. provider.
  174. Arguments:
  175. Device - the device.
  176. Request - the request for the operation.
  177. Return Value:
  178. NTSTATUS - status of operation.
  179. --*/
  180. {
  181. UNREFERENCED_PARAMETER (Device);
  182. UNREFERENCED_PARAMETER (Request);
  183. return STATUS_NOT_IMPLEMENTED;
  184. } // SpxTdiSetInformation