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.

335 lines
8.5 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. query.c
  5. Abstract:
  6. This module contains code which performs the following TDI services:
  7. o TdiQueryInformation
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. //
  15. // Useful macro to obtain the total length of an MDL chain.
  16. //
  17. #define IpxGetMdlChainLength(Mdl, Length) { \
  18. PMDL _Mdl = (Mdl); \
  19. *(Length) = 0; \
  20. while (_Mdl) { \
  21. *(Length) += MmGetMdlByteCount(_Mdl); \
  22. _Mdl = _Mdl->Next; \
  23. } \
  24. }
  25. NTSTATUS
  26. IpxTdiQueryInformation(
  27. IN PDEVICE Device,
  28. IN PREQUEST Request
  29. )
  30. /*++
  31. Routine Description:
  32. This routine performs the TdiQueryInformation request for the transport
  33. provider.
  34. Arguments:
  35. Request - the request for the operation.
  36. Return Value:
  37. NTSTATUS - status of operation.
  38. --*/
  39. {
  40. NTSTATUS status;
  41. PTDI_REQUEST_KERNEL_QUERY_INFORMATION query;
  42. PADDRESS_FILE AddressFile;
  43. ULONG ElementSize, TransportAddressSize;
  44. PTRANSPORT_ADDRESS TransportAddress;
  45. TA_ADDRESS * CurAddress;
  46. PBINDING Binding;
  47. union {
  48. struct {
  49. ULONG ActivityCount;
  50. TA_IPX_ADDRESS IpxAddress;
  51. } AddressInfo;
  52. TDI_DATAGRAM_INFO DatagramInfo;
  53. TDI_ADDRESS_IPX IpxAddress;
  54. } TempBuffer;
  55. UINT i;
  56. IPX_DEFINE_LOCK_HANDLE(LockHandle1)
  57. //
  58. // what type of status do we want?
  59. //
  60. query = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)REQUEST_PARAMETERS(Request);
  61. switch (query->QueryType) {
  62. case TDI_QUERY_ADDRESS_INFO:
  63. //
  64. // The caller wants the exact address value.
  65. //
  66. AddressFile = (PADDRESS_FILE)REQUEST_OPEN_CONTEXT(Request);
  67. status = IpxVerifyAddressFile (AddressFile);
  68. if (status == STATUS_SUCCESS) {
  69. TempBuffer.AddressInfo.ActivityCount = 0;
  70. IpxBuildTdiAddress(
  71. &TempBuffer.AddressInfo.IpxAddress,
  72. Device->SourceAddress.NetworkAddress,
  73. Device->SourceAddress.NodeAddress,
  74. AddressFile->Address->Socket);
  75. #ifdef SUNDOWN
  76. status = TdiCopyBufferToMdl(
  77. &TempBuffer.AddressInfo,
  78. 0,
  79. sizeof(TempBuffer.AddressInfo),
  80. REQUEST_NDIS_BUFFER(Request),
  81. 0,
  82. (PULONG)&REQUEST_INFORMATION(Request));
  83. #else
  84. status = TdiCopyBufferToMdl(
  85. &TempBuffer.AddressInfo,
  86. 0,
  87. sizeof(TempBuffer.AddressInfo),
  88. REQUEST_NDIS_BUFFER(Request),
  89. 0,
  90. &REQUEST_INFORMATION(Request));
  91. #endif
  92. IpxDereferenceAddressFile (AddressFile, AFREF_VERIFY);
  93. }
  94. break;
  95. case TDI_QUERY_PROVIDER_INFO:
  96. #ifdef SUNDOWN
  97. status = TdiCopyBufferToMdl (
  98. &(Device->Information),
  99. 0,
  100. sizeof (TDI_PROVIDER_INFO),
  101. REQUEST_NDIS_BUFFER(Request),
  102. 0,
  103. (PULONG)&REQUEST_INFORMATION(Request));
  104. #else
  105. status = TdiCopyBufferToMdl (
  106. &(Device->Information),
  107. 0,
  108. sizeof (TDI_PROVIDER_INFO),
  109. REQUEST_NDIS_BUFFER(Request),
  110. 0,
  111. &REQUEST_INFORMATION(Request));
  112. #endif
  113. break;
  114. case TDI_QUERY_PROVIDER_STATISTICS:
  115. #ifdef SUNDOWN
  116. status = TdiCopyBufferToMdl (
  117. &Device->Statistics,
  118. 0,
  119. FIELD_OFFSET (TDI_PROVIDER_STATISTICS, ResourceStats[0]),
  120. REQUEST_NDIS_BUFFER(Request),
  121. 0,
  122. (PULONG)&REQUEST_INFORMATION(Request));
  123. #else
  124. status = TdiCopyBufferToMdl (
  125. &Device->Statistics,
  126. 0,
  127. FIELD_OFFSET (TDI_PROVIDER_STATISTICS, ResourceStats[0]),
  128. REQUEST_NDIS_BUFFER(Request),
  129. 0,
  130. &REQUEST_INFORMATION(Request));
  131. #endif
  132. break;
  133. case TDI_QUERY_DATAGRAM_INFO:
  134. TempBuffer.DatagramInfo.MaximumDatagramBytes = 0;
  135. TempBuffer.DatagramInfo.MaximumDatagramCount = 0;
  136. #ifdef SUNDOWN
  137. status = TdiCopyBufferToMdl (
  138. &TempBuffer.DatagramInfo,
  139. 0,
  140. sizeof(TempBuffer.DatagramInfo),
  141. REQUEST_NDIS_BUFFER(Request),
  142. 0,
  143. (PULONG)&REQUEST_INFORMATION(Request));
  144. #else
  145. status = TdiCopyBufferToMdl (
  146. &TempBuffer.DatagramInfo,
  147. 0,
  148. sizeof(TempBuffer.DatagramInfo),
  149. REQUEST_NDIS_BUFFER(Request),
  150. 0,
  151. &REQUEST_INFORMATION(Request));
  152. #endif
  153. break;
  154. case TDI_QUERY_DATA_LINK_ADDRESS:
  155. case TDI_QUERY_NETWORK_ADDRESS:
  156. if (query->QueryType == TDI_QUERY_DATA_LINK_ADDRESS) {
  157. ElementSize = (2 * sizeof(USHORT)) + 6;
  158. } else {
  159. ElementSize = (2 * sizeof(USHORT)) + sizeof(TDI_ADDRESS_IPX);
  160. }
  161. TransportAddress = IpxAllocateMemory(sizeof(int) + (ElementSize * MIN (Device->MaxBindings, Device->ValidBindings)), MEMORY_QUERY, "NetworkAddress");
  162. if (TransportAddress == NULL) {
  163. status = STATUS_INSUFFICIENT_RESOURCES;
  164. } else {
  165. TransportAddress->TAAddressCount = 0;
  166. TransportAddressSize = sizeof(int);
  167. CurAddress = (TA_ADDRESS *)TransportAddress->Address;
  168. IPX_GET_LOCK1(&Device->BindAccessLock, &LockHandle1);
  169. {
  170. ULONG Index = MIN (Device->MaxBindings, Device->ValidBindings);
  171. for (i = FIRST_REAL_BINDING; i <= Index; i++) {
  172. Binding = NIC_ID_TO_BINDING(Device, i);
  173. if ((Binding == NULL) ||
  174. (!Binding->LineUp)) {
  175. continue;
  176. }
  177. if (query->QueryType == TDI_QUERY_DATA_LINK_ADDRESS) {
  178. CurAddress->AddressLength = 6;
  179. #ifdef SUNDOWN
  180. CurAddress->AddressType = (USHORT)Binding->Adapter->MacInfo.RealMediumType;
  181. #else
  182. CurAddress->AddressType = Binding->Adapter->MacInfo.RealMediumType;
  183. #endif
  184. RtlCopyMemory (CurAddress->Address, Binding->LocalAddress.NodeAddress, 6);
  185. } else {
  186. CurAddress->AddressLength = sizeof(TDI_ADDRESS_IPX);
  187. CurAddress->AddressType = TDI_ADDRESS_TYPE_IPX;
  188. RtlCopyMemory (CurAddress->Address, &Binding->LocalAddress, sizeof(TDI_ADDRESS_IPX));
  189. }
  190. ++TransportAddress->TAAddressCount;
  191. TransportAddressSize += ElementSize;
  192. CurAddress = (TA_ADDRESS *)(((PUCHAR)CurAddress) + ElementSize);
  193. }
  194. }
  195. IPX_FREE_LOCK1(&Device->BindAccessLock, LockHandle1);
  196. #ifdef SUNDOWN
  197. status = TdiCopyBufferToMdl (
  198. TransportAddress,
  199. 0,
  200. TransportAddressSize,
  201. REQUEST_NDIS_BUFFER(Request),
  202. 0,
  203. (PULONG)&REQUEST_INFORMATION(Request));
  204. #else
  205. status = TdiCopyBufferToMdl (
  206. TransportAddress,
  207. 0,
  208. TransportAddressSize,
  209. REQUEST_NDIS_BUFFER(Request),
  210. 0,
  211. &REQUEST_INFORMATION(Request));
  212. #endif
  213. CTEFreeMem (TransportAddress);
  214. }
  215. break;
  216. default:
  217. status = STATUS_INVALID_DEVICE_REQUEST;
  218. break;
  219. }
  220. return status;
  221. } /* IpxTdiQueryInformation */
  222. NTSTATUS
  223. IpxTdiSetInformation(
  224. IN PDEVICE Device,
  225. IN PREQUEST Request
  226. )
  227. /*++
  228. Routine Description:
  229. This routine performs the TdiSetInformation request for the transport
  230. provider.
  231. Arguments:
  232. Device - the device.
  233. Request - the request for the operation.
  234. Return Value:
  235. NTSTATUS - status of operation.
  236. --*/
  237. {
  238. UNREFERENCED_PARAMETER (Device);
  239. UNREFERENCED_PARAMETER (Request);
  240. return STATUS_NOT_IMPLEMENTED;
  241. } /* IpxTdiSetInformation */