⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 request.c

📁 e100bex网卡驱动程序
💻 C
📖 第 1 页 / 共 3 页
字号:

    return(Status);

}


//-----------------------------------------------------------------------------
// Procedure:   D100SetInformation
//
// Description: D100SetInformation handles a set operation for a single OID.
//              The only operations that really change the configuration of
//              the adapter are set PACKET_FILTER, and SET_MULTICAST.
//
// Arguments:
//      MiniportAdapterContext - The context value returned by the Miniport
//                               when the adapter was initialized (see the call
//                               NdisMSetAttributes. In reality, it is a
//                               pointer to D100_ADAPTER.
//      Oid - The Oid that is to be set.
//      InformationBuffer -  Holds the data to be set.
//      InformationBufferLength - The length of InformationBuffer.
//
// Result:
//      BytesRead - If the call is successful, returns the number of bytes
//                  read from InformationBuffer.
//      BytesNeeded - If there is not enough data in OvbBuffer to satisfy the
//                    OID, returns the amount of storage needed.
//
// Returns:
//      NDIS_STATUS_SUCCESS
//      NDIS_STATUS_INVALID_LENGTH
//      NDIS_STATUS_INVALID_OID
//      NDIS_STATUS_NOT_SUPPORTED
//      NDIS_STATUS_NOT_ACCEPTED
//-----------------------------------------------------------------------------

NDIS_STATUS
D100SetInformation(
                   IN NDIS_HANDLE MiniportAdapterContext,
                   IN NDIS_OID Oid,
                   IN PVOID InformationBuffer,
                   IN ULONG InformationBufferLength,
                   OUT PULONG BytesRead,
                   OUT PULONG BytesNeeded
                   )

{
    NDIS_STATUS         Status;
    ULONG               PacketFilter;
    PD100_ADAPTER       Adapter;

    DEBUGFUNC("D100SetInformation");

    Adapter = PD100_ADAPTER_FROM_CONTEXT_HANDLE(MiniportAdapterContext);

    REQUEST(Adapter,("\n"));

    DEBUGCHAR(Adapter,'N');

    *BytesRead = 0;
    *BytesNeeded = 0;

    switch (Oid)
    {

    case OID_802_3_MULTICAST_LIST:

        // The data must be a multiple of the Ethernet address size.
        if (InformationBufferLength % ETH_LENGTH_OF_ADDRESS != 0)
            return (NDIS_STATUS_INVALID_LENGTH);

        // Save these new MC addresses to our adapter object
        NdisMoveMemory(Adapter->PrivateMulticastBuffer,
            InformationBuffer,
            InformationBufferLength);

        // Save the number of MC address in our adapter object
        Adapter->NumberOfMcAddresses =
            (InformationBufferLength / ETH_LENGTH_OF_ADDRESS);

        // If this is a miniport driver, then we'll directly call our
        // D100ChangeMCAddress routine, to have the hardware change its mulicast
        // address filter
        Status = D100ChangeMCAddresses(
            Adapter,
            InformationBufferLength /
            ETH_LENGTH_OF_ADDRESS);

        *BytesRead = InformationBufferLength;
        break;


    case OID_GEN_CURRENT_PACKET_FILTER:

        // Verify the Length
        if (InformationBufferLength != 4)
            return (NDIS_STATUS_INVALID_LENGTH);

        // Now call the filter package to set the packet filter.
        NdisMoveMemory((PVOID)&PacketFilter, InformationBuffer, sizeof(ULONG));

        // Verify bits, if any bits are set that we don't support, leave
        if (PacketFilter &
            ~(NDIS_PACKET_TYPE_DIRECTED |
             NDIS_PACKET_TYPE_MULTICAST |
             NDIS_PACKET_TYPE_BROADCAST |
             NDIS_PACKET_TYPE_PROMISCUOUS |
             NDIS_PACKET_TYPE_ALL_MULTICAST))
        {
            REQUEST(Adapter, ("Filter Type %08x not supported\n", PacketFilter));
            Status = NDIS_STATUS_NOT_SUPPORTED;
            *BytesRead = 4;
            break;
        }

        // If this is a miniport driver, the submit the packet filter change
        // to our hardware, by directly calling D100SetPacketFilter.
        Status = D100SetPacketFilter(
            Adapter,
            PacketFilter);

        *BytesRead = InformationBufferLength;
        break;


    case OID_GEN_CURRENT_LOOKAHEAD:

        // Verify the Length
        if (InformationBufferLength != 4)
            return (NDIS_STATUS_INVALID_LENGTH);

        *BytesRead = 4;
        Status = NDIS_STATUS_SUCCESS;
        break;


        // stub the next four cases to set up power management stuff
        // if the adapter had supported power management, the commented lines
        // should replace the stub lines. See the power management spec

    case OID_PNP_SET_POWER:
        TRACEPOWER(("SET: Power State change to 0x%08X!!!\n",InformationBuffer));

        //        *BytesRead = InformationBufferLength;
        //        Status = NDIS_STATUS_SUCCESS;
        *BytesRead = 0;                     //stub
        Status = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;

    case OID_PNP_ADD_WAKE_UP_PATTERN:
        TRACEPOWER(("SET: Got a WakeUpPattern SET    Call\n"));
        // call a function that would program the adapter's wake
        // up pattern, return success
        //*BytesRead = InformationBufferLength;
        *BytesRead = 0;                     //stub
        Status = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;

    case OID_PNP_REMOVE_WAKE_UP_PATTERN:
        TRACEPOWER(("SET: Got a WakeUpPattern REMOVE Call\n"));
        // call a function that would remove the adapter's wake
        // up pattern, return success
        //*BytesRead = InformationBufferLength;
        *BytesRead = 0;                     //stub
        Status = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;

    case OID_PNP_ENABLE_WAKE_UP:
        TRACEPOWER(("SET: Got a EnableWakeUp Call of %08X\n",InformationBuffer));
        // call a function that would enable wake up on the adapter
        // return success
        //*BytesRead = InformationBufferLength;
        *BytesRead = 0;                     //stub
        Status = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;

        /* this OID is for showing how to work with driver specific (custom)
        OIDs and the NDIS 5 WMI interface using GUIDs
        */
    case OID_CUSTOM_DRIVER_SET:
        REQUEST(Adapter,("CUSTOM_DRIVER_SET got a SET\n"));
        *BytesRead = 4;
        Adapter->CustomDriverSet = (ULONG) PtrToUlong(InformationBuffer);
        break;

        /*
        case OID_TCP_TASK_OFFLOAD:
        REQUEST(Adapter,("Task Offload request received\n"));
        // here we would enable whatever features the protocol requested
        // only on a per packet basis though.
        Status = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;
        */
    default:
        Status = NDIS_STATUS_INVALID_OID;
        break;

    }  // end of switch construct
    DEBUGCHAR(Adapter,'n');
    return Status;
}


//-----------------------------------------------------------------------------
// Procedure:   D100QueryInformation
//
// Description: D100QueryInformation handles a query operation for a single
//              OID. Basically we return information about the current state of
//              the OID in question.
//
// Arguments:
//      MiniportAdapterContext - The context value returned by the Miniport
//                               when the adapter was initialized (see the call
//                               NdisMSetAttributes. In reality, it is a
//                               pointer to D100_ADAPTER.
//      Oid - The Oid that is to be queried.
//      InformationBuffer -  A pointer to the buffer that holds the result of
//                           the query.
//      InformationBufferLength - The length of InformationBuffer.
//
// Result:
//      BytesWritten - If the call is successful, returns the number of bytes
//                     written into InformationBuffer.
//      BytesNeeded - If there is not enough data in OvbBuffer to satisfy the
//                    OID, returns the amount of storage needed.
//
// Returns:
//      NDIS_STATUS_SUCCESS
//      NDIS_STATUS_NOT_SUPPORTED
//      NDIS_STATUS_BUFFER_TO_SHORT
//-----------------------------------------------------------------------------

NDIS_STATUS
D100QueryInformation(
                     IN NDIS_HANDLE MiniportAdapterContext,
                     IN NDIS_OID Oid,
                     IN PVOID InformationBuffer,
                     IN ULONG InformationBufferLength,
                     OUT PULONG BytesWritten,
                     OUT PULONG BytesNeeded
                     )

{
    // order is important here because the OIDs should be in order
    // of increasing value
    static
    NDIS_OID        D100GlobalSupportedOids[] =
    {
        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,
        OID_GEN_SUPPORTED_GUIDS,
        OID_GEN_XMIT_OK,
        OID_GEN_RCV_OK,
        OID_GEN_XMIT_ERROR,
        OID_GEN_RCV_ERROR,
        OID_GEN_RCV_NO_BUFFER,
        OID_GEN_RCV_CRC_ERROR,
        OID_GEN_TRANSMIT_QUEUE_LENGTH,
        OID_802_3_PERMANENT_ADDRESS,
        OID_802_3_CURRENT_ADDRESS,
        OID_802_3_MULTICAST_LIST,
        OID_802_3_MAXIMUM_LIST_SIZE,
        /* for ndis 4 packet priority
        OID_802_3_MAC_OPTIONS,
        */
        OID_802_3_RCV_ERROR_ALIGNMENT,
        OID_802_3_XMIT_ONE_COLLISION,
        OID_802_3_XMIT_MORE_COLLISIONS,
        OID_802_3_XMIT_DEFERRED,
        OID_802_3_XMIT_MAX_COLLISIONS,
        OID_802_3_RCV_OVERRUN,
        OID_802_3_XMIT_UNDERRUN,
        OID_802_3_XMIT_HEARTBEAT_FAILURE,
        OID_802_3_XMIT_TIMES_CRS_LOST,
        OID_802_3_XMIT_LATE_COLLISIONS,
        /* tcp/ip checksum offload */
        /*
        OID_TCP_TASK_OFFLOAD,
        */
        /* powermanagement */
        OID_PNP_CAPABILITIES,
        OID_PNP_SET_POWER,
        OID_PNP_QUERY_POWER,
        OID_PNP_ADD_WAKE_UP_PATTERN,
        OID_PNP_REMOVE_WAKE_UP_PATTERN,
        OID_PNP_ENABLE_WAKE_UP,
        /* end powermanagement */
        /* custom oid WMI support */
        OID_CUSTOM_DRIVER_SET,
        OID_CUSTOM_DRIVER_QUERY,
        OID_CUSTOM_ARRAY,
        OID_CUSTOM_STRING
    };


    // String describing our adapter
    char VendorDescriptor[] = VENDORDESCRIPTOR;


    PD100_ADAPTER   Adapter;

    UCHAR           VendorId[4];

    NDIS_MEDIUM     Medium = NdisMedium802_3;
    NDIS_HARDWARE_STATUS HardwareStatus = NdisHardwareStatusReady;

    UINT            GenericUlong;
    USHORT          GenericUShort;
    UCHAR           GenericArray[6];

    NDIS_STATUS     Status = NDIS_STATUS_SUCCESS;

    NDIS_PNP_CAPABILITIES    Power_Management_Capabilities;

    // Common variables for pointing to result of query
    PVOID           MoveSource = (PVOID) (&GenericUlong);
    ULONG           MoveBytes = sizeof(GenericUlong);


    // WMI support
    // check out the e100b.mof file for examples of how the below
    // maps into a .mof file for external advertisement of GUIDs
#define NUM_CUSTOM_GUIDS 4

    static const NDIS_GUID GuidList[NUM_CUSTOM_GUIDS] =
    { { // {F4A80276-23B7-11d1-9ED9-00A0C9010057} example of a uint set
            E100BExampleSetUINT_OIDGuid,
            OID_CUSTOM_DRIVER_SET,
            sizeof(ULONG),
            (fNDIS_GUID_TO_OID)
    },
    { // {F4A80277-23B7-11d1-9ED9-00A0C9010057} example of a uint query
            E100BExampleQueryUINT_OIDGuid,
            OID_CUSTOM_DRIVER_QUERY,
            sizeof(ULONG),
            (fNDIS_GUID_TO_OID)
        },
    { // {F4A80278-23B7-11d1-9ED9-00A0C9010057} example of an array query
            E100BExampleQueryArrayOIDGuid,
            OID_CUSTOM_ARRAY,
            sizeof(UCHAR), // size is size of each element in the array
            (fNDIS_GUID_TO_OID|fNDIS_GUID_ARRAY)
        },
    { // {F4A80279-23B7-11d1-9ED9-00A0C9010057} example of a string query
            E100BExampleQueryStringOIDGuid,
            OID_CUSTOM_STRING,
            (ULONG) -1, // size is -1 for ANSI or NDIS_STRING string types
            (fNDIS_GUID_TO_OID|fNDIS_GUID_ANSI_STRING)
        }
    };


    DEBUGFUNC("D100QueryInformation");
    INITSTR(("\n"));

    Adapter = PD100_ADAPTER_FROM_CONTEXT_HANDLE(MiniportAdapterContext);
    DEBUGCHAR(Adapter,'Q');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -