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

📄 sync.c

📁 华硕无线网卡 167G linux 驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
                    }                }            }            // Copy AP's supported rate to portcfg for creating assoication request            // Also filter out not supported rate            // Supported rate            {                int i;                pAd->PortCfg.SupRateLen = 0;                for (i = 0; i < SupRateLen; i++)                {                    UCHAR Rate = SupRate[i] & 0x7f;                    if ((pAd->PortCfg.PhyMode == PHY_11B) &&                        (Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22))                    {                        pAd->PortCfg.SupRate[pAd->PortCfg.SupRateLen] = SupRate[i];                        pAd->PortCfg.SupRateLen ++;                    }                    else if ((Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22) ||                             (Rate == 12 || Rate == 18 || Rate == 24 || Rate == 36) ||                             (Rate == 48 || Rate == 72 || Rate == 96 || Rate == 108))                    {                        pAd->PortCfg.SupRate[pAd->PortCfg.SupRateLen] = SupRate[i];                        pAd->PortCfg.SupRateLen ++;                    }                }            }            // Copy AP's supported rate to portcfg for creating assoication request            // Also filter out not supported rate            // Extended rate            if (ExtendedRateIeExist == TRUE)            {                int i;                pAd->PortCfg.ExtRateLen = 0;                for (i = 0; i < ExtRateLen; i++)                {                    UCHAR Rate = ExtRate[i] & 0x7f;                    if ((pAd->PortCfg.PhyMode == PHY_11B) &&                        (Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22))                    {                        pAd->PortCfg.ExtRate[pAd->PortCfg.ExtRateLen] = ExtRate[i];                        pAd->PortCfg.ExtRateLen ++;                    }                    else if ((Rate == 2 || Rate == 4 || Rate == 11 || Rate == 22) ||                             (Rate == 12 || Rate == 18 || Rate == 24 || Rate == 36) ||                             (Rate == 48 || Rate == 72 || Rate == 96 || Rate == 108))                    {                        pAd->PortCfg.ExtRate[pAd->PortCfg.ExtRateLen] = ExtRate[i];                        pAd->PortCfg.ExtRateLen ++;                    }                }            }            else            {                pAd->PortCfg.ExtRateLen = 0;            }                        DBGPRINT(RT_DEBUG_TRACE, "SYNC - AP's SupportedRatesLen=%d, set STA's SupportedRateLen=%d\n",                 RatesLen, pAd->PortCfg.SupportedRatesLen);                        // Mask out unnecessary capability information            CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;                        // Check for 802.11g information, if 802.11 b/g mixed mode.            // We can't support its short preamble for now.            pAd->PortCfg.CapabilityInfo = CapabilityInfo;            if ((BssType == BSS_INDEP) && (CAP_IS_IBSS_ON(CapabilityInfo)))             {                pAd->PortCfg.AtimWin = AtimWin;            }             else if (BssType == BSS_INFRA)             {                pAd->PortCfg.CfpPeriod = Cf.CfpPeriod;                pAd->PortCfg.CfpMaxDuration = Cf.CfpMaxDuration;                pAd->PortCfg.CfpDurRemain = Cf.CfpDurRemaining;                pAd->PortCfg.CfpCount = Cf.CfpCount;                pAd->PortCfg.CfpPeriod = Cf.CfpPeriod;                AsicEnableBssSync(pAd);            }            pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;            MlmeCntlConfirm(pAd, MT2_JOIN_CONF, MLME_SUCCESS);        }        // not to me BEACON, ignored    }     // sanity check fail, ignore this frame}/*     ==========================================================================    Description:        receive BEACON from peer    ========================================================================== */VOID PeerBeacon(    IN PRT2570ADAPTER pAd,     IN MLME_QUEUE_ELEM *Elem) {    MACADDR       Bssid, Addr2;    CHAR          Ssid[MAX_LEN_OF_SSID];    CF_PARM       CfParm;    UCHAR         SsidLen, MessageToMe=0, BssType, Channel, Rates[MAX_LEN_OF_SUPPORTED_RATES];    UCHAR         RatesLen, DtimCount=0, DtimPeriod=0, BcastFlag=0, Legacy;    USHORT        CapabilityInfo, AtimWin, BeaconPeriod;    LARGE_INTEGER TimeStamp;    BOOLEAN       CfExist = FALSE;    USHORT        TbttNumToNextWakeUp;    BOOLEAN       ExtendedRateIeExist;    UCHAR         Erp;    UCHAR         SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];    UCHAR         SupRateLen, ExtRateLen;	UCHAR         LenVIE;    // New for WPA security suites    UCHAR                       VarIE[MAX_VIE_LEN];     // Total VIE length = MAX_VIE_LEN - -5    NDIS_802_11_VARIABLE_IEs    *pVIE = NULL;    if (!INFRA_ON(pAd) && !ADHOC_ON(pAd)) {     // return;}    // Init Variable IE structure    pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;    pVIE->Length = 0;    if (PeerBeaconAndProbeRspSanity(pAd,                                 Elem->Msg,                                 Elem->MsgLen,                                 &Addr2,                                 &Bssid,                                 Ssid,                                 &SsidLen,                                 &BssType,                                 &BeaconPeriod,                                 &Channel,                                 &TimeStamp,                                 &CfExist,                                 &CfParm,                                 &AtimWin,                                 &CapabilityInfo,                                 Rates,                                 &RatesLen,                                &ExtendedRateIeExist,                                &Erp,                                &DtimCount,                                 &DtimPeriod,                                 &BcastFlag,                                 &MessageToMe,                                 &Legacy,                                SupRate,                                &SupRateLen,                                ExtRate,                                &ExtRateLen,                                &LenVIE,                                pVIE))     {        BOOLEAN is_my_bssid, is_my_ssid;        ULONG   Bssidx, Now;        BSS_ENTRY *pBss;	// Init Variable IE structure	pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;	pVIE->Length = 0;        is_my_bssid = (MAC_ADDR_EQUAL(&Bssid, &pAd->PortCfg.Bssid) ? TRUE : FALSE);        is_my_ssid = (((pAd->PortCfg.SsidLen == SsidLen) && (memcmp(Ssid, pAd->PortCfg.Ssid, (ULONG) SsidLen) == 0)) ? TRUE : FALSE);        // Mask out unnecessary capability information        CapabilityInfo &= SUPPORTED_CAPABILITY_INFO;        // ignore BEACON not for my SSID        if ((! is_my_ssid) && (! is_my_bssid))            {            return;            }        //        // Housekeeping "SsidBssTab" table for later-on ROAMing usage.         //        Bssidx = BssTableSearch(&pAd->Mlme.CntlAux.SsidBssTab, &Bssid);        if (Bssidx == BSS_NOT_FOUND)        {            // Return immediately when in transition process when changing association            // Found this bug when doing WHQL ad-hoc test case            if (pAd->PortCfg.SsidLen != pAd->Mlme.CntlAux.SsidLen)                return;            if (memcmp(pAd->PortCfg.Ssid, pAd->Mlme.CntlAux.Ssid, pAd->PortCfg.SsidLen) != 0)                return;                        // discover new AP of this network, create BSS entry            Bssidx = BssTableSetEntry(pAd, &pAd->Mlme.CntlAux.SsidBssTab, &Bssid, Ssid, SsidLen,                         BssType, BeaconPeriod, CfExist, &CfParm, AtimWin, CapabilityInfo,                         Rates, RatesLen, ExtendedRateIeExist, Channel, Elem->Rssi, TimeStamp, LenVIE, pVIE);            if (Bssidx == BSS_NOT_FOUND) // return if BSS table full                return;              DBGPRINT(RT_DEBUG_TRACE, "SYNC - New AP added to SsidBssTab[%d], RSSI=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",                 Bssidx, Elem->Rssi, Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],                 Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5]);        }                // if the ssid matched & bssid unmatched, we should select the bssid with large value.        // This might happened when two STA start at the same time        if (is_my_ssid && (! is_my_bssid) && ADHOC_ON(pAd))        {            INT i;            // Add to safe guard adhoc wep status mismatch            if (pAd->PortCfg.WepStatus != pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Bssidx].WepStatus)                return;                        // link down the one with smaller BSSID value.            for (i = 0; i < 6; i++)            {                if (Bssid.Octet[i] > pAd->PortCfg.Bssid.Octet[i])                {                    AsicDisableSync(pAd);                    memcpy(&pAd->PortCfg.Bssid, &Bssid, 6);                    AsicSetBssid(pAd, &pAd->PortCfg.Bssid);                     AsicEnableIbssSync(pAd);                    break;                }            }        }        DBGPRINT(RT_DEBUG_INFO, "SYNC - PeerBeacon from %02x:%02x:%02x:%02x:%02x:%02x - Dtim=%d/%d, Rssi=%02x\n",             Bssid.Octet[0], Bssid.Octet[1], Bssid.Octet[2],             Bssid.Octet[3], Bssid.Octet[4], Bssid.Octet[5],             DtimCount, DtimPeriod, Elem->Rssi);        Now = jiffies;        pBss = &pAd->Mlme.CntlAux.SsidBssTab.BssEntry[Bssidx];        pBss->Rssi = Elem->Rssi;       // lastest RSSI        pBss->LastBeaconRxTime = Now;   // last RX timestamp                //        // BEACON from my BSSID - either IBSS or INFRA network        //         if (is_my_bssid)        {            // 2002/12/06 - patch Abocom AP bug, which forgets to set "Privacy" bit in             // AssocRsp even though this bit is ON in Beacon. So we update according             // to following Beacon frame.            // pAd->PortCfg.PrivacyInvoked = CAP_IS_PRIVACY_ON(CapabilityInfo);                        pAd->PortCfg.LastBeaconRxTime = Now;#if 1            // at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps            // after last 11b peer left for several seconds, we'll auto switch back to 11G rate            // in MlmePeriodicExec()            if (ADHOC_ON(pAd) && (RatesLen <= 4))               {                // this timestamp is for MlmePeriodicExec() to check if all 11B peers have left                pAd->PortCfg.Last11bBeaconRxTime = Now;                                if (pAd->PortCfg.MaxTxRate > RATE_11)                {                    DBGPRINT(RT_DEBUG_TRACE, "SYNC - 11b peer joined. down-grade to 11b TX rates \n");                    memcpy(pAd->PortCfg.SupportedRates, Rates, MAX_LEN_OF_SUPPORTED_RATES);                    pAd->PortCfg.SupportedRatesLen = RatesLen;                    MlmeUpdateTxRates(pAd, FALSE);                    MakeIbssBeacon(pAd);        // supported rates changed                }            }#endif                            // check if RSSI reaches threshold            pAd->PortCfg.LastRssi = (pAd->PortCfg.LastRssi + Elem->Rssi) / 2;            pAd->PortCfg.AvgRssi  = (pAd->PortCfg.AvgRssi * 7 + Elem->Rssi) >> 3;            if ((pAd->PortCfg.RssiTriggerMode == RSSI_TRIGGERED_UPON_BELOW_THRESHOLD) &&                (pAd->PortCfg.LastRssi < pAd->PortCfg.RssiTrigger))            {                NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, &Dbm, sizeof(NDIS_802_11_RSSI));            }            else if ((pAd->PortCfg.RssiTriggerMode == RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD) &&                (pAd->PortCfg.LastRssi > pAd->PortCfg.RssiTrigger))            {                //NDIS_802_11_RSSI Dbm = pAd->PortCfg.LastRssi - pAd->BBPTuningParameters.RSSIToDbmOffset;                NdisMIndicateStatus(pAd->AdapterHandle, NDIS_STATUS_MEDIA_SPECIFIC_INDICATION, &Dbm, sizeof(NDIS_802_11_RSSI));                //DBGPRINT(RT_DEBUG_TRACE, "SYNC - NdisMIndicateStatus *** RSSI %d dBm, greater than threshold %d dBm\n",                 //    Dbm, pAd->PortCfg.RssiTrigger - pAd->BBPTuningParameters.RSSIToDbmOffset);            }            if (INFRA_ON(pAd)) // && (pAd->PortCfg.PhyMode == PHY_11BG_MIXED))            {                BOOLEAN bUseShortSlot, bUseBGProtection;                                // decide to use/change to -                 //      1. long slot (20 us) or short slot (9 us) time                //      2. turn on/off RTS/CTS and/or CTS-to-self protection                //      3. short preamble                bUseShortSlot = (pAd->PortCfg.UseShortSlotTime == TRUE) && CAP_IS_SHORT_SLOT_TIME(CapabilityInfo);                if (bUseShortSlot != pAd->PortCfg.ShortSlotInUsed)                    AsicSetSlotTime(pAd, bUseShortSlot);                bUseBGProtection = (pAd->PortCfg.UseBGProtection == 1) ||    // always use                                   ((pAd->PortCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp));                if (bUseBGProtection != pAd->PortCfg.BGProtectionInUsed)

⌨️ 快捷键说明

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