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

📄 card.cpp

📁 WinCE5.0部分核心源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        else {
            DbgPrint("Using cached BSSID list\n");
            }
        #endif


        if (StatusToReturn == NDIS_STATUS_SUCCESS) {
            MoveSource  = card->bssid_list;
            MoveBytes   = card->bssid_list_size;
            }

        #ifdef DEBUG_BSSID_LIST
        DbgPrint("OID_802_11_BSSID_LIST: leave\n");
        #endif

        break;
        }


    //-----------------------------------------------------------------------
    // Returns the Received Signal Strength Indication in dBm.
    // 
    // Data type:  NDIS_802_11_RSSI.
    // Query:      Returns the current RSSI value.
    // Set:        Not supported.
    // Indication: If an indication request is enabled, then an event is 
    //             triggered according to the value as given in the set.
    //-----------------------------------------------------------------------
    case OID_802_11_RSSI: {
        // 
        // If it's NULL then try to read again since it's possible the firmware
        // has been updated since we tried when the driver started up.
        // 
        if (card->dBmTable == NULL) {
            card->dBmTable = cmdDBMTableGet(card);
            }
        // 
        // If still NULL then this OID is not supported.
        // 
        if (card->dBmTable == NULL) {
            StatusToReturn = NDIS_STATUS_NOT_SUPPORTED;
            }
        else {
            STSTATUS status;
            if (cmdStatusGet(card, &status)) {
/*
                // percent is in the low byte -- don't need this.
                USHORT percent  = (card->dBmTable->table[status.u16SignalStrength] & 0x00FF);
*/
                USHORT rssi = (card->dBmTable->table[status.u16SignalStrength & 0x00FF] & 0xFF00) >> 8;
                ndis_rssi   = (NDIS_802_11_RSSI)rssi * -1;
                if (ndis_rssi < -90 && card->m_MSenceStatus == NDIS_STATUS_MEDIA_CONNECT) {
                    //This keeps netshell from displaying no signal when we are connect on XP.
                    ndis_rssi = -90;
                }

                MoveSource  = &ndis_rssi;
                MoveBytes   = sizeof(NDIS_802_11_RSSI);
                }
            else {
                StatusToReturn = NDIS_STATUS_INVALID_DATA;
                }
            }
        break;
        }

    //-----------------------------------------------------------------------
    // Query shall respond with the WEP status indicating whether WEP is enabled, 
    // WEP is disabled, WEP key is absent, or WEP is not supported. Query response 
    // indicating that WEP is enabled or WEP is disabled implies that WEP key is 
    // available for the NIC to encrypt data, that is, WEP key is available for 
    // MPDU transmission with encryption. Query response indicating WEP key is 
    // absent implies that WEP key is not available for the NIC to encrypt data 
    // and therefore WEP cannot be enabled or disabled. Note that this implies 
    // that while WEP key(s) may be available, the NIC does not have a WEP key 
    // for MPDU transmission with encryption. Query response indicating that WEP 
    // is not supported implies that the NIC does not support the desired WEP, 
    // that is, the NIC is not capable of encrypting data and hence WEP cannot be 
    // enabled or disabled. The NIC is permitted to set the WEP status to either 
    // enable or disable setting only. In order to be able to set the WEP status 
    // to either enable or disable setting, it is required that WEP key is 
    // available for MPDU transmission with encryption. If the set WEP status 
    // operation cannot be done, the driver shall return an NDIS_STATUS value of 
    // NDIS_STATUS_NOT_ACCEPTED.     
    // 
    // Data type:   NDIS_802_11_WEP_STATUS.
    // Query:       Returns the current WEP status.
    // Set:         Permitted to enable or disable WEP only.
    // Indication:  Not supported.
    //-----------------------------------------------------------------------
    case OID_802_11_WEP_STATUS: {
        STCAPS caps;
        if (cmdCapsGet(card, &caps)) {

            // Does card support WEP (40 bit) ?  
            //
            // (NOTE: We can check the SOFT_CAPS_128_BIT_WEP_SUPPORT bit to see if 
            //  128 bit WEP is supported).
            if (caps.u16SoftwareCapabilities & SOFT_CAPS_WEP_ENCRYPTION_SUPPORT) {
                // WEP is supported.  Now let's see if a WEP key is set.
                RID_WEP_Key keyBuf;

                // Read first WEP key RID.
                if (RidGet(card, RID_WEP_SESSION_KEY, &keyBuf, sizeof(RID_WEP_Key))) {

                    // Check key index.  0xFFFF indicates no keys, 4 indicates home key.
                    // All we're interested in are the enterprise keys (index = 0-3).
                    if ((keyBuf.keyindex == 0xFFFF) || (keyBuf.keyindex == 4)) {

                        // WEP key is not set.
                        ndis_wepstatus = Ndis802_11WEPKeyAbsent;
                        }
                    else {

                        // WEP is set, but is it enabled ?
                        if (card->m_activeProfile->zFlags.cfg.AuthenType & AUTH_TYPE_WEP) {
                            ndis_wepstatus = Ndis802_11WEPEnabled;
                            }
                        else {
                            ndis_wepstatus = Ndis802_11WEPDisabled;
                            }
                        }
                    }
                else {
                    StatusToReturn = NDIS_STATUS_INVALID_DATA;
                    }
                }
            else {
                ndis_wepstatus = Ndis802_11WEPNotSupported;
                }

            if (StatusToReturn == NDIS_STATUS_SUCCESS) {
                MoveSource  = &ndis_wepstatus;
                MoveBytes   = sizeof(NDIS_802_11_WEP_STATUS);
                }
            }
        else {
            StatusToReturn = NDIS_STATUS_INVALID_DATA;
            }
        break;
        }

//***************************************************************************
// END 802.11 OIDs
//***************************************************************************

#if NDISVER == 5
    case OID_PNP_CAPABILITIES:
        ndis_pnp_capablities.WakeUpCapabilities.MinMagicPacketWakeUp    = NdisDeviceStateUnspecified;
        ndis_pnp_capablities.WakeUpCapabilities.MinPatternWakeUp        = NdisDeviceStateUnspecified;
        ndis_pnp_capablities.WakeUpCapabilities.MinLinkChangeWakeUp     = NdisDeviceStateUnspecified;
                                                                                                 
        if (0xFFFF != (0xFFFF & card->m_MagicPacketMode)) {
          ndis_pnp_capablities.WakeUpCapabilities.MinMagicPacketWakeUp    = NdisDeviceStateD3;
    // this is necessary to have pattern enabled---2K + XP wont let you wake-on-lan otherwise
          ndis_pnp_capablities.WakeUpCapabilities.MinPatternWakeUp        = NdisDeviceStateD0;
                                                                                                 
          ndis_pnp_capablities.Flags = NDIS_DEVICE_WAKE_UP_ENABLE;
        }

        MoveSource      = (PVOID)&ndis_pnp_capablities; 
        MoveBytes       = sizeof(NDIS_PNP_CAPABILITIES);
        break;

    case OID_PNP_QUERY_POWER:
        MoveBytes       = 0;
        break;

    case OID_PNP_ENABLE_WAKE_UP:
        break;

    case OID_PNP_WAKE_UP_PATTERN_LIST:
        MoveBytes       = 0;
        break;

    case OID_GEN_PHYSICAL_MEDIUM:
        GenericULong    = NdisPhysicalMediumWirelessLan;
        break;

    case OID_TCP_TASK_OFFLOAD:
        if (card->mp_enabled == MP_SENT) {
            card->mp_enabled = MP_ENABLED;
        }
        StatusToReturn = NDIS_STATUS_NOT_SUPPORTED; //stub
        break;
#endif
    default: {
        //spb012
        NDIS_STATUS status=ExtendedOids(card, Oid, InfBuff, InfBuffLen, BytesWritten, BytesNeeded);        
        return status;
        } 
    }

    if (StatusToReturn == NDIS_STATUS_SUCCESS) {
        if (MoveBytes > InfBuffLen) {
            // Not enough room in InfBuff, Punt
            *BytesNeeded    = MoveBytes;
            StatusToReturn  = NDIS_STATUS_BUFFER_TOO_SHORT;
        } 
        else {
            if (MoveBytes) {
                // Store result.
                NdisMoveMemory(InfBuff, MoveSource, MoveBytes); 
                *BytesWritten = MoveBytes;
            }
        }
    }

    return StatusToReturn;
}

//===========================================================================
    NDIS_STATUS cbSetInformation (NDIS_HANDLE     Context,
                                  IN NDIS_OID     Oid,
                                  IN PVOID        InfBuff,
                                  IN ULONG        InfBuffLen,
                                  OUT PULONG      BytesRead,
                                  OUT PULONG      BytesNeeded)
//===========================================================================
// 
// Description: MiniportSetInformation.
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{
    PCARD           card = (PCARD)Context;
    NDIS_STATUS     StatusToReturn  = NDIS_STATUS_SUCCESS;  // Status of the operation.


//    DbgPrint("Oid Set   %X\n", Oid);

    //spb001 Finish Initialization if we haven't yet
    if (!card->initComplete) {
        InitFW1(card);
        InitInterrupts( card ); //spb010
    }

    if (TRUE == CheckCardFlashing(card,&StatusToReturn,Oid )) {  
        return StatusToReturn;
    }

#if NDISVER == 5
    if (card->mp_enabled == MP_ENABLED)
    { 
      InitFW(card, TRUE);
      card->mp_enabled = MP_POWERED;
      InitInterrupts( card );     //spb010
    } 
#endif

    //spb012
    cmdAwaken(card, TRUE);

    switch (Oid) {
    case OID_802_3_MULTICAST_LIST:
        if ((InfBuffLen % AIRONET_LENGTH_OF_ADDRESS) ||
            (InfBuffLen > (DEFAULT_MULTICASTLISTMAX * AIRONET_LENGTH_OF_ADDRESS))) {
            *BytesRead      = 0;
            *BytesNeeded    = 0;
            StatusToReturn  = NDIS_STATUS_INVALID_LENGTH;
            break;
            }
        card->m_CurMulticastSize = InfBuffLen / AIRONET_LENGTH_OF_ADDRESS;
        if (DEFAULT_MULTICASTLISTMAX < card->m_CurMulticastSize) {
            card->m_CurMulticastSize =  DEFAULT_MULTICASTLISTMAX;
            }

        NdisMoveMemory(card->m_Addresses, InfBuff, InfBuffLen);
        StatusToReturn = NDIS_STATUS_SUCCESS;
        break;

    case OID_GEN_CURRENT_PACKET_FILTER:

        if (InfBuffLen != 4) {
            *BytesRead      = 0;
            *BytesNeeded    = 0;
            StatusToReturn  = NDIS_STATUS_INVALID_LENGTH;
            break;
            }

        NdisMoveMemory(&card->m_PacketFilter, InfBuff, 4);

        if (card->m_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 
                                    | NDIS_PACKET_TYPE_PROMISCUOUS)) {
            *BytesRead      = 4;
            *BytesNeeded    = 0;
            StatusToReturn  = NDIS_STATUS_NOT_SUPPORTED;
            break;
            }
        #if 0
        SetPromiscuousMode(card, card->m_PacketFilter & NDIS_PACKET_TYPE_PROMISCUOUS );
        #endif
        break;

    case OID_GEN_CURRENT_LOOKAHEAD:

        if (InfBuffLen != 4) {
            *BytesRead      = 0;
            *BytesNeeded    = 0;
            StatusToReturn  = NDIS_STATUS_INVALID_LENGTH;
            break;
            }

        if (card->m_MaxLookAhead > AIRONET_MAX_LOOKAHEAD) {
            StatusToReturn = NDIS_STATUS_INVALID_LENGTH;
            }
        else {
            NdisMoveMemory(&card->m_MaxLookAhead, InfBuff, 4);
            }
        break;


//***************************************************************************

⌨️ 快捷键说明

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