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

📄 dot11smeaplib.c

📁 PNE 3.3 wlan source code, running at more than vxworks6.x version
💻 C
📖 第 1 页 / 共 5 页
字号:
    (    DOT11_FW * pDot11      /* Ptr to dot11 Framework */    )    {    int i;    DOT11_KSL_ENTRY * pKsl;    STATUS status = OK;    DOT11_AP_OBJ * pAp;    DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,              ("dot11SmeApReset: Called\n", 0,0, 0, 0, 0, 0));    /* Get the pointer to the DOT11_AP_OBJ structure for simple access */    pAp = &pDot11->sme->type.ap;    if (pDot11->sme->ksl.lock(pDot11) != OK)        {        DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT,                  ("dot11SmeApReset: Cannot get lock\n",                   0,0,0,0,0,0));        return ERROR;        }       /* Check each BSS for needed passphrase updates */    for (i=0; i< DOT11_BSS_MAX; i++)        {        if (!pDot11->sme->bss[i].inUse)            {            continue;            }        pDot11->sme->bss[i].linkStatus = DOT11_LINK_UP;        /* Regenerate the beaon, since we're assuming that something has         changed */        if (pDot11->sme->bss[i].pMblkBeacon == NULL)            {            dot11SmeApBeaconUpdate(pDot11, &pDot11->sme->bss[i]);             }        else            {            pDot11->sme->bss[i].pMblkBeacon->mBlkHdr.mLen =                 dot11SmeApBeaconCreate(pDot11,                                        (UINT8*)pDot11->sme->bss[i].pMblkBeacon->mBlkHdr.mData,                                       (UINT16)DOT11_TYPE_BEACON,                                        &pDot11->sme->bss[i]);            }        /* If we're using WPA/RSN passphrase, then ensure that the passphrase         has been regenerated if the SSID changed */        if (((pDot11->sme->bss[i].authPol & DOT11_AUTHPOL_PSK) != 0) &&             (strlen(pDot11->sme->bss[i].rsnPassphrase) != 0) &&            (pDot11->sme->rsn.passphraseSet != NULL))            {            /* Check if it really needs to be regenerated - has the SSID             changed? */            if ((strlen(pDot11->sme->bss[i].rsnPassLastSsid) == 0) ||                 (bcmp(pDot11->sme->bss[i].rsnPassLastSsid,                      pDot11->sme->bss[i].currentSsid,                      max(1,max(strlen(pDot11->sme->bss[i].currentSsid),                                strlen(pDot11->sme->bss[i].rsnPassLastSsid))))                  != 0))                {                if (pDot11->sme->rsn.passphraseSet(pDot11,                       (const char *)pDot11->sme->bss[i].rsnPassphrase) != OK)                    {                    DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                              ("dot11SmeApReset: Error setting"                               " PSK using passphrase \"%s\"\n",                                (int)pDot11->sme->bss[i].rsnPassphrase,                                0, 0, 0, 0, 0));                    }                }            }        }        /* Start and stop the beacons so that any changes to the number of BSSs     take effect */    dot11SmeApBeaconStop(pDot11);    dot11SmeApBeaconStart(pDot11, 0);    /* Go through each hash bucket */    for (i=0; i<DOT11_KSL_MAX_HASH; i++)        {        pKsl = pDot11->sme->ksl.list[i];        while (pKsl != NULL)            {            /* Check if this station is authenticated and/or associated.  If            so, send it a disassoc/deauth message */            if (pKsl->type.sta.associated)                {                DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_INIT,                          ("dot11SmeApReset: Disassc " DOT11_MAC_ADDR_STR "\n",                          DOT11_MAC_ADDR(pKsl->macAddr)));                pKsl->type.sta.associated = FALSE;                status |= pDot11->sme->disassocSend(pDot11, pKsl->macAddr,                                        DOT11_REASON_DISASSOC_LEAVING,                                                     pKsl->pBss);                }                        if (pKsl->type.sta.authenticated)                {                DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_INIT,                          ("dot11SmeApReset: Deauth " DOT11_MAC_ADDR_STR "\n",                          DOT11_MAC_ADDR(pKsl->macAddr)));                pKsl->type.sta.authenticated = FALSE;                status |= pDot11->sme->deauthSend(pDot11, pKsl->macAddr,                                                  DOT11_REASON_DEAUTH_LEAVING,                                                  pKsl->pBss);                }                        pKsl = pKsl->pNext;            }                }    if (pDot11->sme->ksl.unlock(pDot11) != OK)        {        DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT,                  ("dot11SmeApReset: Cannot free lock\n",                   0,0,0,0,0,0));        return ERROR;        }        /* Return the cumulative return value from all the transmissions */    return status;    }/***************************************************************************** dot11SmeApIoctl - The SME-specific IOCTL routine** This routine contains code to handle all IOCTL calls that have different * bahaviour for differnt dot11Modes.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL int dot11SmeApIoctl    (    DOT11_FW * pDot11,     /* Ptr to dot11 Framework */    unsigned int cmd,      /* IOCTL command */    caddr_t data           /* Generic data pointer */    )      {    STATUS status = EINVAL;    DOT11_AP_OBJ * pAp;    DOT11_BSS * pBss;    int i;    pAp = &pDot11->sme->type.ap;    pBss = &pDot11->sme->bss[pDot11->sme->curConfigBss];    /* The pDot11 was already checked in the entrance routine */    switch(cmd)        {        /**************************************************************        * WIOCSSSID: Sets the SSID to the value in data and resets the AP        **************************************************************/        case WIOCSSSID:             /* We need a pointer in <data>.  Make sure it's not NULL */            if ( (char*)data == NULL)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: NULL <data> pointer in IOCTL"                           " 0x%04x\n", cmd, 0, 0, 0, 0, 0));                status = ERROR;                break;                }            if (((char*)data)[0] == 0x00)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: Cannot use NULL SSID in an AP\n",                           0,0,0,0,0,0));                status = ERROR;                break;                }                        strncpy((char *)pDot11->desiredSsid, (char *)data, DOT11_SSID_LEN);            pDot11->desiredSsid[min(DOT11_SSID_LEN, strlen((char *)data))] = 0;            strncpy((char *)pBss->currentSsid, (char *)data, DOT11_SSID_LEN);            pBss->currentSsid[min(DOT11_SSID_LEN, strlen((char *)data))] = 0;                        status = dot11SmeApReset(pDot11);            break;        /**************************************************************        * WIOCSENCRYPTTYPE: Sets the current encryption policy        **************************************************************/        case WIOCSENCRYPTTYPE:             if ((UINT32)data < DOT11_ENCRYPT_MAX)                {                taskLock();                pBss->multiEncryptType = (UINT32)data;                /* Regenerate the beacon.  Since we're in a task lock, the                beacon task can't come along and use it until we're done. */                pBss->pMblkBeacon->mBlkHdr.mLen =                     dot11SmeApBeaconCreate(pDot11,                              (UINT8*)pBss->pMblkBeacon->mBlkHdr.mData,                              (UINT16)DOT11_TYPE_BEACON,                              pBss);                taskUnlock();                status = OK;                }            else                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: Bad encrypt type in"                           " WIOCSENCRYPTTYPE\n", cmd, 0, 0, 0, 0, 0));                status = ERROR;                }            break;        /**************************************************************        * WIOCGTXRATE: This IOCTL is not supported since an AP has many        *              stations for which it maintains a current rate.        **************************************************************/        case WIOCGTXRATE:            break;        /**************************************************************        * WIOCSTXRATE: Sets the allowed transmit rates of the AP        **************************************************************/        case WIOCSTXRATE:            {            DOT11_KSL_ENTRY * pKsl;            int i;            if ( (char*)data == NULL)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: NULL <data> pointer in IOCTL"                           " 0x%04x\n", cmd, 0, 0, 0, 0, 0));                status = ERROR;                break;                }                        if (pDot11->sme->ksl.lock(pDot11) != OK)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: WIOCSTXRATE: Cannot get KSL lck\n"                           , 0, 0, 0, 0, 0, 0));                status = ERROR;                break;                }                        /* Copy the new allowed rates over */            pBss->allowedRates.length =                 min(((DOT11_RATES *)data)->length, DOT11_MAX_RATES);            bcopy((char*)((DOT11_RATES *)data)->rates,                   (char*)pBss->allowedRates.rates,                   pBss->allowedRates.length);                        /* Recalculate the actual rates for all associated stations */             for (i=0; i<DOT11_KSL_MAX_HASH; i++)                {                pKsl = pDot11->sme->ksl.list[i];                while (pKsl != NULL)                    {                    /* Check if this station is authenticated and/or                     associated.  If so, send it a disassoc/deauth message */                                        if (pKsl->type.sta.associated)                        {                                                if (dot11SmeActualRateCalc(pDot11,                                                    &pKsl->suppRates,                                                    &pDot11->sme->suppRates,                                                   &pBss->allowedRates,                                                   &pKsl->actualRates) != OK)                            {                            DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                                      ("dot11SmeApIoctl: smeActualRateCalc "                                       "FAILED for " DOT11_MAC_ADDR_STR "\n",                                       DOT11_MAC_ADDR(pKsl->macAddr)));                            pKsl->type.sta.authenticated = FALSE;                            pKsl->type.sta.associated = FALSE;                            pDot11->sme->deauthSend(pDot11,                                                  pKsl->macAddr,                                                 DOT11_REASON_DEAUTH_LEAVING,                                                 pKsl->pBss);                            }                        }                    pKsl = pKsl->pNext;                    }                }            if (pDot11->sme->ksl.unlock(pDot11) != OK)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: WIOCSTXRATE: Cannot give KSL "                           "lock\n", 0, 0, 0, 0, 0, 0));                status = ERROR;                break;                }                        /* Recalc the broadcast rate */            if (pDot11->sme->txMultiRateSet(pDot11, pBss->bcastRate, pBss)                != OK)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: WIOCSTXRATE: Cannot set "                           "bcast rate\n", 0, 0, 0, 0, 0, 0));                }                        /* Trigger a rate re-evaluation */            semGive(pDot11->sme->rcForceUpdate);            status = OK;            break;            }        /**************************************************************        * WIOCGBCASTRATE: Gets the rate used for multicast packets, in IEEE fmt        **************************************************************/        case WIOCGBCASTRATE:            /* We need a pointer in <data>.  Make sure it's not NULL */            if ( (char*)data == NULL)                {                DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME,                          ("dot11SmeApIoctl: NULL <data> pointer in IOCTL"                           " 0x%04x\n", cmd, 0, 0, 0, 0, 0));                status = ERROR;

⌨️ 快捷键说明

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