source: freewrt/target/linux/generic-2.4/patches/100-wireless-extension.patch@ a3abab6

freewrt_1_0 freewrt_2_0
Last change on this file since a3abab6 was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 39.5 KB
  • include/linux/netdevice.h

    diff -Nur linux-2.4.32/include/linux/netdevice.h linux-2.4.32-we/include/linux/netdevice.h
    old new  
    295295
    296296        /* List of functions to handle Wireless Extensions (instead of ioctl).
    297297         * See <net/iw_handler.h> for details. Jean II */
    298         struct iw_handler_def * wireless_handlers;
     298        const struct iw_handler_def *   wireless_handlers;
     299        /* Instance data managed by the core of Wireless Extensions. */
     300        struct iw_public_data * wireless_data;
    299301
    300302        struct ethtool_ops *ethtool_ops;
    301303
  • include/linux/wireless.h

    diff -Nur linux-2.4.32/include/linux/wireless.h linux-2.4.32-we/include/linux/wireless.h
    old new  
    11/*
    22 * This file define a set of standard wireless extensions
    33 *
    4  * Version :    16      2.4.03
     4 * Version :    18      12.3.05
    55 *
    66 * Authors :    Jean Tourrilhes - HPL - <jt@hpl.hp.com>
    7  * Copyright (c) 1997-2002 Jean Tourrilhes, All Rights Reserved.
     7 * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
    88 */
    99
    1010#ifndef _LINUX_WIRELESS_H
     
    4747 *      # include/net/iw_handler.h
    4848 *
    4949 * Note as well that /proc/net/wireless implementation has now moved in :
    50  *      # include/linux/wireless.c
     50 *      # net/core/wireless.c
    5151 *
    5252 * Wireless Events (2002 -> onward) :
    5353 * --------------------------------
    5454 * Events are defined at the end of this file, and implemented in :
    55  *      # include/linux/wireless.c
     55 *      # net/core/wireless.c
    5656 *
    5757 * Other comments :
    5858 * --------------
     
    8282 * (there is some stuff that will be added in the future...)
    8383 * I just plan to increment with each new version.
    8484 */
    85 #define WIRELESS_EXT    16
     85#define WIRELESS_EXT    18
    8686
    8787/*
    8888 * Changes :
     
    175175 *      - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
    176176 *      - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
    177177 *      - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
     178 *
     179 * V16 to V17
     180 * ----------
     181 *      - Add flags to frequency -> auto/fixed
     182 *      - Document (struct iw_quality *)->updated, add new flags (INVALID)
     183 *      - Wireless Event capability in struct iw_range
     184 *      - Add support for relative TxPower (yick !)
     185 *
     186 * V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>)
     187 * ----------
     188 *      - Add support for WPA/WPA2
     189 *      - Add extended encoding configuration (SIOCSIWENCODEEXT and
     190 *        SIOCGIWENCODEEXT)
     191 *      - Add SIOCSIWGENIE/SIOCGIWGENIE
     192 *      - Add SIOCSIWMLME
     193 *      - Add SIOCSIWPMKSA
     194 *      - Add struct iw_range bit field for supported encoding capabilities
     195 *      - Add optional scan request parameters for SIOCSIWSCAN
     196 *      - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
     197 *        related parameters (extensible up to 4096 parameter values)
     198 *      - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
     199 *        IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
    178200 */
    179201
    180202/**************************** CONSTANTS ****************************/
     
    249271#define SIOCSIWPOWER    0x8B2C          /* set Power Management settings */
    250272#define SIOCGIWPOWER    0x8B2D          /* get Power Management settings */
    251273
     274/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
     275 * This ioctl uses struct iw_point and data buffer that includes IE id and len
     276 * fields. More than one IE may be included in the request. Setting the generic
     277 * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
     278 * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
     279 * are required to report the used IE as a wireless event, e.g., when
     280 * associating with an AP. */
     281#define SIOCSIWGENIE    0x8B30          /* set generic IE */
     282#define SIOCGIWGENIE    0x8B31          /* get generic IE */
     283
     284/* WPA : IEEE 802.11 MLME requests */
     285#define SIOCSIWMLME     0x8B16          /* request MLME operation; uses
     286                                         * struct iw_mlme */
     287/* WPA : Authentication mode parameters */
     288#define SIOCSIWAUTH     0x8B32          /* set authentication mode params */
     289#define SIOCGIWAUTH     0x8B33          /* get authentication mode params */
     290
     291/* WPA : Extended version of encoding configuration */
     292#define SIOCSIWENCODEEXT 0x8B34         /* set encoding token & mode */
     293#define SIOCGIWENCODEEXT 0x8B35         /* get encoding token & mode */
     294
     295/* WPA2 : PMKSA cache management */
     296#define SIOCSIWPMKSA    0x8B36          /* PMKSA cache operation */
     297
    252298/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
    253299
    254 /* These 16 ioctl are wireless device private.
     300/* These 32 ioctl are wireless device private, for 16 commands.
    255301 * Each driver is free to use them for whatever purpose it chooses,
    256302 * however the driver *must* export the description of those ioctls
    257303 * with SIOCGIWPRIV and *must* use arguments as defined below.
     
    266312 * We now have 32 commands, so a bit more space ;-).
    267313 * Also, all 'odd' commands are only usable by root and don't return the
    268314 * content of ifr/iwr to user (but you are not obliged to use the set/get
    269  * convention, just use every other two command).
    270  * And I repeat : you are not obliged to use them with iwspy, but you
     315 * convention, just use every other two command). More details in iwpriv.c.
     316 * And I repeat : you are not forced to use them with iwpriv, but you
    271317 * must be compliant with it.
    272318 */
    273319
     
    290336#define IWEVCUSTOM      0x8C02          /* Driver specific ascii string */
    291337#define IWEVREGISTERED  0x8C03          /* Discovered a new node (AP mode) */
    292338#define IWEVEXPIRED     0x8C04          /* Expired a node (AP mode) */
     339#define IWEVGENIE       0x8C05          /* Generic IE (WPA, RSN, WMM, ..)
     340                                         * (scan results); This includes id and
     341                                         * length fields. One IWEVGENIE may
     342                                         * contain more than one IE. Scan
     343                                         * results may contain one or more
     344                                         * IWEVGENIE events. */
     345#define IWEVMICHAELMICFAILURE 0x8C06    /* Michael MIC failure
     346                                         * (struct iw_michaelmicfailure)
     347                                         */
     348#define IWEVASSOCREQIE  0x8C07          /* IEs used in (Re)Association Request.
     349                                         * The data includes id and length
     350                                         * fields and may contain more than one
     351                                         * IE. This event is required in
     352                                         * Managed mode if the driver
     353                                         * generates its own WPA/RSN IE. This
     354                                         * should be sent just before
     355                                         * IWEVREGISTERED event for the
     356                                         * association. */
     357#define IWEVASSOCRESPIE 0x8C08          /* IEs used in (Re)Association
     358                                         * Response. The data includes id and
     359                                         * length fields and may contain more
     360                                         * than one IE. This may be sent
     361                                         * between IWEVASSOCREQIE and
     362                                         * IWEVREGISTERED events for the
     363                                         * association. */
     364#define IWEVPMKIDCAND   0x8C09          /* PMKID candidate for RSN
     365                                         * pre-authentication
     366                                         * (struct iw_pmkid_cand) */
    293367
    294368#define IWEVFIRST       0x8C00
    295369
     
    352426#define IW_MODE_SECOND  5       /* Secondary master/repeater (backup) */
    353427#define IW_MODE_MONITOR 6       /* Passive monitor (listen only) */
    354428
     429/* Statistics flags (bitmask in updated) */
     430#define IW_QUAL_QUAL_UPDATED    0x1     /* Value was updated since last read */
     431#define IW_QUAL_LEVEL_UPDATED   0x2
     432#define IW_QUAL_NOISE_UPDATED   0x4
     433#define IW_QUAL_QUAL_INVALID    0x10    /* Driver doesn't provide value */
     434#define IW_QUAL_LEVEL_INVALID   0x20
     435#define IW_QUAL_NOISE_INVALID   0x40
     436
     437/* Frequency flags */
     438#define IW_FREQ_AUTO            0x00    /* Let the driver decides */
     439#define IW_FREQ_FIXED           0x01    /* Force a specific value */
     440
    355441/* Maximum number of size of encoding token available
    356442 * they are listed in the range structure */
    357443#define IW_MAX_ENCODING_SIZES   8
     
    390476#define IW_TXPOW_TYPE           0x00FF  /* Type of value */
    391477#define IW_TXPOW_DBM            0x0000  /* Value is in dBm */
    392478#define IW_TXPOW_MWATT          0x0001  /* Value is in mW */
     479#define IW_TXPOW_RELATIVE       0x0002  /* Value is in arbitrary units */
    393480#define IW_TXPOW_RANGE          0x1000  /* Range of value between min/max */
    394481
    395482/* Retry limits and lifetime flags available */
     
    412499#define IW_SCAN_THIS_MODE       0x0020  /* Scan only this Mode */
    413500#define IW_SCAN_ALL_RATE        0x0040  /* Scan all Bit-Rates */
    414501#define IW_SCAN_THIS_RATE       0x0080  /* Scan only this Bit-Rate */
     502/* struct iw_scan_req scan_type */
     503#define IW_SCAN_TYPE_ACTIVE 0
     504#define IW_SCAN_TYPE_PASSIVE 1
    415505/* Maximum size of returned data */
    416506#define IW_SCAN_MAX_DATA        4096    /* In bytes */
    417507
    418508/* Max number of char in custom event - use multiple of them if needed */
    419509#define IW_CUSTOM_MAX           256     /* In bytes */
    420510
     511/* Generic information element */
     512#define IW_GENERIC_IE_MAX       1024
     513
     514/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
     515#define IW_MLME_DEAUTH          0
     516#define IW_MLME_DISASSOC        1
     517
     518/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
     519#define IW_AUTH_INDEX           0x0FFF
     520#define IW_AUTH_FLAGS           0xF000
     521/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
     522 * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
     523 * parameter that is being set/get to; value will be read/written to
     524 * struct iw_param value field) */
     525#define IW_AUTH_WPA_VERSION             0
     526#define IW_AUTH_CIPHER_PAIRWISE         1
     527#define IW_AUTH_CIPHER_GROUP            2
     528#define IW_AUTH_KEY_MGMT                3
     529#define IW_AUTH_TKIP_COUNTERMEASURES    4
     530#define IW_AUTH_DROP_UNENCRYPTED        5
     531#define IW_AUTH_80211_AUTH_ALG          6
     532#define IW_AUTH_WPA_ENABLED             7
     533#define IW_AUTH_RX_UNENCRYPTED_EAPOL    8
     534#define IW_AUTH_ROAMING_CONTROL         9
     535#define IW_AUTH_PRIVACY_INVOKED         10
     536
     537/* IW_AUTH_WPA_VERSION values (bit field) */
     538#define IW_AUTH_WPA_VERSION_DISABLED    0x00000001
     539#define IW_AUTH_WPA_VERSION_WPA         0x00000002
     540#define IW_AUTH_WPA_VERSION_WPA2        0x00000004
     541
     542/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
     543#define IW_AUTH_CIPHER_NONE     0x00000001
     544#define IW_AUTH_CIPHER_WEP40    0x00000002
     545#define IW_AUTH_CIPHER_TKIP     0x00000004
     546#define IW_AUTH_CIPHER_CCMP     0x00000008
     547#define IW_AUTH_CIPHER_WEP104   0x00000010
     548
     549/* IW_AUTH_KEY_MGMT values (bit field) */
     550#define IW_AUTH_KEY_MGMT_802_1X 1
     551#define IW_AUTH_KEY_MGMT_PSK    2
     552
     553/* IW_AUTH_80211_AUTH_ALG values (bit field) */
     554#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
     555#define IW_AUTH_ALG_SHARED_KEY  0x00000002
     556#define IW_AUTH_ALG_LEAP        0x00000004
     557
     558/* IW_AUTH_ROAMING_CONTROL values */
     559#define IW_AUTH_ROAMING_ENABLE  0       /* driver/firmware based roaming */
     560#define IW_AUTH_ROAMING_DISABLE 1       /* user space program used for roaming
     561                                         * control */
     562
     563/* SIOCSIWENCODEEXT definitions */
     564#define IW_ENCODE_SEQ_MAX_SIZE  8
     565/* struct iw_encode_ext ->alg */
     566#define IW_ENCODE_ALG_NONE      0
     567#define IW_ENCODE_ALG_WEP       1
     568#define IW_ENCODE_ALG_TKIP      2
     569#define IW_ENCODE_ALG_CCMP      3
     570/* struct iw_encode_ext ->ext_flags */
     571#define IW_ENCODE_EXT_TX_SEQ_VALID      0x00000001
     572#define IW_ENCODE_EXT_RX_SEQ_VALID      0x00000002
     573#define IW_ENCODE_EXT_GROUP_KEY         0x00000004
     574#define IW_ENCODE_EXT_SET_TX_KEY        0x00000008
     575
     576/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
     577#define IW_MICFAILURE_KEY_ID    0x00000003 /* Key ID 0..3 */
     578#define IW_MICFAILURE_GROUP     0x00000004
     579#define IW_MICFAILURE_PAIRWISE  0x00000008
     580#define IW_MICFAILURE_STAKEY    0x00000010
     581#define IW_MICFAILURE_COUNT     0x00000060 /* 1 or 2 (0 = count not supported)
     582                                            */
     583
     584/* Bit field values for enc_capa in struct iw_range */
     585#define IW_ENC_CAPA_WPA         0x00000001
     586#define IW_ENC_CAPA_WPA2        0x00000002
     587#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
     588#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
     589
     590/* Event capability macros - in (struct iw_range *)->event_capa
     591 * Because we have more than 32 possible events, we use an array of
     592 * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
     593#define IW_EVENT_CAPA_BASE(cmd)         ((cmd >= SIOCIWFIRSTPRIV) ? \
     594                                         (cmd - SIOCIWFIRSTPRIV + 0x60) : \
     595                                         (cmd - SIOCSIWCOMMIT))
     596#define IW_EVENT_CAPA_INDEX(cmd)        (IW_EVENT_CAPA_BASE(cmd) >> 5)
     597#define IW_EVENT_CAPA_MASK(cmd)         (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
     598/* Event capability constants - event autogenerated by the kernel
     599 * This list is valid for most 802.11 devices, customise as needed... */
     600#define IW_EVENT_CAPA_K_0       (IW_EVENT_CAPA_MASK(0x8B04) | \
     601                                 IW_EVENT_CAPA_MASK(0x8B06) | \
     602                                 IW_EVENT_CAPA_MASK(0x8B1A))
     603#define IW_EVENT_CAPA_K_1       (IW_EVENT_CAPA_MASK(0x8B2A))
     604/* "Easy" macro to set events in iw_range (less efficient) */
     605#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
     606#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
     607
     608
    421609/****************************** TYPES ******************************/
    422610
    423611/* --------------------------- SUBTYPES --------------------------- */
     
    456644        __s32           m;              /* Mantissa */
    457645        __s16           e;              /* Exponent */
    458646        __u8            i;              /* List index (when in range struct) */
    459         __u8            pad;            /* Unused - just for alignement */
     647        __u8            flags;          /* Flags (fixed/auto) */
    460648};
    461649
    462650/*
     
    507695        struct iw_quality       high;           /* High threshold */
    508696};
    509697
     698/*
     699 *      Optional data for scan request
     700 *
     701 *      Note: these optional parameters are controlling parameters for the
     702 *      scanning behavior, these do not apply to getting scan results
     703 *      (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
     704 *      provide a merged results with all BSSes even if the previous scan
     705 *      request limited scanning to a subset, e.g., by specifying an SSID.
     706 *      Especially, scan results are required to include an entry for the
     707 *      current BSS if the driver is in Managed mode and associated with an AP.
     708 */
     709struct  iw_scan_req
     710{
     711        __u8            scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
     712        __u8            essid_len;
     713        __u8            num_channels; /* num entries in channel_list;
     714                                       * 0 = scan all allowed channels */
     715        __u8            flags; /* reserved as padding; use zero, this may
     716                                * be used in the future for adding flags
     717                                * to request different scan behavior */
     718        struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
     719                                * individual address of a specific BSS */
     720
     721        /*
     722         * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
     723         * the current ESSID. This allows scan requests for specific ESSID
     724         * without having to change the current ESSID and potentially breaking
     725         * the current association.
     726         */
     727        __u8            essid[IW_ESSID_MAX_SIZE];
     728
     729        /*
     730         * Optional parameters for changing the default scanning behavior.
     731         * These are based on the MLME-SCAN.request from IEEE Std 802.11.
     732         * TU is 1.024 ms. If these are set to 0, driver is expected to use
     733         * reasonable default values. min_channel_time defines the time that
     734         * will be used to wait for the first reply on each channel. If no
     735         * replies are received, next channel will be scanned after this. If
     736         * replies are received, total time waited on the channel is defined by
     737         * max_channel_time.
     738         */
     739        __u32           min_channel_time; /* in TU */
     740        __u32           max_channel_time; /* in TU */
     741
     742        struct iw_freq  channel_list[IW_MAX_FREQUENCIES];
     743};
     744
     745/* ------------------------- WPA SUPPORT ------------------------- */
     746
     747/*
     748 *      Extended data structure for get/set encoding (this is used with
     749 *      SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
     750 *      flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
     751 *      only the data contents changes (key data -> this structure, including
     752 *      key data).
     753 *
     754 *      If the new key is the first group key, it will be set as the default
     755 *      TX key. Otherwise, default TX key index is only changed if
     756 *      IW_ENCODE_EXT_SET_TX_KEY flag is set.
     757 *
     758 *      Key will be changed with SIOCSIWENCODEEXT in all cases except for
     759 *      special "change TX key index" operation which is indicated by setting
     760 *      key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
     761 *
     762 *      tx_seq/rx_seq are only used when respective
     763 *      IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
     764 *      TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
     765 *      TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
     766 *      used only by an Authenticator (AP or an IBSS station) to get the
     767 *      current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
     768 *      RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
     769 *      debugging/testing.
     770 */
     771struct  iw_encode_ext
     772{
     773        __u32           ext_flags; /* IW_ENCODE_EXT_* */
     774        __u8            tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
     775        __u8            rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
     776        struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
     777                               * (group) keys or unicast address for
     778                               * individual keys */
     779        __u16           alg; /* IW_ENCODE_ALG_* */
     780        __u16           key_len;
     781        __u8            key[0];
     782};
     783
     784/* SIOCSIWMLME data */
     785struct  iw_mlme
     786{
     787        __u16           cmd; /* IW_MLME_* */
     788        __u16           reason_code;
     789        struct sockaddr addr;
     790};
     791
     792/* SIOCSIWPMKSA data */
     793#define IW_PMKSA_ADD            1
     794#define IW_PMKSA_REMOVE         2
     795#define IW_PMKSA_FLUSH          3
     796
     797#define IW_PMKID_LEN    16
     798
     799struct  iw_pmksa
     800{
     801        __u32           cmd; /* IW_PMKSA_* */
     802        struct sockaddr bssid;
     803        __u8            pmkid[IW_PMKID_LEN];
     804};
     805
     806/* IWEVMICHAELMICFAILURE data */
     807struct  iw_michaelmicfailure
     808{
     809        __u32           flags;
     810        struct sockaddr src_addr;
     811        __u8            tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
     812};
     813
     814/* IWEVPMKIDCAND data */
     815#define IW_PMKID_CAND_PREAUTH   0x00000001 /* RNS pre-authentication enabled */
     816struct  iw_pmkid_cand
     817{
     818        __u32           flags; /* IW_PMKID_CAND_* */
     819        __u32           index; /* the smaller the index, the higher the
     820                                * priority */
     821        struct sockaddr bssid;
     822};
     823
    510824/* ------------------------ WIRELESS STATS ------------------------ */
    511825/*
    512826 * Wireless statistics (used for /proc/net/wireless)
     
    610924        /* Old Frequency (backward compat - moved lower ) */
    611925        __u16           old_num_channels;
    612926        __u8            old_num_frequency;
    613         /* Filler to keep "version" at the same offset */
    614         __s32           old_freq[6];
     927
     928        /* Wireless event capability bitmasks */
     929        __u32           event_capa[6];
    615930
    616931        /* signal level threshold range */
    617         __s32   sensitivity;
     932        __s32           sensitivity;
    618933
    619934        /* Quality of link & SNR stuff */
    620935        /* Quality range (link, level, noise)
     
    6851000        struct iw_freq  freq[IW_MAX_FREQUENCIES];       /* list */
    6861001        /* Note : this frequency list doesn't need to fit channel numbers,
    6871002         * because each entry contain its channel index */
     1003
     1004        __u32           enc_capa; /* IW_ENC_CAPA_* bit field */
    6881005};
    6891006
    6901007/*
  • include/net/iw_handler.h

    diff -Nur linux-2.4.32/include/net/iw_handler.h linux-2.4.32-we/include/net/iw_handler.h
    old new  
    11/*
    22 * This file define the new driver API for Wireless Extensions
    33 *
    4  * Version :    5       4.12.02
     4 * Version :    6       21.6.04
    55 *
    66 * Authors :    Jean Tourrilhes - HPL - <jt@hpl.hp.com>
    7  * Copyright (c) 2001-2002 Jean Tourrilhes, All Rights Reserved.
     7 * Copyright (c) 2001-2004 Jean Tourrilhes, All Rights Reserved.
    88 */
    99
    1010#ifndef _IW_HANDLER_H
     
    206206 * will be needed...
    207207 * I just plan to increment with each new version.
    208208 */
    209 #define IW_HANDLER_VERSION      5
     209#define IW_HANDLER_VERSION      6
    210210
    211211/*
    212212 * Changes :
     
    224224 * V4 to V5
    225225 * --------
    226226 *      - Add new spy support : struct iw_spy_data & prototypes
     227 *
     228 * V5 to V6
     229 * --------
     230 *      - Change the way we get to spy_data method for added safety
     231 *      - Remove spy #ifdef, they are always on -> cleaner code
     232 *      - Add IW_DESCR_FLAG_NOMAX flag for very large requests
     233 *      - Start migrating get_wireless_stats to struct iw_handler_def
    227234 */
    228235
    229236/**************************** CONSTANTS ****************************/
    230237
    231 /* Enable enhanced spy support. Disable to reduce footprint */
     238/* Enhanced spy support available */
    232239#define IW_WIRELESS_SPY
    233240#define IW_WIRELESS_THRSPY
    234241
     
    258265#define IW_DESCR_FLAG_EVENT     0x0002  /* Generate an event on SET */
    259266#define IW_DESCR_FLAG_RESTRICT  0x0004  /* GET : request is ROOT only */
    260267                                /* SET : Omit payload from generated iwevent */
     268#define IW_DESCR_FLAG_NOMAX     0x0008  /* GET : no limit on request size */
    261269/* Driver level flags */
    262270#define IW_DESCR_FLAG_WAIT      0x0100  /* Wait for driver event */
    263271
     
    311319        /* Array of handlers for standard ioctls
    312320         * We will call dev->wireless_handlers->standard[ioctl - SIOCSIWNAME]
    313321         */
    314         iw_handler *            standard;
     322        const iw_handler *      standard;
    315323
    316324        /* Array of handlers for private ioctls
    317325         * Will call dev->wireless_handlers->private[ioctl - SIOCIWFIRSTPRIV]
    318326         */
    319         iw_handler *            private;
     327        const iw_handler *      private;
    320328
    321329        /* Arguments of private handler. This one is just a list, so you
    322330         * can put it in any order you want and should not leave holes...
    323331         * We will automatically export that to user space... */
    324         struct iw_priv_args *   private_args;
     332        const struct iw_priv_args *     private_args;
    325333
    326         /* Driver enhanced spy support */
    327         long                    spy_offset;     /* Spy data offset */
     334        /* This field will be *removed* in the next version of WE */
     335        long                    spy_offset;     /* DO NOT USE */
    328336
    329         /* In the long term, get_wireless_stats will move from
    330          * 'struct net_device' to here, to minimise bloat. */
     337        /* New location of get_wireless_stats, to de-bloat struct net_device.
     338         * The old pointer in struct net_device will be gradually phased
     339         * out, and drivers are encouraged to use this one... */
     340        struct iw_statistics*   (*get_wireless_stats)(struct net_device *dev);
    331341};
    332342
    333343/* ---------------------- IOCTL DESCRIPTION ---------------------- */
     
    374384 */
    375385struct iw_spy_data
    376386{
    377 #ifdef IW_WIRELESS_SPY
    378387        /* --- Standard spy support --- */
    379388        int                     spy_number;
    380389        u_char                  spy_address[IW_MAX_SPY][ETH_ALEN];
    381390        struct iw_quality       spy_stat[IW_MAX_SPY];
    382 #ifdef IW_WIRELESS_THRSPY
    383391        /* --- Enhanced spy support (event) */
    384392        struct iw_quality       spy_thr_low;    /* Low threshold */
    385393        struct iw_quality       spy_thr_high;   /* High threshold */
    386394        u_char                  spy_thr_under[IW_MAX_SPY];
    387 #endif /* IW_WIRELESS_THRSPY */
    388 #endif /* IW_WIRELESS_SPY */
     395};
     396
     397/* --------------------- DEVICE WIRELESS DATA --------------------- */
     398/*
     399 * This is all the wireless data specific to a device instance that
     400 * is managed by the core of Wireless Extensions.
     401 * We only keep pointer to those structures, so that a driver is free
     402 * to share them between instances.
     403 * This structure should be initialised before registering the device.
     404 * Access to this data follow the same rules as any other struct net_device
     405 * data (i.e. valid as long as struct net_device exist, same locking rules).
     406 */
     407struct iw_public_data {
     408        /* Driver enhanced spy support */
     409        struct iw_spy_data *    spy_data;
    389410};
    390411
    391412/**************************** PROTOTYPES ****************************/
  • net/core/dev.c

    diff -Nur linux-2.4.32/net/core/dev.c linux-2.4.32-we/net/core/dev.c
    old new  
    24262426                                /* Follow me in net/core/wireless.c */
    24272427                                ret = wireless_process_ioctl(&ifr, cmd);
    24282428                                rtnl_unlock();
    2429                                 if (!ret && IW_IS_GET(cmd) &&
     2429                                if (IW_IS_GET(cmd) &&
    24302430                                    copy_to_user(arg, &ifr, sizeof(struct ifreq)))
    24312431                                        return -EFAULT;
    24322432                                return ret;
  • net/core/wireless.c

    diff -Nur linux-2.4.32/net/core/wireless.c linux-2.4.32-we/net/core/wireless.c
    old new  
    22 * This file implement the Wireless Extensions APIs.
    33 *
    44 * Authors :    Jean Tourrilhes - HPL - <jt@hpl.hp.com>
    5  * Copyright (c) 1997-2003 Jean Tourrilhes, All Rights Reserved.
     5 * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
    66 *
    77 * (As all part of the Linux kernel, this file is GPL)
    88 */
     
    4848 *      o Add common spy support : iw_handler_set_spy(), wireless_spy_update()
    4949 *      o Add enhanced spy support : iw_handler_set_thrspy() and event.
    5050 *      o Add WIRELESS_EXT version display in /proc/net/wireless
     51 *
     52 * v6 - 18.06.04 - Jean II
     53 *      o Change get_spydata() method for added safety
     54 *      o Remove spy #ifdef, they are always on -> cleaner code
     55 *      o Allow any size GET request if user specifies length > max
     56 *              and if request has IW_DESCR_FLAG_NOMAX flag or is SIOCGIWPRIV
     57 *      o Start migrating get_wireless_stats to struct iw_handler_def
     58 *      o Add wmb() in iw_handler_set_spy() for non-coherent archs/cpus
     59 * Based on patch from Pavel Roskin <proski@gnu.org> :
     60 *      o Fix kernel data leak to user space in private handler handling
    5161 */
    5262
    5363/***************************** INCLUDES *****************************/
     
    6474
    6575/**************************** CONSTANTS ****************************/
    6676
    67 /* Enough lenience, let's make sure things are proper... */
    68 #define WE_STRICT_WRITE         /* Check write buffer size */
    69 /* I'll probably drop both the define and kernel message in the next version */
    70 
    71 /* Debuging stuff */
     77/* Debugging stuff */
    7278#undef WE_IOCTL_DEBUG           /* Debug IOCTL API */
    7379#undef WE_EVENT_DEBUG           /* Debug Event dispatcher */
    7480#undef WE_SPY_DEBUG             /* Debug enhanced spy support */
     
    131137        { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
    132138        /* SIOCGIWAP */
    133139        { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, IW_DESCR_FLAG_DUMP},
    134         /* -- hole -- */
    135         { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
     140        /* SIOCSIWMLME */
     141        { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_mlme), sizeof(struct iw_mlme), 0},
    136142        /* SIOCGIWAPLIST */
    137         { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_AP, 0},
     143        { IW_HEADER_TYPE_POINT, 0, (sizeof(struct sockaddr) + sizeof(struct iw_quality)), 0, IW_MAX_AP, IW_DESCR_FLAG_NOMAX},
    138144        /* SIOCSIWSCAN */
    139         { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
     145        { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_scan_req), 0},
    140146        /* SIOCGIWSCAN */
    141         { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_SCAN_MAX_DATA, 0},
     147        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_SCAN_MAX_DATA, IW_DESCR_FLAG_NOMAX},
    142148        /* SIOCSIWESSID */
    143149        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_ESSID_MAX_SIZE + 1, IW_DESCR_FLAG_EVENT},
    144150        /* SIOCGIWESSID */
     
    179185        { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
    180186        /* SIOCGIWPOWER */
    181187        { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
     188        /* -- hole -- */
     189        { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
     190        /* -- hole -- */
     191        { IW_HEADER_TYPE_NULL, 0, 0, 0, 0, 0},
     192        /* SIOCSIWGENIE */
     193        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0},
     194        /* SIOCGIWGENIE */
     195        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0},
     196        /* SIOCSIWAUTH */
     197        { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
     198        /* SIOCGIWAUTH */
     199        { IW_HEADER_TYPE_PARAM, 0, 0, 0, 0, 0},
     200        /* SIOCSIWENCODEEXT */
     201        { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_encode_ext), sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX, 0},
     202        /* SIOCGIWENCODEEXT */
     203        { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_encode_ext), sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX, 0},
     204        /* SIOCSIWPMKSA */
     205        { IW_HEADER_TYPE_POINT, 0, 1, sizeof(struct iw_pmksa), sizeof(struct iw_pmksa), 0},
     206        /* -- hole -- */
    182207};
    183208static const int standard_ioctl_num = (sizeof(standard_ioctl) /
    184209                                       sizeof(struct iw_ioctl_description));
     
    198223        { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
    199224        /* IWEVEXPIRED */
    200225        { IW_HEADER_TYPE_ADDR, 0, 0, 0, 0, 0},
     226        /* IWEVGENIE */
     227        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0},
     228        /* IWEVMICHAELMICFAILURE */
     229        { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_michaelmicfailure), 0},
     230        /* IWEVASSOCREQIE */
     231        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0},
     232        /* IWEVASSOCRESPIE */
     233        { IW_HEADER_TYPE_POINT, 0, 1, 0, IW_GENERIC_IE_MAX, 0},
     234        /* IWEVPMKIDCAND */
     235        { IW_HEADER_TYPE_POINT, 0, 1, 0, sizeof(struct iw_pmkid_cand), 0},
    201236};
    202237static const int standard_event_num = (sizeof(standard_event) /
    203238                                       sizeof(struct iw_ioctl_description));
    204239
    205240/* Size (in bytes) of the various private data types */
    206 static const char priv_type_size[] = {
     241static const char iw_priv_type_size[] = {
    207242        0,                              /* IW_PRIV_TYPE_NONE */
    208243        1,                              /* IW_PRIV_TYPE_BYTE */
    209244        1,                              /* IW_PRIV_TYPE_CHAR */
     
    270305 */
    271306static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
    272307{
     308        /* New location */
     309        if((dev->wireless_handlers != NULL) &&
     310           (dev->wireless_handlers->get_wireless_stats != NULL))
     311                return dev->wireless_handlers->get_wireless_stats(dev);
     312
     313        /* Old location, will be phased out in next WE */
    273314        return (dev->get_wireless_stats ?
    274315                dev->get_wireless_stats(dev) :
    275316                (struct iw_statistics *) NULL);
    276         /* In the future, get_wireless_stats may move from 'struct net_device'
    277          * to 'struct iw_handler_def', to de-bloat struct net_device.
    278          * Definitely worse a thought... */
    279317}
    280318
    281319/* ---------------------------------------------------------------- */
     
    310348
    311349/* ---------------------------------------------------------------- */
    312350/*
    313  * Number of private arguments
     351 * Calculate size of private arguments
    314352 */
    315353static inline int get_priv_size(__u16   args)
    316354{
    317355        int     num = args & IW_PRIV_SIZE_MASK;
    318356        int     type = (args & IW_PRIV_TYPE_MASK) >> 12;
    319357
    320         return num * priv_type_size[type];
     358        return num * iw_priv_type_size[type];
     359}
     360
     361/* ---------------------------------------------------------------- */
     362/*
     363 * Re-calculate the size of private arguments
     364 */
     365static inline int adjust_priv_size(__u16                args,
     366                                   union iwreq_data *   wrqu)
     367{
     368        int     num = wrqu->data.length;
     369        int     max = args & IW_PRIV_SIZE_MASK;
     370        int     type = (args & IW_PRIV_TYPE_MASK) >> 12;
     371
     372        /* Make sure the driver doesn't goof up */
     373        if (max < num)
     374                num = max;
     375
     376        return num * iw_priv_type_size[type];
    321377}
    322378
    323379
     
    350406                               dev->name,
    351407                               stats->status,
    352408                               stats->qual.qual,
    353                                stats->qual.updated & 1 ? '.' : ' ',
     409                               stats->qual.updated & IW_QUAL_QUAL_UPDATED
     410                               ? '.' : ' ',
    354411                               ((__u8) stats->qual.level),
    355                                stats->qual.updated & 2 ? '.' : ' ',
     412                               stats->qual.updated & IW_QUAL_LEVEL_UPDATED
     413                               ? '.' : ' ',
    356414                               ((__u8) stats->qual.noise),
    357                                stats->qual.updated & 4 ? '.' : ' ',
     415                               stats->qual.updated & IW_QUAL_NOISE_UPDATED
     416                               ? '.' : ' ',
    358417                               stats->discard.nwid,
    359418                               stats->discard.code,
    360419                               stats->discard.fragment,
     
    470529        /* Check NULL pointer */
    471530        if(iwr->u.data.pointer == NULL)
    472531                return -EFAULT;
    473 #ifdef WE_STRICT_WRITE
     532
    474533        /* Check if there is enough buffer up there */
    475534        if(iwr->u.data.length < dev->wireless_handlers->num_private_args) {
    476                 printk(KERN_ERR "%s (WE) : Buffer for request SIOCGIWPRIV too small (%d<%d)\n", dev->name, iwr->u.data.length, dev->wireless_handlers->num_private_args);
     535                /* User space can't know in advance how large the buffer
     536                 * needs to be. Give it a hint, so that we can support
     537                 * any size buffer we want somewhat efficiently... */
     538                iwr->u.data.length = dev->wireless_handlers->num_private_args;
    477539                return -E2BIG;
    478540        }
    479 #endif  /* WE_STRICT_WRITE */
    480541
    481542        /* Set the number of available ioctls. */
    482543        iwr->u.data.length = dev->wireless_handlers->num_private_args;
     
    505566        const struct iw_ioctl_description *     descr;
    506567        struct iw_request_info                  info;
    507568        int                                     ret = -EINVAL;
    508         int                                     user_size = 0;
    509569
    510570        /* Get the description of the IOCTL */
    511571        if((cmd - SIOCIWFIRST) >= standard_ioctl_num)
     
    536596#endif  /* WE_SET_EVENT */
    537597        } else {
    538598                char *  extra;
     599                int     extra_size;
     600                int     user_length = 0;
    539601                int     err;
    540602
     603                /* Calculate space needed by arguments. Always allocate
     604                 * for max space. Easier, and won't last long... */
     605                extra_size = descr->max_tokens * descr->token_size;
     606
    541607                /* Check what user space is giving us */
    542608                if(IW_IS_SET(cmd)) {
    543609                        /* Check NULL pointer */
     
    554620                        if(iwr->u.data.pointer == NULL)
    555621                                return -EFAULT;
    556622                        /* Save user space buffer size for checking */
    557                         user_size = iwr->u.data.length;
     623                        user_length = iwr->u.data.length;
     624
     625                        /* Don't check if user_length > max to allow forward
     626                         * compatibility. The test user_length < min is
     627                         * implied by the test at the end. */
     628
     629                        /* Support for very large requests */
     630                        if((descr->flags & IW_DESCR_FLAG_NOMAX) &&
     631                           (user_length > descr->max_tokens)) {
     632                                /* Allow userspace to GET more than max so
     633                                 * we can support any size GET requests.
     634                                 * There is still a limit : -ENOMEM. */
     635                                extra_size = user_length * descr->token_size;
     636                                /* Note : user_length is originally a __u16,
     637                                 * and token_size is controlled by us,
     638                                 * so extra_size won't get negative and
     639                                 * won't overflow... */
     640                        }
    558641                }
    559642
    560643#ifdef WE_IOCTL_DEBUG
    561644                printk(KERN_DEBUG "%s (WE) : Malloc %d bytes\n",
    562                        dev->name, descr->max_tokens * descr->token_size);
     645                       dev->name, extra_size);
    563646#endif  /* WE_IOCTL_DEBUG */
    564647
    565                 /* Always allocate for max space. Easier, and won't last
    566                  * long... */
    567                 extra = kmalloc(descr->max_tokens * descr->token_size,
    568                                 GFP_KERNEL);
     648                /* Create the kernel buffer */
     649                extra = kmalloc(extra_size, GFP_KERNEL);
    569650                if (extra == NULL) {
    570651                        return -ENOMEM;
    571652                }
     
    591672
    592673                /* If we have something to return to the user */
    593674                if (!ret && IW_IS_GET(cmd)) {
    594 #ifdef WE_STRICT_WRITE
    595675                        /* Check if there is enough buffer up there */
    596                         if(user_size < iwr->u.data.length) {
    597                                 printk(KERN_ERR "%s (WE) : Buffer for request %04X too small (%d<%d)\n", dev->name, cmd, user_size, iwr->u.data.length);
     676                        if(user_length < iwr->u.data.length) {
    598677                                kfree(extra);
    599678                                return -E2BIG;
    600679                        }
    601 #endif  /* WE_STRICT_WRITE */
    602680
    603681                        err = copy_to_user(iwr->u.data.pointer, extra,
    604682                                           iwr->u.data.length *
     
    661739                                     iw_handler         handler)
    662740{
    663741        struct iwreq *                  iwr = (struct iwreq *) ifr;
    664         struct iw_priv_args *           descr = NULL;
     742        const struct iw_priv_args *     descr = NULL;
    665743        struct iw_request_info          info;
    666744        int                             extra_size = 0;
    667745        int                             i;
     
    701779                           ((extra_size + offset) <= IFNAMSIZ))
    702780                                extra_size = 0;
    703781                } else {
    704                         /* Size of set arguments */
     782                        /* Size of get arguments */
    705783                        extra_size = get_priv_size(descr->get_args);
    706784
    707785                        /* Does it fits in iwr ? */
     
    771849
    772850                /* If we have something to return to the user */
    773851                if (!ret && IW_IS_GET(cmd)) {
     852
     853                        /* Adjust for the actual length if it's variable,
     854                         * avoid leaking kernel bits outside. */
     855                        if (!(descr->get_args & IW_PRIV_SIZE_FIXED)) {
     856                                extra_size = adjust_priv_size(descr->get_args,
     857                                                              &(iwr->u));
     858                        }
     859
    774860                        err = copy_to_user(iwr->u.data.pointer, extra,
    775861                                           extra_size);
    776862                        if (err)
     
    10421128 * One of the main advantage of centralising spy support here is that
    10431129 * it becomes much easier to improve and extend it without having to touch
    10441130 * the drivers. One example is the addition of the Spy-Threshold events.
    1045  * Note : IW_WIRELESS_SPY is defined in iw_handler.h
    10461131 */
    10471132
     1133/* ---------------------------------------------------------------- */
     1134/*
     1135 * Return the pointer to the spy data in the driver.
     1136 * Because this is called on the Rx path via wireless_spy_update(),
     1137 * we want it to be efficient...
     1138 */
     1139static inline struct iw_spy_data * get_spydata(struct net_device *dev)
     1140{
     1141        /* This is the new way */
     1142        if(dev->wireless_data)
     1143                return(dev->wireless_data->spy_data);
     1144
     1145        /* This is the old way. Doesn't work for multi-headed drivers.
     1146         * It will be removed in the next version of WE. */
     1147        return (dev->priv + dev->wireless_handlers->spy_offset);
     1148}
     1149
    10481150/*------------------------------------------------------------------*/
    10491151/*
    10501152 * Standard Wireless Handler : set Spy List
     
    10541156                       union iwreq_data *       wrqu,
    10551157                       char *                   extra)
    10561158{
    1057 #ifdef IW_WIRELESS_SPY
    1058         struct iw_spy_data *    spydata = (dev->priv +
    1059                                            dev->wireless_handlers->spy_offset);
     1159        struct iw_spy_data *    spydata = get_spydata(dev);
    10601160        struct sockaddr *       address = (struct sockaddr *) extra;
    10611161
     1162        /* Make sure driver is not buggy or using the old API */
     1163        if(!spydata)
     1164                return -EOPNOTSUPP;
     1165
    10621166        /* Disable spy collection while we copy the addresses.
    1063          * As we don't disable interrupts, we need to do this to avoid races.
    1064          * As we are the only writer, this is good enough. */
     1167         * While we copy addresses, any call to wireless_spy_update()
     1168         * will NOP. This is OK, as anyway the addresses are changing. */
    10651169        spydata->spy_number = 0;
    10661170
     1171        /* We want to operate without locking, because wireless_spy_update()
     1172         * most likely will happen in the interrupt handler, and therefore
     1173         * have its own locking constraints and needs performance.
     1174         * The rtnl_lock() make sure we don't race with the other iw_handlers.
     1175         * This make sure wireless_spy_update() "see" that the spy list
     1176         * is temporarily disabled. */
     1177        wmb();
     1178
    10671179        /* Are there are addresses to copy? */
    10681180        if(wrqu->data.length > 0) {
    10691181                int i;
     
    10891201                               spydata->spy_address[i][5]);
    10901202#endif  /* WE_SPY_DEBUG */
    10911203        }
     1204
     1205        /* Make sure above is updated before re-enabling */
     1206        wmb();
     1207
    10921208        /* Enable addresses */
    10931209        spydata->spy_number = wrqu->data.length;
    10941210
    10951211        return 0;
    1096 #else /* IW_WIRELESS_SPY */
    1097         return -EOPNOTSUPP;
    1098 #endif /* IW_WIRELESS_SPY */
    10991212}
    11001213
    11011214/*------------------------------------------------------------------*/
     
    11071220                       union iwreq_data *       wrqu,
    11081221                       char *                   extra)
    11091222{
    1110 #ifdef IW_WIRELESS_SPY
    1111         struct iw_spy_data *    spydata = (dev->priv +
    1112                                            dev->wireless_handlers->spy_offset);
     1223        struct iw_spy_data *    spydata = get_spydata(dev);
    11131224        struct sockaddr *       address = (struct sockaddr *) extra;
    11141225        int                     i;
    11151226
     1227        /* Make sure driver is not buggy or using the old API */
     1228        if(!spydata)
     1229                return -EOPNOTSUPP;
     1230
    11161231        wrqu->data.length = spydata->spy_number;
    11171232
    11181233        /* Copy addresses. */
     
    11291244        for(i = 0; i < spydata->spy_number; i++)
    11301245                spydata->spy_stat[i].updated = 0;
    11311246        return 0;
    1132 #else /* IW_WIRELESS_SPY */
    1133         return -EOPNOTSUPP;
    1134 #endif /* IW_WIRELESS_SPY */
    11351247}
    11361248
    11371249/*------------------------------------------------------------------*/
     
    11431255                          union iwreq_data *    wrqu,
    11441256                          char *                extra)
    11451257{
    1146 #ifdef IW_WIRELESS_THRSPY
    1147         struct iw_spy_data *    spydata = (dev->priv +
    1148                                            dev->wireless_handlers->spy_offset);
     1258        struct iw_spy_data *    spydata = get_spydata(dev);
    11491259        struct iw_thrspy *      threshold = (struct iw_thrspy *) extra;
    11501260
     1261        /* Make sure driver is not buggy or using the old API */
     1262        if(!spydata)
     1263                return -EOPNOTSUPP;
     1264
    11511265        /* Just do it */
    11521266        memcpy(&(spydata->spy_thr_low), &(threshold->low),
    11531267               2 * sizeof(struct iw_quality));
     
    11601274#endif  /* WE_SPY_DEBUG */
    11611275
    11621276        return 0;
    1163 #else /* IW_WIRELESS_THRSPY */
    1164         return -EOPNOTSUPP;
    1165 #endif /* IW_WIRELESS_THRSPY */
    11661277}
    11671278
    11681279/*------------------------------------------------------------------*/
     
    11741285                          union iwreq_data *    wrqu,
    11751286                          char *                extra)
    11761287{
    1177 #ifdef IW_WIRELESS_THRSPY
    1178         struct iw_spy_data *    spydata = (dev->priv +
    1179                                            dev->wireless_handlers->spy_offset);
     1288        struct iw_spy_data *    spydata = get_spydata(dev);
    11801289        struct iw_thrspy *      threshold = (struct iw_thrspy *) extra;
    11811290
     1291        /* Make sure driver is not buggy or using the old API */
     1292        if(!spydata)
     1293                return -EOPNOTSUPP;
     1294
    11821295        /* Just do it */
    11831296        memcpy(&(threshold->low), &(spydata->spy_thr_low),
    11841297               2 * sizeof(struct iw_quality));
    11851298
    11861299        return 0;
    1187 #else /* IW_WIRELESS_THRSPY */
    1188         return -EOPNOTSUPP;
    1189 #endif /* IW_WIRELESS_THRSPY */
    11901300}
    11911301
    1192 #ifdef IW_WIRELESS_THRSPY
    11931302/*------------------------------------------------------------------*/
    11941303/*
    11951304 * Prepare and send a Spy Threshold event
     
    12271336        /* Send event to user space */
    12281337        wireless_send_event(dev, SIOCGIWTHRSPY, &wrqu, (char *) &threshold);
    12291338}
    1230 #endif /* IW_WIRELESS_THRSPY */
    12311339
    12321340/* ---------------------------------------------------------------- */
    12331341/*
     
    12401348                         unsigned char *        address,
    12411349                         struct iw_quality *    wstats)
    12421350{
    1243 #ifdef IW_WIRELESS_SPY
    1244         struct iw_spy_data *    spydata = (dev->priv +
    1245                                            dev->wireless_handlers->spy_offset);
     1351        struct iw_spy_data *    spydata = get_spydata(dev);
    12461352        int                     i;
    12471353        int                     match = -1;
    12481354
     1355        /* Make sure driver is not buggy or using the old API */
     1356        if(!spydata)
     1357                return;
     1358
    12491359#ifdef WE_SPY_DEBUG
    12501360        printk(KERN_DEBUG "wireless_spy_update() :  offset %ld, spydata %p, address %02X:%02X:%02X:%02X:%02X:%02X\n", dev->wireless_handlers->spy_offset, spydata, address[0], address[1], address[2], address[3], address[4], address[5]);
    12511361#endif  /* WE_SPY_DEBUG */
     
    12571367                               sizeof(struct iw_quality));
    12581368                        match = i;
    12591369                }
    1260 #ifdef IW_WIRELESS_THRSPY
     1370
    12611371        /* Generate an event if we cross the spy threshold.
    12621372         * To avoid event storms, we have a simple hysteresis : we generate
    12631373         * event only when we go under the low threshold or above the
     
    12771387                        }
    12781388                }
    12791389        }
    1280 #endif /* IW_WIRELESS_THRSPY */
    1281 #endif /* IW_WIRELESS_SPY */
    12821390}
Note: See TracBrowser for help on using the repository browser.