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

📄 hwacproc.c

📁 此压缩包为杰得开发得z228的BSP的源代码,可以实现很多功能,尤其是视频解码有很好的效果.
💻 C
📖 第 1 页 / 共 5 页
字号:
            Adapter->BSSIDList[i].MacAddress[1],
            Adapter->BSSIDList[i].MacAddress[2],
            Adapter->BSSIDList[i].MacAddress[3],
            Adapter->BSSIDList[i].MacAddress[4],
            Adapter->BSSIDList[i].MacAddress[5],
            Adapter->BSSIDList[i].Rssi));
    }
#endif

    //Check the whole BSSID list string if there's invalid character.
    for ( Flag = 0, i=0; (i < Adapter->ulNumOfBSSIDs)||(Flag!=0); i++ )
    {
            // We'll re-check the first one when the previous first one has been discard.
            if (Flag == 1)
            {
                Flag = 0;
                i--;
            }

            do
            {   //Check if there's invalid data rate.
                for ( k=0,TempV=0; k < NDIS_SUPPORTED_RATES; k++)
                    TempV |= Adapter->BSSIDList[i].SupportedRates[k];

                    if (( TempV == 0 ) || (Adapter->BSSIDList[i].SupportedRates[0] == 0))
                    {
                        Flag = 1;
                        DBGPRINT(DBG_SCAN, ("Invalid support rate\n")); 
                        break;
                    }

                    // check for DS config
#if !(defined(MRV_MODE_A) || defined(MRV_MODE_ABG)) //#ifndef MRV_CHIP_8385H       
                if ((Adapter->BSSIDList[i].Configuration.DSConfig<2412)||
                    (Adapter->BSSIDList[i].Configuration.DSConfig>2484) )
                    {
                        Flag = 1;
                        DBGPRINT(DBG_SCAN, ("Invalid DSConfig: %d\n", 
                            Adapter->BSSIDList[i].Configuration.DSConfig))
                        break;
                    }
#endif
                    // marked for support associate to Hide SSID
            if ( Adapter->BSSIDList[i].Ssid.SsidLength == 0 )
                    {   
                           Flag = 1;
                break;
                            DBGPRINT(DBG_SCAN, ("0 length SSID, discard (%d)\n", i));
                    }

                    // Check the invalid SSID.
                for (j=0; j < Adapter->BSSIDList[i].Ssid.SsidLength; j++)
                {
                    if ( Adapter->BSSIDList[i].Ssid.Ssid[j] < 0x20 )
                    {
                            DBGPRINT(DBG_SCAN,("INVALID BSSID Setting flag to discard (%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
                            DBGPRINT(DBG_SCAN,("i = %d, j = %d, TempV = %x, Ssid[j] = %x, dsconfig = %d\n", i,j, TempV, Adapter->BSSIDList[i].Ssid.Ssid[j],Adapter->BSSIDList[i].Configuration.DSConfig));
                            // Replace the current BSSID struct with last one
                            Flag = 1;
                            break;
                    }
                }
            if  ( Adapter->BSSIDList[i].Ssid.Ssid[0] == 0x20 )
            {
                Flag = 1;
                break;      
            }       
            } while (0);

            if (Flag == 1)
            {
                if ((i+1) == Adapter->ulNumOfBSSIDs)
                {
                    DBGPRINT(DBG_SCAN,("INVALID BSSID DISCARDING LAST(%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
                    NdisZeroMemory( &(Adapter->BSSIDList[i]), 
                                    sizeof(NDIS_WLAN_BSSID_EX));
                        NdisZeroMemory( &(Adapter->IEBuffer[i]),
                                        sizeof(MRV_BSSID_IE_LIST));
                    Adapter->ulNumOfBSSIDs -= 1;
                    Flag = 0;
                    break;
                }
                else
                    {
                    //We start replace the current invalid SSID with last SSID in array.
                    DBGPRINT(DBG_SCAN,("INVALID BSSID DISCARDING CURRENT(%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
                    NdisMoveMemory( &(Adapter->BSSIDList[i]), 
                                    &(Adapter->BSSIDList[Adapter->ulNumOfBSSIDs-1]),      
                                    sizeof(NDIS_WLAN_BSSID_EX));
                    NdisZeroMemory( &(Adapter->BSSIDList[Adapter->ulNumOfBSSIDs-1]), 
                                sizeof(NDIS_WLAN_BSSID_EX));
                        NdisMoveMemory( &(Adapter->IEBuffer[i]),
                                        &(Adapter->IEBuffer[Adapter->ulNumOfBSSIDs-1]),
                                        sizeof(MRV_BSSID_IE_LIST));
                        NdisZeroMemory( &(Adapter->IEBuffer[Adapter->ulNumOfBSSIDs-1]),
                                        sizeof(MRV_BSSID_IE_LIST));
                    Adapter->ulNumOfBSSIDs -= 1;
                    }
            } // if (Flag == 1)
        }
  
    DBGPRINT(DBG_CMDRESP| DBG_ALLEN,("HWAC - Background scanned %2d APs\n", Adapter->ulNumOfBSSIDs));  
    
        {
        // active scan, append AP only if it does not already exist
        ULONG   i,j;
        BOOLEAN bFound;

        for ( i=0; i < Adapter->ulNumOfBSSIDs; i++ )
            {
                    bFound = FALSE;
                    for ( j=0; j < Adapter->ulPSNumOfBSSIDs; j++ )
                    {
                        // compare SSID, BSSID, and Mode
                        if ( Adapter->BSSIDList[i].Ssid.SsidLength != 
                            Adapter->PSBSSIDList[j].Ssid.SsidLength )
                        {
                                continue;
                        }
                        if ( NdisEqualMemory(Adapter->BSSIDList[i].Ssid.Ssid,
                                     Adapter->PSBSSIDList[j].Ssid.Ssid,
                                     Adapter->PSBSSIDList[j].Ssid.SsidLength) == 0 )
                        {
                                continue;
                        }
                        if ( NdisEqualMemory(Adapter->BSSIDList[i].MacAddress,
                                     Adapter->PSBSSIDList[j].MacAddress,
                                     ETH_ADDR_LENGTH) == 0 )
                        {
                                continue;
                        }
                        if ( Adapter->BSSIDList[i].InfrastructureMode != 
                            Adapter->PSBSSIDList[j].InfrastructureMode )
                        {
                                continue;
                        }
                        bFound = TRUE;

                        // replace the current entry 
                        NdisMoveMemory(&Adapter->PSBSSIDList[j],
                                    &Adapter->BSSIDList[i],
                                    sizeof(NDIS_WLAN_BSSID_EX));
                        NdisMoveMemory(&Adapter->PSIEBuffer[j],
                                    &Adapter->IEBuffer[i],
                                    sizeof(MRV_BSSID_IE_LIST));  
                    NdisMoveMemory(&Adapter->PSBssDescList[j], 
                                &Adapter->BssDescList[i],
                                    sizeof(BSS_DESCRIPTION_SET_ALL_FIELDS));

                        DBGPRINT(DBG_SCAN, ("PScan: Replace Specific Scan Entry %d "
                                                     "To Scan List\n", j));
                    }
                    
                    if (! bFound)
                    {
                           if (Adapter->ulPSNumOfBSSIDs  < MRVDRV_MAX_BSSID_LIST)
                    {
                            // append at the end
                            NdisMoveMemory( &Adapter->PSBSSIDList[Adapter->ulPSNumOfBSSIDs],
                                                  &Adapter->BSSIDList[i],
                                                  sizeof(NDIS_WLAN_BSSID_EX));
                            NdisMoveMemory( &Adapter->PSIEBuffer[Adapter->ulPSNumOfBSSIDs],
                                                  &Adapter->IEBuffer[i],
                                                  sizeof(MRV_BSSID_IE_LIST)); 
                            NdisMoveMemory( &Adapter->PSBssDescList[Adapter->ulPSNumOfBSSIDs], 
                                                  &Adapter->BssDescList[i],
                                                  sizeof(BSS_DESCRIPTION_SET_ALL_FIELDS)); 

                            Adapter->ulPSNumOfBSSIDs++;

                            DBGPRINT(DBG_SCAN, ("PScan: Append Specific Scan Entry %d "
                                                      "To Scan List\n", i));
                    } 
                }
        }
        }

}


NDIS_STATUS 
HandleBgScanResultEvent ( 
        PMRVDRV_ADAPTER pAdapter 
        )
{
    NDIS_STATUS Status;
        OID_MRVL_DS_BG_SCAN_QUERY       BgQuery;

RETAILMSG(1, (TEXT("HandleBgScanResultEvent() \r\n")));          

        BgQuery.Oid = OID_MRVL_BG_SCAN_QUERY;
    BgQuery.Flush = 1; // flush current results in firmware.

        Status = PrepareAndSendCommand(
                          pAdapter,
                            HostCmd_CMD_802_11_BG_SCAN_QUERY,
                                HostCmd_ACT_GET,
                                HostCmd_OPTION_USE_INT,
                                (NDIS_OID)0,
                                HostCmd_PENDING_ON_NONE,
                                0,
                                FALSE,
                                NULL,
                                NULL,
                                NULL,
                                &BgQuery);   

        DBGPRINT( DBG_SCAN, ("Send out BG_SCAN_QUERY for getting background scan results [return: 0x%x]\n", Status) );

        return Status;
        
}
#endif /* BG_SCAN */

/******************************************************************************
 *
 *  Name: HandleMicError()
 *
 *  Description: handle MIC error
 *
 *  Arguments:  PMRVDRV_ADAPTER Adapter
 *        UINT ErrorType
 *    
 *  Return Value:        
 * 
 *  Notes:               
 *
 *****************************************************************************/

VOID
HandleMicError(
               IN PMRVDRV_ADAPTER Adapter, 
             IN UINT ErrorType)
{
    WPA_NOTIFY_OS   message;
    ULONG           ulCurrTime;
    ULONG           ulTimeDiff;

    NdisZeroMemory(&message, sizeof(WPA_NOTIFY_OS));
    NdisMoveMemory(message.request.Bssid, Adapter->CurrentBSSID, 
                sizeof(Adapter->CurrentBSSID));
    message.request.Length = sizeof(NDIS_802_11_AUTHENTICATION_REQUEST);
    message.status = Ndis802_11StatusType_Authentication;
    
    switch (ErrorType)
    {

    case MACREG_INT_CODE_WPA_MIC_ERR_UNICAST:
        message.request.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
        DBGPRINT(DBG_WARNING, ("Pairwise MIC Error!\n"));
        break;

    case MACREG_INT_CODE_WPA_MIC_ERR_MULTICAST:
        message.request.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR;
        DBGPRINT(DBG_WARNING, ("Groupwise MIC Error!\n"));
        break;

    default:
        DBGPRINT(DBG_ERROR, ("HandleMicError(): do not know how to handle error code 0x%x!\n",
                            ErrorType));
        // skip the indication
        return;
    }

    NdisMIndicateStatus(Adapter->MrvDrvAdapterHdl,
                        NDIS_STATUS_MEDIA_SPECIFIC_INDICATION,
                        &message,
                        sizeof(WPA_NOTIFY_OS));
    NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
    DBGPRINT(DBG_MACEVENT, ("*** Indicated MIC error!\n"));

    NdisGetSystemUpTime(&ulCurrTime);
    
    if ( ulCurrTime > Adapter->ulLastMICErrorTime )
    {
        ulTimeDiff = ulCurrTime - Adapter->ulLastMICErrorTime;
    }
    else
    {
        ulTimeDiff = 0xFFFFFFFF - Adapter->ulLastMICErrorTime + ulCurrTime;
    }

    NdisMSleep(20000);
    
    if ( (Adapter->ulLastMICErrorTime != 0) && (ulTimeDiff < MRVDRV_MIC_ERROR_PERIOD) )
    { 
// tt mic error ++: driver will send out de-auth after de-auth mac event is rising.
        USHORT          usCommand;
       
// tt ++ mic error 2
        Adapter->ulMicErrorStartTime = ulCurrTime;
// tt --
        Adapter->bMicErrorIsHappened = TRUE;
        DBGPRINT( DBG_MACEVENT, ("*** MIC error is happended!\n") );

        NdisMSleep( 1000*500 ); // for sending out "MIC failure report"
        DBGPRINT( DBG_MACEVENT, ("*** Going to send out de-auth and indicate disconnect!\n") );

        if ( Adapter->InfrastructureMode == Ndis802_11Infrastructure )
        {
            usCommand = HostCmd_CMD_802_11_DEAUTHENTICATE;
        }
        else
        {
            usCommand = HostCmd_CMD_802_11_AD_HOC_STOP;
        }

        // completely clean up
        PrepareAndSendCommand(
                  Adapter,
                  usCommand,
                  0,
                  HostCmd_OPTION_USE_INT,
                  0,
                  HostCmd_PENDING_ON_NONE,
                  0,
                  FALSE,
                  NULL,
                  NULL,
                  NULL,
                  NULL);

        NdisMSleep(100000);
        //NdisMSleep(60000);
        DBGPRINT(DBG_MACEVENT, ("Time since last MIC error is %d, disconnect!\n", ulTimeDiff));
        //062905
        ResetDisconnectStatus(Adapter);
    DBGPRINT(DBG_MACEVENT, ("Time since last MIC error is %d, disconnect!\n", ulTimeDiff));

// tt mic error --
    }

    Adapter->ulLastMICErrorTime = ulCurrTime;
  
}

// tt mic error ++
VOID DisconnectDueToMicError( PMRVDRV_ADAPTER pAdapter )
{
    USHORT          usCommand;

    if ( pAdapter->MediaConnectStatus != NdisMediaStateConnected )
    {
        DBGPRINT( DBG_MACEVENT, ("*** Connection had already been disconnected.\n") );
        return;
    }
    
    DBGPRINT( DBG_MACEVENT, ("*** Send out de-authentication due to MIC error\n") );

    if ( pAdapter->InfrastructureMode == Ndis802_11Infrastructure )
        usCommand = HostCmd_CMD_802_11_DEAUTHENTICATE;
    else
        usCommand = HostCmd_CMD_802_11_AD_HOC_STOP;

    DBGPRINT( DBG_WARNING, ("[Mrvl] Send out de-auth due to MIC error\n") );
    
    PrepareAndSendCommand(
                  pAdapter,
                  usCommand,
                  0,
                  HostCmd_OPTION_USE_INT,
                  0,
                  HostCmd_PENDING_ON_NONE,

⌨️ 快捷键说明

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