📄 dot11smeibsslib.c
字号:
/* dot11SmeIbssLib.c - Implements Station Management Entity for IBSS *//* * 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--------------------02l,13dec05,rb Fix to SPR 115265 - Variables reset on AP reset02o,01mar06,rb Merge from 2.1.2 bugfix branch02n,11nov05,rb Added mSSID feature02m,28sep05,rb Update header comments and copyright02l,19aug05,rb Remove advanced security multicast type on start02k,04aug05,rb Fix bug preventing IBSS from active scan response02j,29jul05,rb Fix for Flipper Bug B0062: Garbled SSID02i,20jul05,rb Flush KSL pool on mode exit02h,29jun05,rb Disable security policies upon start of IBSS mode02g,06may05,rb Fix for SPR 108873: WIOCSTXRATE does not have predicatable bahaviour02f,27apr05,rb Updated routines with APIGEN tags02e,21feb05,rb Fix vxWorks 6.1 compile errors02d,05jan05,rb Fix for SPR 103854 - Need to update reference in TXD to use MBlks02c,04oct04,rb Changes from code review02b,30aug04,eja Add support for WIOCGBEACONRATE02a,23aug04,rb Wind River Wireless Ethernet Driver 2.0 FCS*//*DESCRIPTIONSEE ALSOWind Net 802.11 Station 2.0 High Level Design Document\NOMANUAL*/#include <vxWorks.h>#include <muxLib.h>#include <stdio.h>#include <drv/wlan/dot11Lib.h>#include <drv/wlan/dot11SmeLib.h>#include <drv/wlan/dot11SmeIbssLib.h>#include <drv/wlan/dot11TimerLib.h>#include <endLib.h>#include <end.h>#include <tickLib.h>/* Local prototypes */LOCAL STATUS dot11SmeIbssShow(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssFree(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssRxMapInit(DOT11_FW * pDot11);LOCAL int dot11SmeIbssIoctl(DOT11_FW * pDot11, unsigned int cmd, caddr_t data);LOCAL STATUS dot11SmeIbssStateTaskInit(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssStateTaskFree(DOT11_FW * pDot11);LOCAL void dot11SmeIbssStateTask(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssLinkEventNotify(DOT11_FW * pDot11, int event);LOCAL STATUS dot11SmeIbssResetProcess(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssJoinReqProcess(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssJoinIbssProcess(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssCreateIbssProcess(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssSyncIbssProcess(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssBeaconStart(DOT11_FW * pDot11, int lastBeacon);LOCAL STATUS dot11SmeIbssBeaconStop(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssBeaconUpdate(DOT11_FW * pDot11);LOCAL STATUS dot11SmeIbssBeaconFree(DOT11_FW * pDot11);LOCAL DOT11_KSL_ENTRY * dot11SmeIbssKslUpdate(DOT11_FW * pDot11, DOT11_HEADER * pHeader);LOCAL STATUS dot11SmeIbssDataReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssBeaconReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssProbeReqReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssAuthReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssNullDataReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssAtimReceive(DOT11_FW * pDot11, M_BLK_ID pMblk, UINT32 rate, UINT8 ssi);LOCAL STATUS dot11SmeIbssProbeRespSend(DOT11_FW *, UINT8 * macAddr);LOCAL STATUS dot11SmeIbssBssidCreate(DOT11_FW *, UINT8 * bssid);LOCAL INT32 dot11SmeIbssBeaconCreate(DOT11_FW * pDot11,UINT8 * pPacket);const char * dot11SmeIbssStateName[] = {"No IBSS", "Searching", "Syncronizing" ,"Connected"};/***************************************************************************** dot11SmeIbssShow - Show routine for IBSS values** This routine displays parameters that are unique to the IBSS module** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeIbssShow ( DOT11_FW * pDot11 /* Pointer to device structure */ ) { DOT11_IBSS_OBJ * pIbss; /* Get the pointer to the DOT11_IBSS_OBJ structure for simple access */ pIbss = &pDot11->sme->type.ibss; printf(" IBSS: State = %s\n", dot11SmeIbssStateName[pIbss->state]); printf(" IBSS: BeaconInterval = %d tu ATIM Window = %d tu\n", pDot11->sme->beaconInterval, pIbss->atimWindow); printf(" IBSS: Beaconing = %s\n", (pIbss->beaconing)?"TRUE":"FALSE"); return OK; }/***************************************************************************** dot11SmeIbssInit - Initialize the SME structure for an IBSS** This routine initializes the device to operate as a station in IBSS mode.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS dot11SmeIbssInit ( DOT11_FW * pDot11 /* Pointer to device structure */ ) { DOT11_IBSS_OBJ * pIbss; DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11SmeIbssInit: Called. Default channel = (%d, %s)\n", pDot11->defaultChannel, (int)dot11ModeStr[pDot11->radioMode], 0, 0, 0, 0)); if ((DOT11_DEFAULT_BSS->secPol != 0) || (DOT11_DEFAULT_BSS->authPol != 0) || (DOT11_DEFAULT_BSS->ciphPol != 0)) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIbssInit: Advanced security modes (WPA/RSN) are " "not allowed in IBSS mode and will be disabled.\n", 0,0,0,0,0,0)); DOT11_DEFAULT_BSS->secPol = 0; DOT11_DEFAULT_BSS->authPol = 0; DOT11_DEFAULT_BSS->ciphPol = 0; if ((DOT11_DEFAULT_BSS->multiEncryptType == DOT11_KEY_TYPE_TKIP) || (DOT11_DEFAULT_BSS->multiEncryptType == DOT11_KEY_TYPE_AES)) { DOT11_DEFAULT_BSS->multiEncryptType = DOT11_KEY_TYPE_NONE; } } /* Get the pointer to the DOT11_IBSS_OBJ structure for simple access */ pIbss = &pDot11->sme->type.ibss; /* Place the free routine for this module where the SME generic calls can find it */ pDot11->sme->modeFree = dot11SmeIbssFree; pDot11->sme->modeShow = dot11SmeIbssShow; /* Hook up an IBSS-specific IOCTL handler function */ pDot11->sme->smeSpecificIoctl = dot11SmeIbssIoctl; /* Set the current BSS under configuration to be BSS0, since this is the only BSS supported in this mode */ pDot11->sme->curConfigBss = 0; /* Setup defaults */ pDot11->sme->beaconInterval = 300; pIbss->atimWindow = 0; /* We always start IBSS mode in non-beaconing */ pIbss->beaconing = FALSE; /* Set the clBlk allocated for the beacon to NULL. Hence, the dot11SmeIbssBeaconUpdate will know that it needs to allocate one */ pIbss->pMblkBeacon = NULL; if (dot11SmeIbssBeaconUpdate(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIbssInit: Cannot allocate beacon.\n", 0,0,0,0,0,0)); return ERROR; } /* The initial state is NO_IBSS */ pIbss->state = DOT11_IBSS_STATE_NOIBSS; if (dot11SmeIbssStateTaskInit(pDot11) == ERROR) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIbssInit: Cannot init state task.\n", 0,0,0,0,0,0)); dot11SmeIbssBeaconFree(pDot11); return ERROR; } /* Switch to the current default channel */ if ((pDot11->defaultChannel != 0) && (pDot11->radioMode != 0)) { if (pDot11->hdd->channelSet(pDot11, pDot11->defaultChannel, pDot11->radioMode) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIbssInit: Cannot set initial channel.\n", 0,0,0,0,0,0)); dot11SmeIbssStateTaskFree(pDot11); dot11SmeIbssBeaconFree(pDot11); return ERROR; } } else { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_SME, ("dot11SmeIbssInit: Invalid channel or radio mode\n", 0,0,0,0,0,0)); dot11SmeIbssStateTaskFree(pDot11); dot11SmeIbssBeaconFree(pDot11); return ERROR; } /* Initialize the RX Map, so that receive packets go to our routines */ if (dot11SmeIbssRxMapInit(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_SME, ("dot11SmeIbssInit: Error initializing RXMAP\n", 0,0,0,0,0,0)); dot11SmeIbssStateTaskFree(pDot11); dot11SmeIbssBeaconFree(pDot11); return ERROR; } pDot11->hdd->rxFilterSet(pDot11, DOT11_RX_FILTER_UNI|DOT11_RX_FILTER_MULTI| DOT11_RX_FILTER_BEACON | DOT11_RX_FILTER_PROBE_REQ); if ((pDot11->desiredSsid[0] != DOT11_SSID_NONE) && (pDot11->desiredSsid[0] != 0x00)) { dot11SmeIbssLinkEventNotify(pDot11, DOT11_IBSS_EV_JOIN_REQ); } return OK; }/***************************************************************************** dot11SmeIbssFree - De-initialize the SME structure for an IBSS** This routine initializes the device to operate as a station in IBSS mode.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeIbssFree ( DOT11_FW * pDot11 /* Pointer to device structure */ ) { DOT11_IBSS_OBJ * pIbss; DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11SmeIbssFree: Called\n", 0,0, 0, 0, 0, 0)); /* Get the pointer to the DOT11_IBSS_OBJ structure for simple access */ pIbss = &pDot11->sme->type.ibss; /* Stop beacons and move the state to disconnected */ if (pIbss->beaconing) { dot11SmeIbssBeaconStop(pDot11); } dot11SmeIbssStateTaskFree(pDot11); dot11SmeIbssBeaconFree(pDot11); /* Remove an IBSS-specific IOCTL handler function */ pDot11->sme->smeSpecificIoctl = NULL; /* Clean out the KSL - old entries are not going to do us any good here */ if (pDot11->sme->ksl.flush(pDot11) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIbssFree: Cannot flush KSL\n", 0,0,0,0,0,0)); } return OK; }/***************************************************************************** dot11SmeIbssRxMapInit - Initialize receive map** This routine fills in the receive map with the functions appropriate for * IBSS. Packets that are not suitable in an IBSS are discarded.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS dot11SmeIbssRxMapInit ( DOT11_FW * pDot11 /* Pointer to device structure */ ) { DOT11_RX_FUNC rxMap[DOT11_RX_MAP_NUM]; /* zero out all of the non-implemented functions */ bzero((char *)rxMap, sizeof(DOT11_RX_FUNC) * DOT11_RX_MAP_NUM); rxMap[DOT11_RXMAP_ASSOC_REQ] = NULL; rxMap[DOT11_RXMAP_ASSOC_RESP] = NULL; rxMap[DOT11_RXMAP_REASSOC_REQ] = NULL; rxMap[DOT11_RXMAP_REASSOC_RESP] = NULL; rxMap[DOT11_RXMAP_PROBE_REQ] = dot11SmeIbssProbeReqReceive; rxMap[DOT11_RXMAP_PROBE_RESP] = dot11SmeIbssBeaconReceive; rxMap[DOT11_RXMAP_BEACON] = dot11SmeIbssBeaconReceive; rxMap[DOT11_RXMAP_ATIM] = dot11SmeIbssAtimReceive; rxMap[DOT11_RXMAP_DISASSOC] = NULL; rxMap[DOT11_RXMAP_AUTH] = dot11SmeIbssAuthReceive; rxMap[DOT11_RXMAP_DEAUTH] = dot11SmeIbssAuthReceive; rxMap[DOT11_RXMAP_PSPOLL] = NULL; rxMap[DOT11_RXMAP_RTS] = NULL; rxMap[DOT11_RXMAP_CTS] = NULL; rxMap[DOT11_RXMAP_ACK] = NULL; rxMap[DOT11_RXMAP_CFEND] = NULL; rxMap[DOT11_RXMAP_CFENDACK] = NULL; rxMap[DOT11_RXMAP_DATA] = dot11SmeIbssDataReceive; rxMap[DOT11_RXMAP_DATA_CFACK] = NULL; rxMap[DOT11_RXMAP_DATA_CFPOLL] = NULL; rxMap[DOT11_RXMAP_DATA_CFACKPOLL] = NULL; rxMap[DOT11_RXMAP_DATA_NULL] = dot11SmeIbssNullDataReceive; rxMap[DOT11_RXMAP_CF_ACK] = NULL; rxMap[DOT11_RXMAP_CF_POLL] = NULL; rxMap[DOT11_RXMAP_CF_ACK_POLL] = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -