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

📄 cisaironetioctl.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 4 页
字号:
            UINT8 index   = 0;            UINT8 keySize = 0;            /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }                        /* Calculate the proper key to set */            index = (UINT8) (cmd - EIOCSWEPKEY0);            /* Save the key size */            if (pDev->wepType == WLAN_WEP_TYPE_64)                {                keySize = DOT11_40_BIT_KEY_SIZE;                }            else if                 (pDev->wepType == WLAN_WEP_TYPE_128)                {                keySize = DOT11_128_BIT_KEY_SIZE;                }            else                {                status = EINVAL;                break;                }            /* Save the key */            if ( cisAironetHwWepKeySet (pDev,                                        (char *) data,                                        index,                                        keySize,                                        FALSE)                 == ERROR )                {                status = EINVAL;                }            /* Save the wep key to the driver */            (void) cisAironetBcopy ( pDev,                                     (UINT8 *) data,                                     (UINT8 *) pDev->wepKey[index],                                     keySize);            break;            }        /* Set the default wep key */            case EIOCSWEPDEFAULTKEY:            {            INT32  arrayIndex  = 0;            UINT16 wepRidIndex = 0;            UINT8  keySize     = 0;                        /* Get the array index */            arrayIndex = (INT32) data;            /* Bounds checking */            if ( (arrayIndex < 0) ||                 (arrayIndex > (ANET_MAX_WEP_KEYS - 1)) )                {                status = EINVAL;                break;                }                                    /* Get the index of the transmit key */            wepRidIndex = cisAironetHwWepKeyGet (pDev, ANET_TX_KEY);            /* Save the key size */            if (pDev->wepType == WLAN_WEP_TYPE_64)                {                keySize = DOT11_40_BIT_KEY_SIZE;                }            else if                 (pDev->wepType == WLAN_WEP_TYPE_128)                {                keySize = DOT11_128_BIT_KEY_SIZE;                }            else                {                status = EINVAL;                break;                }            /* Set up the WEP key to be used for transmit */            if ( cisAironetHwWepKeySet (pDev,                                         (char *) pDev->wepKey[arrayIndex],                                        wepRidIndex,                                        keySize,                                        FALSE)                 == ERROR )                {                status = EINVAL;                }            /* Save the default key index */            pDev->defaultKey = pDev->broadcastKey = (UINT16) arrayIndex;            break;            }            /* Get WEP type - 40 bit or 128 bit */        case EIOCGWEPTYPE:             {            /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }                        /* return the wep type */            * (UINT16 *) data = (UINT16)pDev->wepType;            break;            }            /* Set WEP type - 40 bit or 128 bit */        case EIOCSWEPTYPE:             {            INT32 wepType = (INT32) data;            /* sanity check */            if ( (wepType != WLAN_WEP_TYPE_64) &&                 (wepType != WLAN_WEP_TYPE_128) )                {                status = EINVAL;                break;                }                        /* return the wep type */            pDev->wepType = (UINT16) wepType;            break;            }            /* Get Authentication protocol */        case EIOCGAUTHTYPE:            {            /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }            /* return the wep type */            * (UINT16 *) data = pDev->authType;            break;            }            /* Set Authentication protocol */        case EIOCSAUTHTYPE:             {            CFG_RID_T   cfg;            CFG_RID_T * pCfg     = (CFG_RID_T *) &cfg;            UINT32      authType = (UINT32) data;            /* disable the MAC */            if ( cisAironetHwMacDisable (pDev)                 == ERROR )                {                status = EINVAL;                break;                }                       /* Get the Cfg Rid */            if ( cisAironetHwRidActualConfigGet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;                }            /* update the config Rid */            pCfg->authType = pDev->authType = authType;            /* Commit the new authentication type  */            if ( cisAironetHwRidConfigSet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;               }                       /* re-enable the MAC */            if ( cisAironetHwMacEnable (pDev)                  == ERROR )                {                status = EINVAL;                }            /* Start scanning */            (void) cisAironetHwScanStart (pDev);            break;            }        /* Get the card mode */        case EIOCGMODE:            {            if (data == NULL)                {                status = EINVAL;                break;                }            *(UINT16*)data = WLAN_CARDMODE_STA; /* only STA mode supported */            break;            }        /* Get Channel used to create IBSS */        case EIOCGCHANNEL:            {            /* Get the status Rid */            STATUS_RID_T   stat;            STATUS_RID_T * pStatus = (STATUS_RID_T *) &stat;            /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }                        /* Get the card status Rid */            if ( cisAironetHwRidStatusGet (pDev, (void *)  pStatus)                 == ERROR )                {                status = EINVAL;                break;                }                        /* Save the current card channel */            * (UINT16 *) data = pStatus->channel;            break;            }            /* Set Channel used to create IBSS */        case EIOCSCHANNEL:              {            CFG_RID_T   cfg;            CFG_RID_T * pCfg      = (CFG_RID_T *) &cfg;            UINT32     txChannel = (UINT32) data;                        /* Check for valid input */            if (txChannel > ANET_MAX_CHANNELS)                {                status = EINVAL;                break;                }            /* disable the MAC */            if ( cisAironetHwMacDisable (pDev)                 == ERROR )                {                status = EINVAL;                break;                }                       /* Get the Cfg Rid */            if ( cisAironetHwRidActualConfigGet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;                }            /* Set the desired tx channel */            pCfg->dsChannel = txChannel;                                /* Commit the new tx channel */            if ( cisAironetHwRidConfigSet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;               }                       /* re-enable the MAC */            if ( cisAironetHwMacEnable (pDev)                  == ERROR )                {                status = EINVAL;                }            break;            }        /* Get the current card tx rate and update pDev with latest value */        case EIOCGTXRATE:            {            STATUS_RID_T   stat;            STATUS_RID_T * pStat   = (STATUS_RID_T *) &stat; /* status RID */            CARD_CTRL_T * pDriver = (CARD_CTRL_T *) cisAironetHwDrvIDGet ();             UINT16 txRate;                        /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }                        /* Read the Status RID */            if ( cisAironetHwRidStatusGet (pDriver, (void *) pStat)                 == ERROR )                {                ANET_DEBUG(DEBUG_ERROR,                           ("cisAironetIoctl: Error reading STATUS RID\n"));                status = EINVAL;                break;                }             txRate = pStat->txRate; /* units of 500 kbps */            txRate = txRate>>1; /* divide by 2 to get mbps */            if (txRate == 1)                * (UINT16 *) data = WLAN_1_MBIT;            else if (txRate == 2)                * (UINT16 *) data = WLAN_2_MBIT;            else if (txRate == 5)                * (UINT16 *) data = WLAN_5_MBIT;            else if (txRate == 11)                * (UINT16 *) data = WLAN_11_MBIT;            else                {                status = EINVAL;                break;                }            break;            }        /* Set the card transmit rate - this is an OR'd bitmask */        case EIOCSTXRATE:            {            CFG_RID_T   cfg;            CFG_RID_T * pCfg   = (CFG_RID_T *) &cfg;            UINT32      count  = 0;            UINT32      txRate = (UINT32) data;             UINT8       rates[8];                        /* Check for valid input */            if (txRate > (WLAN_11_MBIT | WLAN_5_MBIT |                          WLAN_2_MBIT | WLAN_1_MBIT))                {                status = EINVAL;                break;                }            /* disable the MAC */            if ( cisAironetHwMacDisable (pDev)                 == ERROR )                {                status = EINVAL;                break;                }                       /* Get the Cfg Rid */            if ( cisAironetHwRidActualConfigGet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;                }            /* Parse the basic and/or supported rates.  Keep in mind               this deletes the 'basic rate' settings which are only               used in AP mode and are not used at this time. */            if (txRate & WLAN_1_MBIT) /* 1 MBit */                {                rates[count] = 0x02;                count += 1;                }                        if (txRate & WLAN_2_MBIT) /* 2 Mbit */                {                rates[count] = 0x04;                count += 1;                }            if (txRate & WLAN_5_MBIT) /* 5.5 MBit */                {                rates[count] = 0x0B;                count += 1;                }            if (txRate & WLAN_11_MBIT) /* 11 Mbit */                {                rates[count] = 0x16;                count += 1;                }                                   /* set the last rate entry to be zero */            rates[count] = 0;                        /* write the rates to the config RID */            cisAironetBcopy (pDev, rates, pCfg->rates, strlen((char *) rates));                                            /* Commit the new tx rate  */            if ( cisAironetHwRidConfigSet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;               }                       /* re-enable the MAC */            if ( cisAironetHwMacEnable (pDev)                  == ERROR )                {                status = EINVAL;                }            /* Save the new tx rate to the driver control object */            pDev->txRate = txRate;            break;            }                    case EIOCSIBSSMODE:  /* Set IBSS Mode */            {            CFG_RID_T   cfg;            CFG_RID_T * pCfg = (CFG_RID_T *) &cfg;            BOOL ibssMode    = (BOOL) data;            if ( (ibssMode != TRUE) &&                 (ibssMode != FALSE) )                {                /* Non-valid mode requested */                status = EINVAL;                break;                }                        /* disable the MAC */            if ( cisAironetHwMacDisable (pDev)                 == ERROR )                {                status = EINVAL;                break;                }            /* Get the Cfg Rid */            if ( cisAironetHwRidActualConfigGet (pDev, (void *)  pCfg)                 == ERROR )                {                status = EINVAL;                break;                }             if (ibssMode == TRUE)                {                /* Set the card into IBSS mode */                pCfg->opmode = ANET_MODE_STA_IBSS;                }            else                 {                /* Set the card into BSS mode */                pCfg->opmode |= ANET_MODE_STA_ESS;                }            /* Set the Cfg Rid */            if ( cisAironetHwRidConfigSet (pDev, (void *)  pCfg)                 == ERROR )                {

⌨️ 快捷键说明

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