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

📄 dot11smeesslib.c

📁 PNE 3.3 wlan source code, running at more than vxworks6.x version
💻 C
📖 第 1 页 / 共 5 页
字号:
** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeEssAuthReceive    (    DOT11_FW * pDot11,             /* Pointer to dot11 Framework */    M_BLK_ID pMblk,              /* clBlk containing the ingress packet*/    UINT32 rate,                   /* Rate at which packet was RX in kbps */    UINT8  SSI                     /* Signal level of received packet 0-100 */    )    {    UINT8 * pCluster;               /* Cluster containing data */    DOT11_AUTH_PACKET * pAuth;    /* 802.11 Mgmt Header structure */    DOT11_ESS_OBJ * pEss;    pCluster = (UINT8*)pMblk->mBlkHdr.mData;    pAuth = (DOT11_AUTH_PACKET *)pCluster;        pEss = &pDot11->sme->type.ess;    /* Check if this packet is for us, drop it if not */    if (bcmp((char *)pAuth->header.addr1, (char *)pDot11->macAddr,              DOT11_ADDR_LEN) != 0)        {        DOT11_LOG(DOT11_DEBUG_FLOOD, DOT11_AREA_SME,                  ("dot11SmeEssAssocReceive: Not for us\n",0,0,0,0,0,0));        netMblkClChainFree(pMblk);        return ERROR;        }    if (DOT11_FTYPE(DOT11_LE_TO_CPU_16(pAuth->header.frameCtrl))         != DOT11_TYPE_AUTH)        {        /* Just doing a basic check - we really shouldn't have ended up here */                DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                  ("dot11SmeEssAuthReceive: NOT AN AUTH PACKET!\n",                   0,0,0,0,0,0));        netMblkClChainFree(pMblk);        return ERROR;        }    /* The only time we should receive this type of packet is during     association */    if ( (pEss->sm.currentState !=           SME_ESS_AUTHENTICATING) &&          (pEss->sm.currentState !=           SME_ESS_AUTH_SHARED))        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                  ("dot11SmeEssAuthReceive: Unexpected authentication packet "                   "dropped!\n", 0, 0, 0, 0, 0, 0));        netMblkClChainFree(pMblk);        return ERROR;        }        /* Cancel the timer since we got a valid response */    dot11TimerDel(pEss->authTimer);    pEss->authTimer = 0;    /* Right now we only process sequence 2 packets for OS and seq 2 and 4     packets for SK */        /* For an Open System Seq 2, see if we succeeded or not */    if ((DOT11_LE_TO_CPU_16(pAuth->authAlg) == DOT11_AUTH_OPEN) &&        (DOT11_LE_TO_CPU_16(pAuth->authSeq) == 2))        {        if (DOT11_LE_TO_CPU_16(pAuth->status) == DOT11_STATUS_OK)            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply -OK\n",                       0, 0, 0, 0, 0, 0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_SUCCESS);            }        else            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply - FAIL %d\n",                       (int)DOT11_LE_TO_CPU_16(pAuth->status), 0, 0, 0, 0, 0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_FAIL);            }        }    /* If this is shared key authentication, proceed to the next step. */    else if ((DOT11_LE_TO_CPU_16(pAuth->authAlg) == DOT11_AUTH_SHARED_KEY) &&        (DOT11_LE_TO_CPU_16(pAuth->authSeq) == 2))        {        if (DOT11_LE_TO_CPU_16(pAuth->status) == DOT11_STATUS_OK)            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply - SKA/2\n",                       0, 0, 0, 0, 0, 0));                        /* Copy the challenge text over, if present */            if (pEss->pKslAp == NULL)                {                pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_FAIL);                }            else                {                DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                          ("dot11SmeEssAuthReceive: Auth Reply - SKA/2,"                           "chalText len  %d\n",                           pAuth->challenge.length, 0, 0, 0, 0, 0));                bcopy((char*)pAuth->challenge.chalText,                       (char*)pEss->pKslAp->type.ap.skaBuffer,                      min(pAuth->challenge.length,DOT11_AUTH_CHAL_MAX));                pEss->pKslAp->type.ap.skaLength = pAuth->challenge.length;                                pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_SKA);                }            }        else            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply - FAIL %d\n",                       DOT11_LE_TO_CPU_16(pAuth->status), 0, 0, 0, 0, 0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_FAIL);            }        }    else if ((DOT11_LE_TO_CPU_16(pAuth->authAlg) == DOT11_AUTH_SHARED_KEY) &&        (DOT11_LE_TO_CPU_16(pAuth->authSeq) == 4))        {        if (DOT11_LE_TO_CPU_16(pAuth->status) == DOT11_STATUS_OK)            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply SKA - OK\n",                       0, 0, 0, 0, 0, 0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_SUCCESS);            }        else            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssAuthReceive: Auth Reply SKA - FAIL %d\n",                       DOT11_LE_TO_CPU_16(pAuth->status), 0, 0, 0, 0, 0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_FAIL);            }        }    else        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                  ("dot11SmeEssAuthReceive: Bad auth frame!\n",0,0,0,0,0,0));            pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_AUTH_FAIL);        }    netMblkClChainFree(pMblk);    return OK;    }/***************************************************************************** dot11SmeEssDeauthReceive - Processes a received De-authentication packet** A deathentication packet is a really simple packet.  Just a management header* and a Reason field.  The reasons are outlined in 7.3.1.7 of IEEE 802.11 * (2003) but don't really matter, since all of the reasons for a deauth * result in the same action - try to authenticate again.  If the * reauthentication succeeds, then all is good.  If the AP is annoyed and won't* let you on, it'll result in an AUTH_FAIL event.  If it has gone away, then* an AUTH_TIMEOUT event will occur..** This routine is also fed disassociation packets, for whome the behaviour is*  similar.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeEssDeauthReceive    (    DOT11_FW * pDot11,             /* Pointer to dot11 Framework */    M_BLK_ID pMblk,              /* clBlk containing the ingress packet*/    UINT32 rate,                   /* Rate at which packet was RX in kbps */    UINT8  SSI                     /* Signal level of received packet 0-100 */    )    {    UINT8 * pCluster;               /* Cluster containing data */    DOT11_HEADER * pHeader;         /* 802.11 Mgmt Header structure */    DOT11_ESS_OBJ * pEss;    pCluster = (UINT8*)pMblk->mBlkHdr.mData;    pHeader = (DOT11_HEADER *)pCluster;        pEss = &pDot11->sme->type.ess;    /* Verify that this packet is destined for us and is from our AP. */    if ((bcmp((char *)pHeader->addr1, (char *)pDot11->macAddr,               DOT11_ADDR_LEN) == 0) &&         (bcmp((char *)pHeader->addr2, (char *)DOT11_DEFAULT_BSS->bssid,               DOT11_ADDR_LEN) == 0))        {        /* The only time we should not receive this type of packet is during         NOESS state */        if (pEss->sm.currentState ==             SME_ESS_NOESS)            {            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                      ("dot11SmeEssDeauthReceive: Unexpected deauth/disassoc "                       "packet dropped!\n", 0, 0, 0, 0, 0, 0));            netMblkClChainFree(pMblk);            return ERROR;            }        /* Send the event to the state machine */        pDot11->sme->linkEventNotify(pDot11, DOT11_ESS_DEAUTH);        }    netMblkClChainFree(pMblk);    return OK;    }/***************************************************************************** dot11SmeEssScanReceive - Receive hander for beacon and probe frames *                                when in SCANNING state** This is the beacon receive routine for beacon and probe response packets* when the device is not set to a specific SSID or is looking for ANY ssid.** All Beacons and Probe Responses have a similar format.  The following fields* must be present (optional fields are marked with an asterisk)***  1. Timestamp*  2. Beacon interval*  3. Capability*  4. SSID*  5. Supported Rates*  6* FH Parameter Set (One of 6 and 7 will be present)*  7* DS Parameter Set*  8* CF Parameter Set (Only present if PCF supported)*  9* IBSS Parameter Set (Only present if IBSS indicated in capabilities)* 10* Country (Only present if 802.1d support present)* 11* FH Multidomain parameters* 12* FH Pattern Table* 13* RNS IE* 14* Extended Rates IE* 15* WPA IE** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeEssScanReceive    (    DOT11_FW * pDot11,              /* Pointer to dot11 Framework */    M_BLK_ID pMblk,               /* clBlk containing the ingress packet*/    UINT32 rate,                    /* Rate at which packet was RX in kbps */    UINT8  ssi                      /* Signal level of received packet 0-100 */    )    {    UINT8 * pCluster;               /* Cluster containing data */    DOT11_HEADER * pDot11Header;    /* 802.11 Mgmt Header structure */    UINT16    frameCtl;             /* Byte-swapped frame control header */    DOT11_CAPABILITIES * pCap;      /* Pointer to Capabilities field */    DOT11_IE_SSID *      pSsid;     /* Pointer to SSID IE */    DOT11_IE_SUPP_RATES *pRates;    /* Pointer to rates IE */    DOT11_IE_EXT_RATES * pExt;      /* Pointer to extended rates IE */    DOT11_IE_GENERIC *   pBug;      /* Used to crawl along packet */    DOT11_KSL_ENTRY *    pKsl;      /* Ptr to KSL entry */    UINT32 length;        length = pMblk->mBlkHdr.mLen;    pCluster = (UINT8*)pMblk->mBlkHdr.mData;    pDot11Header = (DOT11_HEADER *)pCluster;    frameCtl = DOT11_LE_TO_CPU_16(pDot11Header->frameCtrl);    /* Only process Probe Response packets if active scans are allowed, and    only process Beacon packets if passive scans are allowed */    if ((DOT11_FTYPE(frameCtl) != DOT11_TYPE_PROBE_RESP) &&        (DOT11_FTYPE(frameCtl) != DOT11_TYPE_BEACON))        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                  ("dot11SmeEssScanReceive: Not beacon or probe!\n",                   0,0,0,0,0,0));                netMblkClChainFree(pMblk);        return ERROR;        }            /* If this is a probe response, make sure it is destined for us */    if ((DOT11_FTYPE(frameCtl) == DOT11_TYPE_PROBE_RESP) &&         (bcmp((char *)pDot11Header->addr1, (char *)pDot11->macAddr,               DOT11_ADDR_LEN) != 0))        {        DOT11_LOG(DOT11_DEBUG_FLOOD, DOT11_AREA_SME,                  ("dot11SmeEssScanReceive: Not for us\n",0,0,0,0,0,0));        netMblkClChainFree(pMblk);        return ERROR;        }    /* Ensure that the packet has at least a Timestamp field, a Beacon Rate    field, a Capabilities field and an SSID (can be NULL, ie length of 0)*/    if (length <  (sizeof(DOT11_HEADER) + sizeof(DOT11_TIMESTAMP) +                    sizeof(DOT11_BEACON_RATE) + sizeof(DOT11_CAPABILITIES) +                   DOT11_IE_HEADER_SIZE))        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME,                  ("dot11SmeEssScanReceive: Invalid packet!\n",                   0,0,0,0,0,0));                    netMblkClChainFree(pMblk);        return ERROR;        }            pCap = (DOT11_CAPABILITIES *)(pCluster + sizeof(DOT11_HEADER) +                                   sizeof(DOT11_TIMESTAMP) +                                   sizeof(DOT11_BEACON_RATE));            pRates = NULL;    pExt = NULL;    pSsid = NULL;    /* Point the bug to the first IE */    pBug = (DOT11_IE_GENERIC *)(pCluster + sizeof(DOT11_HEADER) +                                 sizeof(DOT11_TIMESTAMP) +                                 sizeof(DOT11_BEACON_RATE) +                                sizeof(DOT11_CAPABILITIES));                                    /* Just search for rates and extended rates to feed to apUpdate, which    will create the AP entry if it doesn't already exist.  Don't do anything     else. */    while (((int)pBug < (int)(pCluster + length)) &&            (((

⌨️ 快捷键说明

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