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

📄 cisaironetioctl.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* cisAironetIoctl.c - Ioctl routines for the Cisco Aironet 340/350 card *//* Copyright 2001-2003 Wind River Systems, Inc. *//*modification history--------------------01u,09may03,rb  Removed warnings caused by IPv6 integration01t,18mar03,ss  Fixed SPR 86841, Signal Strength value inaccurately displayed01s,26feb03,ss  Fixed diab compiler warnings01r,28may02,dxb  Corrected RID setting for DOT1X mode.01q,20may02,eja  Added code for multicast and unicast wep keys.01p,16may02,dxb  Updated with new advanced config ioctl's.01o,09may02,dxb  Removed CIS_AIRONET_SLEEP and CIS_AIRONET_WAKEUP.01n,09may02,dxb  Updated set pwrman ioctl.01m,06may02,rb  Fixed error in EIOCSAUTHTYPE - WEP settings overwritten01l,06may02,dxb  More updates to API.01k,05may02,dxb  Updated header comments.01j,22apr02,dxb  Endian fixes.01i,19apr02,eja  Added hooks for 802.1x support.01h,15apr02,dxb  Updated EIOCGTXRATE functionality.01g,09apr02,dxb  Added EIOCGDESIREDSSID and updated EIOCGLINKSTAT.01f,08apr02,eja  Code clean up before FCS.01e,07apr02,eja  Added ioctl commands to call the mib ioctl.01d,13mar02,rb  Fixed pointer referencing bug in all get IOCTLs01c,08mar02,eja  Bug fixes for 128 bit wep and power save mode.01b,28feb02,eja  Added code to allow for open key encryption.01a,14feb02,eja  Got rid of DOT11_FALSE references.*//*DESCRIPTIONThis file contains the private WLAN IOCTL routines that handle cardmanagement.  It is called by the cisAironetEndIoctl() routine incisAironetEnd.c when cisAironetEndIoctl() is passed a command that itdoes not recognize.  If cisAironetIoctlHwExt() does not recognize it either, then EINVAL is returned, as specified in the NPT: User's Guide.The command constants (such as EIOCGLINKSTAT) are defined starting at 0x200 - well outside the range (0-128) reserved for MUX system IOCTLs.  They are defined in wlanEnd.hThe commands available for card management are shown in the table below:\tsCommand            | Description                        | Data Type  ------------------------------------------------------------------------EIOCGSTATS         | Get Card Statistics                |  WLAN_STATS *EIOCGLINKSTAT      | Get Link Status                    |  UINT16 *EIOCGDESIREDSSID   | Get Wireless Network Name          |  char *EIOCSSSID          | Set Wireless Network Name          |  const char *EIOCGCONNECTEDSSID | Get current BSS                    |  char *EIOCGSTNNAME       | Get Station Name                   |  char *EIOCSSTNNAME       | Set Station Name                   |  const char *EIOCGTXRATE        | Get current transmit rate          |  UINT16 *EIOCSTXRATE        | Set Transmit Speed                 |  UINT16EIOCGPWRMAN        | Get Power Management Status        |  UINT16 *EIOCSPWRMAN        | Set Power Management Status        |  UINT16EIOCGCOMMQUAL      | Get Communications Quality         |  UINT16 *EIOCSPROMISC       | Set Promiscuous Mode               |  UINT16EIOCGCARDTYPE      | Get Card Type                      |  UINT16 *EIOCGWEPAVAIL      | Get WEP Availability               |  UINT16 *EIOCGWEPSTATUS     | Get WEP Status                     |  UINT16 *EIOCSWEP           | Enable/Disable WEP                 |  UINT16EIOCSWEPKEY0       | Set value for WEP KEY 0            |  UINT8 *EIOCSWEPKEY1       | Set value for WEP KEY 1            |  UINT8 *EIOCSWEPKEY2       | Set value for WEP KEY 2            |  UINT8 *EIOCSWEPKEY3       | Set value for WEP KEY 3            |  UINT8 *EIOCSWEPDEFAULTKEY | Set WEP default key                |  UINT16EIOCGMODE          | Get the Card Mode                  |  UINT16EIOCGCHANNEL       | Get Channel used to create IBSS    |  UINT16 *EIOCSCHANNEL       | Set Channel used to create IBSS    |  UINT16  EIOCGWEPTYPE       | Get WEP type - 64 bit or 128 bit   |  UINT16 *EIOCSWEPTYPE       | Set WEP type - 128 bit or 128 bit  |  UINT16  EIOCGAUTHTYPE      | Get Authentication protocol        |  UINT16 *EIOCSAUTHTYPE      | Set Authentication protocol        |  UINT16   EIOCGCONNECTEDBSSID| Get connected BSSID                |  UINT16 *EIOCSIBSSMODE      | Set IBSS Mode                      |  UINT16 EIOCGIBSSMODE      | Get IBSS Mode                      |  UINT16 *EIOCSAUTHCALLBACK  | Register authentication callback   |  FUNCPTREIOCS802DOT1XMODE  | Set 802.1x mode                    |  UINT16EIOCG802DOT1XMODE  | Get 802.1x mode status             |  UINT16 *EIOCSCTSRTS        | Set CTS/RTS                        |  UINT16EIOCGCTSRTS        | Get CTS/RTS                        |  UINT16 *EIOCSFRAGTHRESH    | Set Fragmentation threshold        |  UINT16EIOCGFRAGTHRESH    | Get Fragmentation threshold        |  UINT16 *EIOCSPREAMBLE      | Set preamble length                |  UINT16EIOCGPREAMBLE      | Get preamble length                |  UINT16 *EIOCSAUTHRESPTO    | Set Authentication response timeout|  UINT16EIOCGAUTHRESPTO    | Get Authentication response timeout|  UINT16 *  EIOCSUNICASTKEYNUM | Set unicast key slot               |  UINT16EIOCGUNICASTKEYNUM | Get unicast key slot               |  UINT16 *EIOCSMULTICASTKEYNUM|Set multicast key slot             |  UINT16EIOCGMULTICASTKEYNUM|Get multicast key slot             |  UINT16 *EIOCSADVSECURITY   | Set advanced security options      |  UINT16EIOCGADVSECURITY   | Get advanced security options      |  UINT16 *\te INCLUDE FILES: cisAironet.h, wlanEnd.hSEE ALSO: cisAironetHw.c, cisAironetEnd.c, configWlan.h*/#include <vxWorks.h>#include <string.h>#include <stdio.h>#include "wrn/wlan/cisAironet.h"#include "wrn/wlan/wlanEnd.h"/*=========================================================================*//*                                                                         *//*                     CARD CONTROL (IOCTL) ROUTINES                       *//*                                                                         *//*=========================================================================*//**************************************************************************** cisAironetHwIoctlExt - WLAN IOCTL handler** The <cisAironetHwIoctl> routine passes any IOCTL calls that are not * standard END calls to this routine.  Any private WLAN calls to modify * 802.11 behaviour are handled here.** WLAN IOCTL CALLS* \is* \i EIOCGSTATS : Get Card Statistics* Returns the current values of the card counters.  <data> is to be a pointer* to a WLAN_STATS structure, or an array of 20 unsigned longs.** \i EIOCGLINKSTAT : Get Link Status* Returns the current link status of the card.  <data> should be a pointer to* a UINT16.  If <data> is NULL, then the link status will be printed to the* console at error level DEBUG_ERROR (if debugging is on).  The return values * are defined as:*     1 - Disabled*     2 - Searching for initial connection*     3 - Connected to IBSS*     4 - Connected to ESS*     5 - Out of range (in ESS)*     6 - Connected to WDS** Note : EIOCGLINKSTAT is not valid for cards in tertiary AP mode** \i EIOCGDESIREDSSID: Get Wireless Network Name* Returns the network name as set by EIOCSDESIREDSSID.  Note that this is not* necessarily the current BSS name, just the <desired> BSS name.  <data> * should be a pointer to a string of at least BSS_NAME_MAX** \i EIOCSSSID : Set Wireless Network Name* Sets the desired network name to the specified value. <data> is a pointer to* a string of length less that BSS_NAME_MAX** \i EIOCGCONNECTEDSSID: Get current BSS* Returns the name of the BSS that the WLAN card is currently connected to.  If* no BSS is currently connected to (Out of range of AP, etc) a string is * returned stating the fact.  <data> should be a pointer to a string of length* BSS_NAME_MAX** \i EIOCGSTNNAME : Get Station Name* Returns the Station Name assigned to the card.  This is for diagnostic and * management purposes only, and does not affect the card's behaviour in any * way.  <data> is a pointer to a string of at least length BSS_NAME_MAX* * \i EIOCSSTNNAME : Set Station Name* Sets the stations anem for the WLAN card. <Data> is a pointer to the string* containing the name** \i EIOCGTXRATE : Get current transmit rate* Returns the last used transmit rate of the card.  This is a bitmask with* one of the following bits set:* \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* Note that this is not the current setting for the card as set by EIOCSTXRATE* but rather the speed at which the last packet transmitted was sent at.* <data> should be a pointer to a UINT16** \i EIOCSTXRATE : Set Transmit Speed* Sets the allowed transmnit speeds of the card.  The rate is a bitmask * in the same format as EIOCGTXRATE, except that more than one may be * specified.** \i EIOCGPWRMAN : Get Power Management Status* Returns the power management setting.  This is a value specifing* whether Power Management is enabled, WLAN_PMANAGE_ENABLED or * WLAN_PMANAGE_DISABLED* <data> should be a pointer to a UINT16** \i EIOCSPWRMAN : Set Power Management Status* <data> = WLAN_PMANAGE_ENABLED , Turn power management ON* <data> = WLAN_PMANAGE_DISABLED , Turn power management OFF** \i EIOCGCOMMQUAL : Get Communications Quality* Returns the communications quality related to the currently connected BSS.  * This is an integer from 0 (disconnected) to 92 (perfect signal), although * the exactl range returned may vary on different cards.  <Data> * should be a pointer to a UINT16* * \i EIOCSPROMISC : Set Promiscuous Mode* A boolean flag setting the state of the card.  If <data> is TRUE, all packets* presented to the interface will be passed to the network stack.  If <data>* is false, only broadcast and unicast packets directed at this station will* be passed to the network stack.* * \i EIOCGCARDTYPE : Get Card Type* Returns the detected card type.  <data> is a pointer to a UINT16.  The * following card types are returned.* \ts*    value   |   Card Type*   --------------------------------------*      -1    |   Unknown card*       0    |   Card not present*       1    |   Lucent Wavelan / Orinoco*       2    |   3Com AirConnect*       3    |   Cisco Aironet*       4    |   Intersil Prism-2 based card*       5    |   Intersil Prism-2.5 based card*       6    |   Intersil Prism-3 based card** \te** \i EIOCGWEPAVAIL : Get WEP Availability* Returns a boolean value indicating whether or not WEP is available on this* card. <data> should be a pointer to a UINT16** \i EIOCGWEPSTATUS : Get WEP Status* Returns a boolean value indicating whether or not WEP is enabled on this* card.  <data> should be a pointer to a UINT16** \i EIOCSWEP : Enable/Disable WEP     * <data> is a boolean value indicating whether to enable or disable WEP** \i EIOCSWEPKEY0 : Set value for WEP KEY 0 * Sets the value for KEY0.  This value is 5 bytes in length for 40/64 bit * encryption, and 13 bytes for 128 bit.  This length is controlled via the* WLAN_WEP_MAX_KEYSIZE macro in intPrismEnd.h or by calling EIOCSWEPTYPE.  Data is a pointer to an array of* UINT8** \i EIOCSWEPKEY1 : Set value for WEP KEY 1   * Sets the value for key 1.  See EIOCSWEPKEY0 for description** \i EIOCSWEPKEY2 : Set value for WEP KEY 2        * Sets the value for key 1.  See EIOCSWEPKEY0 for description** \i EIOCSWEPKEY3 : Set value for WEP KEY 3        * Sets the value for key 1.  See EIOCSWEPKEY0 for description** \i EIOCSWEPDEFAULTKEY : Set WEP default key* Chooses which key to use when encryting data.  <data> is an integer** \i EIOCGMODE : Get the current mode of the Card* Returns an UINT16 representing card mode. <data> should be a ptr. to a UINT16** \i EIOCGCHANNEL : Get channel used to create IBSS * Returns the channel used to create new IBSSs and APs** \i EIOCSCHANNEL : Set channel used to create IBSS * Sets the channel used to create new IBSSs and APs.  Allowed values (for North* America) are 1 - 11.  If the default channel is set to an invalid channel* the value on the card will be unaffected.** \i EIOCGWEPTYPE : Get WEP type - 64 bit or 128 bit * Returns the type of WEP in use - "64" for 40/64 bit and "128" for 104/128 bit** \i EIOCSWEPTYPE : Set WEP type - 128 bit or 128 bit * Sets the type of WEP used.  There is no way to determine if the card supports* 128 bit encryption; this must be done at the application layer.** \i EIOCGAUTHTYPE : Get authentication protocol * Returns the authentication protocol currently in use.  1 = Open System, 2 = * Shared Key, 3 = Both (AP only)** \i EIOCSAUTHTYPE : Set authentication protocol * Sets the currently used authentication protocol.  1=Open System, 2=Shared* Key, 3=Both (AP Only)   Note : Shared key cannot be enabled unless WEP is * enabled.** \i EIOCGCONNECTEDBSSID : Get connected BSSID* Returns the BSSID of the currently connected AP.  This is a six byte field * that is usually the MAC address of the wireless card in the AP.** \i EIOCSIBSSMODE : Set IBSS mode* Enables or disables IBSS mode.  If enabled, any SSID specified is assumed to* be an IBSS.  0 = disabled (ESS Mode)  1 = Enabled (IBSS mode)** \i EIOCGIBSSMODE : Get IBSS mode* Returns the current status of the card.  0 = ESS mode, 1 = IBSS mode** EIOCSAUTHCALLBACK (NOT SUPPORTED) : Register authentication callback* Registers a new function to replace the old callback routine.  This routine* will be called each time a new station authenticates.  No response is * required.  This routine is in addition to that used by EIOCASTA, although* to make full use of this extension, that list should be empty.* data is a function pointer to the function, NULL to disable.** EIOCS802DOT1XMODE : Set 802.1x mode* Enables 802.1x mode.  Note that this cannot be done unless WEP is enabled. * This mod is not supported on Lucent/Agere Orinoco cards.  In this mode, WEP* is configured so that all packets are received, both encrypted and non.  If* a non-encrypted packet in received, then the protocol type is checked.  If* it is an EAPOL packet (ethertype = 0x888e) then it is passed up the stack,* otherwise it is dropped.  In addition, all packets transmitted are monitored* and EAPOL packets are transmitted unencrypted.  <data> is a UINT16 that * is 1 to turn 802.1x mode on, and 0 to turn it off.* Note : WEP cannot be disabled until 802.1x mode is turned off.** EIOCG802DOT1XMODE : Get 802.1x mode status        * <data> is a UINT16 * that points to the location to store the 802.1x status.* If 802.1x mode is enabled, a '1' will be written, otherwise a '0' will be* written.** EIOCSCTSRTS : Set CTS/RTS* Sets the CTS/RTS threshold.  If packets larger than this size are sent, then* they are protected with a CTS/RTS pair.  The default setting is 2304, which* effectively disables this feature (MTU==1500 bytes).  <data> is a UINT16** EIOCGCTSRTS : Get CTS/RTS* Returns the current CTS/RTS threshold.  <data> should be a UINT16 *** EIOCSFRAGTHRESH : Set Fragmentation threshold* Sets the fragmentation threshold.  If packets larger than this threshold are* sent, then they are fragmented into smaller packets (of this maximum size).* Note that this is 802.11 fragmentation and not IP fragmentation - reassembly* is performed by the receiving MAC.  The default settings is 2304, which * effectively disables this feature. (MTU==1500) <data> is a UINT16** EIOCGFRAGTHRESH : Get Fragmentation threshold* Returns the current CTS/RTS threshold.  <data> should be a UINT16 *** EIOCSPREAMBLE : Set preamble length* Set the premable length the card will use to transmit packets.  * Bit 0 = longPreamble, Bit 1 = shortPreamble.  If both bits are set, then * multi/broadcast packets will be sent with long preamble, unicast packets * will be sent with short preamble.  <data> is a UINT16 with one or both bits*  set.** EIOCGPREAMBLE : Get preamble length* Returns the current preamble setting.  <data> is a UINT16 *** EIOCSAUTHRESPTO : Set Authentication response timeout* Sets the timeout for the supplicant to respond to an authentication request.* <data> is a UINT16 specifying the number of Kus.** EIOCGAUTHRESPTO : Get Authentication response timeout* Returns the current authentication response timeout.  <data> is a UINT16 *** EIOCSUNICASTKEYNUM : Set unicast key slot* Sets the key slot (0 to 3) used to encrypt outgoing unicast packets.  This * value overrides that set by EIOCSWEPDEFAULTKEY.  <data> is a UINT16** EIOCGUNICASTKEYNUM : Get unicast key slot* Returns the currently active unicast key slot.  <data> is a UINT16 *** EIOCSMULTICASTKEYNUM : Set multicast key slot* Sets the key slot (0 to 3) used to encrypt outgoing multicast or broadcast* packets.  This value overrides that set by EIOCSWEPDEFAULTKEY.  <data> is * a UINT16** EIOCGMULTICASTKEYNUM : Get multicast key slot* Returns the currently active broadcast key slot.  <data> is a UINT16 ** \ie** RETURNS : OK or EINVAL on error** ERRNO : N/A** SEE ALSO: wlanEnd.h*/INT32 cisAironetHwIoctlExt    (    CARD_CTRL_T * pDev,  /* Pointer to device control structure */    INT32         cmd,   /* ioctl command to execute */    caddr_t       data   /* generic data pointer - varies by cmd */    )    {      INT32 status = OK;    UINT16 linkStatus;        if (pDev == NULL)         {        ANET_DEBUG(DEBUG_ERROR,                    ("cisAironetHwIoctlExt: NULL pointer"));        return (ERROR);        }    switch (cmd)        {        /* Get the current card statistics */        case EIOCGSTATS:               {            /* Get the statistics RID */            if ( cisAironetHwRidStatUpdate (pDev, (void *) &pDev->stats)                 == ERROR )                {                status = EINVAL;                break;                }            break;            }        /* Get the current card link status */        case EIOCGLINKSTAT:            {            /* sanity check */            if (data == NULL)                {                status = EINVAL;                break;                }                        /* get the current link status from the card */            linkStatus = cisAironetHwLinkStatusGet(pDev);                        if (linkStatus == 0x400) /* connected state */                {                if ((UINT16)pDev->ibssMode == 1)                    {                    * (UINT16 *) data = 3; /* IBSS mode */                    }                else                     {                    * (UINT16 *) data = 4; /* BSS mode */                    }                }            else                {                * (UINT16 *) data = 2; /* not connected */                }            break;            }        /* Get the desired SSID or network name, i.e. 'WlanNetwork1' */        case EIOCGDESIREDSSID:            {            STATUS_RID_T   sts;            STATUS_RID_T * pStatus = (STATUS_RID_T *) &sts;            /* sanity check */

⌨️ 快捷键说明

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