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

📄 wmgr.c

📁 VIA VT6656 USB linux source code.
💻 C
📖 第 1 页 / 共 5 页
字号:
    pMgmt->byCSSGK = KEY_CTL_NONE;    pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;        BSSvClearBSSList((HANDLE)pDevice, FALSE);        init_timer(&pMgmt->sTimerSecondCallback);    pMgmt->sTimerSecondCallback.data = (ULONG)pDevice;    pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack;    pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);        init_timer(&pDevice->sTimerCommand);    pDevice->sTimerCommand.data = (ULONG)pDevice;    pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;    pDevice->sTimerCommand.expires = RUN_AT(HZ);    //2007-0115-10<Add>by MikeLiu   #ifdef TxInSleep    init_timer(&pDevice->sTimerTxData);    pDevice->sTimerTxData.data = (ULONG)pDevice;    pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData;    pDevice->sTimerTxData.expires = RUN_AT(10*HZ);      //10s callback    pDevice->fTxDataInSleep = FALSE;     pDevice->IsTxDataTrigger = FALSE;    pDevice->nTxDataTimeCout = 0;   #endif        pDevice->cbFreeCmdQueue = CMD_Q_SIZE;    pDevice->uCmdDequeueIdx = 0;    pDevice->uCmdEnqueueIdx = 0;        pDevice->eCommandState = WLAN_CMD_IDLE;    pDevice->bCmdRunning = FALSE;    pDevice->bCmdClear = FALSE;            return;} /*+ *  * Routine Description: *    Start the station association procedure.  Namely, send an *    association request frame to the AP.  * * Return Value: *    None. *-*/VOID vMgrAssocBeginSta(     IN  HANDLE hDeviceContext,    IN  PSMgmtObject pMgmt,    OUT PCMD_STATUS pStatus    )    {    PSDevice             pDevice = (PSDevice)hDeviceContext;    PSTxMgmtPacket          pTxPacket;    pMgmt->wCurrCapInfo = 0;    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);    if (pDevice->bEncryptionEnable) {            pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);    }    // always allow receive short preamble        //if (pDevice->byPreambleType == 1) {    //    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);    //}    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);        if (pMgmt->wListenInterval == 0)        pMgmt->wListenInterval = 1;    // at least one.            // ERP Phy (802.11g) should support short preamble.    if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {        pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);        if (pDevice->bShortSlotTime == TRUE)            pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);    } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {        if (pDevice->byPreambleType == 1) {            pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);        }    }        if (pMgmt->b11hEnable == TRUE)        pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);            // build an assocreq frame and send it     pTxPacket = s_MgrMakeAssocRequest                (                    pDevice,                  pMgmt,                  pMgmt->abyCurrBSSID,                  pMgmt->wCurrCapInfo,                  pMgmt->wListenInterval,                  (PWLAN_IE_SSID)pMgmt->abyCurrSSID,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates                );                    if (pTxPacket != NULL ){        // send the frame         *pStatus = csMgmt_xmit(pDevice, pTxPacket);        if (*pStatus == CMD_STATUS_PENDING) {            pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING;            *pStatus = CMD_STATUS_SUCCESS;        }    }    else        *pStatus = CMD_STATUS_RESOURCES;        return ;}/*+ *  * Routine Description: *    Start the station re-association procedure. * * Return Value: *    None. *-*/VOID vMgrReAssocBeginSta(     IN  HANDLE hDeviceContext,    IN  PSMgmtObject pMgmt,    OUT PCMD_STATUS pStatus    )    {    PSDevice             pDevice = (PSDevice)hDeviceContext;    PSTxMgmtPacket          pTxPacket;    pMgmt->wCurrCapInfo = 0;    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);    if (pDevice->bEncryptionEnable) {                pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1);    }        //if (pDevice->byPreambleType == 1) {    //    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);    //}    pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);        if (pMgmt->wListenInterval == 0)        pMgmt->wListenInterval = 1;    // at least one.              // ERP Phy (802.11g) should support short preamble.    if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) {        pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);      if (pDevice->bShortSlotTime == TRUE)                  pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1);            } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) {        if (pDevice->byPreambleType == 1) {                       pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1);        }    }        if (pMgmt->b11hEnable == TRUE)        pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1);              pTxPacket = s_MgrMakeReAssocRequest                (                    pDevice,                                  pMgmt,                  pMgmt->abyCurrBSSID,                  pMgmt->wCurrCapInfo,                  pMgmt->wListenInterval,                  (PWLAN_IE_SSID)pMgmt->abyCurrSSID,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates                                  );                    if (pTxPacket != NULL ){        // send the frame         *pStatus = csMgmt_xmit(pDevice, pTxPacket);        if (*pStatus != CMD_STATUS_PENDING) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n");        }        else {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx sending.\n");        }                    }            return ;}  /*+ *  * Routine Description: *    Send an dis-association request frame to the AP.  * * Return Value: *    None. *-*/VOIDvMgrDisassocBeginSta(    IN  HANDLE hDeviceContext,    IN  PSMgmtObject pMgmt,    IN  PBYTE  abyDestAddress,    IN  WORD    wReason,        OUT PCMD_STATUS pStatus    ){    PSDevice            pDevice = (PSDevice)hDeviceContext;                PSTxMgmtPacket      pTxPacket = NULL;    WLAN_FR_DISASSOC    sFrame;    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN);    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));    // Setup the sFrame structure    sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;    sFrame.len = WLAN_DISASSOC_FR_MAXLEN;        // format fixed field frame structure    vMgrEncodeDisassociation(&sFrame);        // Setup the header    sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(        (        WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |         WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DISASSOC)        ));            memcpy( sFrame.pHdr->sA3.abyAddr1, abyDestAddress, WLAN_ADDR_LEN);    memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);    memcpy( sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);        // Set reason code     *(sFrame.pwReason) = cpu_to_le16(wReason);    pTxPacket->cbMPDULen = sFrame.len;    pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN;    // send the frame     *pStatus = csMgmt_xmit(pDevice, pTxPacket);    if (*pStatus == CMD_STATUS_PENDING) {        pMgmt->eCurrState = WMAC_STATE_IDLE;        *pStatus = CMD_STATUS_SUCCESS;    };                return;}                     /*+ *  * Routine Description:(AP function)  *    Handle incoming station association request frames. *    * Return Value: *    None. *-*/staticVOIDs_vMgrRxAssocRequest(    IN PSDevice pDevice,    IN PSMgmtObject pMgmt,    IN PSRxMgmtPacket pRxPacket,    IN UINT uNodeIndex    ){    WLAN_FR_ASSOCREQ    sFrame;      CMD_STATUS          Status;    PSTxMgmtPacket      pTxPacket;    WORD                wAssocStatus = 0;    WORD                wAssocAID = 0;    UINT                uRateLen = WLAN_RATES_MAXLEN;        BYTE                abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];    BYTE                abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];        if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)        return;    //  node index not found      if (!uNodeIndex)        return;                //check if node is authenticated    //decode the frame    memset(&sFrame, 0, sizeof(WLAN_FR_ASSOCREQ));    memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);    memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);        sFrame.len = pRxPacket->cbMPDULen;    sFrame.pBuf = (PBYTE)pRxPacket->p80211Header;        vMgrDecodeAssocRequest(&sFrame);        if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) {        pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC;        pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = cpu_to_le16(*sFrame.pwCapInfo);        pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = cpu_to_le16(*sFrame.pwListenInterval);        pMgmt->sNodeDBTable[uNodeIndex].bPSEnable =                 WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? TRUE : FALSE;        // Todo: check sta basic rate, if ap can't support, set status code        if (pDevice->byBBType == BB_TYPE_11B) {            uRateLen = WLAN_RATES_MAXLEN_11B;        }        abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES;        abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,                                         (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,                                         uRateLen);        abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES;        if (pDevice->byBBType == BB_TYPE_11G) {            abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates,                                                (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,                                                uRateLen);        } else {            abyCurrExtSuppRates[1] = 0;        }                                RATEvParseMaxRate((PVOID)pDevice,                           (PWLAN_IE_SUPP_RATES)abyCurrSuppRates,                           (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates,                           FALSE, // do not change our basic rate                           &(pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate),                           &(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate),                           &(pMgmt->sNodeDBTable[uNodeIndex].wSuppRate),                           &(pMgmt->sNodeDBTable[uNodeIndex].byTopCCKBasicRate),                           &(pMgmt->sNodeDBTable[uNodeIndex].byTopOFDMBasicRate)                          );                        // set max tx rate                             pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate =                 pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate;        // Todo: check sta preamble, if ap can't support, set status code        pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble =                WLAN_GET_CAP_INFO_SHORTPREAMBLE(*sFrame.pwCapInfo);        pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime =                WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo);        pMgmt->sNodeDBTable[uNodeIndex].wAID = (WORD)uNodeIndex;        wAssocStatus = WLAN_MGMT_STATUS_SUCCESS;        wAssocAID = (WORD)uNodeIndex;        // check if ERP support        if(pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M)           pMgmt->sNodeDBTable[uNodeIndex].bERPExist = TRUE;                   if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate <= RATE_11M) {            // B only STA join            pDevice->bProtectMode = TRUE;            pDevice->bNonERPPresent = TRUE;        }        if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble == FALSE) {            pDevice->bBarkerPreambleMd = TRUE;        }                              DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID);        DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n",                   sFrame.pHdr->sA3.abyAddr2[0],                   sFrame.pHdr->sA3.abyAddr2[1],                   sFrame.pHdr->sA3.abyAddr2[2],                   sFrame.pHdr->sA3.abyAddr2[3],                   sFrame.pHdr->sA3.abyAddr2[4],                   sFrame.pHdr->sA3.abyAddr2[5]                  ) ;         DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n",                    pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate);    }        // assoc response reply..                    pTxPacket = s_MgrMakeAssocResponse                (                    pDevice,                                  pMgmt,                  pMgmt->wCurrCapInfo,                  wAssocStatus,                   wAssocAID,                  sFrame.pHdr->sA3.abyAddr2,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,                  (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates                );    if (pTxPacket != NULL ){                if (pDevice->bEnableHostapd) {            return;        }                /* send the frame */        Status = csMgmt_xmit(pDevice, pTxPacket);        if (Status != CMD_STATUS_PENDING) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n");        }        else {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx sending..\n");        }    }                        

⌨️ 快捷键说明

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