ITek_init.c
上传用户:cnfair
上传日期:2007-01-07
资源大小:32k
文件大小:38k
源码类别:

驱动编程

开发平台:

Visual C++

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. //to use the following functions from standard c-library directly
  4. #include  <string.h>
  5. #pragma intrinsic(memcpy, memcmp, memset, strcat, strcmp, strcpy, strlen)
  6. #pragma warning(disable:4201 4514 4100)
  7. //to include Windows95 DDK header files
  8. //
  9. #include  <basedef.h>
  10. #include  <vmm.h>
  11. #include  <debug.h>
  12. #include  <ndis.h>
  13. #include  <vwin32.h>
  14. #include  <efilter.h>
  15. #include "ITek_type.h"
  16. #include "ITek_init.h"
  17. #include "ITek_util.h"
  18. #pragma VxD_LOCKED_CODE_SEG
  19. #pragma VxD_LOCKED_DATA_SEG
  20. NDIS_PHYSICAL_ADDRESS HighestPhysicalAddress = NDIS_PHYSICAL_ADDRESS_CONST(-1,-1);
  21. //candidates for the global vars.
  22. DRIVER_BLOCK        gDriverBlock = {0};
  23. // ITEK MAC supports the following OIDs(Object IDentifiers)
  24. STATIC UINT ITEKSupportedOids[] = 
  25. {
  26. //General Operational Characteristics
  27. OID_GEN_SUPPORTED_LIST,
  28. OID_GEN_HARDWARE_STATUS,
  29. OID_GEN_MEDIA_SUPPORTED,
  30. OID_GEN_MEDIA_IN_USE,
  31. OID_GEN_MAXIMUM_LOOKAHEAD,
  32. OID_GEN_MAXIMUM_FRAME_SIZE,
  33. OID_GEN_LINK_SPEED,
  34. OID_GEN_TRANSMIT_BUFFER_SPACE,
  35. OID_GEN_RECEIVE_BUFFER_SPACE,
  36. OID_GEN_TRANSMIT_BLOCK_SIZE,
  37. OID_GEN_RECEIVE_BLOCK_SIZE,
  38. OID_GEN_VENDOR_ID,
  39. OID_GEN_VENDOR_DESCRIPTION,
  40. OID_GEN_CURRENT_PACKET_FILTER,
  41. OID_GEN_CURRENT_LOOKAHEAD,
  42. OID_GEN_DRIVER_VERSION,
  43. OID_GEN_MAXIMUM_TOTAL_SIZE,
  44. OID_GEN_PROTOCOL_OPTIONS,
  45. OID_GEN_MAC_OPTIONS,
  46. //OID_GEN_MEDIA_CONNECT_STATUS,
  47. //OID_GEN_MAXIMUM_SEND_PACKETS,
  48. //General Statistics
  49. OID_GEN_XMIT_OK,
  50. OID_GEN_RCV_OK,
  51. OID_GEN_XMIT_ERROR,
  52. OID_GEN_RCV_ERROR,
  53. OID_GEN_RCV_NO_BUFFER,
  54. OID_GEN_DIRECTED_BYTES_XMIT,
  55. OID_GEN_DIRECTED_FRAMES_XMIT,
  56. OID_GEN_DIRECTED_BYTES_RCV,
  57. OID_GEN_DIRECTED_FRAMES_RCV,
  58. OID_GEN_RCV_CRC_ERROR,
  59. OID_GEN_TRANSMIT_QUEUE_LENGTH,
  60. //Ethernet Operational Charateraritics
  61. OID_802_3_PERMANENT_ADDRESS,
  62. OID_802_3_CURRENT_ADDRESS,
  63. OID_802_3_MULTICAST_LIST,
  64. OID_802_3_MAXIMUM_LIST_SIZE,
  65. //Ethernet Statistics
  66. OID_802_3_RCV_ERROR_ALIGNMENT,
  67. OID_802_3_XMIT_ONE_COLLISION,
  68. OID_802_3_XMIT_MORE_COLLISIONS,
  69. OID_802_3_XMIT_DEFERRED
  70. };
  71. ///////////////////////////////////////////////////////////////////////////
  72. //
  73. //  DriverEntry
  74. //
  75. ///////////////////////////////////////////////////////////////////////////
  76. NDIS_STATUS NDIS_API
  77. DriverEntry(
  78. IN  PDRIVER_OBJECT  DriverObject,   // NULL in Windows95 CHICAGO
  79. IN  PUNICODE_STRING RegistryPath    // NULL in Windows95 CHICAGO
  80. )
  81. {
  82. NDIS_STATUS         NdisStatus;
  83. NDIS_HANDLE         NdisWrapperHandle = (NDIS_HANDLE)-1;
  84.     PDRIVER_BLOCK pNewMac = &gDriverBlock;
  85.     NDIS_STRING MacName = NDIS_STRING_CONST((PUCHAR)("ITEK"));
  86. #ifdef DEBUG
  87. Debug_Printf("ITEK:DriverEntry() Entryn");
  88. #endif
  89. //to tell NDIS that the ITek ATM  is initializing. 
  90. NdisInitializeWrapper(&NdisWrapperHandle,
  91.           DriverObject,
  92.   RegistryPath,
  93.               NULL);
  94. #ifdef DEBUG
  95. Debug_Printf("ITEK:Wrapper Initialized(0x%x)n", NdisWrapperHandle);
  96. #endif
  97. //here set NdisWrapperHandler to the corresponding global var.
  98. //
  99. pNewMac->DriverObject = DriverObject;
  100. pNewMac->NdisWrapperHandle = NdisWrapperHandle;
  101. pNewMac->NextITek = (PITEK_ADAPTER)NULL;
  102. //to register our NIC callbacks
  103. pNewMac->MacCharacteristics.MajorNdisVersion = ITEK_DRIVER_MAJOR;
  104. pNewMac->MacCharacteristics.MinorNdisVersion = ITEK_DRIVER_MINOR;
  105. pNewMac->MacCharacteristics.Reserved = 0;
  106. pNewMac->MacCharacteristics.OpenAdapterHandler  = ITekOpenAdapter;
  107. pNewMac->MacCharacteristics.CloseAdapterHandler = ITekCloseAdapter;
  108. pNewMac->MacCharacteristics.SendHandler        =  ITekSend;
  109. pNewMac->MacCharacteristics.TransferDataHandler = ITekTransferData;
  110. pNewMac->MacCharacteristics.ResetHandler        = ITekReset;
  111. pNewMac->MacCharacteristics.RequestHandler        = ITekRequest;
  112. pNewMac->MacCharacteristics.QueryGlobalStatisticsHandler = ITekQueryGlobalStatistics;
  113. pNewMac->MacCharacteristics.UnloadMacHandler       = ITekUnload;
  114. pNewMac->MacCharacteristics.AddAdapterHandler      = ITekAddAdapter;
  115. pNewMac->MacCharacteristics.RemoveAdapterHandler   = ITekRemoveAdapter;
  116. pNewMac->MacCharacteristics.Name = MacName;
  117. //to register our NIC driver's entry points and 
  118. //name with the NDIS library when the driver initializes.
  119. NdisRegisterMac(&NdisStatus,
  120. &pNewMac->NdisMacHandle,
  121. NdisWrapperHandle,
  122. (NDIS_HANDLE)&gDriverBlock,
  123. &pNewMac->MacCharacteristics,
  124. sizeof(pNewMac->MacCharacteristics));
  125. //let the device init procedure to handle the result.
  126. if(NdisStatus != NDIS_STATUS_SUCCESS) {
  127. NdisTerminateWrapper(NdisWrapperHandle, NULL);
  128. #ifdef DEBUG
  129. Debug_Printf("ITEK:Registered as Mac Failed(Error#%x), Returnn", NdisStatus);
  130. #endif
  131. } else {
  132. #ifdef DEBUG
  133. Debug_Printf("ITEK:Registered as Mac Succeeded(MacMacContext=0x%x, MacHandle=0x%x) Returnn",
  134. (NDIS_HANDLE)&gDriverBlock, pNewMac->NdisMacHandle);
  135. #endif
  136. }
  137. return (NdisStatus);
  138. }
  139. ///////////////////////////////////////////////////////////////////////////
  140. //  ITekAddAdapter
  141. //
  142. NDIS_STATUS NDIS_API
  143. ITekAddAdapter(
  144. IN NDIS_HANDLE MacMacContext,
  145. IN NDIS_HANDLE ConfigurationHandle,
  146. IN PNDIS_STRING AdapterName
  147. )
  148. {
  149. NDIS_STATUS         NdisStatus;
  150.     PDRIVER_BLOCK pMacContext = (PDRIVER_BLOCK)MacMacContext;
  151. PITEK_ADAPTER      pITekAdapter;
  152.     NDIS_STRING BusTypeStr = NDIS_STRING_CONST((PUCHAR)("BusType"));
  153. NDIS_ADAPTER_INFORMATION AdapterInformation;
  154. #ifdef  DEBUG
  155. Debug_Printf("ITEK:ITekAddAdapter(MacMacContext, ConfigurationHandle, %s) Entryn",
  156. AdapterName->Buffer);
  157. #endif
  158. NdisStatus = NDIS_STATUS_FAILURE;
  159. //alloc the new brabo atm driver
  160. ITekAllocateMemory((PVOID *)&pITekAdapter, sizeof(ITEK_ADAPTER));
  161. if(pITekAdapter == NULL) 
  162. return  (NDIS_STATUS_FAILURE);
  163. NdisZeroMemory(pITekAdapter, sizeof(ITEK_ADAPTER));   
  164. #ifdef  DEBUG
  165. Debug_Printf("ITEK:Allocate One ITek Adapter Object Contextn");
  166. #endif
  167. // Initializing this ITEK adapter object
  168. pITekAdapter->ConfigurationHandle = ConfigurationHandle; //WrapperHandle
  169. pITekAdapter->WrapperHandle =  pMacContext->NdisWrapperHandle;
  170. #ifdef DEBUG
  171. Debug_Printf("ITEK:ConfigurationHandle=0x%x, WrapperHandle=0x%xn",
  172. pITekAdapter->ConfigurationHandle,
  173. pITekAdapter->WrapperHandle);
  174. #endif
  175. pITekAdapter->AdapterType = NdisInterfaceInternal;
  176. pITekAdapter->NicStatus = NIC_DISABLED;
  177. pITekAdapter->MulticastListMax = ITEK_MULTICASTLIST_MAX;
  178. pITekAdapter->PermanentAddress[0] = 0x00;
  179. pITekAdapter->PermanentAddress[1] = 0x00;
  180. pITekAdapter->PermanentAddress[2] = 0x00;
  181. pITekAdapter->PermanentAddress[3] = 0x00;
  182. pITekAdapter->PermanentAddress[4] = 0x00;
  183. pITekAdapter->PermanentAddress[5] = 0x00;
  184. pITekAdapter->CurrentAddress[0] = pITekAdapter->PermanentAddress[0];
  185. pITekAdapter->CurrentAddress[1] = pITekAdapter->PermanentAddress[1];
  186. pITekAdapter->CurrentAddress[2] = pITekAdapter->PermanentAddress[2];
  187. pITekAdapter->CurrentAddress[3] = pITekAdapter->PermanentAddress[3];
  188. pITekAdapter->CurrentAddress[4] = pITekAdapter->PermanentAddress[4];
  189. pITekAdapter->CurrentAddress[5] = pITekAdapter->PermanentAddress[5];
  190. pITekAdapter->DestinationAddress[0] = 0xff;
  191. pITekAdapter->DestinationAddress[1] = 0xff;
  192. pITekAdapter->DestinationAddress[2] = 0xff;
  193. pITekAdapter->DestinationAddress[3] = 0xff;
  194. pITekAdapter->DestinationAddress[4] = 0xff;
  195. pITekAdapter->DestinationAddress[5] = 0xff;
  196. pITekAdapter->pHeadPacket = NULL;
  197. pITekAdapter->pTailPacket = NULL;
  198. pITekAdapter->NicStatus = NIC_CONFIGURING;
  199. // Now we can safely use the ITek ATM NIC's operational registers via its mapped host 
  200. // pointer, pOpRegs.
  201. //add to the global ITek adapter lists
  202. pITekAdapter->NextITek = pMacContext->NextITek;
  203. pMacContext->NextITek = pITekAdapter;
  204. NdisZeroMemory (&AdapterInformation, sizeof(NDIS_ADAPTER_INFORMATION));
  205. AdapterInformation.Master = 0;
  206. AdapterInformation.Dma32BitAddresses = 0;
  207.     AdapterInformation.AdapterType = pITekAdapter->AdapterType;
  208. AdapterInformation.PhysicalMapRegistersNeeded = 0;
  209. AdapterInformation.MaximumPhysicalMapping =  0;
  210.     AdapterInformation.NumberOfPortDescriptors = 0;
  211.     AdapterInformation.PortDescriptors[0].InitialPort = 0;
  212.     AdapterInformation.PortDescriptors[0].NumberOfPorts = 0;
  213. NdisStatus = NdisRegisterAdapter(
  214. &pITekAdapter->ITekAdapterHandle,
  215. pMacContext->NdisMacHandle,
  216. (NDIS_HANDLE)pITekAdapter,
  217. ConfigurationHandle,
  218. AdapterName,
  219. (PVOID)&AdapterInformation); 
  220. if(NdisStatus != NDIS_STATUS_SUCCESS) {
  221. #ifdef  DEBUG
  222. Debug_Printf("ITEK:NdisRegisterAdapter failed(Error#%x)n", NdisStatus);
  223. #endif
  224. return  (NdisStatus);
  225. }
  226. NdisAllocateSpinLock(&pITekAdapter->Lock);
  227. if(EthCreateFilter(
  228. pITekAdapter->MulticastListMax,
  229. ITekAddressChangeAction,
  230. ITekFilterChangeAction,
  231. ITekCloseAction,
  232. pITekAdapter->CurrentAddress,
  233. &pITekAdapter->Lock,
  234. &pITekAdapter->FilterDB) == FALSE)
  235. {
  236. #ifdef  DEBUG
  237. Debug_Printf("ITEK:EthCreateFilter() failedn");
  238. #endif
  239. NdisFreeSpinLock(&pITekAdapter->Lock);
  240. NdisStatus = NDIS_STATUS_FAILURE;
  241. return  (NdisStatus);
  242. #ifdef ITEK_TIMER
  243. NdisInitializeTimer(
  244. &pITekAdapter->NdisTimer,
  245. ITekTimerFunction,
  246. (PVOID)pITekAdapter);
  247. NdisSetTimer(
  248. &pITekAdapter->NdisTimer,
  249. ITEK_TIMEOUT_MSEC); //see datastru.h
  250. #ifdef DEBUG
  251. Debug_Printf("Timer initialized and setn");
  252. #endif
  253. #endif //ITEK_TIMER
  254. pITekAdapter->NicStatus = NIC_ENABLED;
  255. #ifdef  DEBUG
  256. Debug_Printf("ITEK:ITekAddAdapter() Return with 0x%xn", NdisStatus);
  257. #endif
  258. return  (NdisStatus);
  259. }
  260. ///////////////////////////////////////////////////////////////////////////
  261. //  ITekRemoveAdapter
  262. //
  263. VOID NDIS_API
  264. ITekRemoveAdapter(
  265.     IN PVOID MacAdapterContext
  266.     )
  267. {
  268. PITEK_ADAPTER      pITekAdapter = (PITEK_ADAPTER)MacAdapterContext;
  269. #ifdef DEBUG
  270. Debug_Printf("ITEK:ITekRemoveAdapter(MacAdapterContext=0x%x) Entryn", 
  271. MacAdapterContext);
  272. #endif
  273. // free this adapter context
  274. #ifdef DEBUG
  275. Debug_Printf("free this adapter contextn");
  276. #endif
  277. gDriverBlock.NextITek = pITekAdapter->NextITek;
  278. ITekFreeMemory((PVOID)pITekAdapter);
  279. #ifdef DEBUG
  280. Debug_Printf("ITEK:ITekRemoveAdapter() Returnn");
  281. #endif
  282. return;
  283. }
  284. ///////////////////////////////////////////////////////////////////////////
  285. //  ITekOpenAdapter
  286. //
  287. NDIS_STATUS NDIS_API
  288. ITekOpenAdapter(
  289.     OUT PNDIS_STATUS OpenErrorStatus,
  290.     OUT NDIS_HANDLE *MacBindingHandle,
  291.     OUT PUINT SelectedMediumIndex,
  292.     IN PNDIS_MEDIUM MediumArray,
  293.     IN UINT MediumArraySize,
  294.     IN NDIS_HANDLE NdisBindingContext,
  295.     IN NDIS_HANDLE MacAdapterContext,
  296.     IN UINT OpenOptions,
  297.     IN PSTRING AddressingInformation OPTIONAL
  298.     )
  299. {
  300. NDIS_STATUS         NdisStatus;
  301. PITEK_ADAPTER      pITekAdapter = (PITEK_ADAPTER)MacAdapterContext;
  302. PITEK_OPEN pITekOpen = (PITEK_OPEN)NULL;
  303. UINT                uIndex;
  304. #ifdef DEBUG
  305. Debug_Printf("ITEK:ITekOpenAdapter(NdisBindingContext=0x%x) Entryn", NdisBindingContext);
  306. #endif
  307. NdisStatus = NDIS_STATUS_FAILURE;
  308. *OpenErrorStatus = NDIS_STATUS_FAILURE;
  309. //select the supported medium type
  310. for(uIndex = 0; uIndex < MediumArraySize; uIndex) {
  311. if(*(MediumArray+uIndex) == NdisMedium802_3) {
  312. break;
  313. }
  314. }
  315. if(uIndex == MediumArraySize)
  316. return  (NDIS_STATUS_UNSUPPORTED_MEDIA);
  317. *SelectedMediumIndex = uIndex;
  318. ITekAllocateMemory((PVOID *)&pITekOpen, sizeof(ITEK_OPEN));
  319. if(pITekOpen == NULL) {
  320. #ifdef DEBUG
  321. Debug_Printf("Allocating ITEK_OPEN instance failedn");
  322. #endif
  323. return (NDIS_STATUS_RESOURCES);
  324. }
  325. NdisZeroMemory(pITekOpen, sizeof(ITEK_OPEN));   
  326. pITekAdapter->ReferenceCount++;
  327. NdisAcquireSpinLock(&pITekAdapter->Lock);
  328. if(EthNoteFilterOpenAdapter(
  329. pITekAdapter->FilterDB,
  330. pITekOpen,
  331. NdisBindingContext,
  332. &pITekOpen->NdisFilterHandle) == FALSE) {
  333. #ifdef DEBUG
  334. Debug_Printf("EthNoteFilterOpenAdapter() Failedn");
  335. #endif
  336. NdisReleaseSpinLock(&pITekAdapter->Lock);
  337. ITekFreeMemory((PVOID)pITekOpen);
  338. return (NDIS_STATUS_FAILURE);
  339. }
  340. pITekOpen->NextOpen = pITekAdapter->NextOpen;
  341. pITekAdapter->NextOpen = pITekOpen;
  342. pITekOpen->pITekAdapter = pITekAdapter;
  343. pITekOpen->pDriverBlock = &gDriverBlock;
  344. pITekOpen->NdisBindingContext = NdisBindingContext;
  345. pITekOpen->AddressingInformation = AddressingInformation;
  346. pITekOpen->OpenOptions = OpenOptions;
  347. pITekOpen->ProtOptionFlags = 0;
  348. pITekOpen->ReferenceCount = 1;
  349. pITekOpen->Closing = FALSE;
  350. pITekOpen->PacketFilter = 0;
  351. pITekOpen->MaxLookAhead = ITEK_MAX_LOOKAHEAD;
  352. *MacBindingHandle = (NDIS_HANDLE)pITekOpen;
  353. NdisStatus = NDIS_STATUS_SUCCESS;
  354. *OpenErrorStatus = NDIS_STATUS_SUCCESS;
  355. NdisReleaseSpinLock(&pITekAdapter->Lock);
  356. #ifdef DEBUG
  357. Debug_Printf("ITEK:ITekOpenAdapter() Return with MacBindingHandle=0x%xn",
  358. (NDIS_HANDLE)pITekOpen);
  359. #endif
  360. return (NdisStatus);
  361. }
  362. ///////////////////////////////////////////////////////////////////////////
  363. //  ITekCloseAdapter
  364. //
  365. NDIS_STATUS NDIS_API
  366. ITekCloseAdapter(
  367.     IN NDIS_HANDLE MacBindingHandle
  368.     )
  369. {
  370. NDIS_STATUS NdisStatus;
  371. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  372. PITEK_OPEN pTempOpen;
  373. PITEK_ADAPTER pITekAdapter;
  374. #ifdef DEBUG
  375. Debug_Printf("ITEK:ITekCloseAdapter(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
  376. #endif
  377. NdisStatus = NDIS_STATUS_SUCCESS;
  378. pITekAdapter = pITekOpen->pITekAdapter;
  379. if(pITekOpen->Closing == TRUE) {
  380. #ifdef DEBUG
  381. Debug_Printf("ITEK:Closing...Returnn");
  382. #endif
  383. return (NDIS_STATUS_CLOSING);
  384. }
  385. if(pITekOpen == pITekAdapter->NextOpen) {
  386. pITekAdapter->NextOpen =  pITekOpen->NextOpen;
  387. } else {
  388. pTempOpen = pITekAdapter->NextOpen;
  389. while(pTempOpen->NextOpen != pITekOpen) {
  390. pTempOpen = pTempOpen->NextOpen;
  391.         }
  392. pTempOpen->NextOpen = pITekOpen->NextOpen;
  393. }
  394. //pITekOpen->NextOpen = NULL;
  395.     NdisStatus = EthDeleteFilterOpenAdapter(
  396. pITekAdapter->FilterDB,
  397. pITekOpen->NdisFilterHandle,
  398. NULL);
  399. if(NdisStatus != NDIS_STATUS_SUCCESS) {
  400. pITekOpen->Closing = TRUE;
  401. #ifdef DEBUG
  402. Debug_Printf("ITEK:EthDeleteFilterOpenAdapter() pending...n");
  403. #endif
  404. return (NDIS_STATUS_PENDING);
  405. }
  406. pITekOpen->ReferenceCount--;
  407. pITekAdapter->ReferenceCount--;
  408. if(pITekOpen->ReferenceCount == 0) {
  409. #ifdef DEBUG
  410. Debug_Printf("Free Open Instance(0x%x)n", MacBindingHandle);
  411. #endif
  412.         ITekFreeMemory((PVOID)pITekOpen);
  413. }
  414. #ifdef DEBUG
  415. Debug_Printf("ITEK:ITekCloseAdapter() Returnn");
  416. #endif
  417. return (NdisStatus);
  418. }
  419. ///////////////////////////////////////////////////////////////////////////
  420. //  ITekReset
  421. //
  422. NDIS_STATUS NDIS_API
  423. ITekReset(
  424.     IN NDIS_HANDLE MacBindingHandle
  425.     )
  426. {
  427. NDIS_STATUS         NdisStatus;
  428. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  429. PITEK_ADAPTER pITekAdapter;
  430. #ifdef DEBUG
  431. Debug_Printf("ITEK:ITekReset(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
  432. #endif
  433. NdisStatus = NDIS_STATUS_FAILURE;
  434. pITekAdapter = pITekOpen->pITekAdapter;
  435. if(pITekAdapter->NicStatus == NIC_RESETTING) {
  436. #ifdef DEBUG
  437. Debug_Printf("Resetting already progressingn");
  438. #endif
  439. NdisStatus = NDIS_STATUS_RESET_IN_PROGRESS;
  440. } else {
  441. //???
  442. }
  443. #ifdef DEBUG
  444. Debug_Printf("ITEK:ITekReset() Returnn");
  445. #endif
  446. return (NdisStatus);
  447. }
  448. ///////////////////////////////////////////////////////////////////////////
  449. //  ITekRequest
  450. //
  451. NDIS_STATUS NDIS_API
  452. ITekRequest(
  453.     IN NDIS_HANDLE MacBindingHandle,
  454.     IN PNDIS_REQUEST NdisRequest
  455.     )
  456. {
  457. NDIS_STATUS NdisStatus;
  458. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  459. PITEK_ADAPTER pITekAdapter;
  460. ULONG BytesWritten, BytesRead, BytesNeeded;
  461. #ifdef DEBUG
  462. Debug_Printf("ITEK:ITekRequest(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
  463. #endif
  464. pITekAdapter = pITekOpen->pITekAdapter;
  465. BytesWritten = 0;
  466. BytesRead = 0;
  467. BytesNeeded = 0;
  468. if(NdisRequest->RequestType == NdisRequestQueryInformation) {
  469. NdisStatus = ITekQueryInformation(
  470. pITekAdapter,
  471. pITekOpen,
  472. NdisRequest->DATA.QUERY_INFORMATION.Oid,
  473. NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
  474. NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
  475. &BytesWritten,
  476. &BytesNeeded);
  477. NdisRequest->DATA.QUERY_INFORMATION.BytesWritten = (UINT)BytesWritten;
  478. NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
  479.     } else if (NdisRequest->RequestType == NdisRequestSetInformation) {
  480. NdisStatus = ITekSetInformation(
  481. pITekAdapter,
  482. pITekOpen,
  483. NdisRequest,
  484. NdisRequest->DATA.SET_INFORMATION.Oid,
  485. NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
  486. NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
  487. &BytesRead,
  488. &BytesNeeded);
  489. NdisRequest->DATA.SET_INFORMATION.BytesRead = (UINT)BytesRead;
  490. NdisRequest->DATA.SET_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
  491.     } else {
  492. NdisStatus = NDIS_STATUS_NOT_RECOGNIZED;
  493.     }
  494. //NdisCompleteRequest(
  495. // pITekOpen->NdisBindingContext,
  496. // NdisRequest,
  497. // NDIS_STATUS_SUCCESS
  498. // );
  499.  
  500. #ifdef DEBUG
  501. Debug_Printf("ITEK:ITekRequest() Returnn");
  502. #endif
  503. return (NdisStatus);
  504. }
  505. ///////////////////////////////////////////////////////////////////////////
  506. //  ITekQueryGlobalStatistics
  507. //
  508. NDIS_STATUS NDIS_API
  509. ITekQueryGlobalStatistics(
  510.     IN NDIS_HANDLE MacBindingHandle,
  511.     IN PNDIS_REQUEST NdisRequest
  512.     )
  513. {
  514. NDIS_STATUS NdisStatus;
  515. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  516. PITEK_ADAPTER pITekAdapter;
  517. ULONG BytesWritten, BytesNeeded;
  518. #ifdef DEBUG
  519. Debug_Printf("ITEK:ITekQueryGlobalStatistics() Entryn");
  520. #endif
  521. pITekAdapter = pITekOpen->pITekAdapter;
  522. BytesWritten = 0;
  523. BytesNeeded = 0;
  524. NdisStatus = NDIS_STATUS_FAILURE;
  525. NdisStatus = ITekQueryInformation(
  526. pITekAdapter,
  527. pITekOpen,
  528. NdisRequest->DATA.QUERY_INFORMATION.Oid,
  529. NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
  530. NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
  531. &BytesWritten,
  532. &BytesNeeded);
  533. NdisRequest->DATA.QUERY_INFORMATION.BytesWritten = (UINT)BytesWritten;
  534. NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
  535. #ifdef DEBUG
  536. Debug_Printf("ITEK:ITekQueryGlobalStatistics() Return(0x%x)n",
  537. NdisStatus);
  538. #endif
  539. return (NdisStatus);
  540. }
  541. ///////////////////////////////////////////////////////////////////////////
  542. //  ITekUnload
  543. //
  544. VOID NDIS_API
  545. ITekUnload(
  546.     IN NDIS_HANDLE MacMacContext
  547.     )
  548. {
  549. NDIS_STATUS NdisStatus;
  550. PDRIVER_BLOCK pMacContext = (PDRIVER_BLOCK)MacMacContext;
  551. #ifdef DEBUG
  552. Debug_Printf("ITEK:ITekUnload(MacMacContext=0x%x) Entryn",
  553. MacMacContext);
  554. #endif
  555. NdisDeregisterMac(
  556. &NdisStatus,
  557. pMacContext->NdisMacHandle
  558. );
  559. NdisTerminateWrapper(
  560. pMacContext->NdisWrapperHandle,
  561. NULL
  562. );
  563. #ifdef DEBUG
  564. Debug_Printf("ITEK:ITekUnload() Returnn");
  565. #endif
  566. return;
  567. }
  568. ///////////////////////////////////////////////////////////////////////////
  569. //  ITekTransferData
  570. //
  571. NDIS_STATUS NDIS_API
  572. ITekTransferData(
  573.     IN NDIS_HANDLE MacBindingHandle,
  574.     IN NDIS_HANDLE MacReceiveContext,
  575.     IN UINT ByteOffset,
  576.     IN UINT BytesToTransfer,
  577.     OUT PNDIS_PACKET Packet,
  578.     OUT PUINT BytesTransferred
  579.     )
  580. {
  581. NDIS_STATUS         NdisStatus;
  582. #ifdef DEBUG
  583. Debug_Printf("ITEK:ITekTransferData() Entryn");
  584. #endif
  585. NdisStatus = NDIS_STATUS_FAILURE;
  586. #ifdef DEBUG
  587. Debug_Printf("ITEK:ITekTransferData() Returnn");
  588. #endif
  589. return (NdisStatus);
  590. }
  591. ///////////////////////////////////////////////////////////////////////////
  592. //  ITekSend
  593. //
  594. NDIS_STATUS NDIS_API
  595. ITekSend(
  596.     IN NDIS_HANDLE MacBindingHandle,
  597.     IN PNDIS_PACKET Packet
  598.     )
  599. {
  600. NDIS_STATUS NdisStatus;
  601. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  602. PITEK_ADAPTER pITekAdapter;
  603. PNDIS_BUFFER pNdisBuffer;
  604. UINT PhysicalBufferCount;
  605. UINT BufferCount, BufferLength;
  606. UINT TotalPacketLength;
  607. PCHAR pHdrData;
  608. #ifdef DEBUG
  609. Debug_Printf("ITEK:ITekSend(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
  610. #endif
  611. NdisStatus = NDIS_STATUS_SUCCESS;
  612. pITekAdapter = pITekOpen->pITekAdapter;
  613. if(pITekOpen->Closing == TRUE) {
  614. #ifdef DEBUG
  615. Debug_Printf("ITEK:Closing...n");
  616. #endif
  617. return (NDIS_STATUS_CLOSING);
  618. }
  619. NdisQueryPacket(
  620. Packet,
  621. &PhysicalBufferCount,
  622. &BufferCount,
  623. &pNdisBuffer,
  624. &TotalPacketLength);
  625. NdisQueryBuffer(
  626. pNdisBuffer,
  627. (PVOID *)&pHdrData,
  628. &BufferLength);
  629. if(BufferLength < ITEK_PDU_HDRSIZE) {
  630. NdisStatus = NDIS_STATUS_FAILURE;
  631. return (NdisStatus);
  632. }
  633. ITEK_RESERVED(Packet)->pITekOpen = pITekOpen;
  634. if(pITekAdapter->pHeadPacket == NULL) {
  635. pITekAdapter->pHeadPacket = Packet;
  636. } else {
  637. ITEK_RESERVED(pITekAdapter->pTailPacket)->pNextPacket = Packet;
  638. }
  639. ITEK_RESERVED(Packet)->pNextPacket = NULL;
  640. pITekAdapter->pTailPacket = Packet;
  641. //ITekNextSend(pITekAdapter);
  642.         //NdisStatus = NDIS_STATUS_PENDING;
  643.         NdisStatus = NDIS_STATUS_SUCCESS;
  644. #ifdef DEBUG
  645. Debug_Printf("ITEK:ITekSend() returnn");
  646. #endif
  647. return  (NdisStatus);
  648. }
  649. ///////////////////////////////////////////////////////////////////////////
  650. //  ITekQueryInformation
  651. //
  652. NDIS_STATUS NDIS_API 
  653. ITekQueryInformation(
  654. IN  NDIS_HANDLE ITekAdapterContext,
  655. IN NDIS_HANDLE ITekOpenContext,
  656. IN  NDIS_OID    Oid,
  657. IN  PVOID       InformationBuffer,
  658. IN  ULONG       InformationBufferLength,
  659. OUT PULONG      BytesWritten,
  660. OUT PULONG      BytesNeeded
  661. )
  662. {
  663. PITEK_ADAPTER      pITekAdapter = (PITEK_ADAPTER)ITekAdapterContext;
  664. PITEK_OPEN pITekOpen = (PITEK_OPEN)ITekOpenContext;
  665. NDIS_STATUS NdisStatus;
  666. ULONG InfoSize;
  667. ULONG InfoULONG;
  668. USHORT InfoUSHORT;
  669. PVOID InfoSource;
  670. NDIS_HARDWARE_STATUS NicStatus;
  671. NDIS_MEDIUM NicMedium;
  672. InfoSource = (PVOID)&InfoULONG;
  673. InfoSize = 4;
  674. #ifdef DEBUG
  675. Debug_Printf("ITEK:ITekQueryInformation() Entryn");
  676. #endif
  677. NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
  678. switch(Oid) {
  679. //General Operational Charateristics
  680. case OID_GEN_SUPPORTED_LIST:
  681. InfoSource = (PVOID)ITEKSupportedOids;
  682. InfoSize = sizeof(ITEKSupportedOids);
  683. NdisStatus = NDIS_STATUS_SUCCESS;
  684. #ifdef DEBUG
  685. Debug_Printf("Query OID_GEN_SUPPORTED_LIST=size(%u bytes)n", InfoSize);
  686. #endif
  687. break;
  688. case OID_GEN_HARDWARE_STATUS:
  689. if(pITekAdapter->NicStatus == NIC_DISABLED) {
  690. //NicStatus = NdisHardwareStatusNotReady;
  691. NicStatus = NdisHardwareStatusInitializing;
  692. #ifdef DEBUG
  693. Debug_Printf("Query OID_GEN_HARDWARE_STATUS=Initializingn");
  694. #endif
  695. } else {
  696. NicStatus = NdisHardwareStatusReady;
  697. #ifdef DEBUG
  698. Debug_Printf("Query OID_GEN_HARDWARE_STATUS=Readyn");
  699. #endif
  700. }
  701. InfoSource = (PVOID)&NicStatus;
  702. InfoSize = sizeof(NDIS_HARDWARE_STATUS);
  703. NdisStatus = NDIS_STATUS_SUCCESS;
  704. break;
  705. case OID_GEN_MEDIA_SUPPORTED:
  706. case OID_GEN_MEDIA_IN_USE:
  707. #ifdef DEBUG
  708. Debug_Printf("Query OID_GEN_MEDIA_SUPPORTED or OID_GEN_MEDIA_IN_USE=802.3(Ethernet)n");
  709. #endif
  710. NicMedium = NdisMedium802_3;
  711. InfoSource = (PVOID)&NicMedium;
  712. InfoSize = sizeof(NDIS_MEDIUM);
  713. NdisStatus = NDIS_STATUS_SUCCESS;
  714. break;
  715. case OID_GEN_MAXIMUM_LOOKAHEAD:
  716. InfoULONG = ITEK_MAX_LOOKAHEAD;
  717. NdisStatus = NDIS_STATUS_SUCCESS;
  718. #ifdef DEBUG
  719. Debug_Printf("Query OID_GEN_MAXIMUM_LOOKAHEAD=%un",InfoULONG);
  720. #endif
  721. break;
  722. case OID_GEN_MAXIMUM_FRAME_SIZE:
  723. InfoULONG = ITEK_SDU_MAXSIZE; // not equal to Ethernet MTU size (1514-14)
  724. NdisStatus = NDIS_STATUS_SUCCESS;
  725. #ifdef DEBUG
  726. Debug_Printf("Query OID_GEN_MAXIMUM_FRAME_SIZE=%un", InfoULONG);
  727. #endif
  728. break;
  729. case OID_GEN_LINK_SPEED:
  730. InfoULONG = 100000; // 25Mbps
  731. NdisStatus = NDIS_STATUS_SUCCESS;
  732. #ifdef DEBUG
  733. Debug_Printf("Query OID_GEN_LINK_SPEED=%u bpsn", InfoULONG*100);
  734. #endif
  735. break;
  736. case OID_GEN_TRANSMIT_BUFFER_SPACE:
  737. InfoULONG = ITEK_TX_MAXSIZE;
  738. NdisStatus = NDIS_STATUS_SUCCESS;
  739. #ifdef DEBUG
  740. Debug_Printf("Query OID_GEN_TRANSMIT_BUFFER_SPACE=%u bytesn", InfoULONG);
  741. #endif
  742. break;
  743. case OID_GEN_RECEIVE_BUFFER_SPACE:
  744. InfoULONG = 1520;
  745. NdisStatus = NDIS_STATUS_SUCCESS;
  746. #ifdef DEBUG
  747. Debug_Printf("Query OID_GEN_RECEIVE_BUFFER_SPACE=%un", InfoULONG);
  748. #endif
  749. break;
  750. case OID_GEN_TRANSMIT_BLOCK_SIZE:
  751. InfoULONG = ITEK_TX_MINSIZE;
  752. NdisStatus = NDIS_STATUS_SUCCESS;
  753. #ifdef DEBUG
  754. Debug_Printf("Query OID_GEN_TRANSMIT_BLOCK_SIZE=%u bytes(Min.),%u bytes(Max.)n",InfoULONG, ITEK_TX_MAXSIZE);
  755. #endif
  756. break;
  757. case OID_GEN_RECEIVE_BLOCK_SIZE:
  758. InfoULONG = 1520;
  759. NdisStatus = NDIS_STATUS_SUCCESS;
  760. //InfoULONG = ITEK_SDU_MAXSIZE;
  761. #ifdef DEBUG
  762. Debug_Printf("Query OID_GEN_RECEIVE_BLOCK_SIZE=%un", InfoULONG);
  763. #endif
  764. break;
  765. case OID_GEN_VENDOR_ID:
  766. InfoULONG = ITEK_VENDOR_ID;
  767. NdisStatus = NDIS_STATUS_SUCCESS;
  768. #ifdef DEBUG
  769. Debug_Printf("Query OID_GEN_VENDOR_ID=0x%xn", InfoULONG);
  770. #endif
  771. break;
  772. case OID_GEN_VENDOR_DESCRIPTION:
  773. InfoSource = (PVOID)ITEK_DESCRIPTION;
  774. InfoSize = strlen(ITEK_DESCRIPTION);
  775. NdisStatus = NDIS_STATUS_SUCCESS;
  776. #ifdef DEBUG
  777. Debug_Printf("Query OID_GEN_VENDOR_DESCRIPTION=%s(%u)n", ITEK_DESCRIPTION, InfoSize);
  778. #endif
  779. break;
  780. // case OID_GEN_VENDOR_DRIVER_VERSION:
  781. //#ifdef DEBUG
  782. // Debug_Printf("Query OID_GEN_VENDOR_DRIVER_VERSIONn");
  783. //#endif
  784. // break;
  785. case OID_GEN_CURRENT_PACKET_FILTER:
  786. InfoULONG = pITekOpen->PacketFilter;
  787. NdisStatus = NDIS_STATUS_SUCCESS;
  788. #ifdef DEBUG
  789. Debug_Printf("Query OID_GEN_CURRENT_PACKET_FILTER=0x%xn",InfoULONG);
  790. #endif
  791. break;
  792. case OID_GEN_CURRENT_LOOKAHEAD:
  793. InfoULONG = ITEK_MAX_LOOKAHEAD;
  794. NdisStatus = NDIS_STATUS_SUCCESS;
  795. #ifdef DEBUG
  796. Debug_Printf("Query OID_GEN_CURRENT_LOOKAHEAD=%u bytesn", InfoULONG);
  797. #endif
  798. break;
  799. case OID_GEN_DRIVER_VERSION:
  800. InfoUSHORT = (ITEK_DRIVER_MAJOR << 8) | ITEK_DRIVER_MINOR;
  801. InfoSource = (PVOID)&InfoUSHORT;
  802. InfoSize = sizeof(InfoUSHORT);
  803. NdisStatus = NDIS_STATUS_SUCCESS;
  804. #ifdef DEBUG
  805. Debug_Printf("Query OID_GEN_DRIVER_VERSION=0x%xn", InfoUSHORT);
  806. #endif
  807. break;
  808. case OID_GEN_MAXIMUM_TOTAL_SIZE:
  809. #ifdef DEBUG
  810. Debug_Printf("Query OID_GEN_MAXIMUM_TOTAL_SIZE, not yet supported!n");
  811. #endif
  812. break;
  813. case OID_GEN_PROTOCOL_OPTIONS:
  814. #ifdef DEBUG
  815. Debug_Printf("Query OID_GEN_PROTOCOL_OPTIONS, not yet supported!n");
  816. #endif
  817. break;
  818. case OID_GEN_MAC_OPTIONS:
  819. InfoULONG = (ULONG)(NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | 
  820. NDIS_MAC_OPTION_RECEIVE_SERIALIZED | 
  821. NDIS_MAC_OPTION_TRANSFERS_NOT_PEND |
  822. NDIS_MAC_OPTION_NO_LOOPBACK );
  823. //NDIS_MAC_OPTION_FULL_DUPLEX);
  824. NdisStatus = NDIS_STATUS_SUCCESS;
  825. #ifdef DEBUG
  826. Debug_Printf("Query OID_GEN_MAC_OPTIONS =%un", InfoULONG);
  827. #endif
  828. break;
  829. //General Statistics Charateristics
  830. case OID_GEN_XMIT_OK:
  831. #ifdef DEBUG
  832. Debug_Printf("Query OID_GEN_XMIT_OK, not yet supported!n");
  833. #endif
  834. break;
  835. case OID_GEN_RCV_OK:
  836. #ifdef DEBUG
  837. Debug_Printf("Query OID_GEN_RCV_OK, not yet supported!n");
  838. #endif
  839. break;
  840. case OID_GEN_XMIT_ERROR:
  841. #ifdef DEBUG
  842. Debug_Printf("Query OID_GEN_XMIT_ERROR, not yet supported!n");
  843. #endif
  844. break;
  845. case OID_GEN_RCV_ERROR:
  846. #ifdef DEBUG
  847. Debug_Printf("Query OID_GEN_RCV_ERROR, not yet supported!n");
  848. #endif
  849. break;
  850. case OID_GEN_RCV_NO_BUFFER:
  851. #ifdef DEBUG
  852. Debug_Printf("Query OID_GEN_RCV_NO_BUFFER, not yet supported!n");
  853. #endif
  854. break;
  855. case OID_GEN_DIRECTED_BYTES_XMIT:
  856. #ifdef DEBUG
  857. Debug_Printf("Query OID_GEN_DIRECTED_BYTES_XMIT, not yet supported!n");
  858. #endif
  859. break;
  860. case OID_GEN_DIRECTED_FRAMES_XMIT:
  861. #ifdef DEBUG
  862. Debug_Printf("Query OID_GEN_DIRECTED_FRAMES_XMIT, not yet supported!n");
  863. #endif
  864. break;
  865. case OID_GEN_MULTICAST_BYTES_XMIT:
  866. #ifdef DEBUG
  867. Debug_Printf("Query OID_GEN_MULTICAST_BYTES_XMIT, not yet supported!n");
  868. #endif
  869. break;
  870. case OID_GEN_MULTICAST_FRAMES_XMIT:
  871. #ifdef DEBUG
  872. Debug_Printf("Query OID_GEN_MULTICAST_FRAMES_XMIT, not yet supported!n");
  873. #endif
  874. break;
  875. case OID_GEN_BROADCAST_BYTES_XMIT:
  876. #ifdef DEBUG
  877. Debug_Printf("Query OID_GEN_BROADCAST_BYTES_XMIT, not yet supported!n");
  878. #endif
  879. break;
  880. case OID_GEN_BROADCAST_FRAMES_XMIT:
  881. #ifdef DEBUG
  882. Debug_Printf("Query OID_GEN_BROADCAST_FRAMES_XMIT, not yet supported!n");
  883. #endif
  884. break;
  885. case OID_GEN_DIRECTED_BYTES_RCV:
  886. #ifdef DEBUG
  887. Debug_Printf("Query OID_GEN_DIRECTED_BYTES_RCV, not yet supported!n");
  888. #endif
  889. break;
  890. case OID_GEN_DIRECTED_FRAMES_RCV:
  891. #ifdef DEBUG
  892. Debug_Printf("Query OID_GEN_DIRECTED_FRAMES_RCV, not yet supported!n");
  893. #endif
  894. break;
  895. case OID_GEN_MULTICAST_BYTES_RCV:
  896. #ifdef DEBUG
  897. Debug_Printf("Query OID_GEN_MULTICAST_BYTES_RCV, not yet supported!n");
  898. #endif
  899. break;
  900. case OID_GEN_MULTICAST_FRAMES_RCV:
  901. #ifdef DEBUG
  902. Debug_Printf("Query OID_GEN_MULTICAST_FRAMES_RCV, not yet supported!n");
  903. #endif
  904. break;
  905. case OID_GEN_BROADCAST_BYTES_RCV:
  906. #ifdef DEBUG
  907. Debug_Printf("Query OID_GEN_BROADCAST_BYTES_RCV, not yet supported!n");
  908. #endif
  909. break;
  910. case OID_GEN_BROADCAST_FRAMES_RCV:
  911. #ifdef DEBUG
  912. Debug_Printf("Query OID_GEN_BROADCAST_FRAMES_RCV, not yet supported!n");
  913. #endif
  914. break;
  915. case OID_GEN_RCV_CRC_ERROR:
  916. #ifdef DEBUG
  917. Debug_Printf("Query OID_GEN_RCV_CRC_ERROR, not yet supported!n");
  918. #endif
  919. break;
  920. case OID_GEN_TRANSMIT_QUEUE_LENGTH:
  921. #ifdef DEBUG
  922. Debug_Printf("Query OID_GEN_TRANSMIT_QUEUE_LENGTH, not yet supported!n");
  923. #endif
  924. break;
  925. //Ethernet Operational Charateristics
  926. case OID_802_3_PERMANENT_ADDRESS:
  927. InfoSource = (PVOID)pITekAdapter->PermanentAddress;
  928. InfoSize = sizeof(pITekAdapter->PermanentAddress);
  929. NdisStatus = NDIS_STATUS_SUCCESS;
  930. #ifdef DEBUG
  931. Debug_Printf("Query OID_802_3_PERMANENT_ADDRESS=%x:%x:%x:%x:%x:%xn", (UCHAR)pITekAdapter->PermanentAddress[0]
  932. , (UCHAR)pITekAdapter->PermanentAddress[1], (UCHAR)pITekAdapter->PermanentAddress[2]
  933. , (UCHAR)pITekAdapter->PermanentAddress[3], (UCHAR)pITekAdapter->PermanentAddress[4]
  934. , (UCHAR)pITekAdapter->PermanentAddress[5]);
  935. #endif
  936. break;
  937. case OID_802_3_CURRENT_ADDRESS:
  938. InfoSource = (PVOID)pITekAdapter->CurrentAddress;
  939. InfoSize = sizeof(pITekAdapter->CurrentAddress);
  940. NdisStatus = NDIS_STATUS_SUCCESS;
  941. #ifdef DEBUG
  942. Debug_Printf("Query OID_802_3_CURRENT_ADDRESS=%x:%x:%x:%x:%x:%xn", (UCHAR)pITekAdapter->CurrentAddress[0]
  943. , (UCHAR)pITekAdapter->CurrentAddress[1], (UCHAR)pITekAdapter->CurrentAddress[2]
  944. , (UCHAR)pITekAdapter->CurrentAddress[3], (UCHAR)pITekAdapter->CurrentAddress[4]
  945. , (UCHAR)pITekAdapter->CurrentAddress[5]);
  946. #endif
  947. break;
  948. case OID_802_3_MAXIMUM_LIST_SIZE:
  949. InfoULONG = pITekAdapter->MulticastListMax;
  950. NdisStatus = NDIS_STATUS_SUCCESS;
  951. #ifdef DEBUG
  952. Debug_Printf("Query OID_802_3_MAXIMUM_LIST_SIZE=%un", InfoULONG);
  953. #endif
  954. break;
  955. case OID_802_3_MULTICAST_LIST:
  956. #ifdef DEBUG
  957. Debug_Printf("Query OID_802_3_MULTICAST_LIST, not yet supportedn");
  958. #endif
  959. break;
  960. //Ethernet Statistics 
  961. case OID_802_3_RCV_ERROR_ALIGNMENT:
  962. #ifdef DEBUG
  963. Debug_Printf("Query OID_802_3_RCV_ERROR_ALIGNMENT, not yet supportedn");
  964. #endif
  965. break;
  966. case OID_802_3_XMIT_ONE_COLLISION:
  967. #ifdef DEBUG
  968. Debug_Printf("Query OID_802_3_XMIT_ONE_COLLISION, not yet supportedn");
  969. #endif
  970. break;
  971. case OID_802_3_XMIT_MORE_COLLISIONS:
  972. #ifdef DEBUG
  973. Debug_Printf("Query OID_802_3_XMIT_MORE_COLLISIONS, not yet supportedn");
  974. #endif
  975. break;
  976. case OID_802_3_XMIT_DEFERRED:
  977. #ifdef DEBUG
  978. Debug_Printf("Query OID_802_3_XMIT_DEFERRED, not yet supportedn");
  979. #endif
  980. break;
  981. case OID_802_3_XMIT_MAX_COLLISIONS:
  982. #ifdef DEBUG
  983. Debug_Printf("Query OID_802_3_XMIT_MAX_COLLISIONS, not yet supportedn");
  984. #endif
  985. break;
  986. case OID_802_3_RCV_OVERRUN:
  987. #ifdef DEBUG
  988. Debug_Printf("Query OID_802_3_RCV_OVERRUN, not yet supportedn");
  989. #endif
  990. break;
  991. case OID_802_3_XMIT_UNDERRUN:
  992. #ifdef DEBUG
  993. Debug_Printf("Query OID_802_3_XMIT_UNDERRUN, not yet supportedn");
  994. #endif
  995. break;
  996. case OID_802_3_XMIT_HEARTBEAT_FAILURE:
  997. #ifdef DEBUG
  998. Debug_Printf("Query OID_802_3_XMIT_HEARTBEAT_FAILURE, not yet supportedn");
  999. #endif
  1000. break;
  1001. case OID_802_3_XMIT_TIMES_CRS_LOST:
  1002. #ifdef DEBUG
  1003. Debug_Printf("Query OID_802_3_XMIT_TIMES_CRS_LOST, not yet supportedn");
  1004. #endif
  1005. break;
  1006. case OID_802_3_XMIT_LATE_COLLISIONS:
  1007. #ifdef DEBUG
  1008. Debug_Printf("Query OID_802_3_XMIT_LATE_COLLISIONS, not yet supportedn");
  1009. #endif
  1010. break;
  1011. default:
  1012. #ifdef DEBUG
  1013. Debug_Printf("Qeury Unknownn");
  1014. #endif
  1015. NdisStatus = NDIS_STATUS_INVALID_OID;
  1016. break;
  1017. } //switch(Oid)
  1018. if(NdisStatus == NDIS_STATUS_SUCCESS){
  1019. if (InfoSize > InformationBufferLength){
  1020. *BytesNeeded = InfoSize;
  1021. NdisStatus = NDIS_STATUS_INVALID_LENGTH;
  1022. } else {
  1023. memcpy(InformationBuffer, InfoSource, InfoSize);
  1024. (*BytesWritten) += InfoSize;
  1025. }
  1026. }
  1027.     
  1028. #ifdef DEBUG
  1029. Debug_Printf("ITEK:ITekQueryInformation() Return with %xn",NdisStatus);
  1030. #endif
  1031. return  (NdisStatus);
  1032. }
  1033. ///////////////////////////////////////////////////////////////////////////
  1034. //  ITekSetInformation
  1035. //
  1036. NDIS_STATUS NDIS_API 
  1037. ITekSetInformation(
  1038. IN  NDIS_HANDLE ITekAdapterContext,
  1039. IN NDIS_HANDLE ITekOpenContext,
  1040. IN PNDIS_REQUEST NdisRequest,
  1041. IN  NDIS_OID    Oid,
  1042. IN  PVOID       InformationBuffer,
  1043. IN  ULONG       InformationBufferLength,
  1044. OUT PULONG      BytesRead,
  1045. OUT PULONG      BytesNeeded
  1046. )
  1047. {
  1048. PITEK_ADAPTER      pITekAdapter = (PITEK_ADAPTER)ITekAdapterContext;
  1049. PITEK_OPEN pITekOpen = (PITEK_OPEN)ITekOpenContext;
  1050. NDIS_STATUS NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
  1051. ULONG PacketFilter;
  1052. PUCHAR InfoSource;
  1053. #ifdef DEBUG
  1054. Debug_Printf("ITEK:ITekSetInformation() Entryn");
  1055. #endif
  1056. InfoSource = (PUCHAR)InformationBuffer;
  1057. //we don't need these objects at all.
  1058. switch(Oid) {
  1059. // General Operational Charateristics
  1060. case OID_GEN_CURRENT_PACKET_FILTER:
  1061. if(InformationBufferLength != 4) {
  1062. NdisStatus = NDIS_STATUS_INVALID_LENGTH;
  1063. *BytesRead = 0;
  1064. *BytesNeeded = 0;
  1065. #ifdef DEBUG
  1066. Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - INVALID_LENGTHn");
  1067. #endif
  1068. break;
  1069. }
  1070. PacketFilter = *(PULONG)InformationBuffer;
  1071. if(PacketFilter &(NDIS_PACKET_TYPE_SOURCE_ROUTING |
  1072. NDIS_PACKET_TYPE_SMT | NDIS_PACKET_TYPE_MAC_FRAME | 
  1073. NDIS_PACKET_TYPE_FUNCTIONAL | NDIS_PACKET_TYPE_ALL_FUNCTIONAL |
  1074. NDIS_PACKET_TYPE_GROUP)) {
  1075. NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
  1076. *BytesRead = 4;
  1077. *BytesNeeded = 0;
  1078. #ifdef DEBUG
  1079. Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - NOT_ACCEPTEDn");
  1080. #endif
  1081. break;
  1082. } else if(PacketFilter > 0x8000) {
  1083. NdisStatus = NDIS_STATUS_INVALID_DATA;
  1084. *BytesRead = 4;
  1085. *BytesNeeded = 0;
  1086. #ifdef DEBUG
  1087. Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - INVALID_DATAn");
  1088. #endif
  1089. break;
  1090. }
  1091. NdisAcquireSpinLock(&pITekAdapter->Lock);
  1092. NdisStatus = EthFilterAdjust(
  1093. pITekAdapter->FilterDB,
  1094. pITekOpen->NdisFilterHandle,
  1095. NdisRequest,
  1096. PacketFilter,
  1097. TRUE);
  1098. NdisReleaseSpinLock(&pITekAdapter->Lock);
  1099. pITekOpen->PacketFilter = PacketFilter;
  1100. #ifdef DEBUG
  1101. Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER=0x%x with status=0x%xn", 
  1102. PacketFilter, NdisStatus);
  1103. #endif
  1104. break;
  1105. case OID_GEN_CURRENT_LOOKAHEAD:
  1106. //NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
  1107. NdisStatus = NDIS_STATUS_SUCCESS;
  1108. pITekOpen->MaxLookAhead = *(PULONG)InformationBuffer;
  1109. #ifdef DEBUG
  1110. Debug_Printf("Set OID_GEN_CURRENT_LOOKAHEAD(%u), acceptedn", 
  1111. pITekOpen->MaxLookAhead);
  1112. #endif
  1113. break;
  1114. case OID_GEN_PROTOCOL_OPTIONS:
  1115. NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
  1116. #ifdef DEBUG
  1117. Debug_Printf("Set OID_GEN_PROTOCOL_OPTIONS, not acceptedn");
  1118. #endif
  1119. break;
  1120. // Ethernet Operational Characteristics
  1121. case OID_802_3_MULTICAST_LIST:
  1122. //NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
  1123. NdisStatus = NDIS_STATUS_SUCCESS;
  1124. if((InformationBufferLength % ETH_LENGTH_OF_ADDRESS) != 0) {
  1125. NdisStatus = NDIS_STATUS_INVALID_LENGTH;
  1126. *BytesRead = 0;
  1127. *BytesNeeded = 0;
  1128. #ifdef DEBUG
  1129. Debug_Printf("Set OID_802_3_MULTICAST_LIST-INVALID LENGTH(%u)n", 
  1130. InformationBufferLength);
  1131. #endif
  1132. } else {
  1133. NdisAcquireSpinLock(&pITekAdapter->Lock);
  1134. NdisStatus = EthChangeFilterAddresses(
  1135. pITekAdapter->FilterDB,
  1136. pITekOpen->NdisFilterHandle,
  1137. NdisRequest,
  1138. (UINT)(InformationBufferLength/ETH_LENGTH_OF_ADDRESS),
  1139. InformationBuffer,
  1140. TRUE);
  1141. NdisReleaseSpinLock(&pITekAdapter->Lock);
  1142. #ifdef DEBUG
  1143. Debug_Printf("Set OID_802_3_MULTICAST_LIST(%u Addresses), acceptedn", 
  1144. (UINT)(InformationBufferLength/ETH_LENGTH_OF_ADDRESS));
  1145. #endif
  1146. }
  1147. break;
  1148. default:
  1149. #ifdef DEBUG
  1150. Debug_Printf("Set Unknwon Oidn");
  1151. #endif
  1152. NdisStatus = NDIS_STATUS_INVALID_OID;
  1153. *BytesRead = 0;
  1154. *BytesNeeded = 0;
  1155. break;
  1156. } // switch(Oid)
  1157. if(NdisStatus == NDIS_STATUS_SUCCESS) {
  1158. *BytesRead = InformationBufferLength;
  1159. *BytesNeeded = 0;
  1160. }
  1161. #ifdef DEBUG
  1162. Debug_Printf("ITEK:ITekSetInformation() Return with 0x%xn",NdisStatus);
  1163. #endif
  1164. return  (NdisStatus);
  1165. }
  1166. NDIS_STATUS NDIS_API
  1167. ITekAddressChangeAction(
  1168. IN UINT OldFilterCount,
  1169. IN CHAR OldAddresses[][ETH_LENGTH_OF_ADDRESS],
  1170. IN UINT NewFilterCount,
  1171. IN CHAR NewAddresses[][ETH_LENGTH_OF_ADDRESS],
  1172. IN NDIS_HANDLE MacBindingHandle,
  1173. IN PNDIS_REQUEST NdisRequest,
  1174. IN BOOLEAN Set
  1175. )
  1176. {
  1177. NDIS_STATUS NdisStatus;
  1178. #ifdef DEBUG
  1179. Debug_Printf("ITEK:ITekAddressChangeAction(MacBindingHandle=0x%x) Entryn",
  1180. MacBindingHandle);
  1181. #endif
  1182. NdisStatus = NDIS_STATUS_SUCCESS;
  1183. #ifdef DEBUG
  1184. Debug_Printf("ITEK:ITekAddressChangeAction() Returnn");
  1185. #endif
  1186. return (NdisStatus);
  1187. }
  1188. NDIS_STATUS NDIS_API
  1189. ITekFilterChangeAction(
  1190.     IN UINT OldFilterClasses,
  1191.     IN UINT NewFilterClasses,
  1192.     IN NDIS_HANDLE MacBindingHandle,
  1193.     IN PNDIS_REQUEST NdisRequest,
  1194.     IN BOOLEAN Set
  1195.     )
  1196. {
  1197. NDIS_STATUS NdisStatus;
  1198. #ifdef DEBUG
  1199. Debug_Printf("ITEK:ITekFilterChangeAction(OldFilterClasses=0x%x, NewFilterClasses=0x%x, MacBindingHandle=0x%x) Entryn",
  1200. OldFilterClasses, NewFilterClasses, MacBindingHandle);
  1201. #endif
  1202. NdisStatus = NDIS_STATUS_SUCCESS;
  1203. #ifdef DEBUG
  1204. Debug_Printf("ITEK:ITekFilterChangeAction() Returnn");
  1205. #endif
  1206. return (NdisStatus);
  1207. }
  1208. VOID NDIS_API
  1209. ITekCloseAction(
  1210. IN NDIS_HANDLE MacBindingHandle
  1211. )
  1212. {
  1213. PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
  1214. #ifdef DEBUG
  1215. Debug_Printf("ITEK:ITekCloseAction(MacBindingHandle=0x%x) Entryn",
  1216. MacBindingHandle);
  1217. #endif
  1218. pITekOpen->ReferenceCount--;
  1219. #ifdef DEBUG
  1220. Debug_Printf("pITekOpen->ReferenceCount=%un", pITekOpen->ReferenceCount);
  1221. #endif
  1222. #ifdef DEBUG
  1223. Debug_Printf("ITEK:ITekCloseAction Returnn");
  1224. #endif
  1225. return;
  1226. }