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

📄 intprismtertap.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* intPrismTertAp.c - Routines for starting/configuring a Tertiary AP *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history --------------------02p,18jul03,rb  Added ARMARCH4 back to #ifdef for ARM integrator stability                 enhancements02o,09may03,rb  Removed warnings caused by IPv6 integration02n,29apr03,rb  Fix for SPR 87953 - change ARMARCH4 workaround to XSCALE and                 STRONGARM02m,22apr03,ss  renamed file from intPrismAp.c to intPrismTertAp.c, updated API02l,09may02,ss  changed debug messages for authenticate02k,06may02,rb  More comment fixes02j,03may02,rb  Updated comments as per doc review02i,24apr02,ss  free tert buffer after TAP started02h,08apr02,ss  Updated to use pWlanDev everywhere02g,04apr02,dxb  Added Prism 3 support.02f,01apr02,rb  Put card in WLAN_STATUS_DOWN state when initializing02e,18mar02,ss  Update to support WLAN_CARDTYPE_INTERSIL_2_502d,12mar02,rb  Moved bridging code to intPrismBridge.c02c,07mar02,ss  Fix WEP enable bug02b,12feb02,ss  Updated for API changes in intPrismDownload.c02a,06feb02,dxb  More changes for wlanEnd.h.01z,05feb02,dxb  Updated to include changes to wlanEnd.h.01y,17jan02,ss  Added routine to perform a Card<->Tert compatibility check01x,16jan02,ss  Update comments01w,11dec01,ss  Moved general download routines to intPrismDownload01v,26nov01,ss  Fixed bug in intPrismApStationAuthenticate (jumbled byte order                 for MAC addr)01u,16nov01,ss  Changed log level for status msg in intPrismApStart01t,16nov01,ss  Allow channel selection up to/including 1401s,15nov01,ss  fixed bug in intPrismApStationAdd (was allowing duplicates)01r,14nov01,ss  check if the wln card is Intersil before enabling AP01q,05nov01,rb  Changed APIs    wlan->intPrism01p,02nov01,dxb  Updated with new file name.01o,25sep01,ss  Enable WEP in d/l routines if WLAN_DEFAULT_WEP_ENABLE is                 defined01n,21sep01,ss  added channel scan support01m,21sep01,ss  rename show routines with prefix wlanApShow01l,18sep01,ss  Fixed pdaRecords increment bug for MIPS compiler01k,10sep01,ss  Documentation updates01j,07sep01,ss  Added example routines wlanApFileDownload, wlanApFtpDownload01i,07sep01,ss  Use reference to pCookie (from muxBind) in muxSend calls 01h,04sep01,ss  Reformatted refgen comments01g,30aug01,ss  Removed unused routine wlanAuxDataRead01g,29aug01,ss  Added important comments for wlanApAuthenticateStation routine01f,29aug01,ss  Added STA authentication routines01e,27aug01,ss  Free up memory allocated for data records, info records and                 pda records associated data01d,20aug01,ss  Removed dependency on filesystem for opening tertiary hex file01c,16aug01,ss  Update includes of wlan header files01b,15aug01,ss  Verify that card type is Intersil before performing download01a,14aug01,ss  Created*//*DESCRIPTIONThis module provides the ability to turn an Intersil Prism based wlan card into an Access Point (AP), assuming that the correct Tertiary AP Firmware forthe given card has been obtained from Intersil Corp. (http://www.intersil.com).These routines have been tested with Teriary Hex files TH010000.hex and TF010102.hex on PRISM cards with component IDs 0x8002, 0x800C, 0x8012The AP can be initiated by calling intPrismTertApInit, followed by intPrismTertApStart. Alternatively, an ioctl call that encompasses both intPrismTertApInit andintPrismTertApStart is provided. The example routines intPrismTertApFileDownloadand intPrismTertApFtpDownload demonstrate use of the AP ioctl.Support for creating an Access Control List for the AP is also provided by this module.INCLUDE FILES: wrn/wlan/intPrismDownload.h wrn/wlan/intPrismTertAp.h wrn/wlan/intPrismHw.h wrn/wlan/wlanEnd.h *//* includes */#include <vxWorks.h>#include <string.h>#include <stdio.h>#include <ioLib.h>#include <stdlib.h>#include <stat.h>#include <taskLib.h>#include <memLib.h>#include <ftpLib.h> /* needed for example routine intPrismTertApFtpDownload */#include "wrn/wlan/wlanEnd.h"#include "wrn/wlan/intPrismHw.h"#include "wrn/wlan/intPrismTertAp.h"#include "wrn/wlan/intPrismDownload.h"/**************************************************************************** * Local variables ***************************************************************************/LOCAL END_OBJ * pWiredDev;      /* pointer to wired interface providing                                    connection to network */LOCAL WLAN_DEV * pWlanDev;  /* pointer to wireless interface *//* AP config params set by user of this module */LOCAL AP_CONFIG apConfig;/* pointer to a linked list of STA's allowed to authenticate with AP */LOCAL STA_ID * pStations;/* Flag indicating if intPrismTertApInit has been called successfully */LOCAL BOOL inited = FALSE;/*************************************************************************** * DEFINES **************************************************************************/#define MAX_BUFF_SIZE 200000 /* max num of bytes in Tertiary file - value is                                 used by example routine                                 intPrismTertApFtpDownload *//*************************************************************************** * External references **************************************************************************/IMPORT INT32 wlanDlDebug; /* the download debug level *//* gets the default config parameters set in <bsp>/configWlan.h */IMPORT STATUS sysWlanCfgParamGet (UINT32 cmd, INT32 data);/****************************************************************************** intPrismTertApInit - Set-up properties of the TAP* * This routine must be called before intPrismTertApStart(), as it sets important * properties for the AP.  Currently, only paramCardType = * WLAN_CARDTYPE_INTERSIL_2, WLAN_CARDTYPE_INTERSIL_2_5 and* WLAN_CARDTYPE_INTERSIL_3 are supported. * If simple bridging support is not required, the paramWiredDevName value must * be NULL or an empty string ""** RETURNS: OK if all params were accepted, otherwise ERROR* ERRNO: N/A*/STATUS intPrismTertApInit    (    UINT16 paramCardType,       /* the type of card to run as an AP */    char * paramApName,         /* SSID to assign to the AP */       UINT16 paramApChannel,      /* channel for the AP to use (1-14) */    UINT16 paramApInterfaceNum, /* dev num of AP card interface */    char * paramWiredDevName,   /* dev name of the wired interface */    UINT16 paramWiredDevNum     /* dev num of the wired interface */    )    {        /*      * set the card type - this is verified later, only      * WLAN_CARDTYPE_INTERSIL_2, WLAN_CARDTYPE_INTERSIL_2_5 or     * WLAN_CARDTYPE_INTERSIL_3 are presently     * supported     */    apConfig.apCardType = paramCardType;        if (paramApName != NULL)         {        apConfig.apName = paramApName;        }    else         {        WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApInit: NULL AP name\n"));        return ERROR;        }        /* allowed channels: 1 - 14 (only up to 11 available in N.America */    if ( (paramApChannel > 0) && (paramApChannel < 15) )        {        apConfig.apChannel = paramApChannel;        }    else         {        WLANDL_DEBUG(DEBUG_ERROR,                     ("intPrismTertApInit: invalid channel requested:%i",                      paramApChannel));        return ERROR;        }        apConfig.apInterfaceNum = paramApInterfaceNum;        /* an END dev with this name and interface num will be referenced later,       wiredDevName can be NULL if no bridging is required */    apConfig.wiredDevName = paramWiredDevName;    apConfig.wiredDevNum = paramWiredDevNum;        inited = TRUE;    return OK;    }/******************************************************************************* intPrismTertApStart - reconfigure Prism STA card to run in TAP mode** This routine assumes that a Prism station card is installed in the system, * initialized and running as an END device.  It also assumes that a * Tertiary AP hex file that supports the given card is being used as the* source of the buffer pointer parameter.** Once the Tertiary F/W is loaded into card RAM and the device is * successfully configured as an AP, simple packet bridging is turned on, * whereby all packets the wireless interface receives will be copied to the * wired interface and vice versa.  This feature is disabled if a valid * wired device was not indicated in intPrismTertApInit.** Note : intPrismTertApInit must be called prior to calling this routine.** RETURNS: OK if the card was successfully configured into an AP, else ERROR* ERRNO: N/A*/STATUS intPrismTertApStart    (    char * pTertiaryBuffer,  /* pointer to a character buffer containing all                                 the chars (including end of line's) in the                                 Tertiary hex file                              */    UINT32 numBytes          /* num of bytes in the Tertiary char buffer */    )     {    STATUS status = OK;    UINT32 i, j;        /* verify that intPrismTertApInit has been called prior to this routine */    if (!inited)         {        WLANDL_DEBUG(DEBUG_ERROR,                     ("intPrismTertApStart: Error - intPrismTertApInit has not"                       " been called successfully\n"));        return ERROR;        }        /* temporarily suspend the keep-alive thread running on device with      * the SA1111 co-processor (ie. StormPad)      */#if (CPU==STRONGARM) || (CPU==XSCALE) || (CPU==ARMARCH4)    if (taskSuspend (taskNameToId("tWlanPoll")) == ERROR)        {        WLANDL_DEBUG(DEBUG_INFO,                      ("intPrismTertApStart:could not suspend task tWlanPoll\n"));        }#endif        /* get reference to the wired and wireless END devices */    pWlanDev = (WLAN_DEV *) endFindByName(WLAN_IFNAME,                                           apConfig.apInterfaceNum);    if (pWlanDev == NULL)         {        WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApInit: Error - could not find "                                   "wireless END device %s%i\n", WLAN_IFNAME,                                    apConfig.apInterfaceNum));                        goto ERR;        }        if ( (apConfig.wiredDevName != NULL) && (strlen(apConfig.wiredDevName) != 0))        {        pWiredDev = (END_OBJ *) endFindByName(apConfig.wiredDevName,                                               apConfig.wiredDevNum);        if (pWiredDev == NULL)             {            WLANDL_DEBUG(DEBUG_ERROR,                         ("intPrismTertApInit: Error - could not find END"                          "device %s%i\n", apConfig.wiredDevName,                           apConfig.wiredDevNum));                        goto ERR;            }        }    else         {        /*          user must not want our simple bridge turned on, perhaps they          are supplying their own bridge        */        pWiredDev = NULL;        }            /* At this time, only Prism based cards are supported */    if ((((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_2) &&        (((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_2_5) &&        (((WLAN_DEV *)pWlanDev)->cardType != WLAN_CARDTYPE_INTERSIL_3))        {        WLANDL_DEBUG(DEBUG_ERROR,                     ("intPrismTertApStart: Card Type is not Intersil - "                      "AP download cannot be performed\n"));                goto ERR;        }    pWlanDev->cardStatus = WLAN_STATUS_DOWN;        /* Disable card interrupts */    WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0);        /* Disable Mac Port */    if (intPrismCommand (pWlanDev, WLAN_CMD_DISABLE, 0, 0, 0) == ERROR)         {        WLANDL_DEBUG(DEBUG_ERROR,                    ("intPrismTertApStart: could not issue disable command\n"));                goto ERR;        }            /* download the tertiary firmware onto the card */    if (intPrismTertiaryDownload(pWlanDev, pTertiaryBuffer, numBytes) ==         ERROR)         {        WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApStart: Error - could not load"                                   " tertiary code onto card\n"));                goto ERR;        }        /* (re)init the card */    if (intPrismCommand(pWlanDev, WLAN_CMD_INI, 0, 0, 0) == ERROR)         {        WLANDL_DEBUG(DEBUG_ERROR, ("intPrismDownloadTertiary: Error re-initing"                                   " card after download\n"));        return ERROR;        }        /* BEGIN: lifted from intPrismInit */        /* Acknowledge all events, to get a clean start */    WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, 0xffff);        /* Set the maximum data length */    status |= intPrismRIDWordWrite(pWlanDev, WLAN_RID_MAX_DATALEN,                                WLAN_MAX_PACKET);            /* Make sure interrupts are not enabled until we want them */    WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0x0000);        /* Ask the card to allocate a buffer for us */    /* First, make sure another alloc is not is progress */            for (j = 0; j < WLAN_MAX_TX_BUF; j++)        {                i = 0;        while((WLAN_IN_16(WLAN_BASE_ADDR + WLAN_EVENT_STAT) &                WLAN_EV_ALLOC) != 0)            {            if (i++ > WLAN_DEVICE_TIMEOUT)                {                WLANDL_DEBUG(DEBUG_FATAL,("Error allocing NIC Memory - stuck"                                        " ALLOC \n"));                WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK,WLAN_EV_ALLOC);                return ERROR;                }            }                   if (intPrismCommand(pWlanDev, WLAN_CMD_ALLOC_MEM,                         WLAN_MAX_PACKET + sizeof(WLAN_FRAME),                         0, 0) == ERROR)            {            return ERROR;            }                i = 0;        while((WLAN_IN_16(WLAN_BASE_ADDR + WLAN_EVENT_STAT) &                WLAN_EV_ALLOC) == 0)            {            if (i++ > (WLAN_DEVICE_TIMEOUT * 10) )                {                            WLAN_LOG(DEBUG_FATAL, ("Error Allocating NIC memory\n",                                       0,0,0,0,0,0));                return ERROR;

⌨️ 快捷键说明

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