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

📄 intprismwdsend.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* intPrismWDSEnd.c - END driver for Wireless LAN cards *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------01i,18jul03,rb  Added ARMARCH4 back to #ifdef for ARM integrator stability                 enhancements01h,09jun03,rb  Added RX buffer chaining compatability01g,09may03,rb  Removed warnings caused by IPv6 integration01f,08may03,rb  Fixed refgen error with filename01e,29apr03,rb  Fix for SPR 87953 - change ARMARCH4 workaround to XSCALE and                 STRONGARM01d,22apr03,ss  updated to include intPrismTertAp.h01c,27feb03,rb  Fixed endian bug w/ BE systems01b,26feb03,ss  Fixed diab compiler warnings01a,02feb03,rb  Created*//*DESCRIPTIONThis is an add-on to either the Tertiary-AP (intPrismTertAp.c) or the Host-based AP (intPrismHostAp.c).  It provides a means for access points to pass packets amoungst themselves.  This driver is initialized like a normal END device driver using muxDevLoad, but it must be attached to a physical AP driver to actually have something to get and send WDS packets from.  In addition, a WDS link is point-to-point and must know the MAC address of the other side ofthe link. The pWlanDev for the attached wireless device and the MAC address of the other side of the WDS link are passed as initialization parameters.  Multiple WDS link END drivers can be attached to one AP - they form a linked list.Packet flow:  The physical wireless ISR (intPrismInt() or intPrismHostApInt()) will detect an incoming packet and transfer it into a netCluster.  It will then recognise that the incoming packet is a WDS packet (sent by another WDS-enabled wireless device) and pass it to the last initialized WDS receive routine (intPrismWdsReceive()) rather than the standard receive routine.  The WDS receive routine then checks if the packet was transmitted from the partner AP (on the wother side of the WDS link) of this particular instance.  If not, it calls the next WDS receive routine attached to the physical driver.  It it is, it then processes the receivedpacket, and passes it to MUX as though it was received from the WDS driver (toallow bridging)Outgoing packets are sent the the WDS send routine by the bridge.  This routineformats them as a WDS packet and sends them using the physical device to whichthe WDS link is bound.Two new IOCTL calls have been created: EIOCSWDSTXRATE and EIOCGWDSTXRATE.  These calls are used to change the rate at which WDS packets are sent.\is\i EIOCGWDSTXRATEReturns the current rate at which WDS packets are sent.  <data> is a UINT16 *, and the current rate will be placed in the location to which it points.  The rate will be returned in the format used by EIOCGTXRATE. \ts    Bit  | Speed     |  Macro --------------------------------    0    |  1 Mbps   | WLAN_1_MBIT    1    |  2 Mbps   | WLAN_2_MBIT    2    |  5.5 Mbps | WLAN_5_MBIT    3    |  11 Mbps  | WLAN_11_MBIT\te\i EIOCSWDSTXRATESets the rate at which WDS packets are sent.  <data> is a UINT16 containing the rate as specified in the format used by EIOCGTXRATE. 0001 for 1 Mbps, 0002 for 2 Mbps, 0004 for 5.5 Mbps and 0008 for 11 Mbps.  Unlike EIOCSTXRATE, you can only choose one rate, since there is no auto-fallback mechanism provided.\ieEND-DRIVER PARAMETERSThese parameters are passed to the intPrismLoad routine in an initializationstring of the form:"<pWlanDev>:<DstMACAddr>"<pWlanDev> is specified in hex, as the memory address of the END_OBJ corresponding to the original wireless device.<dstMacAddr> is the MAC address of the AP on the other side of the WDS link. This is specified colon-separated, ie. 00:02:43:56:78:9aINITIALIZATIONFor the WDS driver to be useful, you also need some type of advanced bridge, such as the learning bridge.  This example shows how to use the learning bridge and the host-based AP to set up a WDS link with another AP, with MACaddress 00:01:02:03:04:05.void initAll()    {	END_OBJ * pEnd;    char initString[245];    void * pCookie;    intPrismHostAp("SSID",1,"intPr",0,NULL, 0);    bridgeInit();        ifFlagChange("elPci0", IFF_PROMISC, TRUE);    bridgePortAdd("intPr",0);    bridgePortAdd("elPci",0);	pEnd = endFindByName("intPr", 0);    sprintf(initString, "0x%08x:00:01:02:03:04:05", pEnd);    if((pCookie = muxDevLoad(0, intPrismWDSLoad, initString, 0,0)) == NULL)        {        printf("pCookie == NULL\n");        }    else        {        muxDevStart(pCookie);        }        bridgePortAdd("iPrWDS",0);    }SEE ALSOPRISM Driver Programmer's Manual (CHOICE-Intersil Corporation)*/#include <vxWorks.h>#include <string.h>#include <intLib.h>#include <semLib.h>#include <logLib.h>#include <netLib.h>#include <stdio.h> #include <sysLib.h>#include <memLib.h>#include <end.h>			/* Common END structures. */#include <endLib.h>#include "net/mbuf.h"#include "wrn/wlan/wlanEnd.h"#include "wrn/wlan/intPrismHw.h"#include "wrn/wlan/intPrismTertAp.h"#include "wrn/wlan/intPrismHostAp.h"#include "wrn/wlan/intPrismDownload.h"#define INTPRWDS_IFNAME          "iPrWDS"/**************************************************************************** Local Prototypes**************************************************************************/LOCAL STATUS intPrismWDSStart(END_OBJ* pDrvCtrl);LOCAL STATUS intPrismWDSStop(END_OBJ* pDrvCtrl);LOCAL STATUS intPrismWDSUnload(END_OBJ* pDrvCtrl);STATUS intPrismWDSSend(END_OBJ * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS intPrismWDSPollSend(END_OBJ * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS intPrismWDSPollRcv(END_OBJ * pDrvCtrl, M_BLK_ID pMblk);int intPrismWDSIoctl(END_OBJ* pDrvCtrl, unsigned int cmd, caddr_t data );LOCAL STATUS intPrismWDSReceive(END_OBJ * pEnd, RX_PACKET *pRxPacket,                                 int datalen);LOCAL STATUS	intPrismWDSMCastAdd (END_OBJ * pDrvCtrl, char * pAddress);LOCAL STATUS	intPrismWDSMCastDel (END_OBJ * pDrvCtrl, char * pAddress);LOCAL STATUS	intPrismWDSMCastGet (END_OBJ * pDrvCtrl,MULTI_TABLE * pTable);LOCAL STATUS intPrismWDSParse (INTPRWDS_DEV * pIntPrWdsDev, char *initString );int intPrismIoctl(END_OBJ* pDrvCtrl, unsigned int cmd, caddr_t data );/******************************************************************************       Basic END functions* These are the basic functions that are required to implement an END driver****************************************************************************/NET_FUNCS intPrismWDSFuncTable =     {    (FUNCPTR) intPrismWDSStart,   	/* Function to start the device. */    (FUNCPTR) intPrismWDSStop,  	/* Function to stop the device. */    (FUNCPTR) intPrismWDSUnload,	/* Unloading function for the driver. */    (FUNCPTR) intPrismWDSIoctl,	/* Ioctl function for the driver. */    (FUNCPTR) intPrismWDSSend,	    /* Send function for the driver. */    (FUNCPTR) intPrismWDSMCastAdd,/* Multicast add function for the  driver. */    (FUNCPTR) intPrismWDSMCastDel,	/* Multicast delete function*/    (FUNCPTR) intPrismWDSMCastGet,	/* Multicast retrieve function*/    (FUNCPTR) intPrismWDSPollSend,	/* Polling send function */    (FUNCPTR) intPrismWDSPollRcv,	/* Polling receive function */    endEtherAddressForm,	/* put address info into a NET_BUFFER */    endEtherPacketDataGet,	/* get pointer to data in NET_BUFFER */    endEtherPacketAddrGet  	/* Get packet addresses. */    };/***************************************************************************** intPrismWDSLoad - END load function for the WDS pseduo-driver** This routine is an END load routine for the WDS driver.  It must be passed* the pEnd of the physical wireless driver running the AP, and the MAC* address of the other AP to which we are to connect.  ** These parameters are passed to the intPrismLoad routine in an initialization* string of the form:* "<pWlanDev>:<DstMACAddr>"* <pWlanDev> is specified in hex, as the memory address of the END_OBJ * corresponding to the original wireless device.* <dstMacAddr> is the MAC address of the AP on the other side of the WDS link. * This is specified colon-separated, ie. 00:02:43:56:78:9a* * RETURNS: Pointer to the device handle created or NULL on error** ERRNO: N/A** SEE ALSO: muxLib, muxDevLoad()*/END_OBJ *intPrismWDSLoad    (    char *initString,    /* Initial parameters to initialize device with */    void * pBSP          /* Ptr. to a UINT8 value that identifies card access                             method */    )    {    WLAN_DEV *pWlanDev;    INTPRWDS_DEV * pIntPrWdsDev;    INTPRWDS_DEV * pBug;    int unitNum;    WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSLoad : Loading WDS lin "                            "Network Driver \n"));    /* Check that we got a valid init string.  "Null string" for the first    pass means it contains no data.  The string must still exist */    if (initString == NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismWDSLoad : NULL initString\n"));        return NULL;        }    /* If we're on the first pass, then the first character of the initstring    must be 0x00 */    if (initString[0] == 0x00)        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSLoad : First Pass.  Returning i/f "                                "name %s\n", INTPRWDS_IFNAME));        bcopy(INTPRWDS_IFNAME, initString, strlen(INTPRWDS_IFNAME));         /* Add a terminating NULL char, so we don't have to rely on the init        string to be initially zeroed */        initString[strlen(INTPRWDS_IFNAME)] = 0x00;        return NULL;        }    WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSLoad : Second Pass Init String = %s\n",                            initString));      /* If we got this far, then we're on our second pass, and the unit number    is the first character of the string (assuming we have <10 devices,     which is probably a reasonable assumption */    unitNum = (int)initString[0] - 0x30;    if (unitNum > INTPR_WDS_MAXLINK)        {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSLoad: Too many WDS links\n"));        return NULL;        }    if ((pIntPrWdsDev = calloc(1,sizeof(INTPRWDS_DEV))) == NULL)        {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSLoad: Error allocating memory "                                 "for device structure\n"));        return NULL;        }        /* Parse the init string to get the pDev and dst MAC address*/    intPrismWDSParse(pIntPrWdsDev, initString);        /* WDS is only applicable to APs */    if (pIntPrWdsDev->pWlanDev->cardMode == WLAN_CARDMODE_STA)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismWDSLoad: Card must be in AP mode to "                                 "start a WDS link\n"));        }        pIntPrWdsDev->macPort = unitNum + 1;    pWlanDev = pIntPrWdsDev->pWlanDev;    if (pWlanDev->pWds == NULL)        {        /* Give the 802.11 driver a link to the WDS */        pWlanDev->pWds = pIntPrWdsDev;        pIntPrWdsDev->pNext = NULL;        }    else        {        /* If at least one other WDS link is linked to the 802.11 driver, we         need to check for a conflict in port numbers . . . */                pBug = pWlanDev->pWds;        while (pBug != NULL)            {            if (pBug->macPort == pIntPrWdsDev->macPort)                {                WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSLoad: MAC port conflict -"                                         " a WDS link to " MAC_ADDR_STRING                                          " is already using MAC port %d\n",                                          MAC_ADDR(pBug->dstMacAddr),                                          pBug->macPort));                    return NULL;                }            pBug = pBug->pNext;            }                /* Insert this link at the head of the linked list.  No particular         reason for any placement - we know the maximum depth is 6, so . . .*/        pIntPrWdsDev->pNext = pWlanDev->pWds;        pWlanDev->pWds = pIntPrWdsDev;        }    pIntPrWdsDev->receiveRtn = intPrismWDSReceive;    pIntPrWdsDev->txRate = 0x6e;  /* Default to 11 Mbps */    /* Do standard END structure initialization.  Must be done after card    initialization, as we need the MAC address to initialize MIB2 stuff*/    if ((END_OBJ_INIT (&pIntPrWdsDev->endObj, (DEV_OBJ *)pIntPrWdsDev,                        (char *)INTPRWDS_IFNAME,                       unitNum,                        &intPrismWDSFuncTable,                       "WDS link") == ERROR))        {        WLAN_DEBUG(DEBUG_FATAL,("intPrismWDSLoad: END or MIB2 init failed\n"));        return NULL;        }    /* Init the MIB-II table */    if (mib2Init(&(pIntPrWdsDev->endObj.mib2Tbl), M2_ifType_ethernet_csmacd,                 pWlanDev->MACAddr, WLAN_ENET_ADDR_LEN, ETHERMTU,                 WLAN_END_SPEED) == ERROR)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismWDSLoad: Failed MIB-II init.\n"));        return NULL;        }    /* Don't use the MAC_ADDR macro here since the MACADDR is already     swapped */    printf("Dest is " MAC_ADDR_STRING " \n",            pIntPrWdsDev->dstMacAddr[0],pIntPrWdsDev->dstMacAddr[1],           pIntPrWdsDev->dstMacAddr[2],pIntPrWdsDev->dstMacAddr[3],           pIntPrWdsDev->dstMacAddr[4], pIntPrWdsDev->dstMacAddr[5]);

⌨️ 快捷键说明

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