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.

1832 lines
79 KiB

  1. /***************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. REQUEST.C
  5. Abstract:
  6. Handles set and query requests
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  11. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  13. PURPOSE.
  14. Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  15. Revision History:
  16. 5/13/99 : created
  17. Author:
  18. Tom Green
  19. ****************************************************************************/
  20. #include "precomp.h"
  21. #ifdef TESTING
  22. extern PUCHAR pOffloadBuffer;
  23. extern ULONG OffloadSize;
  24. #endif
  25. // supported OID list
  26. NDIS_OID RndismpSupportedOids[] =
  27. {
  28. OID_GEN_SUPPORTED_LIST,
  29. OID_GEN_MEDIA_IN_USE,
  30. OID_GEN_MAXIMUM_LOOKAHEAD,
  31. OID_GEN_MAXIMUM_TOTAL_SIZE,
  32. OID_GEN_PROTOCOL_OPTIONS,
  33. OID_GEN_TRANSMIT_BUFFER_SPACE,
  34. OID_GEN_RECEIVE_BUFFER_SPACE,
  35. OID_GEN_TRANSMIT_BLOCK_SIZE,
  36. OID_GEN_RECEIVE_BLOCK_SIZE,
  37. OID_GEN_VENDOR_DESCRIPTION,
  38. OID_GEN_DRIVER_VERSION,
  39. OID_GEN_VENDOR_ID,
  40. OID_GEN_VENDOR_DRIVER_VERSION,
  41. OID_GEN_CURRENT_LOOKAHEAD,
  42. OID_GEN_MAXIMUM_SEND_PACKETS,
  43. OID_GEN_XMIT_OK,
  44. OID_GEN_RCV_OK,
  45. OID_GEN_XMIT_ERROR,
  46. OID_GEN_RCV_ERROR,
  47. OID_GEN_RCV_NO_BUFFER,
  48. OID_GEN_MAC_OPTIONS,
  49. OID_RNDISMP_STATISTICS,
  50. #ifdef TESTING
  51. OID_TCP_TASK_OFFLOAD,
  52. OID_GEN_TRANSPORT_HEADER_OFFSET,
  53. OID_GEN_PHYSICAL_MEDIUM,
  54. #endif
  55. OID_GEN_SUPPORTED_GUIDS
  56. };
  57. UINT RndismpSupportedOidsNum = sizeof(RndismpSupportedOids) / sizeof(NDIS_OID);
  58. #ifdef BINARY_MOF_TEST
  59. UCHAR RndismpBinaryMof[] = {
  60. 0x46, 0x4f, 0x4d, 0x42, 0x01, 0x00, 0x00, 0x00, 0x45, 0x02, 0x00, 0x00, 0xbc, 0x04, 0x00, 0x00,
  61. 0x44, 0x53, 0x00, 0x01, 0x1a, 0x7d, 0xda, 0x54, 0x18, 0x44, 0x82, 0x00, 0x01, 0x06, 0x18, 0x42,
  62. 0x20, 0xe4, 0x03, 0x89, 0xc0, 0x61, 0x68, 0x24, 0x18, 0x06, 0xe5, 0x01, 0x44, 0x6a, 0x20, 0xe4,
  63. 0x82, 0x89, 0x09, 0x10, 0x01, 0x21, 0xaf, 0x02, 0x6c, 0x0a, 0x30, 0x09, 0xa2, 0xfe, 0xfd, 0x15,
  64. 0xa1, 0xa1, 0x84, 0x40, 0x48, 0xa2, 0x00, 0xf3, 0x02, 0x74, 0x0b, 0x30, 0x2c, 0xc0, 0xb6, 0x00,
  65. 0xd3, 0x02, 0x1c, 0x23, 0x12, 0x65, 0xd0, 0x94, 0xc0, 0x4a, 0x20, 0x24, 0x54, 0x80, 0x72, 0x01,
  66. 0xbe, 0x05, 0x68, 0x07, 0x94, 0x64, 0x01, 0x96, 0x61, 0x34, 0x07, 0x0e, 0xc6, 0x09, 0x8a, 0x46,
  67. 0x46, 0xa9, 0x80, 0x90, 0x67, 0x01, 0xd6, 0x71, 0x09, 0x41, 0xf7, 0x02, 0xa4, 0x09, 0x70, 0x26,
  68. 0xc0, 0xdb, 0x34, 0xa4, 0x59, 0xc0, 0x30, 0x22, 0xd8, 0x16, 0x8e, 0x30, 0xe2, 0x9c, 0x42, 0x94,
  69. 0xc6, 0x10, 0x84, 0x19, 0x31, 0x4a, 0x73, 0x58, 0x82, 0x8a, 0x11, 0xa5, 0x30, 0x04, 0x01, 0x86,
  70. 0x88, 0x55, 0x9c, 0x00, 0x6b, 0x58, 0x42, 0x39, 0x80, 0x13, 0xb0, 0xfd, 0x39, 0x48, 0x13, 0x84,
  71. 0x1c, 0x4c, 0x0b, 0x25, 0x7b, 0x40, 0x9a, 0xc6, 0xf1, 0x05, 0x39, 0x87, 0x83, 0x61, 0x26, 0x86,
  72. 0x2c, 0x55, 0x98, 0x28, 0x2d, 0x73, 0x23, 0xe3, 0xb4, 0x45, 0x01, 0xe2, 0x05, 0x08, 0x07, 0xd5,
  73. 0x58, 0x3b, 0xc7, 0xd0, 0x05, 0x80, 0xa9, 0x1e, 0x1e, 0x4a, 0xcc, 0x98, 0x09, 0x5a, 0xbc, 0x93,
  74. 0x38, 0xcc, 0xc0, 0x61, 0x4b, 0xc7, 0xd0, 0x40, 0x02, 0x27, 0x68, 0x10, 0x49, 0x8a, 0x71, 0x84,
  75. 0x14, 0xe4, 0x5c, 0x42, 0x9c, 0x7c, 0x41, 0x02, 0x94, 0x0a, 0xd0, 0x09, 0xac, 0x19, 0x77, 0x3a,
  76. 0x66, 0x4d, 0x39, 0x50, 0x78, 0x8f, 0xdc, 0xf8, 0x41, 0xe2, 0xf4, 0x09, 0xac, 0x79, 0x44, 0x89,
  77. 0x13, 0xba, 0xa9, 0x09, 0x28, 0xa4, 0x02, 0x88, 0x16, 0x40, 0x94, 0x66, 0x32, 0xa8, 0xab, 0x40,
  78. 0x82, 0x47, 0x03, 0x8f, 0xe0, 0xa8, 0x0c, 0x7a, 0x1a, 0x41, 0xe2, 0x7b, 0x18, 0xef, 0x04, 0x1e,
  79. 0x99, 0x87, 0x79, 0x8a, 0x0c, 0xf3, 0xff, 0xff, 0x8e, 0x80, 0x75, 0x8d, 0xa7, 0x11, 0x9d, 0x80,
  80. 0xe5, 0xa0, 0xa1, 0xae, 0x03, 0x1e, 0x57, 0xb4, 0xf8, 0xa7, 0x6c, 0xb8, 0xba, 0xc6, 0x82, 0xba,
  81. 0x2a, 0xd8, 0xe1, 0x54, 0x34, 0xb6, 0x52, 0x05, 0x98, 0x1d, 0x9c, 0xe6, 0x9c, 0xe0, 0x68, 0x3c,
  82. 0x55, 0xcf, 0xe6, 0xe1, 0x20, 0xc1, 0x23, 0x82, 0xa7, 0xc0, 0xa7, 0x65, 0x1d, 0xc3, 0x25, 0x03,
  83. 0x34, 0x62, 0xb8, 0x73, 0x32, 0x7a, 0x82, 0x3b, 0x94, 0x80, 0xd1, 0xc0, 0xbd, 0x1b, 0x1c, 0x0d,
  84. 0xec, 0x59, 0xbf, 0x04, 0x44, 0x78, 0x38, 0xf0, 0x5c, 0x3d, 0x06, 0xfd, 0x08, 0xe4, 0x64, 0x36,
  85. 0x28, 0x3d, 0x37, 0x02, 0x7a, 0x05, 0xe0, 0x27, 0x09, 0x76, 0x3c, 0x30, 0xc8, 0x29, 0x1d, 0xad,
  86. 0x53, 0x43, 0xe8, 0xad, 0xe1, 0x19, 0xc1, 0x05, 0x7e, 0x4c, 0x00, 0xcb, 0xe9, 0x00, 0x3b, 0x16,
  87. 0x3c, 0x52, 0xe3, 0x47, 0x0c, 0xe1, 0x18, 0x31, 0xc6, 0x69, 0x04, 0x0a, 0xeb, 0x91, 0x04, 0xa9,
  88. 0x70, 0xf6, 0x64, 0x98, 0x6f, 0x0a, 0x35, 0x0a, 0xb8, 0x09, 0x58, 0xd4, 0x65, 0x02, 0x25, 0xe5,
  89. 0x32, 0x81, 0x98, 0x47, 0xd8, 0xb7, 0x04, 0x4f, 0xf8, 0xac, 0x7c, 0x98, 0xf0, 0xa5, 0x00, 0xfe,
  90. 0xed, 0xc3, 0xc3, 0x08, 0xfd, 0xb0, 0xf1, 0x44, 0xe2, 0x23, 0x43, 0x5c, 0xcc, 0xff, 0x1f, 0xd7,
  91. 0x03, 0xb7, 0x5f, 0x01, 0x08, 0xb1, 0xcb, 0xbc, 0x16, 0xe8, 0x38, 0x11, 0x21, 0xc1, 0x1b, 0x05,
  92. 0x16, 0xe3, 0x60, 0x3c, 0x50, 0x9f, 0x13, 0x3c, 0x4c, 0x83, 0x1c, 0x59, 0xbc, 0x88, 0x09, 0x4e,
  93. 0xed, 0xa8, 0xb1, 0x73, 0xe0, 0x03, 0x38, 0x86, 0xf0, 0xe7, 0x13, 0xfe, 0x00, 0xa2, 0x1c, 0xc7,
  94. 0x21, 0x79, 0xc8, 0x46, 0x38, 0x81, 0x72, 0x2f, 0x2b, 0xe4, 0x58, 0x72, 0x14, 0xa7, 0xf5, 0x74,
  95. 0x10, 0xe8, 0x04, 0x30, 0x0a, 0x6d, 0xfa, 0xd4, 0x68, 0xd4, 0xaa, 0x41, 0x99, 0x1a, 0x65, 0x1a,
  96. 0xd4, 0xea, 0x53, 0xa9, 0x31, 0x63, 0xf3, 0xb5, 0xb4, 0x77, 0x83, 0x40, 0x1c, 0x0a, 0x84, 0x66,
  97. 0xa4, 0x10, 0x88, 0xff, 0xff};
  98. ULONG RndismpBinaryMofSize = sizeof(RndismpBinaryMof);
  99. #define RNDISMPDeviceOIDGuid \
  100. { 0x437cf222,0x72fe,0x11d4, { 0x97,0xf9,0x00,0x20,0x48,0x57,0x03,0x37}}
  101. #endif // BINARY_MOF_TEST
  102. NDIS_GUID CustomGuidList[] =
  103. {
  104. {
  105. RNDISMPStatisticsOIDGuid,
  106. OID_RNDISMP_STATISTICS,
  107. sizeof(UINT32), // size is size of each element in the array
  108. (fNDIS_GUID_TO_OID|fNDIS_GUID_ARRAY)
  109. }
  110. #ifdef BINARY_MOF_TEST
  111. ,
  112. {
  113. RNDISMPDeviceOIDGuid,
  114. OID_RNDISMP_DEVICE_OID,
  115. sizeof(UINT32),
  116. fNDIS_GUID_TO_OID
  117. },
  118. {
  119. BINARY_MOF_GUID,
  120. OID_RNDISMP_GET_MOF_OID,
  121. sizeof(UINT8),
  122. (fNDIS_GUID_TO_OID|fNDIS_GUID_ARRAY)
  123. }
  124. #endif
  125. };
  126. UINT CustomGuidCount = sizeof(CustomGuidList)/sizeof(NDIS_GUID);
  127. /****************************************************************************/
  128. /* RndismpQueryInformation */
  129. /****************************************************************************/
  130. /* */
  131. /* Routine Description: */
  132. /* */
  133. /* NDIS Entry point called to handle a query for a particular OID. */
  134. /* */
  135. /* Arguments: */
  136. /* */
  137. /* MiniportAdapterContext - a context version of our Adapter pointer */
  138. /* Oid - the NDIS_OID to process. */
  139. /* InformationBuffer - a pointer into the NdisRequest->InformationBuffer */
  140. /* into which store the result of the query. */
  141. /* InformationBufferLength - a pointer to the number of bytes left in */
  142. /* the InformationBuffer. */
  143. /* pBytesWritten - a pointer to the number of bytes written into the */
  144. /* InformationBuffer. */
  145. /* pBytesNeeded - If there is not enough room in the information buffer */
  146. /* then this will contain the number of bytes needed to complete the */
  147. /* request. */
  148. /* */
  149. /* Return: */
  150. /* */
  151. /* NDIS_STATUS */
  152. /* */
  153. /****************************************************************************/
  154. NDIS_STATUS
  155. RndismpQueryInformation(IN NDIS_HANDLE MiniportAdapterContext,
  156. IN NDIS_OID Oid,
  157. IN PVOID InformationBuffer,
  158. IN ULONG InformationBufferLength,
  159. OUT PULONG pBytesWritten,
  160. OUT PULONG pBytesNeeded)
  161. {
  162. PRNDISMP_ADAPTER pAdapter;
  163. NDIS_STATUS Status;
  164. // get adapter context
  165. pAdapter = PRNDISMP_ADAPTER_FROM_CONTEXT_HANDLE(MiniportAdapterContext);
  166. CHECK_VALID_ADAPTER(pAdapter);
  167. TRACE3(("RndismpQueryInformation\n"));
  168. Status = ProcessQueryInformation(pAdapter,
  169. NULL,
  170. NULL,
  171. Oid,
  172. InformationBuffer,
  173. InformationBufferLength,
  174. pBytesWritten,
  175. pBytesNeeded);
  176. return Status;
  177. }
  178. /****************************************************************************/
  179. /* ProcessQueryInformation */
  180. /****************************************************************************/
  181. /* */
  182. /* Routine Description: */
  183. /* */
  184. /* Utility routine to process a Query (connection-less or connection- */
  185. /* oriented). */
  186. /* */
  187. /* Arguments: */
  188. /* */
  189. /* pAdapter - Pointer to our adapter structure */
  190. /* pVc - Pointer to a VC, possibly NULL. */
  191. /* pRequest - Pointer to NDIS request, if this came via our CoRequest */
  192. /* handler. */
  193. /* Oid - the NDIS_OID to process. */
  194. /* InformationBuffer - a pointer into the NdisRequest->InformationBuffer */
  195. /* into which store the result of the query. */
  196. /* InformationBufferLength - a pointer to the number of bytes left in */
  197. /* the InformationBuffer. */
  198. /* pBytesWritten - a pointer to the number of bytes written into the */
  199. /* InformationBuffer. */
  200. /* pBytesNeeded - If there is not enough room in the information buffer */
  201. /* then this will contain the number of bytes needed to complete the */
  202. /* request. */
  203. /* */
  204. /* Return: */
  205. /* */
  206. /* NDIS_STATUS */
  207. /* */
  208. /****************************************************************************/
  209. NDIS_STATUS
  210. ProcessQueryInformation(IN PRNDISMP_ADAPTER pAdapter,
  211. IN PRNDISMP_VC pVc,
  212. IN PNDIS_REQUEST pRequest,
  213. IN NDIS_OID Oid,
  214. IN PVOID InformationBuffer,
  215. IN ULONG InformationBufferLength,
  216. OUT PULONG pBytesWritten,
  217. OUT PULONG pBytesNeeded)
  218. {
  219. NDIS_STATUS Status;
  220. UINT OIDHandler;
  221. OIDHandler = GetOIDSupport(pAdapter, Oid);
  222. switch(OIDHandler)
  223. {
  224. case DRIVER_SUPPORTED_OID:
  225. Status = DriverQueryInformation(pAdapter,
  226. pVc,
  227. pRequest,
  228. Oid,
  229. InformationBuffer,
  230. InformationBufferLength,
  231. pBytesWritten,
  232. pBytesNeeded);
  233. break;
  234. case DEVICE_SUPPORTED_OID:
  235. Status = DeviceQueryInformation(pAdapter,
  236. pVc,
  237. pRequest,
  238. Oid,
  239. InformationBuffer,
  240. InformationBufferLength,
  241. pBytesWritten,
  242. pBytesNeeded);
  243. break;
  244. case OID_NOT_SUPPORTED:
  245. default:
  246. TRACE2(("Invalid Query OID (%08X)\n", Oid));
  247. Status = NDIS_STATUS_INVALID_OID;
  248. break;
  249. }
  250. TRACE2(("ProcessQueryInfo: Oid %08X, returning Status %x\n", Oid, Status));
  251. return Status;
  252. } // ProcessQueryInformation
  253. /****************************************************************************/
  254. /* RndismpSetInformation */
  255. /****************************************************************************/
  256. /* */
  257. /* Routine Description: */
  258. /* */
  259. /* The RndismpSetInformation processes a Set request for */
  260. /* NDIS_OIDs that are specific about the Driver. */
  261. /* */
  262. /* Arguments: */
  263. /* */
  264. /* MiniportAdapterContext - a context version of our Adapter pointer */
  265. /* Oid - the NDIS_OID to process. */
  266. /* InformationBuffer - Holds the data to be set. */
  267. /* InformationBufferLength - The length of InformationBuffer. */
  268. /* pBytesRead - If the call is successful, returns the number */
  269. /* of bytes read from InformationBuffer. */
  270. /* pBytesNeeded - If there is not enough data in InformationBuffer */
  271. /* to satisfy the OID, returns the amount of storage needed. */
  272. /* */
  273. /* Return: */
  274. /* */
  275. /* NDIS_STATUS */
  276. /* */
  277. /****************************************************************************/
  278. NDIS_STATUS
  279. RndismpSetInformation(IN NDIS_HANDLE MiniportAdapterContext,
  280. IN NDIS_OID Oid,
  281. IN PVOID InformationBuffer,
  282. IN ULONG InformationBufferLength,
  283. OUT PULONG pBytesRead,
  284. OUT PULONG pBytesNeeded)
  285. {
  286. PRNDISMP_ADAPTER pAdapter;
  287. NDIS_STATUS Status;
  288. // get adapter context
  289. pAdapter = PRNDISMP_ADAPTER_FROM_CONTEXT_HANDLE(MiniportAdapterContext);
  290. CHECK_VALID_ADAPTER(pAdapter);
  291. TRACE3(("RndismpSetInformation\n"));
  292. Status = ProcessSetInformation(pAdapter,
  293. NULL,
  294. NULL,
  295. Oid,
  296. InformationBuffer,
  297. InformationBufferLength,
  298. pBytesRead,
  299. pBytesNeeded);
  300. return Status;
  301. }
  302. /****************************************************************************/
  303. /* ProcessSetInformation */
  304. /****************************************************************************/
  305. /* */
  306. /* Routine Description: */
  307. /* */
  308. /* Utility routine to process a Set (connection-less or connection- */
  309. /* oriented). */
  310. /* */
  311. /* Arguments: */
  312. /* */
  313. /* pAdapter - Pointer to our adapter structure */
  314. /* pVc - Pointer to a VC, possibly NULL. */
  315. /* pRequest - Pointer to NDIS request, if this came via our CoRequest */
  316. /* handler. */
  317. /* Oid - the NDIS_OID to process. */
  318. /* InformationBuffer - a pointer into the NdisRequest->InformationBuffer */
  319. /* into which store the result of the query. */
  320. /* InformationBufferLength - a pointer to the number of bytes left in */
  321. /* the InformationBuffer. */
  322. /* pBytesRead - a pointer to the number of bytes read from the */
  323. /* InformationBuffer. */
  324. /* pBytesNeeded - If there is not enough room in the information buffer */
  325. /* then this will contain the number of bytes needed to complete the */
  326. /* request. */
  327. /* */
  328. /* Return: */
  329. /* */
  330. /* NDIS_STATUS */
  331. /* */
  332. /****************************************************************************/
  333. NDIS_STATUS
  334. ProcessSetInformation(IN PRNDISMP_ADAPTER pAdapter,
  335. IN PRNDISMP_VC pVc OPTIONAL,
  336. IN PNDIS_REQUEST pRequest OPTIONAL,
  337. IN NDIS_OID Oid,
  338. IN PVOID InformationBuffer,
  339. IN ULONG InformationBufferLength,
  340. OUT PULONG pBytesRead,
  341. OUT PULONG pBytesNeeded)
  342. {
  343. NDIS_STATUS Status;
  344. UINT OIDHandler;
  345. OIDHandler = GetOIDSupport(pAdapter, Oid);
  346. switch(OIDHandler)
  347. {
  348. case DRIVER_SUPPORTED_OID:
  349. Status = DriverSetInformation(pAdapter,
  350. pVc,
  351. pRequest,
  352. Oid,
  353. InformationBuffer,
  354. InformationBufferLength,
  355. pBytesRead,
  356. pBytesNeeded);
  357. break;
  358. case DEVICE_SUPPORTED_OID:
  359. Status = DeviceSetInformation(pAdapter,
  360. pVc,
  361. pRequest,
  362. Oid,
  363. InformationBuffer,
  364. InformationBufferLength,
  365. pBytesRead,
  366. pBytesNeeded);
  367. break;
  368. case OID_NOT_SUPPORTED:
  369. default:
  370. TRACE1(("Invalid Set OID (%08X), Adapter %p\n", Oid, pAdapter));
  371. Status = NDIS_STATUS_INVALID_OID;
  372. break;
  373. }
  374. return Status;
  375. } // ProcessSetInformation
  376. /****************************************************************************/
  377. /* DriverQueryInformation */
  378. /****************************************************************************/
  379. /* */
  380. /* Routine Description: */
  381. /* */
  382. /* The RndismpQueryInformation processes a Query request for */
  383. /* NDIS_OIDs that are specific about the Driver. This routine */
  384. /* Handles OIDs supported by the driver instead of the device */
  385. /* */
  386. /* Arguments: */
  387. /* */
  388. /* pAdapter - Pointer to our adapter structure */
  389. /* pVc - Pointer to a VC, possibly NULL. */
  390. /* pRequest - Pointer to NDIS request, if this came via our CoRequest */
  391. /* handler. */
  392. /* Oid - the NDIS_OID to process. */
  393. /* InformationBuffer - a pointer into the NdisRequest->InformationBuffer */
  394. /* into which store the result of the query. */
  395. /* InformationBufferLength - a pointer to the number of bytes left in */
  396. /* the InformationBuffer. */
  397. /* pBytesWritten - a pointer to the number of bytes written into the */
  398. /* InformationBuffer. */
  399. /* pBytesNeeded - If there is not enough room in the information buffer */
  400. /* then this will contain the number of bytes needed to complete the */
  401. /* request. */
  402. /* */
  403. /* Return: */
  404. /* */
  405. /* NDIS_STATUS */
  406. /* */
  407. /****************************************************************************/
  408. NDIS_STATUS
  409. DriverQueryInformation(IN PRNDISMP_ADAPTER pAdapter,
  410. IN PRNDISMP_VC pVc OPTIONAL,
  411. IN PNDIS_REQUEST pRequest OPTIONAL,
  412. IN NDIS_OID Oid,
  413. IN PVOID InformationBuffer,
  414. IN ULONG InformationBufferLength,
  415. OUT PULONG pBytesWritten,
  416. OUT PULONG pBytesNeeded)
  417. {
  418. NDIS_STATUS Status;
  419. PVOID MoveSource;
  420. UINT MoveBytes;
  421. ULONG GenericUlong;
  422. USHORT GenericUshort;
  423. CHAR VendorDescription[] = "Remote NDIS Network Card";
  424. TRACE3(("DriverQueryInformation\n"));
  425. OID_NAME_TRACE(Oid, "DriverQuery");
  426. Status = NDIS_STATUS_SUCCESS;
  427. MoveSource = (PVOID) (&GenericUlong);
  428. MoveBytes = sizeof(GenericUlong);
  429. // this is one we have to handle
  430. switch(Oid)
  431. {
  432. case OID_GEN_DRIVER_VERSION:
  433. GenericUshort = (pAdapter->DriverBlock->MajorNdisVersion << 8) +
  434. (pAdapter->DriverBlock->MinorNdisVersion);
  435. MoveSource = (PVOID)&GenericUshort;
  436. MoveBytes = sizeof(GenericUshort);
  437. break;
  438. case OID_GEN_VENDOR_ID:
  439. TRACE1(("Query for OID_GEN_VENDOR_ID not supported by device!\n"));
  440. GenericUlong = 0xFFFFFF;
  441. break;
  442. case OID_GEN_VENDOR_DESCRIPTION:
  443. TRACE1(("Query for OID_GEN_VENDOR_DESCRIPTION not supported by device!\n"));
  444. if (pAdapter->FriendlyNameAnsi.Length != 0)
  445. {
  446. MoveSource = pAdapter->FriendlyNameAnsi.Buffer;
  447. MoveBytes = pAdapter->FriendlyNameAnsi.Length;
  448. }
  449. else
  450. {
  451. MoveSource = VendorDescription;
  452. MoveBytes = sizeof(VendorDescription);
  453. }
  454. break;
  455. case OID_GEN_VENDOR_DRIVER_VERSION:
  456. TRACE1(("Query for OID_GEN_VENDOR_DRIVER_VERSION not supported by device!\n"));
  457. GenericUlong = 0xA000B;
  458. break;
  459. case OID_GEN_MAC_OPTIONS:
  460. GenericUlong = pAdapter->MacOptions;
  461. break;
  462. case OID_GEN_SUPPORTED_LIST:
  463. // get the list we generated
  464. MoveSource = (PVOID) (pAdapter->SupportedOIDList);
  465. MoveBytes = pAdapter->SupportedOIDListSize;
  466. break;
  467. case OID_GEN_MEDIA_IN_USE:
  468. Status = DeviceQueryInformation(pAdapter,
  469. pVc,
  470. pRequest,
  471. OID_GEN_MEDIA_SUPPORTED,
  472. InformationBuffer,
  473. InformationBufferLength,
  474. pBytesWritten,
  475. pBytesNeeded);
  476. break;
  477. case OID_GEN_MAXIMUM_LOOKAHEAD:
  478. Status = DeviceQueryInformation(pAdapter,
  479. pVc,
  480. pRequest,
  481. OID_GEN_MAXIMUM_FRAME_SIZE,
  482. InformationBuffer,
  483. InformationBufferLength,
  484. pBytesWritten,
  485. pBytesNeeded);
  486. break;
  487. case OID_GEN_TRANSMIT_BUFFER_SPACE:
  488. GenericUlong = pAdapter->MaxTransferSize;
  489. break;
  490. case OID_GEN_RECEIVE_BUFFER_SPACE:
  491. GenericUlong = pAdapter->MaxReceiveSize * 8;
  492. break;
  493. case OID_GEN_CURRENT_LOOKAHEAD:
  494. Status = DeviceQueryInformation(pAdapter,
  495. pVc,
  496. pRequest,
  497. OID_GEN_MAXIMUM_FRAME_SIZE,
  498. InformationBuffer,
  499. InformationBufferLength,
  500. pBytesWritten,
  501. pBytesNeeded);
  502. break;
  503. case OID_GEN_MAXIMUM_FRAME_SIZE:
  504. Status = DeviceQueryInformation(pAdapter,
  505. pVc,
  506. pRequest,
  507. OID_GEN_MAXIMUM_FRAME_SIZE,
  508. InformationBuffer,
  509. InformationBufferLength,
  510. pBytesWritten,
  511. pBytesNeeded);
  512. break;
  513. case OID_GEN_MAXIMUM_TOTAL_SIZE:
  514. TRACE1(("Query for OID_GEN_MAXIMUM_TOTAL_SIZE not supported by device!\n"));
  515. GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE;
  516. break;
  517. case OID_GEN_TRANSMIT_BLOCK_SIZE:
  518. TRACE1(("Query for OID_GEN_TRANSMIT_BLOCK_SIZE not supported by device!\n"));
  519. GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE;
  520. break;
  521. case OID_GEN_RECEIVE_BLOCK_SIZE:
  522. TRACE1(("Query for OID_GEN_RECEIVE_BLOCK_SIZE not supported by device!\n"));
  523. GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE;
  524. break;
  525. case OID_GEN_MAXIMUM_SEND_PACKETS:
  526. GenericUlong = (ULONG) pAdapter->MaxPacketsPerMessage;
  527. break;
  528. case OID_PNP_CAPABILITIES:
  529. case OID_PNP_QUERY_POWER:
  530. Status = NDIS_STATUS_NOT_SUPPORTED;
  531. break;
  532. case OID_GEN_XMIT_OK:
  533. GenericUlong = RNDISMP_GET_ADAPTER_STATS(pAdapter, XmitOk);
  534. break;
  535. case OID_GEN_XMIT_ERROR:
  536. GenericUlong = RNDISMP_GET_ADAPTER_STATS(pAdapter, XmitError);
  537. break;
  538. case OID_GEN_RCV_OK:
  539. GenericUlong = RNDISMP_GET_ADAPTER_STATS(pAdapter, RecvOk);
  540. break;
  541. case OID_GEN_RCV_ERROR:
  542. GenericUlong = RNDISMP_GET_ADAPTER_STATS(pAdapter, RecvError);
  543. break;
  544. case OID_GEN_RCV_NO_BUFFER:
  545. GenericUlong = RNDISMP_GET_ADAPTER_STATS(pAdapter, RecvNoBuf);
  546. break;
  547. case OID_GEN_SUPPORTED_GUIDS:
  548. MoveSource = (PVOID)&CustomGuidList[0];
  549. MoveBytes = sizeof(CustomGuidList);
  550. TRACE1(("Query for supported GUIDs, len %d\n", InformationBufferLength));
  551. break;
  552. case OID_RNDISMP_STATISTICS:
  553. MoveSource = &pAdapter->Statistics;
  554. MoveBytes = sizeof(pAdapter->Statistics);
  555. break;
  556. #ifdef BINARY_MOF_TEST
  557. case OID_RNDISMP_DEVICE_OID:
  558. DbgPrint("*** RNDISMP: Query for Device OID\n");
  559. GenericUlong = 0xabcdefab;
  560. break;
  561. case OID_RNDISMP_GET_MOF_OID:
  562. DbgPrint("*** RNDISMP: Query for MOF Info: Src %p, Size %d\n",
  563. RndismpBinaryMof, RndismpBinaryMofSize);
  564. MoveSource = RndismpBinaryMof;
  565. MoveBytes = RndismpBinaryMofSize;
  566. break;
  567. #endif // BINARY_MOF_TEST
  568. #ifdef TESTING
  569. case OID_TCP_TASK_OFFLOAD:
  570. DbgPrint("RNDISMP: got query for TCP offload\n");
  571. MoveSource = pOffloadBuffer;
  572. MoveBytes = OffloadSize;
  573. break;
  574. case OID_GEN_PHYSICAL_MEDIUM:
  575. DbgPrint("RNDISMP: got query for physical medium\n");
  576. GenericUlong = NdisPhysicalMediumDSL;
  577. break;
  578. #endif
  579. default:
  580. Status = NDIS_STATUS_INVALID_OID;
  581. break;
  582. }
  583. // copy stuff to information buffer
  584. if (Status == NDIS_STATUS_SUCCESS)
  585. {
  586. if (MoveBytes > InformationBufferLength)
  587. {
  588. // Not enough room in InformationBuffer
  589. *pBytesNeeded = MoveBytes;
  590. Status = NDIS_STATUS_BUFFER_TOO_SHORT;
  591. }
  592. else
  593. {
  594. // Copy result into InformationBuffer
  595. *pBytesWritten = MoveBytes;
  596. if (MoveBytes > 0)
  597. RNDISMP_MOVE_MEM(InformationBuffer, MoveSource, MoveBytes);
  598. }
  599. }
  600. TRACE2(("Status (%08X) BytesWritten (%08X)\n", Status, *pBytesWritten));
  601. return Status;
  602. } // DriverQueryInformation
  603. /****************************************************************************/
  604. /* DeviceQueryInformation */
  605. /****************************************************************************/
  606. /* */
  607. /* Routine Description: */
  608. /* */
  609. /* The DeviceQueryInformation processes a Query request */
  610. /* that is going to the Remote NDIS device */
  611. /* */
  612. /* Arguments: */
  613. /* */
  614. /* pAdapter - pointer to our Adapter structure */
  615. /* pVc - optional pointer to our VC structure, if this is a per-Vc req. */
  616. /* pRequest - optional pointer to NDIS request, if CONDIS. */
  617. /* Oid - the NDIS_OID to process. */
  618. /* InformationBuffer - a pointer into the NdisRequest->InformationBuffer */
  619. /* into which store the result of the query. */
  620. /* InformationBufferLength - a pointer to the number of bytes left in */
  621. /* the InformationBuffer. */
  622. /* pBytesWritten - a pointer to the number of bytes written into the */
  623. /* InformationBuffer. */
  624. /* pBytesNeeded - If there is not enough room in the information buffer */
  625. /* then this will contain the number of bytes needed to complete the */
  626. /* request. */
  627. /* */
  628. /* Return: */
  629. /* */
  630. /* NDIS_STATUS */
  631. /* */
  632. /****************************************************************************/
  633. NDIS_STATUS
  634. DeviceQueryInformation(IN PRNDISMP_ADAPTER pAdapter,
  635. IN PRNDISMP_VC pVc OPTIONAL,
  636. IN PNDIS_REQUEST pRequest OPTIONAL,
  637. IN NDIS_OID Oid,
  638. IN PVOID InformationBuffer,
  639. IN ULONG InformationBufferLength,
  640. OUT PULONG pBytesWritten,
  641. OUT PULONG pBytesNeeded)
  642. {
  643. PRNDISMP_MESSAGE_FRAME pMsgFrame;
  644. PRNDISMP_REQUEST_CONTEXT pReqContext;
  645. NDIS_STATUS Status;
  646. TRACE3(("DeviceQueryInformation\n"));
  647. OID_NAME_TRACE(Oid, "DeviceQuery");
  648. TRACE3(("DeviceQuery: InfoBuf %p, Len %d, pBytesWrit %p, pBytesNeed %p\n",
  649. InformationBuffer, InformationBufferLength, pBytesWritten, pBytesNeeded));
  650. do
  651. {
  652. if (pAdapter->Halting)
  653. {
  654. Status = NDIS_STATUS_NOT_ACCEPTED;
  655. break;
  656. }
  657. pReqContext = AllocateRequestContext(pAdapter);
  658. if (pReqContext == NULL)
  659. {
  660. Status = NDIS_STATUS_RESOURCES;
  661. break;
  662. }
  663. //
  664. // HACKHACK to avoid a strange length from going to the device
  665. // At least one device does not like this.
  666. //
  667. // In general, there is no point sending a huge information buffer
  668. // along with a Query that does not require an IN parameter.
  669. // Long term, we may have to separate out the few OIDs that do
  670. // use IN parameters and allow those buffers to pass through
  671. //
  672. pMsgFrame = BuildRndisMessageCommon(pAdapter,
  673. pVc,
  674. REMOTE_NDIS_QUERY_MSG,
  675. Oid,
  676. InformationBuffer,
  677. ((InformationBufferLength > 48)?
  678. 48: InformationBufferLength));
  679. // see if we got a message
  680. if (!pMsgFrame)
  681. {
  682. Status = NDIS_STATUS_RESOURCES;
  683. FreeRequestContext(pAdapter, pReqContext);
  684. break;
  685. }
  686. Status = NDIS_STATUS_PENDING;
  687. pReqContext->InformationBuffer = InformationBuffer;
  688. pReqContext->InformationBufferLength = InformationBufferLength;
  689. pReqContext->pBytesRead = NULL;
  690. pReqContext->pBytesWritten = pBytesWritten;
  691. pReqContext->pBytesNeeded = pBytesNeeded;
  692. pReqContext->Oid = Oid;
  693. pReqContext->RetryCount = 0;
  694. pReqContext->bInternal = FALSE;
  695. pReqContext->pVc = pVc;
  696. pReqContext->pNdisRequest = pRequest;
  697. pMsgFrame->pReqContext = pReqContext;
  698. // Add a ref to keep the frame around until we complete the request.
  699. ReferenceMsgFrame(pMsgFrame);
  700. // send the message to the microport
  701. RNDISMP_SEND_TO_MICROPORT(pAdapter, pMsgFrame, TRUE, CompleteSendDeviceRequest);
  702. break;
  703. }
  704. while (FALSE);
  705. return Status;
  706. } // DeviceQueryInformation
  707. /****************************************************************************/
  708. /* DriverSetInformation */
  709. /****************************************************************************/
  710. /* */
  711. /* Routine Description: */
  712. /* */
  713. /* Utility routine to handle SetInformation requests that aren't */
  714. /* specific to the device. We also land up here for requests for any */
  715. /* OIDs that aren't supported by the device. */
  716. /* */
  717. /* Arguments: */
  718. /* */
  719. /* pAdapter - Pointer to our adapter structure */
  720. /* pVc - Pointer to a VC, possibly NULL. */
  721. /* pRequest - Pointer to NDIS request, if this came via our CoRequest */
  722. /* handler. */
  723. /* Oid - the NDIS_OID to process. */
  724. /* InformationBuffer - Holds the data to be set. */
  725. /* InformationBufferLength - The length of InformationBuffer. */
  726. /* pBytesRead - If the call is successful, returns the number */
  727. /* of bytes read from InformationBuffer. */
  728. /* pBytesNeeded - If there is not enough data in InformationBuffer */
  729. /* to satisfy the OID, returns the amount of storage needed. */
  730. /* */
  731. /* Return: */
  732. /* */
  733. /* NDIS_STATUS */
  734. /* */
  735. /****************************************************************************/
  736. NDIS_STATUS
  737. DriverSetInformation(IN PRNDISMP_ADAPTER pAdapter,
  738. IN PRNDISMP_VC pVc OPTIONAL,
  739. IN PNDIS_REQUEST pRequest OPTIONAL,
  740. IN NDIS_OID Oid,
  741. IN PVOID InformationBuffer,
  742. IN ULONG InformationBufferLength,
  743. OUT PULONG pBytesRead,
  744. OUT PULONG pBytesNeeded)
  745. {
  746. NDIS_STATUS Status;
  747. TRACE2(("DriverSetInformation: Adapter %p, Oid %x\n", pAdapter, Oid));
  748. OID_NAME_TRACE(Oid, "DriverSet");
  749. Status = NDIS_STATUS_SUCCESS;
  750. switch(Oid)
  751. {
  752. case OID_GEN_CURRENT_LOOKAHEAD:
  753. // Verify the Length
  754. if(InformationBufferLength != sizeof(ULONG))
  755. Status = NDIS_STATUS_INVALID_LENGTH;
  756. *pBytesRead = sizeof(ULONG);
  757. break;
  758. case OID_PNP_SET_POWER:
  759. case OID_PNP_ADD_WAKE_UP_PATTERN:
  760. case OID_PNP_REMOVE_WAKE_UP_PATTERN:
  761. case OID_PNP_ENABLE_WAKE_UP:
  762. Status = NDIS_STATUS_NOT_SUPPORTED;
  763. break;
  764. #ifdef TESTING
  765. case OID_TCP_TASK_OFFLOAD:
  766. Status = NDIS_STATUS_SUCCESS;
  767. DbgPrint("RNDISMP: Set TCP_TASK_OFFLOAD\n");
  768. break;
  769. case OID_GEN_TRANSPORT_HEADER_OFFSET:
  770. Status = NDIS_STATUS_SUCCESS;
  771. break;
  772. #endif
  773. default:
  774. Status = NDIS_STATUS_INVALID_OID;
  775. break;
  776. }
  777. TRACE2(("Status (%08X) BytesRead (%08X)\n", Status, *pBytesRead));
  778. return Status;
  779. } // DriverSetInformation
  780. /****************************************************************************/
  781. /* DeviceSetInformation */
  782. /****************************************************************************/
  783. /* */
  784. /* Routine Description: */
  785. /* */
  786. /* The DeviceSetInformation processes a set request */
  787. /* that is going to the Remote NDIS device */
  788. /* */
  789. /* Arguments: */
  790. /* */
  791. /* pAdapter - pointer to our Adapter structure */
  792. /* pVc - optional pointer to our VC structure, if this is a per-Vc req. */
  793. /* pRequest - optional pointer to NDIS request, if CONDIS. */
  794. /* Oid - the NDIS_OID to process. */
  795. /* InformationBuffer - Holds the data to be set. */
  796. /* InformationBufferLength - The length of InformationBuffer. */
  797. /* pBytesRead - If the call is successful, returns the number */
  798. /* of bytes read from InformationBuffer. */
  799. /* pBytesNeeded - If there is not enough data in InformationBuffer */
  800. /* to satisfy the OID, returns the amount of storage needed. */
  801. /* */
  802. /* Return: */
  803. /* */
  804. /* NDIS_STATUS */
  805. /* */
  806. /****************************************************************************/
  807. NDIS_STATUS
  808. DeviceSetInformation(IN PRNDISMP_ADAPTER pAdapter,
  809. IN PRNDISMP_VC pVc OPTIONAL,
  810. IN PNDIS_REQUEST pRequest OPTIONAL,
  811. IN NDIS_OID Oid,
  812. IN PVOID InformationBuffer,
  813. IN ULONG InformationBufferLength,
  814. OUT PULONG pBytesRead,
  815. OUT PULONG pBytesNeeded)
  816. {
  817. PRNDISMP_MESSAGE_FRAME pMsgFrame;
  818. PRNDISMP_REQUEST_CONTEXT pReqContext;
  819. NDIS_STATUS Status;
  820. TRACE2(("DeviceSetInformation: Adapter %p, Oid %x\n"));
  821. OID_NAME_TRACE(Oid, "DeviceSet");
  822. #if DBG
  823. if (Oid == OID_GEN_CURRENT_PACKET_FILTER)
  824. {
  825. PULONG pFilter = (PULONG)InformationBuffer;
  826. TRACE1(("DeviceSetInfo: Adapter %p: Setting packet filter to %x\n",
  827. pAdapter, *pFilter));
  828. }
  829. #endif
  830. do
  831. {
  832. if (pAdapter->Halting)
  833. {
  834. TRACE1(("DeviceSetInfo: Adapter %p is halting: succeeding Oid %x\n",
  835. pAdapter, Oid));
  836. Status = NDIS_STATUS_SUCCESS;
  837. break;
  838. }
  839. pReqContext = AllocateRequestContext(pAdapter);
  840. if (pReqContext == NULL)
  841. {
  842. Status = NDIS_STATUS_RESOURCES;
  843. break;
  844. }
  845. pMsgFrame = BuildRndisMessageCommon(pAdapter,
  846. pVc,
  847. REMOTE_NDIS_SET_MSG,
  848. Oid,
  849. InformationBuffer,
  850. InformationBufferLength);
  851. // see if we got a message
  852. if (!pMsgFrame)
  853. {
  854. Status = NDIS_STATUS_RESOURCES;
  855. FreeRequestContext(pAdapter, pReqContext);
  856. break;
  857. }
  858. Status = NDIS_STATUS_PENDING;
  859. pReqContext->InformationBuffer = InformationBuffer;
  860. pReqContext->InformationBufferLength = InformationBufferLength;
  861. pReqContext->pBytesRead = pBytesRead;
  862. pReqContext->pBytesWritten = NULL;
  863. pReqContext->pBytesNeeded = pBytesNeeded;
  864. pReqContext->Oid = Oid;
  865. pReqContext->RetryCount = 0;
  866. pReqContext->bInternal = FALSE;
  867. pReqContext->pVc = pVc;
  868. pReqContext->pNdisRequest = pRequest;
  869. pMsgFrame->pReqContext = pReqContext;
  870. #ifndef BUILD_WIN9X
  871. // Add a ref to keep the frame around until we complete the request.
  872. ReferenceMsgFrame(pMsgFrame);
  873. // send the message to the microport
  874. RNDISMP_SEND_TO_MICROPORT(pAdapter, pMsgFrame, TRUE, CompleteSendDeviceRequest);
  875. #else
  876. //
  877. // Win9X!
  878. //
  879. // Special-case for setting the current packet filter to 0.
  880. // We complete this one synchronously, otherwise NdisCloseAdapter
  881. // doesn't seem to complete.
  882. //
  883. if ((Oid == OID_GEN_CURRENT_PACKET_FILTER) &&
  884. (*(PULONG)InformationBuffer == 0))
  885. {
  886. //
  887. // Do not queue the request, so that when we get a completion
  888. // from the device, we simply drop it.
  889. //
  890. RNDISMP_SEND_TO_MICROPORT(pAdapter, pMsgFrame, FALSE, CompleteSendDiscardDeviceRequest);
  891. Status = NDIS_STATUS_SUCCESS;
  892. }
  893. else
  894. {
  895. // Add a ref to keep the frame around until we complete the request.
  896. ReferenceMsgFrame(pMsgFrame);
  897. // send the message to the microport
  898. RNDISMP_SEND_TO_MICROPORT(pAdapter, pMsgFrame, TRUE, CompleteSendDeviceRequest);
  899. }
  900. #endif // BUILD_WIN9X
  901. break;
  902. }
  903. while (FALSE);
  904. return Status;
  905. } // DeviceSetInformation
  906. /****************************************************************************/
  907. /* QuerySetCompletionMessage */
  908. /****************************************************************************/
  909. /* */
  910. /* Routine Description: */
  911. /* */
  912. /* Completion message from microport in response to query or set message */
  913. /* miniport sent. This information is now ready to pass to upper layers */
  914. /* since the original call into the miniport returned STATUS_PENDING */
  915. /* */
  916. /* Danger Danger - an OID_GEN_SUPPORTED_LIST query is special cased here */
  917. /* This is only sent to the device from the adapter init routine to build */
  918. /* a list of OIDs supported by the driver and device. */
  919. /* All OID_GEN_SUPPORTED_LIST queries from upper layers are handled by */
  920. /* the driver and not the device. */
  921. /* */
  922. /* Arguments: */
  923. /* */
  924. /* pAdapter - Pointer to our adapter structure */
  925. /* pMessage - pointer to RNDIS message */
  926. /* pMdl - pointer to MDL from microport */
  927. /* TotalLength - length of complete message */
  928. /* MicroportMessageContext - context for message from microport */
  929. /* ReceiveStatus - used by microport to indicate it is low on resource */
  930. /* bMessageCopied - is this a copy of the original message? */
  931. /* */
  932. /* Return: */
  933. /* */
  934. /* BOOLEAN - should the message be returned to the microport? */
  935. /* */
  936. /****************************************************************************/
  937. BOOLEAN
  938. QuerySetCompletionMessage(IN PRNDISMP_ADAPTER pAdapter,
  939. IN PRNDIS_MESSAGE pMessage,
  940. IN PMDL pMdl,
  941. IN ULONG TotalLength,
  942. IN NDIS_HANDLE MicroportMessageContext,
  943. IN NDIS_STATUS ReceiveStatus,
  944. IN BOOLEAN bMessageCopied)
  945. {
  946. PRNDISMP_MESSAGE_FRAME pMsgFrame;
  947. PRNDISMP_REQUEST_CONTEXT pReqContext;
  948. PRNDIS_QUERY_COMPLETE pQueryComplMessage;
  949. PRNDIS_SET_COMPLETE pSetComplMessage;
  950. UINT32 NdisMessageType;
  951. NDIS_STATUS Status;
  952. UINT BytesWritten;
  953. UINT BytesRead;
  954. BOOLEAN bInternal;
  955. TRACE3(("QuerySetCompletionMessage\n"));
  956. pReqContext = NULL;
  957. pMsgFrame = NULL;
  958. pQueryComplMessage = RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(pMessage);
  959. pSetComplMessage = RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(pMessage);
  960. bInternal = FALSE;
  961. NdisMessageType = 0xdead;
  962. Status = NDIS_STATUS_SUCCESS;
  963. do
  964. {
  965. // get request frame from request ID in message
  966. RNDISMP_LOOKUP_PENDING_MESSAGE(pMsgFrame, pAdapter, pQueryComplMessage->RequestId);
  967. if (pMsgFrame == NULL)
  968. {
  969. // invalid request ID or aborted request.
  970. TRACE1(("Invalid/aborted request ID %08X in Query/Set Complete msg %p\n",
  971. pQueryComplMessage->RequestId, pQueryComplMessage));
  972. break;
  973. }
  974. pReqContext = pMsgFrame->pReqContext;
  975. ASSERT(pReqContext != NULL);
  976. bInternal = pReqContext->bInternal;
  977. NdisMessageType = pMessage->NdisMessageType;
  978. if (NdisMessageType != RNDIS_COMPLETION(pMsgFrame->NdisMessageType))
  979. {
  980. TRACE1(("Query/Response mismatch: Msg @ %p, ReqId %d, req type %X, compl type %X\n",
  981. pMessage,
  982. pQueryComplMessage->RequestId,
  983. pMsgFrame->NdisMessageType,
  984. NdisMessageType));
  985. ASSERT(FALSE);
  986. pMsgFrame = NULL;
  987. Status = NDIS_STATUS_FAILURE;
  988. break;
  989. }
  990. switch(NdisMessageType)
  991. {
  992. // a query complete message indicates we have a response
  993. // to a query message the miniport sent down. we carry around
  994. // appropriate context so we can indicate the completion
  995. // to upper layers and pass the query data up
  996. //
  997. // OID_GEN_SUPPORTED_LIST is a special case since it
  998. // is never indicated to upper layers from the device
  999. case REMOTE_NDIS_QUERY_CMPLT:
  1000. // an OID_GEN_SUPPORTED_LIST is never completed to the upper
  1001. // layers. This is sent from our adapter init routine
  1002. // in preparation for building a list of OIDs
  1003. TRACE2(("QueryCompl: OID %08X, %d bytes, Status %x\n",
  1004. pReqContext->Oid,
  1005. pQueryComplMessage->InformationBufferLength,
  1006. pQueryComplMessage->Status));
  1007. pReqContext->CompletionStatus = pQueryComplMessage->Status;
  1008. if (pReqContext->Oid == OID_GEN_SUPPORTED_LIST)
  1009. {
  1010. if (pReqContext->CompletionStatus == NDIS_STATUS_SUCCESS)
  1011. {
  1012. // Build a list of supported OIDs.
  1013. TRACE1(("QueryComplete: SupportedList: InfoBufLength %d (%d OIDs)\n",
  1014. pQueryComplMessage->InformationBufferLength,
  1015. pQueryComplMessage->InformationBufferLength/sizeof(NDIS_OID)));
  1016. Status = BuildOIDLists(pAdapter,
  1017. (PNDIS_OID) (((PUCHAR)(pQueryComplMessage)) +
  1018. pQueryComplMessage->InformationBufferOffset),
  1019. pQueryComplMessage->InformationBufferLength / sizeof(NDIS_OID),
  1020. pAdapter->DriverOIDList,
  1021. pAdapter->NumDriverOIDs);
  1022. }
  1023. // the adapter init routine is waiting for a response
  1024. NdisSetEvent(pReqContext->pEvent);
  1025. // The message frame is freed by the Init routine.
  1026. pMsgFrame = NULL;
  1027. break;
  1028. }
  1029. // something other than OID_GEN_SUPPORTED_LIST
  1030. *pReqContext->pBytesNeeded = pQueryComplMessage->InformationBufferLength;
  1031. if (pQueryComplMessage->InformationBufferLength > pReqContext->InformationBufferLength)
  1032. {
  1033. TRACE0(("Query Complete (Oid = %08X): InfoBuffLen %d < %d\n",
  1034. pReqContext->Oid,
  1035. pQueryComplMessage->InformationBufferLength,
  1036. pReqContext->InformationBufferLength));
  1037. Status = NDIS_STATUS_BUFFER_TOO_SHORT;
  1038. break;
  1039. }
  1040. if (pQueryComplMessage->Status != RNDIS_STATUS_SUCCESS)
  1041. {
  1042. TRACE0(("Query Complete (Oid = %08X): error status %08X\n",
  1043. pReqContext->Oid, pQueryComplMessage->Status));
  1044. *pReqContext->pBytesNeeded = pQueryComplMessage->InformationBufferLength;
  1045. *pReqContext->pBytesWritten = 0;
  1046. Status = pQueryComplMessage->Status;
  1047. }
  1048. else
  1049. {
  1050. // copy information from RNDIS message to NDIS buffer passed down
  1051. TRACE3(("QueryCompl: copy %d bytes to %p\n",
  1052. pQueryComplMessage->InformationBufferLength,
  1053. pReqContext->InformationBuffer));
  1054. RNDISMP_MOVE_MEM(pReqContext->InformationBuffer,
  1055. MESSAGE_TO_INFO_BUFFER(pQueryComplMessage),
  1056. pQueryComplMessage->InformationBufferLength);
  1057. // tell the upper layers the size
  1058. *pReqContext->pBytesWritten = pQueryComplMessage->InformationBufferLength;
  1059. BytesWritten = *pReqContext->pBytesWritten;
  1060. TRACE3(("Query Compl OK: Adapter %p, Oid %x\n",
  1061. pAdapter, pReqContext->Oid));
  1062. TRACE2(("Info Data (%08X)\n", *((PUINT) pReqContext->InformationBuffer)));
  1063. if (pReqContext->Oid == OID_GEN_MEDIA_CONNECT_STATUS)
  1064. {
  1065. TRACE3(("Adapter %p: link is %s\n",
  1066. pAdapter, (((*(PULONG)pReqContext->InformationBuffer) == NdisMediaStateConnected)?
  1067. "Connected": "Not connected")));
  1068. }
  1069. if (pReqContext->Oid == OID_GEN_MAC_OPTIONS)
  1070. {
  1071. PULONG pMacOptions = (PULONG)pReqContext->InformationBuffer;
  1072. ULONG MacOptions = *pMacOptions;
  1073. TRACE1(("Adapter %p: OID_GEN_MAC_OPTIONS from device is %x\n",
  1074. pAdapter, MacOptions));
  1075. //
  1076. // We only let the device dictate some of these bits.
  1077. //
  1078. MacOptions = (MacOptions & RNDIS_DEVICE_MAC_OPTIONS_MASK) |
  1079. pAdapter->MacOptions;
  1080. *pMacOptions = MacOptions;
  1081. TRACE1(("Adapter %p: Modified OID_GEN_MAC_OPTIONS is %x\n",
  1082. pAdapter, *pMacOptions));
  1083. }
  1084. #if 0
  1085. //
  1086. // Temp hack for old-firmware Peracom devices - report a smaller
  1087. // value for max multicast list aize.
  1088. //
  1089. if (pReqContext->Oid == OID_802_3_MAXIMUM_LIST_SIZE)
  1090. {
  1091. PULONG pListSize = (PULONG)pReqContext->InformationBuffer;
  1092. if (*pListSize > 64)
  1093. {
  1094. TRACE1(("Adapter %p: Truncating max multicast list size from %d to 63!\n",
  1095. pAdapter, *pListSize));
  1096. *pListSize = 64;
  1097. }
  1098. }
  1099. #endif
  1100. Status = NDIS_STATUS_SUCCESS;
  1101. }
  1102. break;
  1103. case REMOTE_NDIS_SET_CMPLT:
  1104. TRACE2(("SetCompl: OID %08X, Status %x\n",
  1105. pReqContext->Oid,
  1106. pSetComplMessage->Status));
  1107. if (pSetComplMessage->Status == RNDIS_STATUS_SUCCESS)
  1108. {
  1109. *pReqContext->pBytesRead = pReqContext->InformationBufferLength;
  1110. BytesRead = *pReqContext->pBytesRead;
  1111. Status = NDIS_STATUS_SUCCESS;
  1112. }
  1113. else
  1114. {
  1115. // don't really expect to see this other than via NDISTEST
  1116. TRACE1(("Set Complete (Oid = %08X) failure: %08X\n",
  1117. pReqContext->Oid,
  1118. pSetComplMessage->Status));
  1119. *pReqContext->pBytesRead = 0;
  1120. BytesRead = 0;
  1121. Status = pSetComplMessage->Status;
  1122. }
  1123. pReqContext->CompletionStatus = Status;
  1124. if (bInternal && pReqContext->pEvent)
  1125. {
  1126. NdisSetEvent(pReqContext->pEvent);
  1127. pMsgFrame = NULL;
  1128. pReqContext = NULL;
  1129. }
  1130. break;
  1131. default:
  1132. TRACE1(("Invalid Ndis Message Type (%08X)\n", NdisMessageType));
  1133. ASSERT(FALSE); // we shouldn't have sent an invalid message type!
  1134. break;
  1135. }
  1136. break;
  1137. }
  1138. while (FALSE);
  1139. //
  1140. // Send the completion to the upper layers unless it was a request
  1141. // we generated outselves.
  1142. //
  1143. if (!bInternal && pReqContext)
  1144. {
  1145. if (pReqContext->pNdisRequest)
  1146. {
  1147. NdisMCoRequestComplete(Status,
  1148. pAdapter->MiniportAdapterHandle,
  1149. pReqContext->pNdisRequest);
  1150. }
  1151. else
  1152. {
  1153. if (NdisMessageType == REMOTE_NDIS_QUERY_CMPLT)
  1154. {
  1155. TRACE2(("Status (%08X) BytesWritten (%08X)\n", Status, BytesWritten));
  1156. // complete the query
  1157. NdisMQueryInformationComplete(pAdapter->MiniportAdapterHandle,
  1158. Status);
  1159. }
  1160. else if (NdisMessageType == REMOTE_NDIS_SET_CMPLT)
  1161. {
  1162. TRACE2(("Status (%08X) BytesRead (%08X)\n", Status, BytesRead));
  1163. // complete the set
  1164. NdisMSetInformationComplete(pAdapter->MiniportAdapterHandle,
  1165. Status);
  1166. }
  1167. }
  1168. }
  1169. if (pReqContext)
  1170. {
  1171. FreeRequestContext(pAdapter, pReqContext);
  1172. }
  1173. if (pMsgFrame)
  1174. {
  1175. DereferenceMsgFrame(pMsgFrame);
  1176. }
  1177. return (TRUE);
  1178. } // QuerySetCompletionMessage
  1179. /****************************************************************************/
  1180. /* CompleteSendDeviceRequest */
  1181. /****************************************************************************/
  1182. /* */
  1183. /* Routine Description: */
  1184. /* */
  1185. /* Completion of send of a device set or query request thru the microport. */
  1186. /* If the message send failed, complete the request right now. */
  1187. /* */
  1188. /* Arguments: */
  1189. /* */
  1190. /* pMsgFrame - our context for the message */
  1191. /* SendStatus - microport's send status */
  1192. /* */
  1193. /* Return: */
  1194. /* */
  1195. /* None. */
  1196. /* */
  1197. /****************************************************************************/
  1198. VOID
  1199. CompleteSendDeviceRequest(IN PRNDISMP_MESSAGE_FRAME pMsgFrame,
  1200. IN NDIS_STATUS SendStatus)
  1201. {
  1202. PRNDISMP_ADAPTER pAdapter;
  1203. PRNDISMP_MESSAGE_FRAME pOrgMsgFrame;
  1204. PRNDISMP_REQUEST_CONTEXT pReqContext;
  1205. UINT NdisMessageType;
  1206. pAdapter = pMsgFrame->pAdapter;
  1207. TRACE3(("CompleteSendDevice Request: Adapter %p, MsgFrame %p, Status %x\n",
  1208. pAdapter, pMsgFrame, SendStatus));
  1209. if (SendStatus != NDIS_STATUS_SUCCESS)
  1210. {
  1211. //
  1212. // Microport failed to send the Request message;
  1213. // attempt to fail the original NDIS request.
  1214. //
  1215. TRACE1(("CompleteSendDeviceReq: Adapter %p, MsgFrame %p, failed %x\n",
  1216. pAdapter, pMsgFrame, SendStatus));
  1217. RNDISMP_LOOKUP_PENDING_MESSAGE(pOrgMsgFrame, pAdapter, pMsgFrame->RequestId);
  1218. if (pOrgMsgFrame == pMsgFrame)
  1219. {
  1220. //
  1221. // The request has not been aborted, so complete it now.
  1222. //
  1223. pReqContext = pMsgFrame->pReqContext;
  1224. NdisMessageType = pMsgFrame->NdisMessageType;
  1225. TRACE1(("CompleteSendReq: Adapter %p: Device req send failed, Oid %x, retry count %d\n",
  1226. pAdapter, pReqContext->Oid, pReqContext->RetryCount));
  1227. if (NdisMessageType == REMOTE_NDIS_QUERY_MSG)
  1228. {
  1229. // complete the query
  1230. NdisMQueryInformationComplete(pAdapter->MiniportAdapterHandle,
  1231. SendStatus);
  1232. }
  1233. else if (NdisMessageType == REMOTE_NDIS_SET_MSG)
  1234. {
  1235. // complete the set
  1236. NdisMSetInformationComplete(pAdapter->MiniportAdapterHandle,
  1237. SendStatus);
  1238. }
  1239. else
  1240. {
  1241. ASSERT(FALSE);
  1242. }
  1243. FreeRequestContext(pAdapter, pReqContext);
  1244. pMsgFrame->pReqContext = (PRNDISMP_REQUEST_CONTEXT)UlongToPtr(0xbcbcbcbc);
  1245. //
  1246. // Deref for NDIS request completion:
  1247. //
  1248. DereferenceMsgFrame(pMsgFrame);
  1249. }
  1250. //
  1251. // else we failed to locate the request on the pending list;
  1252. // it must have been removed when aborting all requests due
  1253. // to a reset.
  1254. //
  1255. }
  1256. //
  1257. // else sent the message out successfully; wait for a response.
  1258. //
  1259. //
  1260. // Deref for send-complete:
  1261. //
  1262. DereferenceMsgFrame(pMsgFrame);
  1263. }
  1264. #ifdef BUILD_WIN9X
  1265. /****************************************************************************/
  1266. /* CompleteSendDiscardDeviceRequest */
  1267. /****************************************************************************/
  1268. /* */
  1269. /* Routine Description: */
  1270. /* */
  1271. /* Completion of send of a device set or query request thru the microport. */
  1272. /* The sender of the request just wants us to free it up here. */
  1273. /* */
  1274. /* Arguments: */
  1275. /* */
  1276. /* pMsgFrame - our context for the message */
  1277. /* SendStatus - microport's send status */
  1278. /* */
  1279. /* Return: */
  1280. /* */
  1281. /* None. */
  1282. /* */
  1283. /****************************************************************************/
  1284. VOID
  1285. CompleteSendDiscardDeviceRequest(IN PRNDISMP_MESSAGE_FRAME pMsgFrame,
  1286. IN NDIS_STATUS SendStatus)
  1287. {
  1288. PRNDISMP_ADAPTER pAdapter;
  1289. PRNDISMP_REQUEST_CONTEXT pReqContext;
  1290. pAdapter = pMsgFrame->pAdapter;
  1291. pReqContext = pMsgFrame->pReqContext;
  1292. TRACE1(("CompleteSendDiscard: Adapter %p, MsgFrame %p, ReqContext %p\n",
  1293. pAdapter, pMsgFrame, pReqContext));
  1294. FreeRequestContext(pAdapter, pReqContext);
  1295. DereferenceMsgFrame(pMsgFrame);
  1296. }
  1297. #endif // BUILD_WIN9X
  1298. /****************************************************************************/
  1299. /* BuildOIDLists */
  1300. /****************************************************************************/
  1301. /* */
  1302. /* Routine Description: */
  1303. /* */
  1304. /* Build list of supported OIDs and associated function pointers */
  1305. /* */
  1306. /* Arguments: */
  1307. /* */
  1308. /* Adapter - Adapter object */
  1309. /* DeviceOIDList - list of OIDs supported by the device */
  1310. /* NumDeviceOID - number of OIDs supported by device */
  1311. /* DriverOIDList - list of OIDs supported by the driver */
  1312. /* NumDriverOID - number of OIDs supported by driver */
  1313. /* */
  1314. /* Return: */
  1315. /* */
  1316. /* NDIS_STATUS */
  1317. /* */
  1318. /****************************************************************************/
  1319. NDIS_STATUS
  1320. BuildOIDLists(IN PRNDISMP_ADAPTER Adapter,
  1321. IN PNDIS_OID DeviceOIDList,
  1322. IN UINT NumDeviceOID,
  1323. IN PNDIS_OID DriverOIDList,
  1324. IN UINT NumDriverOID)
  1325. {
  1326. UINT DeviceIndex;
  1327. UINT DriverIndex;
  1328. UINT NumOID;
  1329. NDIS_STATUS Status;
  1330. PNDIS_OID OIDList;
  1331. PUINT OIDHandlerList;
  1332. TRACE3(("BuildOIDLists\n"));
  1333. ASSERT(DeviceOIDList);
  1334. ASSERT(DriverOIDList);
  1335. NumOID = NumDriverOID;
  1336. // see what OIDs are duplicated in the device and route
  1337. // those to the device
  1338. for(DeviceIndex = 0; DeviceIndex < NumDeviceOID; DeviceIndex++)
  1339. {
  1340. for(DriverIndex = 0; DriverIndex < NumDriverOID; DriverIndex++)
  1341. {
  1342. if(DeviceOIDList[DeviceIndex] == DriverOIDList[DriverIndex])
  1343. {
  1344. // this OID is supported by the device, so don't
  1345. // support in the driver, set to 0 for when we build new list
  1346. DriverOIDList[DriverIndex] = 0;
  1347. break;
  1348. }
  1349. }
  1350. // if no match, increment the OID count
  1351. if(DriverIndex == NumDriverOID)
  1352. NumOID++;
  1353. }
  1354. // allocate OID list
  1355. Status = MemAlloc(&Adapter->SupportedOIDList,
  1356. NumOID * sizeof(NDIS_OID));
  1357. // see if we got our buffer
  1358. if(Status == NDIS_STATUS_SUCCESS)
  1359. {
  1360. Adapter->SupportedOIDListSize = NumOID * sizeof(NDIS_OID);
  1361. }
  1362. else
  1363. {
  1364. Adapter->OIDHandlerList = (PUINT) NULL;
  1365. Adapter->OIDHandlerListSize = 0;
  1366. Adapter->SupportedOIDList = (PNDIS_OID) NULL;
  1367. Adapter->SupportedOIDListSize = 0;
  1368. Status = NDIS_STATUS_FAILURE;
  1369. goto BuildDone;
  1370. }
  1371. // allocate list to indicate whether the OID is device or driver supported
  1372. Status = MemAlloc(&Adapter->OIDHandlerList,
  1373. NumOID * sizeof(UINT));
  1374. // see if we got our buffer
  1375. if(Status == NDIS_STATUS_SUCCESS)
  1376. {
  1377. Adapter->OIDHandlerListSize = NumOID * sizeof(UINT);
  1378. }
  1379. else
  1380. {
  1381. // free up allocated OID list cause this allocation failed
  1382. MemFree(Adapter->SupportedOIDList, Adapter->SupportedOIDListSize);
  1383. Adapter->OIDHandlerList = (PUINT) NULL;
  1384. Adapter->OIDHandlerListSize = 0;
  1385. Adapter->SupportedOIDList = (PNDIS_OID) NULL;
  1386. Adapter->SupportedOIDListSize = 0;
  1387. Status = NDIS_STATUS_FAILURE;
  1388. goto BuildDone;
  1389. }
  1390. Adapter->NumOIDSupported = NumOID;
  1391. OIDHandlerList = Adapter->OIDHandlerList;
  1392. OIDList = Adapter->SupportedOIDList;
  1393. // O.K., build our lists
  1394. for(DriverIndex = 0; DriverIndex < NumDriverOID; DriverIndex++)
  1395. {
  1396. if(DriverOIDList[DriverIndex] != 0)
  1397. {
  1398. // got one, so add to the list
  1399. *OIDList = DriverOIDList[DriverIndex];
  1400. OIDList++;
  1401. // set flag
  1402. *OIDHandlerList = DRIVER_SUPPORTED_OID;
  1403. OIDHandlerList++;
  1404. }
  1405. }
  1406. // let's add device supported OIDs
  1407. for(DeviceIndex = 0; DeviceIndex < NumDeviceOID; DeviceIndex++)
  1408. {
  1409. if(DeviceOIDList[DeviceIndex] != 0)
  1410. {
  1411. // got one, so add to the list
  1412. *OIDList = DeviceOIDList[DeviceIndex];
  1413. OIDList++;
  1414. // set flag
  1415. *OIDHandlerList = DEVICE_SUPPORTED_OID;
  1416. OIDHandlerList++;
  1417. }
  1418. }
  1419. // Now do a fixup to point OID_GEN_SUPPORTED_LIST at the driver since
  1420. // we now have a complete list.
  1421. //
  1422. for(DeviceIndex = 0; DeviceIndex < Adapter->NumOIDSupported; DeviceIndex++)
  1423. {
  1424. if (Adapter->SupportedOIDList[DeviceIndex] == OID_GEN_SUPPORTED_LIST)
  1425. {
  1426. Adapter->OIDHandlerList[DeviceIndex] = DRIVER_SUPPORTED_OID;
  1427. }
  1428. }
  1429. BuildDone:
  1430. if(Status == NDIS_STATUS_SUCCESS)
  1431. {
  1432. DISPLAY_OID_LIST(Adapter);
  1433. }
  1434. return Status;
  1435. } // BuildOIDLists
  1436. /****************************************************************************/
  1437. /* GetOIDSupport */
  1438. /****************************************************************************/
  1439. /* */
  1440. /* Routine Description: */
  1441. /* */
  1442. /* Returns flag to indicate if OID is device or driver supported */
  1443. /* */
  1444. /* Arguments: */
  1445. /* */
  1446. /* Adapter - Adapter object */
  1447. /* Oid - looking for a match on this OID */
  1448. /* */
  1449. /* Return: */
  1450. /* */
  1451. /* UINT */
  1452. /* */
  1453. /****************************************************************************/
  1454. UINT
  1455. GetOIDSupport(IN PRNDISMP_ADAPTER Adapter, IN NDIS_OID Oid)
  1456. {
  1457. UINT Index;
  1458. TRACE3(("GetOIDSupport\n"));
  1459. // sanity check
  1460. ASSERT(Adapter->SupportedOIDList);
  1461. ASSERT(Adapter->OIDHandlerList);
  1462. // search for a match on the OID
  1463. for(Index = 0; Index < Adapter->NumOIDSupported; Index++)
  1464. {
  1465. if(Adapter->SupportedOIDList[Index] == Oid)
  1466. {
  1467. return Adapter->OIDHandlerList[Index];
  1468. }
  1469. }
  1470. return OID_NOT_SUPPORTED;
  1471. } // GetOIDSupport
  1472. /****************************************************************************/
  1473. /* FreeOIDLists */
  1474. /****************************************************************************/
  1475. /* */
  1476. /* Routine Description: */
  1477. /* */
  1478. /* Free OID and handler lists */
  1479. /* */
  1480. /* Arguments: */
  1481. /* */
  1482. /* Adapter - Adapter object */
  1483. /* */
  1484. /* Return: */
  1485. /* */
  1486. /* VOID */
  1487. /* */
  1488. /****************************************************************************/
  1489. VOID
  1490. FreeOIDLists(IN PRNDISMP_ADAPTER Adapter)
  1491. {
  1492. UINT Size1, Size2;
  1493. PUCHAR Buffer1, Buffer2;
  1494. TRACE3(("FreeOIDLists\n"));
  1495. // grab the spinlock
  1496. NdisAcquireSpinLock(&Adapter->Lock);
  1497. Buffer1 = (PUCHAR) Adapter->SupportedOIDList;
  1498. Size1 = Adapter->SupportedOIDListSize;
  1499. Buffer2 = (PUCHAR) Adapter->OIDHandlerList;
  1500. Size2 = Adapter->OIDHandlerListSize;
  1501. Adapter->SupportedOIDList = (PUINT) NULL;
  1502. Adapter->SupportedOIDListSize = 0;
  1503. Adapter->OIDHandlerList = (PUINT) NULL;
  1504. Adapter->OIDHandlerListSize = 0;
  1505. Adapter->NumOIDSupported = 0;
  1506. // release spinlock
  1507. NdisReleaseSpinLock(&Adapter->Lock);
  1508. if(Buffer1)
  1509. MemFree(Buffer1, Size1);
  1510. if(Buffer2)
  1511. MemFree(Buffer2, Size2);
  1512. } // FreeOIDLists
  1513. /****************************************************************************/
  1514. /* AllocateRequestContext */
  1515. /****************************************************************************/
  1516. /* */
  1517. /* Routine Description: */
  1518. /* */
  1519. /* Allocate a context structure to keep track of an NDIS request */
  1520. /* */
  1521. /* Arguments: */
  1522. /* */
  1523. /* pAdapter - Pointer to our adapter structure */
  1524. /* */
  1525. /* Return: */
  1526. /* */
  1527. /* PRNDISMP_REQUEST_CONTEXT */
  1528. /* */
  1529. /****************************************************************************/
  1530. PRNDISMP_REQUEST_CONTEXT
  1531. AllocateRequestContext(IN PRNDISMP_ADAPTER pAdapter)
  1532. {
  1533. NDIS_STATUS Status;
  1534. PRNDISMP_REQUEST_CONTEXT pReqContext;
  1535. TRACE3(("AllocateRequestContext\n"));
  1536. Status = MemAlloc(&pReqContext, sizeof(RNDISMP_REQUEST_CONTEXT));
  1537. if (Status != NDIS_STATUS_SUCCESS)
  1538. {
  1539. pReqContext = NULL;
  1540. }
  1541. return pReqContext;
  1542. } // AllocateRequestContext
  1543. /****************************************************************************/
  1544. /* FreeRequestContext */
  1545. /****************************************************************************/
  1546. /* */
  1547. /* Routine Description: */
  1548. /* */
  1549. /* Freeing up miniport resources associated with a request */
  1550. /* */
  1551. /* Arguments: */
  1552. /* */
  1553. /* pAdapter - Pointer to our adapter structure */
  1554. /* pReqContext - Pointer to request context to be freed */
  1555. /* */
  1556. /* Return: */
  1557. /* */
  1558. /* VOID */
  1559. /* */
  1560. /****************************************************************************/
  1561. VOID
  1562. FreeRequestContext(IN PRNDISMP_ADAPTER pAdapter,
  1563. IN PRNDISMP_REQUEST_CONTEXT pReqContext)
  1564. {
  1565. TRACE3(("FreeRequestContext\n"));
  1566. MemFree(pReqContext, -1);
  1567. } // FreeRequestContext