ITek_init.c
资源名称:mac.zip [点击查看]
上传用户:cnfair
上传日期:2007-01-07
资源大小:32k
文件大小:38k
源码类别:
驱动编程
开发平台:
Visual C++
- ///////////////////////////////////////////////////////////////////////////
- //
- //to use the following functions from standard c-library directly
- #include <string.h>
- #pragma intrinsic(memcpy, memcmp, memset, strcat, strcmp, strcpy, strlen)
- #pragma warning(disable:4201 4514 4100)
- //to include Windows95 DDK header files
- //
- #include <basedef.h>
- #include <vmm.h>
- #include <debug.h>
- #include <ndis.h>
- #include <vwin32.h>
- #include <efilter.h>
- #include "ITek_type.h"
- #include "ITek_init.h"
- #include "ITek_util.h"
- #pragma VxD_LOCKED_CODE_SEG
- #pragma VxD_LOCKED_DATA_SEG
- NDIS_PHYSICAL_ADDRESS HighestPhysicalAddress = NDIS_PHYSICAL_ADDRESS_CONST(-1,-1);
- //candidates for the global vars.
- DRIVER_BLOCK gDriverBlock = {0};
- // ITEK MAC supports the following OIDs(Object IDentifiers)
- STATIC UINT ITEKSupportedOids[] =
- {
- //General Operational Characteristics
- OID_GEN_SUPPORTED_LIST,
- OID_GEN_HARDWARE_STATUS,
- OID_GEN_MEDIA_SUPPORTED,
- OID_GEN_MEDIA_IN_USE,
- OID_GEN_MAXIMUM_LOOKAHEAD,
- OID_GEN_MAXIMUM_FRAME_SIZE,
- OID_GEN_LINK_SPEED,
- OID_GEN_TRANSMIT_BUFFER_SPACE,
- OID_GEN_RECEIVE_BUFFER_SPACE,
- OID_GEN_TRANSMIT_BLOCK_SIZE,
- OID_GEN_RECEIVE_BLOCK_SIZE,
- OID_GEN_VENDOR_ID,
- OID_GEN_VENDOR_DESCRIPTION,
- OID_GEN_CURRENT_PACKET_FILTER,
- OID_GEN_CURRENT_LOOKAHEAD,
- OID_GEN_DRIVER_VERSION,
- OID_GEN_MAXIMUM_TOTAL_SIZE,
- OID_GEN_PROTOCOL_OPTIONS,
- OID_GEN_MAC_OPTIONS,
- //OID_GEN_MEDIA_CONNECT_STATUS,
- //OID_GEN_MAXIMUM_SEND_PACKETS,
- //General Statistics
- OID_GEN_XMIT_OK,
- OID_GEN_RCV_OK,
- OID_GEN_XMIT_ERROR,
- OID_GEN_RCV_ERROR,
- OID_GEN_RCV_NO_BUFFER,
- OID_GEN_DIRECTED_BYTES_XMIT,
- OID_GEN_DIRECTED_FRAMES_XMIT,
- OID_GEN_DIRECTED_BYTES_RCV,
- OID_GEN_DIRECTED_FRAMES_RCV,
- OID_GEN_RCV_CRC_ERROR,
- OID_GEN_TRANSMIT_QUEUE_LENGTH,
- //Ethernet Operational Charateraritics
- OID_802_3_PERMANENT_ADDRESS,
- OID_802_3_CURRENT_ADDRESS,
- OID_802_3_MULTICAST_LIST,
- OID_802_3_MAXIMUM_LIST_SIZE,
- //Ethernet Statistics
- OID_802_3_RCV_ERROR_ALIGNMENT,
- OID_802_3_XMIT_ONE_COLLISION,
- OID_802_3_XMIT_MORE_COLLISIONS,
- OID_802_3_XMIT_DEFERRED
- };
- ///////////////////////////////////////////////////////////////////////////
- //
- // DriverEntry
- //
- ///////////////////////////////////////////////////////////////////////////
- NDIS_STATUS NDIS_API
- DriverEntry(
- IN PDRIVER_OBJECT DriverObject, // NULL in Windows95 CHICAGO
- IN PUNICODE_STRING RegistryPath // NULL in Windows95 CHICAGO
- )
- {
- NDIS_STATUS NdisStatus;
- NDIS_HANDLE NdisWrapperHandle = (NDIS_HANDLE)-1;
- PDRIVER_BLOCK pNewMac = &gDriverBlock;
- NDIS_STRING MacName = NDIS_STRING_CONST((PUCHAR)("ITEK"));
- #ifdef DEBUG
- Debug_Printf("ITEK:DriverEntry() Entryn");
- #endif
- //to tell NDIS that the ITek ATM is initializing.
- NdisInitializeWrapper(&NdisWrapperHandle,
- DriverObject,
- RegistryPath,
- NULL);
- #ifdef DEBUG
- Debug_Printf("ITEK:Wrapper Initialized(0x%x)n", NdisWrapperHandle);
- #endif
- //here set NdisWrapperHandler to the corresponding global var.
- //
- pNewMac->DriverObject = DriverObject;
- pNewMac->NdisWrapperHandle = NdisWrapperHandle;
- pNewMac->NextITek = (PITEK_ADAPTER)NULL;
- //to register our NIC callbacks
- pNewMac->MacCharacteristics.MajorNdisVersion = ITEK_DRIVER_MAJOR;
- pNewMac->MacCharacteristics.MinorNdisVersion = ITEK_DRIVER_MINOR;
- pNewMac->MacCharacteristics.Reserved = 0;
- pNewMac->MacCharacteristics.OpenAdapterHandler = ITekOpenAdapter;
- pNewMac->MacCharacteristics.CloseAdapterHandler = ITekCloseAdapter;
- pNewMac->MacCharacteristics.SendHandler = ITekSend;
- pNewMac->MacCharacteristics.TransferDataHandler = ITekTransferData;
- pNewMac->MacCharacteristics.ResetHandler = ITekReset;
- pNewMac->MacCharacteristics.RequestHandler = ITekRequest;
- pNewMac->MacCharacteristics.QueryGlobalStatisticsHandler = ITekQueryGlobalStatistics;
- pNewMac->MacCharacteristics.UnloadMacHandler = ITekUnload;
- pNewMac->MacCharacteristics.AddAdapterHandler = ITekAddAdapter;
- pNewMac->MacCharacteristics.RemoveAdapterHandler = ITekRemoveAdapter;
- pNewMac->MacCharacteristics.Name = MacName;
- //to register our NIC driver's entry points and
- //name with the NDIS library when the driver initializes.
- NdisRegisterMac(&NdisStatus,
- &pNewMac->NdisMacHandle,
- NdisWrapperHandle,
- (NDIS_HANDLE)&gDriverBlock,
- &pNewMac->MacCharacteristics,
- sizeof(pNewMac->MacCharacteristics));
- //let the device init procedure to handle the result.
- if(NdisStatus != NDIS_STATUS_SUCCESS) {
- NdisTerminateWrapper(NdisWrapperHandle, NULL);
- #ifdef DEBUG
- Debug_Printf("ITEK:Registered as Mac Failed(Error#%x), Returnn", NdisStatus);
- #endif
- } else {
- #ifdef DEBUG
- Debug_Printf("ITEK:Registered as Mac Succeeded(MacMacContext=0x%x, MacHandle=0x%x) Returnn",
- (NDIS_HANDLE)&gDriverBlock, pNewMac->NdisMacHandle);
- #endif
- }
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekAddAdapter
- //
- NDIS_STATUS NDIS_API
- ITekAddAdapter(
- IN NDIS_HANDLE MacMacContext,
- IN NDIS_HANDLE ConfigurationHandle,
- IN PNDIS_STRING AdapterName
- )
- {
- NDIS_STATUS NdisStatus;
- PDRIVER_BLOCK pMacContext = (PDRIVER_BLOCK)MacMacContext;
- PITEK_ADAPTER pITekAdapter;
- NDIS_STRING BusTypeStr = NDIS_STRING_CONST((PUCHAR)("BusType"));
- NDIS_ADAPTER_INFORMATION AdapterInformation;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekAddAdapter(MacMacContext, ConfigurationHandle, %s) Entryn",
- AdapterName->Buffer);
- #endif
- NdisStatus = NDIS_STATUS_FAILURE;
- //alloc the new brabo atm driver
- ITekAllocateMemory((PVOID *)&pITekAdapter, sizeof(ITEK_ADAPTER));
- if(pITekAdapter == NULL)
- return (NDIS_STATUS_FAILURE);
- NdisZeroMemory(pITekAdapter, sizeof(ITEK_ADAPTER));
- #ifdef DEBUG
- Debug_Printf("ITEK:Allocate One ITek Adapter Object Contextn");
- #endif
- // Initializing this ITEK adapter object
- pITekAdapter->ConfigurationHandle = ConfigurationHandle; //WrapperHandle
- pITekAdapter->WrapperHandle = pMacContext->NdisWrapperHandle;
- #ifdef DEBUG
- Debug_Printf("ITEK:ConfigurationHandle=0x%x, WrapperHandle=0x%xn",
- pITekAdapter->ConfigurationHandle,
- pITekAdapter->WrapperHandle);
- #endif
- pITekAdapter->AdapterType = NdisInterfaceInternal;
- pITekAdapter->NicStatus = NIC_DISABLED;
- pITekAdapter->MulticastListMax = ITEK_MULTICASTLIST_MAX;
- pITekAdapter->PermanentAddress[0] = 0x00;
- pITekAdapter->PermanentAddress[1] = 0x00;
- pITekAdapter->PermanentAddress[2] = 0x00;
- pITekAdapter->PermanentAddress[3] = 0x00;
- pITekAdapter->PermanentAddress[4] = 0x00;
- pITekAdapter->PermanentAddress[5] = 0x00;
- pITekAdapter->CurrentAddress[0] = pITekAdapter->PermanentAddress[0];
- pITekAdapter->CurrentAddress[1] = pITekAdapter->PermanentAddress[1];
- pITekAdapter->CurrentAddress[2] = pITekAdapter->PermanentAddress[2];
- pITekAdapter->CurrentAddress[3] = pITekAdapter->PermanentAddress[3];
- pITekAdapter->CurrentAddress[4] = pITekAdapter->PermanentAddress[4];
- pITekAdapter->CurrentAddress[5] = pITekAdapter->PermanentAddress[5];
- pITekAdapter->DestinationAddress[0] = 0xff;
- pITekAdapter->DestinationAddress[1] = 0xff;
- pITekAdapter->DestinationAddress[2] = 0xff;
- pITekAdapter->DestinationAddress[3] = 0xff;
- pITekAdapter->DestinationAddress[4] = 0xff;
- pITekAdapter->DestinationAddress[5] = 0xff;
- pITekAdapter->pHeadPacket = NULL;
- pITekAdapter->pTailPacket = NULL;
- pITekAdapter->NicStatus = NIC_CONFIGURING;
- // Now we can safely use the ITek ATM NIC's operational registers via its mapped host
- // pointer, pOpRegs.
- //add to the global ITek adapter lists
- pITekAdapter->NextITek = pMacContext->NextITek;
- pMacContext->NextITek = pITekAdapter;
- NdisZeroMemory (&AdapterInformation, sizeof(NDIS_ADAPTER_INFORMATION));
- AdapterInformation.Master = 0;
- AdapterInformation.Dma32BitAddresses = 0;
- AdapterInformation.AdapterType = pITekAdapter->AdapterType;
- AdapterInformation.PhysicalMapRegistersNeeded = 0;
- AdapterInformation.MaximumPhysicalMapping = 0;
- AdapterInformation.NumberOfPortDescriptors = 0;
- AdapterInformation.PortDescriptors[0].InitialPort = 0;
- AdapterInformation.PortDescriptors[0].NumberOfPorts = 0;
- NdisStatus = NdisRegisterAdapter(
- &pITekAdapter->ITekAdapterHandle,
- pMacContext->NdisMacHandle,
- (NDIS_HANDLE)pITekAdapter,
- ConfigurationHandle,
- AdapterName,
- (PVOID)&AdapterInformation);
- if(NdisStatus != NDIS_STATUS_SUCCESS) {
- #ifdef DEBUG
- Debug_Printf("ITEK:NdisRegisterAdapter failed(Error#%x)n", NdisStatus);
- #endif
- return (NdisStatus);
- }
- NdisAllocateSpinLock(&pITekAdapter->Lock);
- if(EthCreateFilter(
- pITekAdapter->MulticastListMax,
- ITekAddressChangeAction,
- ITekFilterChangeAction,
- ITekCloseAction,
- pITekAdapter->CurrentAddress,
- &pITekAdapter->Lock,
- &pITekAdapter->FilterDB) == FALSE)
- {
- #ifdef DEBUG
- Debug_Printf("ITEK:EthCreateFilter() failedn");
- #endif
- NdisFreeSpinLock(&pITekAdapter->Lock);
- NdisStatus = NDIS_STATUS_FAILURE;
- return (NdisStatus);
- }
- #ifdef ITEK_TIMER
- NdisInitializeTimer(
- &pITekAdapter->NdisTimer,
- ITekTimerFunction,
- (PVOID)pITekAdapter);
- NdisSetTimer(
- &pITekAdapter->NdisTimer,
- ITEK_TIMEOUT_MSEC); //see datastru.h
- #ifdef DEBUG
- Debug_Printf("Timer initialized and setn");
- #endif
- #endif //ITEK_TIMER
- pITekAdapter->NicStatus = NIC_ENABLED;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekAddAdapter() Return with 0x%xn", NdisStatus);
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekRemoveAdapter
- //
- VOID NDIS_API
- ITekRemoveAdapter(
- IN PVOID MacAdapterContext
- )
- {
- PITEK_ADAPTER pITekAdapter = (PITEK_ADAPTER)MacAdapterContext;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekRemoveAdapter(MacAdapterContext=0x%x) Entryn",
- MacAdapterContext);
- #endif
- // free this adapter context
- #ifdef DEBUG
- Debug_Printf("free this adapter contextn");
- #endif
- gDriverBlock.NextITek = pITekAdapter->NextITek;
- ITekFreeMemory((PVOID)pITekAdapter);
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekRemoveAdapter() Returnn");
- #endif
- return;
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekOpenAdapter
- //
- NDIS_STATUS NDIS_API
- ITekOpenAdapter(
- OUT PNDIS_STATUS OpenErrorStatus,
- OUT NDIS_HANDLE *MacBindingHandle,
- OUT PUINT SelectedMediumIndex,
- IN PNDIS_MEDIUM MediumArray,
- IN UINT MediumArraySize,
- IN NDIS_HANDLE NdisBindingContext,
- IN NDIS_HANDLE MacAdapterContext,
- IN UINT OpenOptions,
- IN PSTRING AddressingInformation OPTIONAL
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_ADAPTER pITekAdapter = (PITEK_ADAPTER)MacAdapterContext;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)NULL;
- UINT uIndex;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekOpenAdapter(NdisBindingContext=0x%x) Entryn", NdisBindingContext);
- #endif
- NdisStatus = NDIS_STATUS_FAILURE;
- *OpenErrorStatus = NDIS_STATUS_FAILURE;
- //select the supported medium type
- for(uIndex = 0; uIndex < MediumArraySize; uIndex) {
- if(*(MediumArray+uIndex) == NdisMedium802_3) {
- break;
- }
- }
- if(uIndex == MediumArraySize)
- return (NDIS_STATUS_UNSUPPORTED_MEDIA);
- *SelectedMediumIndex = uIndex;
- ITekAllocateMemory((PVOID *)&pITekOpen, sizeof(ITEK_OPEN));
- if(pITekOpen == NULL) {
- #ifdef DEBUG
- Debug_Printf("Allocating ITEK_OPEN instance failedn");
- #endif
- return (NDIS_STATUS_RESOURCES);
- }
- NdisZeroMemory(pITekOpen, sizeof(ITEK_OPEN));
- pITekAdapter->ReferenceCount++;
- NdisAcquireSpinLock(&pITekAdapter->Lock);
- if(EthNoteFilterOpenAdapter(
- pITekAdapter->FilterDB,
- pITekOpen,
- NdisBindingContext,
- &pITekOpen->NdisFilterHandle) == FALSE) {
- #ifdef DEBUG
- Debug_Printf("EthNoteFilterOpenAdapter() Failedn");
- #endif
- NdisReleaseSpinLock(&pITekAdapter->Lock);
- ITekFreeMemory((PVOID)pITekOpen);
- return (NDIS_STATUS_FAILURE);
- }
- pITekOpen->NextOpen = pITekAdapter->NextOpen;
- pITekAdapter->NextOpen = pITekOpen;
- pITekOpen->pITekAdapter = pITekAdapter;
- pITekOpen->pDriverBlock = &gDriverBlock;
- pITekOpen->NdisBindingContext = NdisBindingContext;
- pITekOpen->AddressingInformation = AddressingInformation;
- pITekOpen->OpenOptions = OpenOptions;
- pITekOpen->ProtOptionFlags = 0;
- pITekOpen->ReferenceCount = 1;
- pITekOpen->Closing = FALSE;
- pITekOpen->PacketFilter = 0;
- pITekOpen->MaxLookAhead = ITEK_MAX_LOOKAHEAD;
- *MacBindingHandle = (NDIS_HANDLE)pITekOpen;
- NdisStatus = NDIS_STATUS_SUCCESS;
- *OpenErrorStatus = NDIS_STATUS_SUCCESS;
- NdisReleaseSpinLock(&pITekAdapter->Lock);
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekOpenAdapter() Return with MacBindingHandle=0x%xn",
- (NDIS_HANDLE)pITekOpen);
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekCloseAdapter
- //
- NDIS_STATUS NDIS_API
- ITekCloseAdapter(
- IN NDIS_HANDLE MacBindingHandle
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- PITEK_OPEN pTempOpen;
- PITEK_ADAPTER pITekAdapter;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekCloseAdapter(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
- #endif
- NdisStatus = NDIS_STATUS_SUCCESS;
- pITekAdapter = pITekOpen->pITekAdapter;
- if(pITekOpen->Closing == TRUE) {
- #ifdef DEBUG
- Debug_Printf("ITEK:Closing...Returnn");
- #endif
- return (NDIS_STATUS_CLOSING);
- }
- if(pITekOpen == pITekAdapter->NextOpen) {
- pITekAdapter->NextOpen = pITekOpen->NextOpen;
- } else {
- pTempOpen = pITekAdapter->NextOpen;
- while(pTempOpen->NextOpen != pITekOpen) {
- pTempOpen = pTempOpen->NextOpen;
- }
- pTempOpen->NextOpen = pITekOpen->NextOpen;
- }
- //pITekOpen->NextOpen = NULL;
- NdisStatus = EthDeleteFilterOpenAdapter(
- pITekAdapter->FilterDB,
- pITekOpen->NdisFilterHandle,
- NULL);
- if(NdisStatus != NDIS_STATUS_SUCCESS) {
- pITekOpen->Closing = TRUE;
- #ifdef DEBUG
- Debug_Printf("ITEK:EthDeleteFilterOpenAdapter() pending...n");
- #endif
- return (NDIS_STATUS_PENDING);
- }
- pITekOpen->ReferenceCount--;
- pITekAdapter->ReferenceCount--;
- if(pITekOpen->ReferenceCount == 0) {
- #ifdef DEBUG
- Debug_Printf("Free Open Instance(0x%x)n", MacBindingHandle);
- #endif
- ITekFreeMemory((PVOID)pITekOpen);
- }
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekCloseAdapter() Returnn");
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekReset
- //
- NDIS_STATUS NDIS_API
- ITekReset(
- IN NDIS_HANDLE MacBindingHandle
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- PITEK_ADAPTER pITekAdapter;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekReset(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
- #endif
- NdisStatus = NDIS_STATUS_FAILURE;
- pITekAdapter = pITekOpen->pITekAdapter;
- if(pITekAdapter->NicStatus == NIC_RESETTING) {
- #ifdef DEBUG
- Debug_Printf("Resetting already progressingn");
- #endif
- NdisStatus = NDIS_STATUS_RESET_IN_PROGRESS;
- } else {
- //???
- }
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekReset() Returnn");
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekRequest
- //
- NDIS_STATUS NDIS_API
- ITekRequest(
- IN NDIS_HANDLE MacBindingHandle,
- IN PNDIS_REQUEST NdisRequest
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- PITEK_ADAPTER pITekAdapter;
- ULONG BytesWritten, BytesRead, BytesNeeded;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekRequest(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
- #endif
- pITekAdapter = pITekOpen->pITekAdapter;
- BytesWritten = 0;
- BytesRead = 0;
- BytesNeeded = 0;
- if(NdisRequest->RequestType == NdisRequestQueryInformation) {
- NdisStatus = ITekQueryInformation(
- pITekAdapter,
- pITekOpen,
- NdisRequest->DATA.QUERY_INFORMATION.Oid,
- NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
- NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
- &BytesWritten,
- &BytesNeeded);
- NdisRequest->DATA.QUERY_INFORMATION.BytesWritten = (UINT)BytesWritten;
- NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
- } else if (NdisRequest->RequestType == NdisRequestSetInformation) {
- NdisStatus = ITekSetInformation(
- pITekAdapter,
- pITekOpen,
- NdisRequest,
- NdisRequest->DATA.SET_INFORMATION.Oid,
- NdisRequest->DATA.SET_INFORMATION.InformationBuffer,
- NdisRequest->DATA.SET_INFORMATION.InformationBufferLength,
- &BytesRead,
- &BytesNeeded);
- NdisRequest->DATA.SET_INFORMATION.BytesRead = (UINT)BytesRead;
- NdisRequest->DATA.SET_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
- } else {
- NdisStatus = NDIS_STATUS_NOT_RECOGNIZED;
- }
- //NdisCompleteRequest(
- // pITekOpen->NdisBindingContext,
- // NdisRequest,
- // NDIS_STATUS_SUCCESS
- // );
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekRequest() Returnn");
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekQueryGlobalStatistics
- //
- NDIS_STATUS NDIS_API
- ITekQueryGlobalStatistics(
- IN NDIS_HANDLE MacBindingHandle,
- IN PNDIS_REQUEST NdisRequest
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- PITEK_ADAPTER pITekAdapter;
- ULONG BytesWritten, BytesNeeded;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekQueryGlobalStatistics() Entryn");
- #endif
- pITekAdapter = pITekOpen->pITekAdapter;
- BytesWritten = 0;
- BytesNeeded = 0;
- NdisStatus = NDIS_STATUS_FAILURE;
- NdisStatus = ITekQueryInformation(
- pITekAdapter,
- pITekOpen,
- NdisRequest->DATA.QUERY_INFORMATION.Oid,
- NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer,
- NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength,
- &BytesWritten,
- &BytesNeeded);
- NdisRequest->DATA.QUERY_INFORMATION.BytesWritten = (UINT)BytesWritten;
- NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded = (UINT)BytesNeeded;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekQueryGlobalStatistics() Return(0x%x)n",
- NdisStatus);
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekUnload
- //
- VOID NDIS_API
- ITekUnload(
- IN NDIS_HANDLE MacMacContext
- )
- {
- NDIS_STATUS NdisStatus;
- PDRIVER_BLOCK pMacContext = (PDRIVER_BLOCK)MacMacContext;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekUnload(MacMacContext=0x%x) Entryn",
- MacMacContext);
- #endif
- NdisDeregisterMac(
- &NdisStatus,
- pMacContext->NdisMacHandle
- );
- NdisTerminateWrapper(
- pMacContext->NdisWrapperHandle,
- NULL
- );
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekUnload() Returnn");
- #endif
- return;
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekTransferData
- //
- NDIS_STATUS NDIS_API
- ITekTransferData(
- IN NDIS_HANDLE MacBindingHandle,
- IN NDIS_HANDLE MacReceiveContext,
- IN UINT ByteOffset,
- IN UINT BytesToTransfer,
- OUT PNDIS_PACKET Packet,
- OUT PUINT BytesTransferred
- )
- {
- NDIS_STATUS NdisStatus;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekTransferData() Entryn");
- #endif
- NdisStatus = NDIS_STATUS_FAILURE;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekTransferData() Returnn");
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekSend
- //
- NDIS_STATUS NDIS_API
- ITekSend(
- IN NDIS_HANDLE MacBindingHandle,
- IN PNDIS_PACKET Packet
- )
- {
- NDIS_STATUS NdisStatus;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- PITEK_ADAPTER pITekAdapter;
- PNDIS_BUFFER pNdisBuffer;
- UINT PhysicalBufferCount;
- UINT BufferCount, BufferLength;
- UINT TotalPacketLength;
- PCHAR pHdrData;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekSend(MacBindingHandle=0x%x) Entryn", MacBindingHandle);
- #endif
- NdisStatus = NDIS_STATUS_SUCCESS;
- pITekAdapter = pITekOpen->pITekAdapter;
- if(pITekOpen->Closing == TRUE) {
- #ifdef DEBUG
- Debug_Printf("ITEK:Closing...n");
- #endif
- return (NDIS_STATUS_CLOSING);
- }
- NdisQueryPacket(
- Packet,
- &PhysicalBufferCount,
- &BufferCount,
- &pNdisBuffer,
- &TotalPacketLength);
- NdisQueryBuffer(
- pNdisBuffer,
- (PVOID *)&pHdrData,
- &BufferLength);
- if(BufferLength < ITEK_PDU_HDRSIZE) {
- NdisStatus = NDIS_STATUS_FAILURE;
- return (NdisStatus);
- }
- ITEK_RESERVED(Packet)->pITekOpen = pITekOpen;
- if(pITekAdapter->pHeadPacket == NULL) {
- pITekAdapter->pHeadPacket = Packet;
- } else {
- ITEK_RESERVED(pITekAdapter->pTailPacket)->pNextPacket = Packet;
- }
- ITEK_RESERVED(Packet)->pNextPacket = NULL;
- pITekAdapter->pTailPacket = Packet;
- //ITekNextSend(pITekAdapter);
- //NdisStatus = NDIS_STATUS_PENDING;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekSend() returnn");
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekQueryInformation
- //
- NDIS_STATUS NDIS_API
- ITekQueryInformation(
- IN NDIS_HANDLE ITekAdapterContext,
- IN NDIS_HANDLE ITekOpenContext,
- IN NDIS_OID Oid,
- IN PVOID InformationBuffer,
- IN ULONG InformationBufferLength,
- OUT PULONG BytesWritten,
- OUT PULONG BytesNeeded
- )
- {
- PITEK_ADAPTER pITekAdapter = (PITEK_ADAPTER)ITekAdapterContext;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)ITekOpenContext;
- NDIS_STATUS NdisStatus;
- ULONG InfoSize;
- ULONG InfoULONG;
- USHORT InfoUSHORT;
- PVOID InfoSource;
- NDIS_HARDWARE_STATUS NicStatus;
- NDIS_MEDIUM NicMedium;
- InfoSource = (PVOID)&InfoULONG;
- InfoSize = 4;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekQueryInformation() Entryn");
- #endif
- NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
- switch(Oid) {
- //General Operational Charateristics
- case OID_GEN_SUPPORTED_LIST:
- InfoSource = (PVOID)ITEKSupportedOids;
- InfoSize = sizeof(ITEKSupportedOids);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_SUPPORTED_LIST=size(%u bytes)n", InfoSize);
- #endif
- break;
- case OID_GEN_HARDWARE_STATUS:
- if(pITekAdapter->NicStatus == NIC_DISABLED) {
- //NicStatus = NdisHardwareStatusNotReady;
- NicStatus = NdisHardwareStatusInitializing;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_HARDWARE_STATUS=Initializingn");
- #endif
- } else {
- NicStatus = NdisHardwareStatusReady;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_HARDWARE_STATUS=Readyn");
- #endif
- }
- InfoSource = (PVOID)&NicStatus;
- InfoSize = sizeof(NDIS_HARDWARE_STATUS);
- NdisStatus = NDIS_STATUS_SUCCESS;
- break;
- case OID_GEN_MEDIA_SUPPORTED:
- case OID_GEN_MEDIA_IN_USE:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MEDIA_SUPPORTED or OID_GEN_MEDIA_IN_USE=802.3(Ethernet)n");
- #endif
- NicMedium = NdisMedium802_3;
- InfoSource = (PVOID)&NicMedium;
- InfoSize = sizeof(NDIS_MEDIUM);
- NdisStatus = NDIS_STATUS_SUCCESS;
- break;
- case OID_GEN_MAXIMUM_LOOKAHEAD:
- InfoULONG = ITEK_MAX_LOOKAHEAD;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MAXIMUM_LOOKAHEAD=%un",InfoULONG);
- #endif
- break;
- case OID_GEN_MAXIMUM_FRAME_SIZE:
- InfoULONG = ITEK_SDU_MAXSIZE; // not equal to Ethernet MTU size (1514-14)
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MAXIMUM_FRAME_SIZE=%un", InfoULONG);
- #endif
- break;
- case OID_GEN_LINK_SPEED:
- InfoULONG = 100000; // 25Mbps
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_LINK_SPEED=%u bpsn", InfoULONG*100);
- #endif
- break;
- case OID_GEN_TRANSMIT_BUFFER_SPACE:
- InfoULONG = ITEK_TX_MAXSIZE;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_TRANSMIT_BUFFER_SPACE=%u bytesn", InfoULONG);
- #endif
- break;
- case OID_GEN_RECEIVE_BUFFER_SPACE:
- InfoULONG = 1520;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RECEIVE_BUFFER_SPACE=%un", InfoULONG);
- #endif
- break;
- case OID_GEN_TRANSMIT_BLOCK_SIZE:
- InfoULONG = ITEK_TX_MINSIZE;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_TRANSMIT_BLOCK_SIZE=%u bytes(Min.),%u bytes(Max.)n",InfoULONG, ITEK_TX_MAXSIZE);
- #endif
- break;
- case OID_GEN_RECEIVE_BLOCK_SIZE:
- InfoULONG = 1520;
- NdisStatus = NDIS_STATUS_SUCCESS;
- //InfoULONG = ITEK_SDU_MAXSIZE;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RECEIVE_BLOCK_SIZE=%un", InfoULONG);
- #endif
- break;
- case OID_GEN_VENDOR_ID:
- InfoULONG = ITEK_VENDOR_ID;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_VENDOR_ID=0x%xn", InfoULONG);
- #endif
- break;
- case OID_GEN_VENDOR_DESCRIPTION:
- InfoSource = (PVOID)ITEK_DESCRIPTION;
- InfoSize = strlen(ITEK_DESCRIPTION);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_VENDOR_DESCRIPTION=%s(%u)n", ITEK_DESCRIPTION, InfoSize);
- #endif
- break;
- // case OID_GEN_VENDOR_DRIVER_VERSION:
- //#ifdef DEBUG
- // Debug_Printf("Query OID_GEN_VENDOR_DRIVER_VERSIONn");
- //#endif
- // break;
- case OID_GEN_CURRENT_PACKET_FILTER:
- InfoULONG = pITekOpen->PacketFilter;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_CURRENT_PACKET_FILTER=0x%xn",InfoULONG);
- #endif
- break;
- case OID_GEN_CURRENT_LOOKAHEAD:
- InfoULONG = ITEK_MAX_LOOKAHEAD;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_CURRENT_LOOKAHEAD=%u bytesn", InfoULONG);
- #endif
- break;
- case OID_GEN_DRIVER_VERSION:
- InfoUSHORT = (ITEK_DRIVER_MAJOR << 8) | ITEK_DRIVER_MINOR;
- InfoSource = (PVOID)&InfoUSHORT;
- InfoSize = sizeof(InfoUSHORT);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_DRIVER_VERSION=0x%xn", InfoUSHORT);
- #endif
- break;
- case OID_GEN_MAXIMUM_TOTAL_SIZE:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MAXIMUM_TOTAL_SIZE, not yet supported!n");
- #endif
- break;
- case OID_GEN_PROTOCOL_OPTIONS:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_PROTOCOL_OPTIONS, not yet supported!n");
- #endif
- break;
- case OID_GEN_MAC_OPTIONS:
- InfoULONG = (ULONG)(NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
- NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
- NDIS_MAC_OPTION_TRANSFERS_NOT_PEND |
- NDIS_MAC_OPTION_NO_LOOPBACK );
- //NDIS_MAC_OPTION_FULL_DUPLEX);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MAC_OPTIONS =%un", InfoULONG);
- #endif
- break;
- //General Statistics Charateristics
- case OID_GEN_XMIT_OK:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_XMIT_OK, not yet supported!n");
- #endif
- break;
- case OID_GEN_RCV_OK:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RCV_OK, not yet supported!n");
- #endif
- break;
- case OID_GEN_XMIT_ERROR:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_XMIT_ERROR, not yet supported!n");
- #endif
- break;
- case OID_GEN_RCV_ERROR:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RCV_ERROR, not yet supported!n");
- #endif
- break;
- case OID_GEN_RCV_NO_BUFFER:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RCV_NO_BUFFER, not yet supported!n");
- #endif
- break;
- case OID_GEN_DIRECTED_BYTES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_DIRECTED_BYTES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_DIRECTED_FRAMES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_DIRECTED_FRAMES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_MULTICAST_BYTES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MULTICAST_BYTES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_MULTICAST_FRAMES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MULTICAST_FRAMES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_BROADCAST_BYTES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_BROADCAST_BYTES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_BROADCAST_FRAMES_XMIT:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_BROADCAST_FRAMES_XMIT, not yet supported!n");
- #endif
- break;
- case OID_GEN_DIRECTED_BYTES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_DIRECTED_BYTES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_DIRECTED_FRAMES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_DIRECTED_FRAMES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_MULTICAST_BYTES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MULTICAST_BYTES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_MULTICAST_FRAMES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_MULTICAST_FRAMES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_BROADCAST_BYTES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_BROADCAST_BYTES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_BROADCAST_FRAMES_RCV:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_BROADCAST_FRAMES_RCV, not yet supported!n");
- #endif
- break;
- case OID_GEN_RCV_CRC_ERROR:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_RCV_CRC_ERROR, not yet supported!n");
- #endif
- break;
- case OID_GEN_TRANSMIT_QUEUE_LENGTH:
- #ifdef DEBUG
- Debug_Printf("Query OID_GEN_TRANSMIT_QUEUE_LENGTH, not yet supported!n");
- #endif
- break;
- //Ethernet Operational Charateristics
- case OID_802_3_PERMANENT_ADDRESS:
- InfoSource = (PVOID)pITekAdapter->PermanentAddress;
- InfoSize = sizeof(pITekAdapter->PermanentAddress);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_PERMANENT_ADDRESS=%x:%x:%x:%x:%x:%xn", (UCHAR)pITekAdapter->PermanentAddress[0]
- , (UCHAR)pITekAdapter->PermanentAddress[1], (UCHAR)pITekAdapter->PermanentAddress[2]
- , (UCHAR)pITekAdapter->PermanentAddress[3], (UCHAR)pITekAdapter->PermanentAddress[4]
- , (UCHAR)pITekAdapter->PermanentAddress[5]);
- #endif
- break;
- case OID_802_3_CURRENT_ADDRESS:
- InfoSource = (PVOID)pITekAdapter->CurrentAddress;
- InfoSize = sizeof(pITekAdapter->CurrentAddress);
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_CURRENT_ADDRESS=%x:%x:%x:%x:%x:%xn", (UCHAR)pITekAdapter->CurrentAddress[0]
- , (UCHAR)pITekAdapter->CurrentAddress[1], (UCHAR)pITekAdapter->CurrentAddress[2]
- , (UCHAR)pITekAdapter->CurrentAddress[3], (UCHAR)pITekAdapter->CurrentAddress[4]
- , (UCHAR)pITekAdapter->CurrentAddress[5]);
- #endif
- break;
- case OID_802_3_MAXIMUM_LIST_SIZE:
- InfoULONG = pITekAdapter->MulticastListMax;
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_MAXIMUM_LIST_SIZE=%un", InfoULONG);
- #endif
- break;
- case OID_802_3_MULTICAST_LIST:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_MULTICAST_LIST, not yet supportedn");
- #endif
- break;
- //Ethernet Statistics
- case OID_802_3_RCV_ERROR_ALIGNMENT:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_RCV_ERROR_ALIGNMENT, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_ONE_COLLISION:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_ONE_COLLISION, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_MORE_COLLISIONS:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_MORE_COLLISIONS, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_DEFERRED:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_DEFERRED, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_MAX_COLLISIONS:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_MAX_COLLISIONS, not yet supportedn");
- #endif
- break;
- case OID_802_3_RCV_OVERRUN:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_RCV_OVERRUN, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_UNDERRUN:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_UNDERRUN, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_HEARTBEAT_FAILURE:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_HEARTBEAT_FAILURE, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_TIMES_CRS_LOST:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_TIMES_CRS_LOST, not yet supportedn");
- #endif
- break;
- case OID_802_3_XMIT_LATE_COLLISIONS:
- #ifdef DEBUG
- Debug_Printf("Query OID_802_3_XMIT_LATE_COLLISIONS, not yet supportedn");
- #endif
- break;
- default:
- #ifdef DEBUG
- Debug_Printf("Qeury Unknownn");
- #endif
- NdisStatus = NDIS_STATUS_INVALID_OID;
- break;
- } //switch(Oid)
- if(NdisStatus == NDIS_STATUS_SUCCESS){
- if (InfoSize > InformationBufferLength){
- *BytesNeeded = InfoSize;
- NdisStatus = NDIS_STATUS_INVALID_LENGTH;
- } else {
- memcpy(InformationBuffer, InfoSource, InfoSize);
- (*BytesWritten) += InfoSize;
- }
- }
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekQueryInformation() Return with %xn",NdisStatus);
- #endif
- return (NdisStatus);
- }
- ///////////////////////////////////////////////////////////////////////////
- // ITekSetInformation
- //
- NDIS_STATUS NDIS_API
- ITekSetInformation(
- IN NDIS_HANDLE ITekAdapterContext,
- IN NDIS_HANDLE ITekOpenContext,
- IN PNDIS_REQUEST NdisRequest,
- IN NDIS_OID Oid,
- IN PVOID InformationBuffer,
- IN ULONG InformationBufferLength,
- OUT PULONG BytesRead,
- OUT PULONG BytesNeeded
- )
- {
- PITEK_ADAPTER pITekAdapter = (PITEK_ADAPTER)ITekAdapterContext;
- PITEK_OPEN pITekOpen = (PITEK_OPEN)ITekOpenContext;
- NDIS_STATUS NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
- ULONG PacketFilter;
- PUCHAR InfoSource;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekSetInformation() Entryn");
- #endif
- InfoSource = (PUCHAR)InformationBuffer;
- //we don't need these objects at all.
- switch(Oid) {
- // General Operational Charateristics
- case OID_GEN_CURRENT_PACKET_FILTER:
- if(InformationBufferLength != 4) {
- NdisStatus = NDIS_STATUS_INVALID_LENGTH;
- *BytesRead = 0;
- *BytesNeeded = 0;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - INVALID_LENGTHn");
- #endif
- break;
- }
- PacketFilter = *(PULONG)InformationBuffer;
- if(PacketFilter &(NDIS_PACKET_TYPE_SOURCE_ROUTING |
- NDIS_PACKET_TYPE_SMT | NDIS_PACKET_TYPE_MAC_FRAME |
- NDIS_PACKET_TYPE_FUNCTIONAL | NDIS_PACKET_TYPE_ALL_FUNCTIONAL |
- NDIS_PACKET_TYPE_GROUP)) {
- NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
- *BytesRead = 4;
- *BytesNeeded = 0;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - NOT_ACCEPTEDn");
- #endif
- break;
- } else if(PacketFilter > 0x8000) {
- NdisStatus = NDIS_STATUS_INVALID_DATA;
- *BytesRead = 4;
- *BytesNeeded = 0;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER - INVALID_DATAn");
- #endif
- break;
- }
- NdisAcquireSpinLock(&pITekAdapter->Lock);
- NdisStatus = EthFilterAdjust(
- pITekAdapter->FilterDB,
- pITekOpen->NdisFilterHandle,
- NdisRequest,
- PacketFilter,
- TRUE);
- NdisReleaseSpinLock(&pITekAdapter->Lock);
- pITekOpen->PacketFilter = PacketFilter;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_CURRENT_PACKET_FILTER=0x%x with status=0x%xn",
- PacketFilter, NdisStatus);
- #endif
- break;
- case OID_GEN_CURRENT_LOOKAHEAD:
- //NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
- NdisStatus = NDIS_STATUS_SUCCESS;
- pITekOpen->MaxLookAhead = *(PULONG)InformationBuffer;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_CURRENT_LOOKAHEAD(%u), acceptedn",
- pITekOpen->MaxLookAhead);
- #endif
- break;
- case OID_GEN_PROTOCOL_OPTIONS:
- NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
- #ifdef DEBUG
- Debug_Printf("Set OID_GEN_PROTOCOL_OPTIONS, not acceptedn");
- #endif
- break;
- // Ethernet Operational Characteristics
- case OID_802_3_MULTICAST_LIST:
- //NdisStatus = NDIS_STATUS_NOT_ACCEPTED;
- NdisStatus = NDIS_STATUS_SUCCESS;
- if((InformationBufferLength % ETH_LENGTH_OF_ADDRESS) != 0) {
- NdisStatus = NDIS_STATUS_INVALID_LENGTH;
- *BytesRead = 0;
- *BytesNeeded = 0;
- #ifdef DEBUG
- Debug_Printf("Set OID_802_3_MULTICAST_LIST-INVALID LENGTH(%u)n",
- InformationBufferLength);
- #endif
- } else {
- NdisAcquireSpinLock(&pITekAdapter->Lock);
- NdisStatus = EthChangeFilterAddresses(
- pITekAdapter->FilterDB,
- pITekOpen->NdisFilterHandle,
- NdisRequest,
- (UINT)(InformationBufferLength/ETH_LENGTH_OF_ADDRESS),
- InformationBuffer,
- TRUE);
- NdisReleaseSpinLock(&pITekAdapter->Lock);
- #ifdef DEBUG
- Debug_Printf("Set OID_802_3_MULTICAST_LIST(%u Addresses), acceptedn",
- (UINT)(InformationBufferLength/ETH_LENGTH_OF_ADDRESS));
- #endif
- }
- break;
- default:
- #ifdef DEBUG
- Debug_Printf("Set Unknwon Oidn");
- #endif
- NdisStatus = NDIS_STATUS_INVALID_OID;
- *BytesRead = 0;
- *BytesNeeded = 0;
- break;
- } // switch(Oid)
- if(NdisStatus == NDIS_STATUS_SUCCESS) {
- *BytesRead = InformationBufferLength;
- *BytesNeeded = 0;
- }
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekSetInformation() Return with 0x%xn",NdisStatus);
- #endif
- return (NdisStatus);
- }
- NDIS_STATUS NDIS_API
- ITekAddressChangeAction(
- IN UINT OldFilterCount,
- IN CHAR OldAddresses[][ETH_LENGTH_OF_ADDRESS],
- IN UINT NewFilterCount,
- IN CHAR NewAddresses[][ETH_LENGTH_OF_ADDRESS],
- IN NDIS_HANDLE MacBindingHandle,
- IN PNDIS_REQUEST NdisRequest,
- IN BOOLEAN Set
- )
- {
- NDIS_STATUS NdisStatus;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekAddressChangeAction(MacBindingHandle=0x%x) Entryn",
- MacBindingHandle);
- #endif
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekAddressChangeAction() Returnn");
- #endif
- return (NdisStatus);
- }
- NDIS_STATUS NDIS_API
- ITekFilterChangeAction(
- IN UINT OldFilterClasses,
- IN UINT NewFilterClasses,
- IN NDIS_HANDLE MacBindingHandle,
- IN PNDIS_REQUEST NdisRequest,
- IN BOOLEAN Set
- )
- {
- NDIS_STATUS NdisStatus;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekFilterChangeAction(OldFilterClasses=0x%x, NewFilterClasses=0x%x, MacBindingHandle=0x%x) Entryn",
- OldFilterClasses, NewFilterClasses, MacBindingHandle);
- #endif
- NdisStatus = NDIS_STATUS_SUCCESS;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekFilterChangeAction() Returnn");
- #endif
- return (NdisStatus);
- }
- VOID NDIS_API
- ITekCloseAction(
- IN NDIS_HANDLE MacBindingHandle
- )
- {
- PITEK_OPEN pITekOpen = (PITEK_OPEN)MacBindingHandle;
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekCloseAction(MacBindingHandle=0x%x) Entryn",
- MacBindingHandle);
- #endif
- pITekOpen->ReferenceCount--;
- #ifdef DEBUG
- Debug_Printf("pITekOpen->ReferenceCount=%un", pITekOpen->ReferenceCount);
- #endif
- #ifdef DEBUG
- Debug_Printf("ITEK:ITekCloseAction Returnn");
- #endif
- return;
- }