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

📄 intprismhostap.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* intPrismHostAp.c - Host based Access Point code for Intersil PRISM chips *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------02s,15sep03,rb  Fix problem when learning bridge started before HAP-SPR 9072502r,18jul03,rb  Added ARMARCH4 back to #ifdef for ARM integrator stability                 enhancements02q,17jul03,rb  Moved txSemWd to HAP struct so that HAP1.1 will work with STA                 1.102p,09jul03,rb  Fix for SPR 8782302o,03jul03,rb  Added moderated RX buffer chaining support02n,02jul03,rb  Fix for SPR 89388, backed out 02m until stabilized more02m,15may03,rb  Implemented receive buffer chaining as per SPR 8772302l,09may03,rb  Removed warnings caused by IPv6 integration02k,30apr03,ss  updated dot1x header file inclusion02j,30apr03,ss  removed SUBEND references02i,29apr03,rb  Fix for SPR 87953 - change ARMARCH4 workaround to XSCALE and                 STRONGARM02h,22apr03,ss  added version info02g,26feb03,ss  Fixed diab compiler warnings02r,13feb03,rb  Added support for WDS links via intPrismWdsEnd.c02q,23jul02,rb  Made disassociation smoother - STA that has timers cancelled                 will still disassociate02p,18jul02,rb  Removed dot1xEndAuthCallbackInstall() as per Gilbert's request02o,18jun02,rb  Fix for SPR 78797 - Authentication out of sequence loop; Also                 fixed 802.1X extensions to boolean values02n,12jun02,rb  Added direct call model to 802.1X support02m,23may02,ss  Moved the LTV read for Info events back to the ISR02l,22may02,rb  Fixed bug in hostDecyrpt - did not work on BE machines02k,21may02,rb  Fixed endianness in unicast WEP key support02j,21may02,ss  Moved INFO event handling out of ISR02i,16may02,rb  Added split unicast/multicast WEP key functionality02h,13may02,rb  Improved RX filters in ISR to reduce unnecessary cluster                  allocations; changed INCLUDE_INTPR_SUBEND to                  INCLUDE_WLAN_SUBEND; added CMD event to isr do-while loop.02g,13may02,rb  Fixed bug where starting HAP kills MUX proto. stack02f,08may02,rb  Fixed crashes - remove intPrismHostApPMEnqueueAll and                 custom PM pool02e,06may02,rb  Fix for SPR 76390 - Added intPrismReset() to EIOCSWEP02d,06may02,cjl  Diab warning suppression: int to unsigned int in ioctl02c,06may02,rb  More comment updates02b,25apr02,rb  Implemented host decrypt; made host en/decrypt optional;                 Changed comments as per doc review02a,24apr02,rb  Modified receive routine to respond correctly to                 disassociation packets01z,22apr02,rb  Fixed SPR 75641 - NULL-data's w/o PWRMAN do not turn it off01y,18apr02,rb  Implemented WLAN_INT_LOCK for better stability01x,11apr02,rb  Fixed auth. callback on disassociation - moved to new                 parameters01w,09apr02,ss  Update to use WLAN_BASE_ADDR and pWlanDev everywhere01v,08apr02,rb  Check authType when allowing/forbidding connections; Changed                 authentication callback parameters for 802.1X group.01u,01apr02,rb  Placed card in CARD_STATUS_DOWN while initializing.  01u,04apr02,dxb  Added Prism 3 support.01t,01apr02,rb  Put card in WLAN_STATUS_DOWN state when initializing01s,28mar02,rb  Fix for SPR 73754 - Stability problems under high load01r,21mar02,rb  More work on power management support; fixed IOCTL bug with                 WEP01q,21mar02,rb  Fixed alignment problem in receive data frame - IP header not                 long aligned01p,18mar02,rb  Corrected blocking behaviour when out of txFIDs - use                  END_ERR_BLOCK and call muxTxRestart.  Modified prototype                 for 802.1X callback function01o,18mar02,ss  Update to use card types WLAN_CARDTYPE_INTERSIL_2 and _2_501n,12mar02,rb  Moved bridging code to intPrismBridge.c01m,07mar02,rb  Improved stability of TX data path 01l,21feb02,rb  Added power management support01k,13feb02,rb  Implented basic rates01j,11feb02,rb  Added shared key support01i,07feb02,rb  Implemented IOCTL controls01h,06feb02,dxb  More changes for wlanEnd.h.01g,05feb02,dxb  Updated to include changes to wlanEnd.h01f,31jan02,rb  Code review changes01e,24jan02,rb  Refined authentication structure, added watchdogs on station                 list01d,18jan02,rb  Big Endian support01c,10jan02,rb  Cleanup and optimization; Removed some de-auth cases to                 improve stability01b,19dec01,rb  Further development; Implemented software-driven WEP01a,06sep01,rb  Created*//*DESCRIPTIONThis file implements the host-based access point on Intersil PRISM-2, PRISM-2.5, and PRISM 3 chipsets.  All AP functions with the exception of beaconing and probe responses are performed in this modules.The host-based AP requires a station Intersil driver (intPrismEnd.c) to be running before the host-based AP is initialized.  When initialized, thisdriver stops the STA driver and disconnects the interrupts.  A custom ISRis then installed that handles all types of packets, and passes the raw frame,including Intersil and 802.11 headers,  to the host-ap receive routine to parse and react to.  Packet transmission from the network stack is handled through intPrismHostApSend(), which forms a data packet around them (if the station is associated or if the dst addr. is broadcast) and transmits it.A list of all stations that have transmitted data over the wireless network  (typically stations that have transmitted data on our channel) is maintained.Each record tracks whether the station is authenticated and associated.  Checks are made when transmitting and receiving  data that any station involved in data communications (as opposed to the authentication or association process itself) are associated - if not, the packet is dropped.This list may be shown using intPrismHostApStaShow()Due to a firmware glitch in Intersil secondary firmware (confirmed present in version up to and including 1.4.9, fixed in 1.5.0), on-card  firmware will not encrypt outgoing packets.  Thus, "host encrypt" mode is used where <data> packets areencrypted in software before transmission.   This code is part of intPrismHostApSendData().  Support is also provided for host decrypt if desired.*/#include <vxWorks.h>#include <string.h>#include <cacheLib.h>#include <semLib.h>#include <logLib.h>#include <netLib.h> #include <stdio.h>#include <sysLib.h> #include <memLib.h>#include <iosLib.h>#include <end.h>			/* Common END structures. */#include <endLib.h>#include <etherMultiLib.h>		/* multicast stuff. */#include <intLib.h>#include <taskLib.h>/* Needed for wdGetTimeLeft() */#include <wdLib.h>#include <qLib.h>#include <private/wdLibP.h>#include <private/kernelLibP.h>/* Custom header files */#include "wrn/wlan/wlanEnd.h"#include "wrn/wlan/intPrismHw.h"#include "wrn/wlan/intPrismHostAp.h"#include "wrn/wlan/snmp802dot11.h"#undef INCLUDE_INTPR_DOT1X_END#ifdef INCLUDE_INTPR_DOT1X_END      /* Define to use 802.1X without subEND */#include "wrn/dot1x/dot1xEndLib.h"#endif /* INCLUDE_INTPR_DOT1X_END *//***************************************************i************************ Global variables / defines**************************************************************************/char * wlanHapVersion = WLAN_HAP_VERSION;WLAN_HOST_AP *  pWlanHostAp = NULL;#define CRC32_POLY            0xEDB88320LLOCAL UINT32 CRC32_lookupTable[256];/*************************************************************************** * Import functions we use from intPrismEnd.c **************************************************************************/IMPORT STATUS intPrismApStart (void * pTertiaryBuffer, UINT32 numBytes ); IMPORT STATUS	intPrismStop(END_OBJ * pDrvCtrl);int	    intPrismIoctl(END_OBJ * pDrvCtrl, unsigned int cmd, caddr_t data);IMPORT STATUS    intPrismUnload (END_OBJ * pDrvCtrl);IMPORT STATUS	intPrismMCastAdd (END_OBJ * pDrvCtrl, char * pAddress);IMPORT STATUS	intPrismMCastDel (END_OBJ * pDrvCtrl, char * pAddress);IMPORT STATUS	intPrismMCastGet (END_OBJ * pDrvCtrl,                              MULTI_TABLE * pTable);IMPORT STATUS    intPrismPollStart (END_OBJ * pDrvCtrl);IMPORT STATUS    intPrismPollStop (END_OBJ * pDrvCtrl);IMPORT STATUS	intPrismPollSend (END_OBJ * pDrvCtrl, M_BLK_ID pBuf);IMPORT STATUS	intPrismPollRcv (END_OBJ * pDrvCtrl, M_BLK_ID pBuf);IMPORT STATUS    intPrismParse (WLAN_DEV * pWlanDev, char * initString);IMPORT STATUS    intPrismMemInit(WLAN_DEV * pWlanDev); STATUS    intPrismInt(WLAN_DEV * pWlanDev );IMPORT STATUS    intPrismReceive(WLAN_DEV * pWlanDev, RX_PACKET * pRxPacket,                                  int datalen1);WLAN_DEV * intPrismDevGet(int unitnum);STATUS intPrismFlags (WLAN_DEV * pWlanDev );IMPORT int      intPrismManage (WLAN_DEV * pWlanDev, int cmd, caddr_t data );IMPORT INT32 endMultiLstCnt (END_OBJ *);IMPORT STATUS sysWlanCfgParamGet (UINT32 cmd, INT32 data);/***************************************************i************************ Local variables/function declarations**************************************************************************/LOCAL void   intPrismHostApInfoFidRead();LOCAL STATUS intPrismHostApStart (END_OBJ * pDrvCtrl);LOCAL STATUS intPrismHostApStop(END_OBJ * pDrvCtrl);LOCAL STATUS intPrismHostApSendFrame (WLAN_DEV * pDev, UINT8 * pData,                                      int length);LOCAL STATUS intPrismHostApSend (END_OBJ * pDrvCtrl, M_BLK_ID pMblk);LOCAL void   intPrismHostApInt(WLAN_DEV * pDev);LOCAL STATUS intPrismHostApReceive(WLAN_DEV * pDev, RX_PACKET * pRxPacket);LOCAL STATUS intPrismHostApReceiveData(WLAN_DEV * pWlanDev, WLAN_STA * pSta,                                         RX_PACKET * pRxPacket,                                        WLAN_RX_FRAME *pRxFrame );LOCAL STATUS intPrismHostApReceiveMgmt(WLAN_DEV * pWlanDev, WLAN_STA * pSta,                                         RX_PACKET * pRxPacket,                                        WLAN_RX_FRAME *pRxFrame );LOCAL STATUS intPrismManagementFrameSend (WLAN_DEV *pDev,UINT16 subType,                                           char * pData, INT32 dataSize,                                           WLAN_STA *pSta );LOCAL STATUS intPrismAuthReply (WLAN_DEV * pDev, WLAN_RX_FRAME * pOldFrame,                                 UINT16 algorithm, UINT16 sequence,                                 UINT16 status );LOCAL STATUS  intPrismAssocReply(WLAN_DEV * pDev, WLAN_RX_FRAME * pOldFrame,                                  BOOL success);LOCAL UINT8* intPrismHostApPacketDecrypt (WLAN_DEV * pWlanDev, UINT8 * pData,                                          UINT32 * length, WLAN_STA * pSta);/* Packet transmission functions */LOCAL UINT32 intPrismCRC32Calc (UINT8 * data, int length);LOCAL VOID CRC32Init();LOCAL void intPrismWEPEncrypt(UINT8 * data, int len, UINT8* key, int keyLen);/* Functions for pruning known station list */LOCAL int wdGetTimeLeft(WDOG_ID wd);LOCAL STATUS intPrismHostApRemoveSta(WLAN_STA * pSta);LOCAL STATUS intPrismHostApRemoveStaTask(WLAN_STA * pSta);/* IOCTL handler */LOCAL int intPrismHostApIoctl (END_OBJ * pEnd, int cmd, caddr_t data );/* Access control list functions */LOCAL STATUS intPrismHostApACAdd( UINT8* MACAddr );LOCAL STATUS intPrismHostApACRemove( UINT8* MACAddr );LOCAL STATUS intPrismHostApACLookup( UINT8* MACAddr );/* Power Management functions */LOCAL STATUS intPrismHostApTIMSet(WLAN_DEV * pDev, int AID, int status);LOCAL STATUS intPrismHostApPMHandle(WLAN_DEV * pDev, WLAN_STA * pSta);LOCAL STATUS intPrismHostApPMEnqueue(WLAN_STA * pSta, M_BLK_ID pMblk);LOCAL M_BLK_ID intPrismHostApPMDequeue(WLAN_STA * pSta);LOCAL STATUS intPrismHostApSendData(END_OBJ * pDrvCtrl, M_BLK_ID pMblk);LOCAL void intPrismKeepTxAlive(WLAN_DEV * pWlanDev);LOCAL STATUS intPrismWakeUpTx(int txBufferNum);LOCAL INT32 intPrismAIDGet ( );LOCAL INT32 tInfoFidRead = -1; /* TID of intPrismHostApInfoFidRead task */LOCAL INT16 infoFidReadPriority = 56; /* priority of tInfoFidRead */LOCAL SEM_ID semInfoFidRead; /* sem that tInfoFidRead blocks on, given by ISR */LOCAL LTV_RECORD ltvInfoEvent; /* the filled in (by ISR) LTV for an Info Event *//***************************************************************************** * Updated END table * We've got to use our own functions for some of this stuff . . .    ****************************************************************************/NET_FUNCS intPrismHostApFuncTable =     {    (FUNCPTR) intPrismHostApStart,   	/* Function to start the device. */    (FUNCPTR) intPrismHostApStop,  	/* Function to stop the device. */    (FUNCPTR) intPrismUnload,	/* Unloading function for the driver. */    (FUNCPTR) intPrismIoctl,	/* Ioctl function for the driver. */    (FUNCPTR) intPrismHostApSend,	    /* Send function for the driver. */    (FUNCPTR) intPrismMCastAdd,	/* Multicast add function for the  driver. */    (FUNCPTR) intPrismMCastDel,	/* Multicast delete function*/    (FUNCPTR) intPrismMCastGet,	/* Multicast retrieve function*/    (FUNCPTR) intPrismPollSend,	/* Polling send function */    (FUNCPTR) intPrismPollRcv,	/* Polling receive function */    endEtherAddressForm,	/* put address info into a NET_BUFFER */    endEtherPacketDataGet,	/* get pointer to data in NET_BUFFER */    endEtherPacketAddrGet  	/* Get packet addresses. */    };/***************************************************************************** intPrismHostAp - Initializes the host-based AP** This function loads the host-based access point.  The station driver must* be installed first.  This routine installs a new set of END function * pointers, which include its own send, receive, start and stop routines.* In addition, the ISR is stopped and disconnected, and a new ISR is then* connected and re-started.  The card is then put into host-AP mode.  If* the "wiredIf" parameter is non-NULL, then a basic bridge is started.  If* you have your own bridge, then pass NULL to "wiredIf".* * RETURNS: OK or ERROR** ERRNO: N/A*/STATUS intPrismHostAp    (    char * ssid,                /* SSID to create */    int channel,                /* Channel to create the BSS on */    char * wirelessIf,          /* Text name of wireless interface */    int wirelessIfnum,         /* Unit number of WLAN driver to use */    char * wiredIf,             /* Text name of wireless interface */    int wiredIfnum             /* Unit number of WLAN driver to use */    )    {    WLAN_DEV * pWlanDev;    int result;    int i;    UINT16 brate;    UINT16 region;    UINT16 wepEnable;    UINT16 wepType;    UINT8 wepKey[WLAN_WEP_MAX_KEYSIZE];    STATUS status;    UINT16 wepKeyNumber;    char pDescription[] = "Wind River Systems WLAN END driver for Host "        "Based AP";        if (pWlanHostAp != NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: Already initialized\n"));        return ERROR;        }        /*Get a pointer to the device control structure for the specified device*/    if ((pWlanDev = intPrismDevGet(wirelessIfnum)) == NULL)        {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismHostAp: intPrismDevGet() failed for"                                 " device %s%d!\n", wirelessIf,                                  wirelessIfnum));        return ERROR;        }            if ( (pWlanDev->cardType != WLAN_CARDTYPE_INTERSIL_2) &&          (pWlanDev->cardType != WLAN_CARDTYPE_INTERSIL_2_5) &&         (pWlanDev->cardType != WLAN_CARDTYPE_INTERSIL_3) )       {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: Host AP only supported on"

⌨️ 快捷键说明

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