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.

1082 lines
28 KiB

  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. // Copyright (c) 1996, 1997 Microsoft Corporation
  5. //
  6. //
  7. // Module Name:
  8. // test.c
  9. //
  10. // Abstract:
  11. //
  12. // This file is a test to find out if dual binding to NDIS and KS works
  13. //
  14. // Author:
  15. //
  16. // P Porzuczek
  17. //
  18. // Environment:
  19. //
  20. // Revision History:
  21. //
  22. //
  23. //////////////////////////////////////////////////////////////////////////////
  24. #include <forward.h>
  25. #include <memory.h>
  26. #include <ndis.h>
  27. #include <link.h>
  28. #include <ipsink.h>
  29. #include "device.h"
  30. #include "main.h"
  31. #include "NdisApi.h"
  32. #include "frame.h"
  33. #include "mem.h"
  34. #include "adapter.h"
  35. //////////////////////////////////////////////////////////
  36. //
  37. // Global vars
  38. //
  39. PDRIVER_OBJECT pGlobalDriverObject = NULL;
  40. extern ULONG ulGlobalInstance;
  41. extern UCHAR achGlobalVendorDescription [];
  42. //////////////////////////////////////////////////////////
  43. //
  44. // List of supported OID for this driver.
  45. //
  46. //
  47. static UINT SupportedOids[] = {
  48. //
  49. // Required General OIDs
  50. //
  51. OID_GEN_SUPPORTED_LIST,
  52. OID_GEN_HARDWARE_STATUS,
  53. OID_GEN_MEDIA_CAPABILITIES,
  54. OID_GEN_MEDIA_SUPPORTED,
  55. OID_GEN_MEDIA_IN_USE,
  56. OID_GEN_MAXIMUM_LOOKAHEAD,
  57. OID_GEN_MAXIMUM_FRAME_SIZE,
  58. OID_GEN_LINK_SPEED,
  59. OID_GEN_TRANSMIT_BUFFER_SPACE,
  60. OID_GEN_RECEIVE_BUFFER_SPACE,
  61. OID_GEN_TRANSMIT_BLOCK_SIZE,
  62. OID_GEN_RECEIVE_BLOCK_SIZE,
  63. OID_GEN_VENDOR_ID,
  64. OID_GEN_VENDOR_DESCRIPTION,
  65. OID_GEN_CURRENT_PACKET_FILTER,
  66. OID_GEN_CURRENT_LOOKAHEAD,
  67. OID_GEN_DRIVER_VERSION,
  68. OID_GEN_MAXIMUM_TOTAL_SIZE,
  69. OID_GEN_MAC_OPTIONS,
  70. OID_GEN_MEDIA_CONNECT_STATUS,
  71. OID_GEN_MAXIMUM_SEND_PACKETS,
  72. OID_GEN_VENDOR_DRIVER_VERSION,
  73. OID_GEN_TRANSPORT_HEADER_OFFSET,
  74. //
  75. // Required General Statistics
  76. //
  77. OID_GEN_XMIT_OK,
  78. OID_GEN_RCV_OK,
  79. OID_GEN_XMIT_ERROR,
  80. OID_GEN_RCV_ERROR,
  81. OID_GEN_RCV_NO_BUFFER,
  82. //
  83. // Optional General Statistics
  84. //
  85. OID_GEN_DIRECTED_BYTES_XMIT,
  86. OID_GEN_DIRECTED_FRAMES_XMIT,
  87. OID_GEN_MULTICAST_BYTES_XMIT,
  88. OID_GEN_MULTICAST_FRAMES_XMIT,
  89. OID_GEN_BROADCAST_BYTES_XMIT,
  90. OID_GEN_BROADCAST_FRAMES_XMIT,
  91. OID_GEN_DIRECTED_BYTES_RCV,
  92. OID_GEN_DIRECTED_FRAMES_RCV,
  93. OID_GEN_MULTICAST_BYTES_RCV,
  94. OID_GEN_MULTICAST_FRAMES_RCV,
  95. OID_GEN_BROADCAST_BYTES_RCV,
  96. OID_GEN_BROADCAST_FRAMES_RCV,
  97. OID_GEN_RCV_CRC_ERROR,
  98. OID_GEN_TRANSMIT_QUEUE_LENGTH,
  99. //
  100. // Required 802.3 OIDs
  101. //
  102. OID_802_3_PERMANENT_ADDRESS,
  103. OID_802_3_CURRENT_ADDRESS,
  104. OID_802_3_MULTICAST_LIST,
  105. OID_802_3_MAXIMUM_LIST_SIZE,
  106. OID_802_3_MAC_OPTIONS,
  107. OID_802_3_RCV_ERROR_ALIGNMENT,
  108. OID_802_3_XMIT_ONE_COLLISION,
  109. OID_802_3_XMIT_MORE_COLLISIONS,
  110. };
  111. //////////////////////////////////////////////////////////
  112. //
  113. //$BUGBUG - Fix Permanent Ethernet Address
  114. //
  115. //
  116. UCHAR rgchPermanentAddress[ETHERNET_ADDRESS_LENGTH] =
  117. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  118. //$BUGBUG - Fix Ethernet Station Address
  119. UCHAR rgchStationAddress[ETHERNET_ADDRESS_LENGTH] =
  120. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  121. NTSTATUS
  122. ntInitializeDriverObject(
  123. PDRIVER_OBJECT *ppDriverObject
  124. );
  125. VOID
  126. vSetDriverDispatchTable(
  127. PDRIVER_OBJECT pDriverObject
  128. );
  129. VOID
  130. vUnload(
  131. IN PDRIVER_OBJECT pDriverObject
  132. )
  133. {
  134. return;
  135. }
  136. //////////////////////////////////////////////////////////////////////////////
  137. NTSTATUS
  138. NdisDriverInitialize (
  139. IN PDRIVER_OBJECT DriverObject,
  140. IN PUNICODE_STRING RegistryPath,
  141. IN PNDIS_HANDLE pNdishWrapper
  142. )
  143. //////////////////////////////////////////////////////////////////////////////
  144. {
  145. NTSTATUS ntStatus = STATUS_SUCCESS;
  146. NDIS_STATUS nsResult = NDIS_STATUS_SUCCESS;
  147. //
  148. // NDIS data
  149. //
  150. NDIS_MINIPORT_CHARACTERISTICS ndisMiniChar = {0};
  151. NDIS_HANDLE ndishWrapper = {0};
  152. TEST_DEBUG (TEST_DBG_TRACE, ("NdisDriverInitialize Called\n"));
  153. //
  154. // Initialize Driver Object.
  155. // NOTE: The value of pDriverObject may change.
  156. //
  157. #ifdef WIN9X
  158. ntStatus = ntInitializeDriverObject(&DriverObject);
  159. if (ntStatus != STATUS_SUCCESS)
  160. {
  161. goto ret;
  162. }
  163. #endif
  164. //////////////////////////////////////////////////////
  165. //
  166. // Initialize the NDIS wrapper.
  167. //
  168. NdisMInitializeWrapper (&ndishWrapper,
  169. DriverObject,
  170. RegistryPath,
  171. NULL);
  172. //////////////////////////////////////////////////////
  173. //
  174. // Initialize the Miniport Dispatch Table
  175. //
  176. ndisMiniChar.MajorNdisVersion = 4;
  177. ndisMiniChar.MinorNdisVersion = 0;
  178. #ifdef NDIS30
  179. ndisMiniChar.Flags = 0;
  180. #endif // NDIS30
  181. ndisMiniChar.HaltHandler = NdisIPHalt;
  182. ndisMiniChar.InitializeHandler = NdisIPInitialize;
  183. ndisMiniChar.QueryInformationHandler = NdisIPQueryInformation;
  184. ndisMiniChar.ResetHandler = NdisIPReset;
  185. ndisMiniChar.SendHandler = NdisIPSend;
  186. ndisMiniChar.SetInformationHandler = NdisIPSetInformation;
  187. ndisMiniChar.ReturnPacketHandler = NdisIPReturnPacket;
  188. //
  189. // Register the miniport driver
  190. //
  191. nsResult = NdisMRegisterMiniport (ndishWrapper, &ndisMiniChar, sizeof(ndisMiniChar));
  192. if (nsResult != NDIS_STATUS_SUCCESS)
  193. {
  194. ntStatus = STATUS_UNSUCCESSFUL;
  195. goto ret;
  196. }
  197. *pNdishWrapper = ndishWrapper;
  198. #ifdef WIN9X
  199. vSetDriverDispatchTable (DriverObject);
  200. #endif
  201. ret:
  202. TEST_DEBUG (TEST_DBG_TRACE, ("NdisDriverInitialize Called, ntStatus = %08X\n", ntStatus));
  203. return ntStatus;
  204. }
  205. ///////////////////////////////////////////////////////////////////////////////////
  206. extern
  207. NDIS_STATUS
  208. NdisIPInitialize(
  209. OUT PNDIS_STATUS pnsOpenResult,
  210. OUT PUINT puiSelectedMedium,
  211. IN PNDIS_MEDIUM pNdisMediumArray,
  212. IN UINT ucNdispNdisMediumArrayEntries,
  213. IN NDIS_HANDLE ndishAdapterContext,
  214. IN NDIS_HANDLE ndishWrapperConfiguration
  215. )
  216. ///////////////////////////////////////////////////////////////////////////////////
  217. {
  218. NDIS_STATUS nsResult = NDIS_STATUS_SUCCESS;
  219. NDIS_HANDLE ndishConfiguration = NULL;
  220. PADAPTER pAdapter = NULL;
  221. UINT uTemp = 0;
  222. TEST_DEBUG (TEST_DBG_TRACE, ("NdisInitialize handler called\n"));
  223. //
  224. // Search for the medium type (DSS) in the given array.
  225. //
  226. for ( uTemp = 0; uTemp < ucNdispNdisMediumArrayEntries; uTemp++)
  227. {
  228. if (pNdisMediumArray[uTemp] == NdisMedium802_3)
  229. {
  230. break;
  231. }
  232. }
  233. if (uTemp == ucNdispNdisMediumArrayEntries)
  234. {
  235. return NDIS_STATUS_UNSUPPORTED_MEDIA;
  236. }
  237. *puiSelectedMedium = uTemp;
  238. nsResult = CreateAdapter (&pAdapter, global_ndishWrapper, ndishAdapterContext);
  239. if (nsResult != NDIS_STATUS_SUCCESS)
  240. {
  241. return nsResult;
  242. }
  243. //
  244. // Initialize the information used to do indicates with
  245. //
  246. Adapter_IndicateReset (pAdapter);
  247. TEST_DEBUG (TEST_DBG_TRACE, ("NdisInitialize Handler Completed, nsResult = %08x\n", nsResult));
  248. return nsResult;
  249. }
  250. //////////////////////////////////////////////////////////////////////////////
  251. // Removes an adapter that was previously initialized.
  252. //
  253. extern
  254. VOID
  255. NdisIPHalt(
  256. IN NDIS_HANDLE ndishAdapter
  257. )
  258. //////////////////////////////////////////////////////////////////////////////
  259. {
  260. PADAPTER pAdapter = (PADAPTER) ndishAdapter;
  261. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPHalt Handler Called\n"));
  262. #ifndef WIN9X
  263. //
  264. // Deregister our device interface. This should shut down the link to the
  265. // streaming component.
  266. //
  267. NdisMDeregisterDevice(pAdapter->ndisDeviceHandle);
  268. #endif
  269. //
  270. // Signal the Streaming component that we're halting.
  271. //
  272. if (pAdapter)
  273. {
  274. if (pAdapter->pFilter)
  275. {
  276. if (pAdapter->pFilter->lpVTable->IndicateStatus)
  277. {
  278. pAdapter->pFilter->lpVTable->IndicateStatus (pAdapter->pFilter, IPSINK_EVENT_SHUTDOWN);
  279. //
  280. // Release the filter reference
  281. //
  282. pAdapter->pFilter->lpVTable->Release (pAdapter->pFilter);
  283. //
  284. // Release the frame pool
  285. //
  286. pAdapter->pFramePool->lpVTable->Release (pAdapter->pFramePool);
  287. }
  288. }
  289. }
  290. //
  291. // Release the adapter
  292. //
  293. pAdapter->lpVTable->Release (pAdapter);
  294. return;
  295. }
  296. //////////////////////////////////////////////////////////////////////////////////////
  297. // The TestReset request, instructs the Miniport to issue
  298. // a hardware reset to the network adapter. The driver also
  299. // resets its software state. See the description of NdisMReset
  300. // for a detailed description of this request.
  301. //
  302. NDIS_STATUS
  303. NdisIPReset(
  304. OUT PBOOLEAN pfAddressingReset,
  305. IN NDIS_HANDLE ndishAdapter
  306. )
  307. //////////////////////////////////////////////////////////////////////////////////////
  308. {
  309. NDIS_STATUS nsResult = NDIS_STATUS_SUCCESS;
  310. PADAPTER pAdapter = (PADAPTER) ndishAdapter;
  311. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPRest Handler Called\n"));
  312. nsResult = NDIS_STATUS_NOT_RESETTABLE;
  313. return nsResult;
  314. }
  315. //////////////////////////////////////////////////////////////////////////////////////
  316. NDIS_STATUS
  317. NdisIPQueryInformation (
  318. NDIS_HANDLE ndishAdapter,
  319. NDIS_OID ndisOid,
  320. PVOID pvInformationBuffer,
  321. ULONG dwcbInformationBuffer,
  322. PULONG pdwBytesWritten,
  323. PULONG pdwBytesNeeded
  324. )
  325. //////////////////////////////////////////////////////////////////////////////////////
  326. {
  327. NDIS_STATUS nsResult = NDIS_STATUS_SUCCESS;
  328. PADAPTER pAdapter = (PADAPTER) ndishAdapter;
  329. ULONG ulcbWritten = 0;
  330. ULONG ulcbNeeded = 0;
  331. //
  332. // These variables hold the result of queries on General OIDS.
  333. //
  334. NDIS_HARDWARE_STATUS ndisHardwareStatus = NdisHardwareStatusReady;
  335. NDIS_MEDIUM ndisMedium = NdisMedium802_3;
  336. ULONG dwGeneric = 0;
  337. USHORT wGeneric = 0;
  338. UINT ucbToMove = 0;
  339. PUCHAR pbMoveSource = NULL;
  340. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPQuery Handler Called, ndsOid: %08X\n", ndisOid));
  341. if (!pAdapter || !pdwBytesWritten || !pdwBytesNeeded)
  342. {
  343. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPQuery Handler Complete, nsResult: NDIS_STATUS_INVALID_DATA,\n"));
  344. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPQuery Handler pAdapter: %08X pdwBytesWritten: %08X pdwBytesNeeded: %08X\n",
  345. pAdapter, pdwBytesWritten, pdwBytesNeeded));
  346. return (NDIS_STATUS_INVALID_DATA);
  347. }
  348. //
  349. // Process OID's
  350. //
  351. pbMoveSource = (PUCHAR) (&dwGeneric);
  352. ulcbWritten = sizeof(ULONG);
  353. switch (ndisOid)
  354. {
  355. case OID_GEN_MEDIA_CAPABILITIES:
  356. dwGeneric = NDIS_MEDIA_CAP_RECEIVE;
  357. break;
  358. case OID_GEN_MAC_OPTIONS:
  359. dwGeneric = (ULONG) ( NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
  360. | NDIS_MAC_OPTION_RECEIVE_SERIALIZED
  361. | NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
  362. | NDIS_MAC_OPTION_NO_LOOPBACK);
  363. break;
  364. case OID_GEN_SUPPORTED_LIST:
  365. pbMoveSource = (PUCHAR) (SupportedOids);
  366. ulcbWritten = sizeof(SupportedOids);
  367. break;
  368. case OID_GEN_MEDIA_SUPPORTED:
  369. case OID_GEN_MEDIA_IN_USE:
  370. pbMoveSource = (PUCHAR) (&ndisMedium);
  371. ulcbWritten = sizeof(NDIS_MEDIUM);
  372. break;
  373. case OID_GEN_MAXIMUM_LOOKAHEAD:
  374. dwGeneric = BDA_802_3_MAX_LOOKAHEAD;
  375. break;
  376. case OID_GEN_MAXIMUM_SEND_PACKETS:
  377. dwGeneric = 1;
  378. break;
  379. case OID_GEN_MAXIMUM_FRAME_SIZE:
  380. dwGeneric = BDA_802_3_MAX_LOOKAHEAD;
  381. break;
  382. case OID_GEN_MAXIMUM_TOTAL_SIZE:
  383. dwGeneric = (ULONG)(BDA_802_3_MAX_PACKET);
  384. break;
  385. case OID_GEN_TRANSMIT_BUFFER_SPACE:
  386. dwGeneric = (ULONG)(BDA_802_3_MAX_PACKET);
  387. break;
  388. case OID_GEN_TRANSMIT_BLOCK_SIZE:
  389. dwGeneric = BDA_802_3_MAX_LOOKAHEAD;
  390. break;
  391. case OID_GEN_RECEIVE_BLOCK_SIZE:
  392. dwGeneric = BDA_802_3_MAX_LOOKAHEAD;
  393. break;
  394. case OID_GEN_CURRENT_LOOKAHEAD:
  395. dwGeneric = BDA_802_3_MAX_LOOKAHEAD;
  396. break;
  397. case OID_GEN_CURRENT_PACKET_FILTER:
  398. dwGeneric = (ULONG) pAdapter->ulPacketFilter;
  399. break;
  400. case OID_GEN_XMIT_OK:
  401. dwGeneric = pAdapter->stats.ulOID_GEN_XMIT_OK;
  402. break;
  403. case OID_GEN_RCV_OK:
  404. dwGeneric = pAdapter->stats.ulOID_GEN_RCV_OK;
  405. break;
  406. case OID_GEN_XMIT_ERROR:
  407. dwGeneric = pAdapter->stats.ulOID_GEN_XMIT_ERROR;
  408. break;
  409. case OID_GEN_RCV_ERROR:
  410. dwGeneric = pAdapter->stats.ulOID_GEN_RCV_ERROR;
  411. break;
  412. case OID_GEN_RCV_NO_BUFFER:
  413. dwGeneric = pAdapter->stats.ulOID_GEN_RCV_NO_BUFFER;
  414. break;
  415. case OID_GEN_DIRECTED_BYTES_XMIT:
  416. dwGeneric = pAdapter->stats.ulOID_GEN_DIRECTED_BYTES_XMIT;
  417. break;
  418. case OID_GEN_DIRECTED_FRAMES_XMIT:
  419. dwGeneric = pAdapter->stats.ulOID_GEN_DIRECTED_FRAMES_XMIT;
  420. break;
  421. case OID_GEN_MULTICAST_BYTES_XMIT:
  422. dwGeneric = pAdapter->stats.ulOID_GEN_MULTICAST_BYTES_XMIT;
  423. break;
  424. case OID_GEN_MULTICAST_FRAMES_XMIT:
  425. dwGeneric = pAdapter->stats.ulOID_GEN_MULTICAST_FRAMES_XMIT;
  426. break;
  427. case OID_GEN_BROADCAST_BYTES_XMIT:
  428. dwGeneric = pAdapter->stats.ulOID_GEN_BROADCAST_BYTES_XMIT;
  429. break;
  430. case OID_GEN_BROADCAST_FRAMES_XMIT:
  431. dwGeneric = pAdapter->stats.ulOID_GEN_BROADCAST_FRAMES_XMIT;
  432. break;
  433. case OID_GEN_DIRECTED_BYTES_RCV:
  434. dwGeneric = pAdapter->stats.ulOID_GEN_DIRECTED_BYTES_RCV;
  435. break;
  436. case OID_GEN_DIRECTED_FRAMES_RCV:
  437. dwGeneric = pAdapter->stats.ulOID_GEN_DIRECTED_FRAMES_RCV;
  438. break;
  439. case OID_GEN_MULTICAST_BYTES_RCV:
  440. dwGeneric = pAdapter->stats.ulOID_GEN_MULTICAST_BYTES_RCV;
  441. break;
  442. case OID_GEN_MULTICAST_FRAMES_RCV:
  443. dwGeneric = pAdapter->stats.ulOID_GEN_MULTICAST_FRAMES_RCV;
  444. break;
  445. case OID_GEN_BROADCAST_BYTES_RCV:
  446. dwGeneric = pAdapter->stats.ulOID_GEN_BROADCAST_BYTES_RCV;
  447. break;
  448. case OID_GEN_BROADCAST_FRAMES_RCV:
  449. dwGeneric = pAdapter->stats.ulOID_GEN_BROADCAST_FRAMES_RCV;
  450. break;
  451. case OID_GEN_RCV_CRC_ERROR:
  452. dwGeneric = pAdapter->stats.ulOID_GEN_RCV_CRC_ERROR;
  453. break;
  454. case OID_GEN_TRANSMIT_QUEUE_LENGTH:
  455. dwGeneric = pAdapter->stats.ulOID_GEN_TRANSMIT_QUEUE_LENGTH;
  456. break;
  457. case OID_802_3_RCV_ERROR_ALIGNMENT:
  458. dwGeneric = 0;
  459. break;
  460. case OID_802_3_XMIT_ONE_COLLISION:
  461. dwGeneric = 0;
  462. break;
  463. case OID_802_3_XMIT_MORE_COLLISIONS:
  464. dwGeneric = 0;
  465. break;
  466. case OID_802_3_PERMANENT_ADDRESS:
  467. pbMoveSource = (PVOID)(rgchPermanentAddress);
  468. ulcbWritten = sizeof(rgchPermanentAddress);
  469. break;
  470. case OID_802_3_CURRENT_ADDRESS:
  471. pbMoveSource = (PVOID)(rgchStationAddress);
  472. ulcbWritten = sizeof(rgchStationAddress);
  473. break;
  474. case OID_802_3_MAXIMUM_LIST_SIZE:
  475. dwGeneric = MULTICAST_LIST_SIZE;
  476. break;
  477. case OID_GEN_HARDWARE_STATUS:
  478. ndisHardwareStatus = NdisHardwareStatusReady;
  479. pbMoveSource = (PUCHAR)(&ndisHardwareStatus);
  480. ulcbWritten = sizeof(NDIS_HARDWARE_STATUS);
  481. break;
  482. case OID_GEN_LINK_SPEED:
  483. dwGeneric = (ULONG)(300000);
  484. break;
  485. case OID_GEN_RECEIVE_BUFFER_SPACE:
  486. dwGeneric = BDA_802_3_MAX_PACKET * 20;
  487. break;
  488. case OID_GEN_DRIVER_VERSION:
  489. dwGeneric = ((USHORT) 4 << 8) | 0;
  490. pbMoveSource = (PVOID)(&dwGeneric);
  491. ulcbWritten = sizeof(dwGeneric);
  492. break;
  493. case OID_GEN_VENDOR_ID:
  494. wGeneric = (USHORT) 0xDDDD; // BOGUS ID
  495. pbMoveSource = (PVOID)(&wGeneric);
  496. ulcbWritten = sizeof(wGeneric);
  497. break;
  498. case OID_GEN_VENDOR_DESCRIPTION:
  499. pbMoveSource = (PVOID) pAdapter->pVendorDescription;
  500. ulcbWritten = MyStrLen (pAdapter->pVendorDescription);
  501. break;
  502. case OID_GEN_VENDOR_DRIVER_VERSION:
  503. dwGeneric = 0x0401;
  504. pbMoveSource = (PVOID)(&dwGeneric);
  505. ulcbWritten = sizeof(dwGeneric);
  506. break;
  507. case OID_GEN_MEDIA_CONNECT_STATUS:
  508. dwGeneric = NdisMediaStateConnected;
  509. break;
  510. case OID_802_3_MAC_OPTIONS:
  511. dwGeneric = 0;
  512. break;
  513. case OID_PNP_CAPABILITIES:
  514. dwGeneric = 0;
  515. break;
  516. case OID_802_3_MULTICAST_LIST:
  517. pbMoveSource = (PVOID)(pAdapter->multicastList[0]);
  518. ulcbWritten = pAdapter->ulcbMulticastListEntries;
  519. break;
  520. case OID_PNP_QUERY_POWER:
  521. nsResult = NDIS_STATUS_SUCCESS;
  522. ulcbWritten = 0;
  523. break;
  524. case OID_TCP_TASK_OFFLOAD:
  525. case OID_TCP_TASK_IPSEC_ADD_SA:
  526. case OID_TCP_TASK_IPSEC_DELETE_SA:
  527. case OID_TCP_SAN_SUPPORT:
  528. case OID_FFP_SUPPORT:
  529. case OID_FFP_FLUSH:
  530. case OID_FFP_CONTROL:
  531. case OID_FFP_PARAMS:
  532. case OID_FFP_DATA:
  533. case OID_FFP_DRIVER_STATS:
  534. case OID_FFP_ADAPTER_STATS:
  535. case OID_PNP_WAKE_UP_OK:
  536. case OID_PNP_WAKE_UP_ERROR:
  537. nsResult = NDIS_STATUS_NOT_SUPPORTED;
  538. break;
  539. default:
  540. //
  541. nsResult = NDIS_STATUS_INVALID_OID;
  542. break;
  543. }
  544. //
  545. // First take care of the case where the size of the output buffer is
  546. // zero, or the pointer to the buffer is NULL
  547. //
  548. if (nsResult == NDIS_STATUS_SUCCESS)
  549. {
  550. ulcbNeeded = ulcbWritten;
  551. if (ulcbWritten > dwcbInformationBuffer)
  552. {
  553. //
  554. // There isn't enough room in InformationBuffer.
  555. // Don't move any of the info.
  556. //
  557. ulcbWritten = 0;
  558. nsResult = NDIS_STATUS_INVALID_LENGTH;
  559. }
  560. else if (ulcbNeeded && (pvInformationBuffer == NULL))
  561. {
  562. ulcbWritten = 0;
  563. nsResult = NDIS_STATUS_INVALID_LENGTH;
  564. }
  565. else if (ulcbNeeded)
  566. {
  567. //
  568. // Move the requested information into the info buffer.
  569. //
  570. NdisMoveMemory (pvInformationBuffer, pbMoveSource, ulcbWritten);
  571. }
  572. }
  573. if (nsResult == NDIS_STATUS_SUCCESS)
  574. {
  575. //
  576. // A status of success always indicates 0 bytes needed.
  577. //
  578. *pdwBytesWritten = ulcbWritten;
  579. *pdwBytesNeeded = 0;
  580. }
  581. else if (nsResult == NDIS_STATUS_INVALID_LENGTH)
  582. {
  583. //
  584. // For us a failure status always indicates 0 bytes read.
  585. //
  586. *pdwBytesWritten = 0;
  587. *pdwBytesNeeded = ulcbNeeded;
  588. }
  589. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPQuery Handler Complete, nsResult: %08X\n", nsResult));
  590. return nsResult;
  591. }
  592. ////////////////////////////////////////////////////////////////////////
  593. extern
  594. NDIS_STATUS
  595. NdisIPSetInformation (
  596. NDIS_HANDLE ndishAdapterContext,
  597. NDIS_OID ndisOid,
  598. PVOID pvInformationBuffer,
  599. ULONG dwcbInformationBuffer,
  600. PULONG pdwBytesRead,
  601. PULONG pdwBytesNeeded
  602. )
  603. ////////////////////////////////////////////////////////////////////////
  604. {
  605. ULONG ulcbNeeded = 0;
  606. NDIS_STATUS nsResult = NDIS_STATUS_SUCCESS;
  607. PADAPTER pAdapter = (PADAPTER) ndishAdapterContext;
  608. #ifdef PFP
  609. ASSERT (pAdapter != NULL);
  610. ASSERT (pvInformationBuffer != NULL);
  611. ASSERT (pdwBytesRead != NULL);
  612. ASSERT (pdwBytesNeeded != NULL);
  613. #endif
  614. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPSetInfo Handler Called, ndsOid: %08X\n", ndisOid));
  615. if (!pAdapter || !pvInformationBuffer || !pdwBytesRead || !pdwBytesNeeded)
  616. {
  617. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPSetInfo Handler returns Invalid data\n"));
  618. return (NDIS_STATUS_INVALID_DATA);
  619. }
  620. switch (ndisOid)
  621. {
  622. case OID_GEN_CURRENT_PACKET_FILTER:
  623. {
  624. pAdapter->ulPacketFilter = * ((PULONG) pvInformationBuffer);
  625. *pdwBytesRead = 4;
  626. }
  627. break;
  628. case OID_GEN_CURRENT_LOOKAHEAD:
  629. if (dwcbInformationBuffer != 4)
  630. {
  631. nsResult = NDIS_STATUS_INVALID_LENGTH;
  632. *pdwBytesRead = 0;
  633. break;
  634. }
  635. //
  636. // Current Lookahead is not set this way so just ignore the
  637. // data.
  638. //
  639. *pdwBytesRead = 4;
  640. break;
  641. case OID_802_3_MULTICAST_LIST:
  642. // If our current multicast address buffer isn't big
  643. // enough, then free it.
  644. //
  645. if (dwcbInformationBuffer > sizeof (pAdapter->multicastList))
  646. {
  647. nsResult = NDIS_STATUS_RESOURCES;
  648. break;
  649. }
  650. // Copy the Multicast List.
  651. //
  652. RtlCopyMemory (pAdapter->multicastList,
  653. pvInformationBuffer,
  654. dwcbInformationBuffer
  655. );
  656. pAdapter->ulcbMulticastListEntries = dwcbInformationBuffer;
  657. //
  658. // Now we send the multicast list to the stream component so
  659. // it can get passed on to the net provider filter
  660. //
  661. if (pAdapter)
  662. {
  663. if (pAdapter->pFilter)
  664. {
  665. if (pAdapter->pFilter->lpVTable->SetMulticastList)
  666. {
  667. pAdapter->pFilter->lpVTable->SetMulticastList (
  668. pAdapter->pFilter,
  669. pAdapter->multicastList,
  670. pAdapter->ulcbMulticastListEntries
  671. );
  672. }
  673. }
  674. }
  675. break;
  676. case OID_802_3_PERMANENT_ADDRESS:
  677. RtlCopyMemory (rgchPermanentAddress,
  678. pvInformationBuffer,
  679. dwcbInformationBuffer
  680. );
  681. break;
  682. case OID_802_3_CURRENT_ADDRESS:
  683. RtlCopyMemory (rgchStationAddress,
  684. pvInformationBuffer,
  685. dwcbInformationBuffer
  686. );
  687. break;
  688. case OID_PNP_SET_POWER:
  689. nsResult = NDIS_STATUS_SUCCESS;
  690. ulcbNeeded = 0;
  691. break;
  692. default:
  693. nsResult = NDIS_STATUS_INVALID_OID;
  694. *pdwBytesRead = 0;
  695. ulcbNeeded = 0;
  696. break;
  697. }
  698. if (nsResult == NDIS_STATUS_SUCCESS)
  699. {
  700. //
  701. // A status of success always indicates 0 bytes needed.
  702. //
  703. *pdwBytesRead = dwcbInformationBuffer;
  704. *pdwBytesNeeded = 0;
  705. }
  706. else
  707. {
  708. //
  709. // A failure status always indicates 0 bytes read.
  710. //
  711. *pdwBytesRead = 0;
  712. *pdwBytesNeeded = ulcbNeeded;
  713. }
  714. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPSetInfo Handler Complete, nsResult: %08X\n", nsResult));
  715. return nsResult;
  716. }
  717. //////////////////////////////////////////////////////////////////////////////////////
  718. VOID
  719. NdisIPReturnPacket(
  720. IN NDIS_HANDLE ndishAdapterContext,
  721. IN PNDIS_PACKET pNdisPacket
  722. )
  723. //////////////////////////////////////////////////////////////////////////////////////
  724. {
  725. PFRAME pFrame = NULL;
  726. ULONG ulMediaSpecificInfoSize;
  727. PIPSINK_MEDIA_SPECIFIC_INFORAMTION pMediaSpecificInfo;
  728. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPReturnPacket Handler Called\n"));
  729. NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO (pNdisPacket,&pMediaSpecificInfo,&ulMediaSpecificInfoSize);
  730. //
  731. // Make sure we free up any frames
  732. //
  733. if (pMediaSpecificInfo)
  734. {
  735. pFrame = (PFRAME) pMediaSpecificInfo->pFrame;
  736. ASSERT(pFrame);
  737. }
  738. //
  739. // NDIS is through with the packet so we need to free it
  740. // here.
  741. //
  742. NdisFreePacket (pNdisPacket);
  743. //
  744. // Put Frame back on available queue.
  745. //
  746. if (pFrame)
  747. {
  748. //
  749. // Release this frame since we're done using it
  750. //
  751. pFrame->lpVTable->Release (pFrame);
  752. //
  753. // Store the frame back on the available queue
  754. //
  755. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPReturnPacket: Putting frame %08X back on Available Queue\n", pFrame));
  756. PutFrame (pFrame->pFramePool, &pFrame->pFramePool->leAvailableQueue, pFrame);
  757. }
  758. return;
  759. }
  760. //////////////////////////////////////////////////////////////////////////////
  761. NDIS_STATUS
  762. NdisIPSend(
  763. IN NDIS_HANDLE ndishAdapterContext,
  764. IN PNDIS_PACKET Packet,
  765. IN UINT Flags
  766. )
  767. //////////////////////////////////////////////////////////////////////////////
  768. {
  769. PADAPTER pAdapter = (PADAPTER) ndishAdapterContext;
  770. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPSend Handler Called\n"));
  771. pAdapter->stats.ulOID_GEN_XMIT_ERROR += 1;
  772. return NDIS_STATUS_FAILURE;
  773. }
  774. //////////////////////////////////////////////////////////////////////////////
  775. extern VOID
  776. NdisIPShutdown(
  777. IN PVOID ShutdownContext
  778. )
  779. //////////////////////////////////////////////////////////////////////////////
  780. {
  781. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIPShutdown Handler Called\n"));
  782. //BREAK(0x10);
  783. }
  784. //////////////////////////////////////////////////////////////////////////////
  785. NTSTATUS
  786. RegisterDevice(
  787. IN PVOID NdisWrapperHandle,
  788. IN UNICODE_STRING *DeviceName,
  789. IN UNICODE_STRING *SymbolicName,
  790. IN PDRIVER_DISPATCH pDispatchTable[],
  791. OUT PDEVICE_OBJECT *pDeviceObject,
  792. OUT PVOID *NdisDeviceHandle
  793. )
  794. //////////////////////////////////////////////////////////////////////////////
  795. {
  796. NDIS_STATUS status;
  797. status = NdisMRegisterDevice ((NDIS_HANDLE) NdisWrapperHandle,
  798. DeviceName,
  799. SymbolicName,
  800. pDispatchTable,
  801. pDeviceObject,
  802. (NDIS_HANDLE *) NdisDeviceHandle);
  803. return (NTSTATUS) status;
  804. }
  805. //////////////////////////////////////////////////////////////////////////////
  806. NTSTATUS
  807. StreamIndicateEvent (
  808. IN PVOID pvEvent
  809. )
  810. //////////////////////////////////////////////////////////////////////////////
  811. {
  812. NTSTATUS ntStatus = STATUS_SUCCESS;
  813. //ntStatus = StreamIPIndicateEvent (pvEvent);
  814. return ntStatus;
  815. }
  816. //////////////////////////////////////////////////////////////////////////////
  817. NTSTATUS
  818. IndicateCallbackHandler (
  819. IN NDIS_HANDLE ndishMiniport,
  820. IN PINDICATE_CONTEXT pIndicateContext
  821. )
  822. //////////////////////////////////////////////////////////////////////////////
  823. {
  824. PFRAME pFrame = NULL;
  825. PVOID pvData = NULL;
  826. ULONG ulcbData = 0L;
  827. NTSTATUS ntStatus = STATUS_SUCCESS;
  828. PADAPTER pAdapter;
  829. pAdapter = pIndicateContext->pAdapter;
  830. //
  831. // Take the source data and stuff the data into a FRAME object
  832. //
  833. while ((pFrame = GetFrame (pAdapter->pFramePool, &pAdapter->pFramePool->leIndicateQueue)) != NULL)
  834. {
  835. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIP: Getting Frame (%08X) from Indicate Queue\n", pFrame));
  836. //
  837. // Indicate the NDIS packet
  838. //
  839. ntStatus = IndicateFrame (pFrame, pFrame->ulcbData);
  840. }
  841. if (pFrame == NULL)
  842. {
  843. TEST_DEBUG (TEST_DBG_TRACE, ("NdisIP: No more frames on Indicate Queue\n", pFrame));
  844. }
  845. //
  846. // Free up the context area. NOTE: this is alloc'ed in the indicate handler
  847. //
  848. FreeMemory (pIndicateContext, sizeof (INDICATE_CONTEXT));
  849. return ntStatus;
  850. }