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

📄 dot11dpelib.c

📁 PNE 3.3 wlan source code, running at more than vxworks6.x version
💻 C
📖 第 1 页 / 共 5 页
字号:
/* dot11DpeLib.c - Implements data path for wireless framework *//*  * Copyright (c) 2004-2006 Wind River Systems, Inc.  * * The right to copy, distribute, modify or otherwise make use  * of this software may be licensed only pursuant to the terms  * of an applicable Wind River license agreement.  *//* Modification History--------------------03c,16mar06,rb  Fix Coverity issues (SPR 119148)03b,02mar06,rb  Fix to SPR 118377 - AppleTalk packets are not correctly                 handled03i,05jan06,rb  Fix for SPR 116443 - Framentation threshold max value is                 incorrect03h,16dec05,rb  Fix for SPR 115960 - Bad fragmentation calculations03g,14dec05,rb  Fix for SPR 113959 - WEP padding bits not checked03f,13dec05,rb  Fix to SPR 115958 - Incorrect fragmentation03e,28feb06,rb  Merge from 2.1.2 bugfix branch03d,27feb06,rb  Changes from code inspection03c,22feb06,rb  Fix minor bug with 802.1X and vlanId != 003b,17feb06,rb  Fix endianess problem with VLANs03a,17feb06,rb  Code cleanup and warning removal02z,13feb06,rb  Added VLAN tagging support02y,11nov05,rb  Added mSSID feature02x,28sep05,rb  Update header comments and copyright02w,18aug05,rb  Fix for problem with multicast keys02v,29jul05,rb  Fix for SPR 110957 - poor performance in power management02u,28jun05,rb  Fix for SPR 110403 - WEP does not work with keyIndex > 002t,23jun05,rb  Fix for SPR 110080: fragmentation does not work with TKIP/AES02s,29apr05,rb  Fix for bug B0270: WEP does not seem to be working02r,27apr05,rb  Fix for SPR 108017 - Improved statistics02q,27apr05,rb  Updated routines with APIGEN tags02p,25apr05,rb  Fix for B0258: Problems with 802.1X legacy mode02o,06apr05,rb  Fix for SPR 107235: data path does not handle non-ethernet                 packets correctly02n,23mar05,rb  Moved sta-sta bridging for AP into endReceive()02m,07mar05,rb  Changes from dot11RsnLib.c code review02l,02feb05,rb  Resolved vxWorks 6.0 compatibility issues02k,25jan05,rb  Made security component optionally buildable02j,20jan05,rb  Added 802.1X and decrypt err statistics02i,19jan05,rb  802.1X State machine bug02h,19jan05,rb  fixed compiler error02g,19jan05,rb  Fix dropping 802.1X packets02f,10jan05,rb  Changes to the 802.1X port control functionality02e,05jan05,rb  Fix for SPR 103854 - Need to update reference in TXD to use                 MBlks02d,22dec04,rb  Fixed handling of ICV in AES02c,05nov04,rb  Added code to intercept EAPOL-Key messages and send them to                 the RSN module02b,24sep04,rb  Fix for SPR 102025 - IPv6 Incompatabilities02a,25aug04,rb  Wind River Wireless Ethernet Driver 2.0 FCS*//*DESCRIPTIONThe data path entity is the portion of the driver that moves packets betweenthe MUX subsystem and the device hardware.  It converts between the 802.3 frames used by the MUX and the 802.11 frames used by the driver.SEE ALSOWind Net 802.11 Station 2.0 High Level Design Document\NOMANUAL*/#include <vxWorks.h>#include <muxLib.h>#include <end.h>#include <netBufLib.h>#include <endLib.h>#include <stdlib.h>#include <netLib.h>#include <tickLib.h>#include <netinet/in.h>#include <drv/wlan/dot11Lib.h>#include <drv/wlan/dot11SmeLib.h>#include <drv/wlan/dot11TimerLib.h>/* Local prototypes */LOCAL STATUS dot11DpeFree(DOT11_FW * pDot11);LOCAL STATUS dot11DpeEndSend(END_OBJ * pEnd, M_BLK_ID pMblk);LOCAL STATUS dot11DpeEndSendBss(DOT11_FW * pDot11, M_BLK_ID pDataMblk,                                DOT11_BSS * pBss);LOCAL STATUS dot11DpeFragmentSend(DOT11_FW * pDot11,                                   UINT8 * pDstAddr,                                   UINT8 * pSrcAddr,                                   M_BLK_ID pDataMblk,                                  int fragNum,                                  int nextFragLen,                                  DOT11_BSS * pBss);LOCAL STATUS dot11DpeEndReceive(DOT11_FW * pDot11, M_BLK_ID pMblk,                                 UINT32 rate, UINT8 SSI);LOCAL STATUS dot11DpeFragThresholdSet(DOT11_FW* pDot11, UINT32 fragThresh);LOCAL STATUS dot11DpeFragThresholdGet(DOT11_FW* pDot11,UINT32 * fragThresh);LOCAL STATUS dot11DpeEndPollRcv(END_OBJ* pEnd, M_BLK_ID pMblk);LOCAL STATUS dot11DpeEndPollSend(END_OBJ* pEnd, M_BLK_ID pMblk);LOCAL M_BLK_ID dot11DpeReassemble(DOT11_FW * pDot11, M_BLK_ID pMblk,                                   DOT11_KSL_ENTRY * pKsl);LOCAL DOT11_FRAGMENT * dot11DpeReassemblePktGet(DOT11_FW * pDot11,                                                 DOT11_HEADER * pHeader);LOCAL VOID dot11DpeReassembleTimeout(DOT11_FW * pDot11, int fragSlot);LOCAL DOT11_FRAGMENT * dot11DpeReassemblePktCreate(DOT11_FW * pDot11,                                                    DOT11_HEADER * pHeader);LOCAL STATUS dot11DpeTransmitQueueFlush(DOT11_FW * pDot11);/***************************************************************************** dot11DpeInit - Initializes the data path entity** This function inializes the DPE object, allocating memory and filling in* function pointers as necessary.** RETURNS: OK or ERROR on memory alloc failure.** ERRNO: N/A*/STATUS dot11DpeInit    (    DOT11_FW *  pDot11            /* Pointer to device structure */    )    {    int i;    /* Allocate a DPE object and connect it to the DOT11_FW */    if ((pDot11->dpe = calloc(1, sizeof(DPE_OBJ))) == NULL)        {        DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT,                  ("dot11DpeInit: Error allocating device structure\n", 0, 0,                    0, 0, 0, 0));        return ERROR;        }        /* Fill in the function pointers for the DPE */    pDot11->dpe->free = dot11DpeFree;    pDot11->dpe->endSend = dot11DpeEndSend;    pDot11->dpe->endReceive = dot11DpeEndReceive;    pDot11->dpe->fragThresholdSet = dot11DpeFragThresholdSet;    pDot11->dpe->fragThresholdGet = dot11DpeFragThresholdGet;    pDot11->dpe->endPollSend = dot11DpeEndPollSend;    pDot11->dpe->endPollRcv = dot11DpeEndPollRcv;    pDot11->dpe->transmitQueueFlush = dot11DpeTransmitQueueFlush;    /* Start the initialization vector at 1, to avoid 0 which is weak */    pDot11->dpe->currentIV = 1;    /* Set the exclusion policy to disallow unencrypted packets when WEP    is enabled */    pDot11->dpe->exclusionPolicy = DOT11_EX_DOT1X;    /* The fragmentation is diabled by setting the threshold to MAX */    pDot11->dpe->fragThreshold = DOT11_MAX_PACKET;    /* Initialize the reassembly buffer */    for (i=0; i<DOT11_MAX_REASSEMBLY; i++)        {        pDot11->dpe->reassemblyBuff.packet[i].used = FALSE;        pDot11->dpe->reassemblyBuff.packet[i].pHead = NULL;        }    /* Initialize the transmit semaphore */    if ((pDot11->dpe->transmitSem = semMCreate(SEM_INVERSION_SAFE |                                                SEM_Q_PRIORITY)) == NULL)        {        DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT,                  ("dot11DpeInit: Error allocating \n", 0, 0,                    0, 0, 0, 0));        free(pDot11->dpe);        pDot11->dpe = NULL;        return ERROR;        }    /* NULL out the transmit queue */    pDot11->dpe->transmitQueueHead = NULL;    pDot11->dpe->transmitQueueTail = NULL;    return OK;    }/***************************************************************************** dot11DpeFree - Frees all memory allocated in dot11DpeInit** Returns all memory allocated by DPE.  System is not useable after this point.** RETURNS: OK** ERRNO: N/A*/LOCAL STATUS dot11DpeFree    (    DOT11_FW *  pDot11            /* Pointer to device structure */    )    {    STATUS status;    status = semDelete(pDot11->dpe->transmitSem);    free(pDot11->dpe);    pDot11->dpe = NULL;    return status;    }/***************************************************************************** dot11DpeEndReceive - Receive routine for 802.11 Data packets;** This is the END receive routine.  It takes an incoming 802.11 data frame* and strips the 802.11 header.   ** The HDD passes packets to this function in a Cl-Blk/cluster frame, with * 802.11 and SNAP headers in front of the payload.  This function strips the * 802.11 header in place, copying the DA and SA to form the etherHeader on top* of the SNAP header.  The <mData> field in the new Mblk is set to point to* the start of the new RFC1042 packet. All of the conversion takes place in * the original cluster - there is no copy or additional cluster added.** Note that in response to SPR 107235, the above conversion only takes place on* Ethernet or 802.1h packets.  Other layer two packets with an LLC header* will be transmitted as is. ** RETURNS: OK or ERROR on allocation error.** ERRNO: N/A*/LOCAL STATUS dot11DpeEndReceive    (    DOT11_FW *  pDot11,           /* Pointer to device structure */    M_BLK_ID   pMblk,             /* mBlk containing data buffer */    UINT32 rate,                  /* Rate at which packet was RX in 500 kbps */    UINT8  SSI                    /* Signal level of received packet 0-100 */    )    {    UINT8 * pCluster;             /* Cluster containing rx'd packet */    M_BLK_ID pHeadMblk;           /* New Mblk to link cluster into */    DOT11_HEADER * pHeader;       /* Pointer to 802.11 Hdr */    DOT11_KSL_ENTRY * pKsl;       /* Pointer to KSL entry for source */    DOT11_KSL_ENTRY * pBridgeKsl; /* Pointer to KSL entry for quickbridge */    UINT32 pDataOffset;           /* Keeps track of where payload starts*/    DOT11_LLC_HEADER * pLlcHeader;/* The packer's LLC/SNAP header */    BOOL stripLlc;                /* Becomes true if we need to strip the LLC                                     header before passing to stack */    /* Sanity check */    if ((pDot11 == NULL) || (pMblk == NULL) || (pMblk->mBlkHdr.mLen == 0))        {        return ERROR;        }    pCluster = (UINT8*)pMblk->mBlkHdr.mData;    pHeader = (DOT11_HEADER *)pCluster;    /* Get the KSL entry for the immediate source-addr 2 (BSSID in a ESS). If    the entry does not exist, then we cannot be associated to the AP, so drop     the packet.  Calling this function also serves to update the KSL timer    and enter the received rate and SSI information into the SME state     machine*/    if ((pKsl = pDot11->sme->ksl.rxUpdate(pDot11, pHeader->addr2, rate,                                           SSI)) == NULL)        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_DPE,                  ("dot11DpeEndReceive: Not Associated.  Dropping packet.\n",                    0, 0, 0, 0, 0, 0));        /* The packet must be freed */        netMblkClChainFree(pMblk);        return ERROR;        }    /* Check if we're in a state to allow data packet reception */    if (pKsl->pBss->linkStatus == DOT11_LINK_DOWN)        {        DOT11_LOG(DOT11_DEBUG_FLOOD, DOT11_AREA_DPE,                  ("dot11DpeEndReceive: Not CONNECTED!\n", 0, 0, 0, 0,                   0,0));        /* The packet must be freed */        netMblkClChainFree(pMblk);        return ERROR;        }    if (pDot11->sme->ksl.lock(pDot11) != OK)        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_DPE,                  ("dot11DpeEndReceive: Cannot get KSL lock.\n",                    0, 0, 0, 0, 0, 0));        /* The packet must be freed */        netMblkClChainFree(pMblk);        return ERROR;        }        /* Check if this is a station in power management, and the packet has the     more data bit set. */    if ((pDot11->dot11Mode == DOT11_MODE_ESS) &&         (((DOT11_LE_TO_CPU_16(pHeader->frameCtrl)) & DOT11_FCTL_MORE_DATA)!=0) &&        (pDot11->sme->powerManagement) &&        (!DOT11_IS_MCAST(pHeader->addr1)))        {        DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_DPE,                  ("dot11DpeEndReceive: Requesting MORE_DATA.\n",                    0, 0, 0, 0, 0, 0));        netJobAdd((FUNCPTR)pDot11->hdd->psPollSend, (int)pDot11,0,0,0,0);                /* Continue processing this packet */        }    /* Check if we have an unencrypted packet when encryption is turned on.     Generally this is a bad thing, unless explicitly allowed, either by virtue    of being an EAPOL packet when dot1x is enabled or by an explicit policy     decision */    if (((pKsl->uniEncryptType != DOT11_ENCRYPT_NONE) ||          (pKsl->pBss->multiEncryptType != DOT11_ENCRYPT_NONE)) &&         (((DOT11_LE_TO_CPU_16(pHeader->frameCtrl)) & DOT11_FCTL_WEP)==0)&&        (pDot11->dpe->exclusionPolicy != DOT11_EX_NONE))        {        /* The packet is unencrypted, and encryption is specified */        if (((!pKsl->dot1xControlled) && (pKsl->negSecPol == 0)) ||            ((pKsl->dot1xControlled) &&              (*(UINT16 *)(pCluster + sizeof(DOT11_HEADER) +                           DOT11_SNAP_HEADER_LEN - sizeof(UINT16)) !=              (DOT1X_ETHERTYPE))))            {            /* Return OK, since the packet was succesfully consumed; it was not            an error that it was dropped, just a policy decision. */            pDot11->sme->ksl.unlock(pDot11);            DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_DPE,                      ("dot11DpeEndReceive: Dropping non-EAPOL packet by "                       "policy\n",                        0, 0, 0, 0, 0, 0));

⌨️ 快捷键说明

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