linux/drivers/staging/rtl8188eu/include/ieee80211.h
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms of version 2 of the GNU General Public License as
   7 * published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope that it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12 * more details.
  13 *
  14 ******************************************************************************/
  15#ifndef __IEEE80211_H
  16#define __IEEE80211_H
  17
  18#include <osdep_service.h>
  19#include <drv_types.h>
  20#include "wifi.h"
  21#include <linux/wireless.h>
  22
  23#define MGMT_QUEUE_NUM 5
  24
  25#define ETH_ALEN        6
  26#define ETH_TYPE_LEN            2
  27#define PAYLOAD_TYPE_LEN        1
  28
  29#ifdef CONFIG_88EU_AP_MODE
  30
  31#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
  32
  33/* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
  34enum {
  35        RTL871X_HOSTAPD_FLUSH = 1,
  36        RTL871X_HOSTAPD_ADD_STA = 2,
  37        RTL871X_HOSTAPD_REMOVE_STA = 3,
  38        RTL871X_HOSTAPD_GET_INFO_STA = 4,
  39        /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
  40        RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
  41        RTL871X_SET_ENCRYPTION = 6,
  42        RTL871X_GET_ENCRYPTION = 7,
  43        RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
  44        RTL871X_HOSTAPD_GET_RID = 9,
  45        RTL871X_HOSTAPD_SET_RID = 10,
  46        RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
  47        RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
  48        RTL871X_HOSTAPD_MLME = 13,
  49        RTL871X_HOSTAPD_SCAN_REQ = 14,
  50        RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
  51        RTL871X_HOSTAPD_SET_BEACON = 16,
  52        RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
  53        RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
  54        RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
  55        RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
  56        RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
  57        RTL871X_HOSTAPD_ACL_ADD_STA = 22,
  58        RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
  59};
  60
  61/* STA flags */
  62#define WLAN_STA_AUTH BIT(0)
  63#define WLAN_STA_ASSOC BIT(1)
  64#define WLAN_STA_PS BIT(2)
  65#define WLAN_STA_TIM BIT(3)
  66#define WLAN_STA_PERM BIT(4)
  67#define WLAN_STA_AUTHORIZED BIT(5)
  68#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  69#define WLAN_STA_SHORT_PREAMBLE BIT(7)
  70#define WLAN_STA_PREAUTH BIT(8)
  71#define WLAN_STA_WME BIT(9)
  72#define WLAN_STA_MFP BIT(10)
  73#define WLAN_STA_HT BIT(11)
  74#define WLAN_STA_WPS BIT(12)
  75#define WLAN_STA_MAYBE_WPS BIT(13)
  76#define WLAN_STA_NONERP BIT(31)
  77
  78#endif
  79
  80#define IEEE_CMD_SET_WPA_PARAM                  1
  81#define IEEE_CMD_SET_WPA_IE                             2
  82#define IEEE_CMD_SET_ENCRYPTION                 3
  83#define IEEE_CMD_MLME                                           4
  84
  85#define IEEE_PARAM_WPA_ENABLED                          1
  86#define IEEE_PARAM_TKIP_COUNTERMEASURES         2
  87#define IEEE_PARAM_DROP_UNENCRYPTED                     3
  88#define IEEE_PARAM_PRIVACY_INVOKED                      4
  89#define IEEE_PARAM_AUTH_ALGS                                    5
  90#define IEEE_PARAM_IEEE_802_1X                          6
  91#define IEEE_PARAM_WPAX_SELECT                          7
  92
  93#define AUTH_ALG_OPEN_SYSTEM                    0x1
  94#define AUTH_ALG_SHARED_KEY                     0x2
  95#define AUTH_ALG_LEAP                           0x00000004
  96
  97#define IEEE_MLME_STA_DEAUTH                            1
  98#define IEEE_MLME_STA_DISASSOC                  2
  99
 100#define IEEE_CRYPT_ERR_UNKNOWN_ALG                      2
 101#define IEEE_CRYPT_ERR_UNKNOWN_ADDR                     3
 102#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED                4
 103#define IEEE_CRYPT_ERR_KEY_SET_FAILED                   5
 104#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED                6
 105#define IEEE_CRYPT_ERR_CARD_CONF_FAILED         7
 106
 107
 108#define IEEE_CRYPT_ALG_NAME_LEN                 16
 109
 110#define WPA_CIPHER_NONE         BIT(0)
 111#define WPA_CIPHER_WEP40        BIT(1)
 112#define WPA_CIPHER_WEP104 BIT(2)
 113#define WPA_CIPHER_TKIP         BIT(3)
 114#define WPA_CIPHER_CCMP         BIT(4)
 115
 116
 117
 118#define WPA_SELECTOR_LEN 4
 119extern u8 RTW_WPA_OUI_TYPE[];
 120extern u8 WPA_AUTH_KEY_MGMT_NONE[];
 121extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
 122extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
 123extern u8 WPA_CIPHER_SUITE_NONE[];
 124extern u8 WPA_CIPHER_SUITE_WEP40[];
 125extern u8 WPA_CIPHER_SUITE_TKIP[];
 126extern u8 WPA_CIPHER_SUITE_WRAP[];
 127extern u8 WPA_CIPHER_SUITE_CCMP[];
 128extern u8 WPA_CIPHER_SUITE_WEP104[];
 129
 130
 131#define RSN_HEADER_LEN 4
 132#define RSN_SELECTOR_LEN 4
 133
 134extern u16 RSN_VERSION_BSD;
 135extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
 136extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
 137extern u8 RSN_CIPHER_SUITE_NONE[];
 138extern u8 RSN_CIPHER_SUITE_WEP40[];
 139extern u8 RSN_CIPHER_SUITE_TKIP[];
 140extern u8 RSN_CIPHER_SUITE_WRAP[];
 141extern u8 RSN_CIPHER_SUITE_CCMP[];
 142extern u8 RSN_CIPHER_SUITE_WEP104[];
 143
 144enum ratr_table_mode {
 145        RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
 146        RATR_INX_WIRELESS_NG = 1,       /*  GN or N */
 147        RATR_INX_WIRELESS_NB = 2,       /*  BGN 20 Mhz 2SS 1SS  or BN */
 148        RATR_INX_WIRELESS_N = 3,
 149        RATR_INX_WIRELESS_GB = 4,
 150        RATR_INX_WIRELESS_G = 5,
 151        RATR_INX_WIRELESS_B = 6,
 152        RATR_INX_WIRELESS_MC = 7,
 153        RATR_INX_WIRELESS_AC_N = 8,
 154};
 155
 156enum NETWORK_TYPE {
 157        WIRELESS_INVALID = 0,
 158        /* Sub-Element */
 159        WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */
 160        WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/
 161        WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */
 162        WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */
 163        WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */
 164        WIRELESS_AC             = BIT(6),
 165
 166        /* Combination */
 167        /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
 168        WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
 169        /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
 170        WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N),
 171        /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
 172        WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N),
 173        /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
 174        WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N),
 175        /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
 176        WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N |
 177                          WIRELESS_11_5N),
 178        WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G |
 179                           WIRELESS_11_24N | WIRELESS_11_5N),
 180};
 181
 182#define SUPPORTED_24G_NETTYPE_MSK                               \
 183         (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
 184#define SUPPORTED_5G_NETTYPE_MSK                                \
 185         (WIRELESS_11A | WIRELESS_11_5N)
 186
 187#define IsSupported24G(NetType)                                 \
 188        ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
 189#define IsSupported5G(NetType)                                  \
 190        ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false)
 191
 192#define IsEnableHWCCK(NetType)                                  \
 193        IsSupported24G(NetType)
 194#define IsEnableHWOFDM(NetType)                                 \
 195        ((NetType) & (WIRELESS_11G | WIRELESS_11_24N |          \
 196         SUPPORTED_5G_NETTYPE_MSK) ? true : false)
 197
 198#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
 199#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
 200#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType)
 201
 202#define IsSupportedTxCCK(NetType)                               \
 203        ((NetType) & (WIRELESS_11B) ? true : false)
 204#define IsSupportedTxOFDM(NetType)                              \
 205        ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false)
 206#define IsSupportedTxMCS(NetType)                               \
 207        ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false)
 208
 209
 210struct ieee_param {
 211        u32 cmd;
 212        u8 sta_addr[ETH_ALEN];
 213        union {
 214                struct {
 215                        u8 name;
 216                        u32 value;
 217                } wpa_param;
 218                struct {
 219                        u32 len;
 220                        u8 reserved[32];
 221                        u8 data[0];
 222                } wpa_ie;
 223                struct {
 224                        int command;
 225                        int reason_code;
 226                } mlme;
 227                struct {
 228                        u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
 229                        u8 set_tx;
 230                        u32 err;
 231                        u8 idx;
 232                        u8 seq[8]; /* sequence counter (set: RX, get: TX) */
 233                        u16 key_len;
 234                        u8 key[0];
 235                } crypt;
 236#ifdef CONFIG_88EU_AP_MODE
 237                struct {
 238                        u16 aid;
 239                        u16 capability;
 240                        int flags;
 241                        u8 tx_supp_rates[16];
 242                        struct rtw_ieee80211_ht_cap ht_cap;
 243                } add_sta;
 244                struct {
 245                        u8      reserved[2];/* for set max_num_sta */
 246                        u8      buf[0];
 247                } bcn_ie;
 248#endif
 249
 250        } u;
 251};
 252
 253#ifdef CONFIG_88EU_AP_MODE
 254struct ieee_param_ex {
 255        u32 cmd;
 256        u8 sta_addr[ETH_ALEN];
 257        u8 data[0];
 258};
 259
 260struct sta_data {
 261        u16 aid;
 262        u16 capability;
 263        int flags;
 264        u32 sta_set;
 265        u8 tx_supp_rates[16];
 266        u32 tx_supp_rates_len;
 267        struct rtw_ieee80211_ht_cap ht_cap;
 268        u64     rx_pkts;
 269        u64     rx_bytes;
 270        u64     rx_drops;
 271        u64     tx_pkts;
 272        u64     tx_bytes;
 273        u64     tx_drops;
 274};
 275#endif
 276
 277#define IEEE80211_DATA_LEN              2304
 278/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
 279   6.2.1.1.2.
 280
 281   The figure in section 7.1.2 suggests a body size of up to 2312
 282   bytes is allowed, which is a bit confusing, I suspect this
 283   represents the 2304 bytes of real data, plus a possible 8 bytes of
 284   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
 285
 286
 287#define IEEE80211_HLEN                  30
 288#define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
 289
 290
 291/* this is stolen from ipw2200 driver */
 292#define IEEE_IBSS_MAC_HASH_SIZE 31
 293
 294struct ieee_ibss_seq {
 295        u8 mac[ETH_ALEN];
 296        u16 seq_num;
 297        u16 frag_num;
 298        unsigned long packet_time;
 299        struct list_head list;
 300};
 301
 302struct rtw_ieee80211_hdr {
 303        __le16 frame_ctl;
 304        __le16 duration_id;
 305        u8 addr1[ETH_ALEN];
 306        u8 addr2[ETH_ALEN];
 307        u8 addr3[ETH_ALEN];
 308        u16 seq_ctl;
 309        u8 addr4[ETH_ALEN];
 310} __packed;
 311
 312struct rtw_ieee80211_hdr_3addr {
 313        __le16 frame_ctl;
 314        __le16 duration_id;
 315        u8 addr1[ETH_ALEN];
 316        u8 addr2[ETH_ALEN];
 317        u8 addr3[ETH_ALEN];
 318        u16 seq_ctl;
 319} __packed;
 320
 321struct rtw_ieee80211_hdr_qos {
 322        __le16 frame_ctl;
 323        __le16 duration_id;
 324        u8 addr1[ETH_ALEN];
 325        u8 addr2[ETH_ALEN];
 326        u8 addr3[ETH_ALEN];
 327        u16 seq_ctl;
 328        u8 addr4[ETH_ALEN];
 329        u16     qc;
 330}  __packed;
 331
 332struct rtw_ieee80211_hdr_3addr_qos {
 333        __le16 frame_ctl;
 334        __le16 duration_id;
 335        u8 addr1[ETH_ALEN];
 336        u8 addr2[ETH_ALEN];
 337        u8 addr3[ETH_ALEN];
 338        u16 seq_ctl;
 339        u16     qc;
 340}  __packed;
 341
 342struct eapol {
 343        u8 snap[6];
 344        u16 ethertype;
 345        u8 version;
 346        u8 type;
 347        u16 length;
 348} __packed;
 349
 350enum eap_type {
 351        EAP_PACKET = 0,
 352        EAPOL_START,
 353        EAPOL_LOGOFF,
 354        EAPOL_KEY,
 355        EAPOL_ENCAP_ASF_ALERT
 356};
 357
 358#define IEEE80211_3ADDR_LEN 24
 359#define IEEE80211_4ADDR_LEN 30
 360#define IEEE80211_FCS_LEN    4
 361
 362#define MIN_FRAG_THRESHOLD     256U
 363#define MAX_FRAG_THRESHOLD     2346U
 364
 365/* Frame control field constants */
 366#define RTW_IEEE80211_FCTL_VERS         0x0003
 367#define RTW_IEEE80211_FCTL_FTYPE        0x000c
 368#define RTW_IEEE80211_FCTL_STYPE        0x00f0
 369#define RTW_IEEE80211_FCTL_TODS         0x0100
 370#define RTW_IEEE80211_FCTL_FROMDS       0x0200
 371#define RTW_IEEE80211_FCTL_MOREFRAGS    0x0400
 372#define RTW_IEEE80211_FCTL_RETRY        0x0800
 373#define RTW_IEEE80211_FCTL_PM           0x1000
 374#define RTW_IEEE80211_FCTL_MOREDATA     0x2000
 375#define RTW_IEEE80211_FCTL_PROTECTED    0x4000
 376#define RTW_IEEE80211_FCTL_ORDER        0x8000
 377#define RTW_IEEE80211_FCTL_CTL_EXT      0x0f00
 378
 379#define RTW_IEEE80211_FTYPE_MGMT        0x0000
 380#define RTW_IEEE80211_FTYPE_CTL         0x0004
 381#define RTW_IEEE80211_FTYPE_DATA        0x0008
 382#define RTW_IEEE80211_FTYPE_EXT         0x000c
 383
 384/* management */
 385#define RTW_IEEE80211_STYPE_ASSOC_REQ   0x0000
 386#define RTW_IEEE80211_STYPE_ASSOC_RESP  0x0010
 387#define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
 388#define RTW_IEEE80211_STYPE_REASSOC_RESP        0x0030
 389#define RTW_IEEE80211_STYPE_PROBE_REQ   0x0040
 390#define RTW_IEEE80211_STYPE_PROBE_RESP  0x0050
 391#define RTW_IEEE80211_STYPE_BEACON      0x0080
 392#define RTW_IEEE80211_STYPE_ATIM        0x0090
 393#define RTW_IEEE80211_STYPE_DISASSOC    0x00A0
 394#define RTW_IEEE80211_STYPE_AUTH        0x00B0
 395#define RTW_IEEE80211_STYPE_DEAUTH      0x00C0
 396#define RTW_IEEE80211_STYPE_ACTION      0x00D0
 397
 398/* control */
 399#define RTW_IEEE80211_STYPE_CTL_EXT     0x0060
 400#define RTW_IEEE80211_STYPE_BACK_REQ    0x0080
 401#define RTW_IEEE80211_STYPE_BACK        0x0090
 402#define RTW_IEEE80211_STYPE_PSPOLL      0x00A0
 403#define RTW_IEEE80211_STYPE_RTS         0x00B0
 404#define RTW_IEEE80211_STYPE_CTS         0x00C0
 405#define RTW_IEEE80211_STYPE_ACK         0x00D0
 406#define RTW_IEEE80211_STYPE_CFEND       0x00E0
 407#define RTW_IEEE80211_STYPE_CFENDACK    0x00F0
 408
 409/* data */
 410#define RTW_IEEE80211_STYPE_DATA        0x0000
 411#define RTW_IEEE80211_STYPE_DATA_CFACK  0x0010
 412#define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
 413#define RTW_IEEE80211_STYPE_DATA_CFACKPOLL      0x0030
 414#define RTW_IEEE80211_STYPE_NULLFUNC    0x0040
 415#define RTW_IEEE80211_STYPE_CFACK       0x0050
 416#define RTW_IEEE80211_STYPE_CFPOLL      0x0060
 417#define RTW_IEEE80211_STYPE_CFACKPOLL   0x0070
 418#define RTW_IEEE80211_STYPE_QOS_DATA    0x0080
 419#define RTW_IEEE80211_STYPE_QOS_DATA_CFACK      0x0090
 420#define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL     0x00A0
 421#define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL  0x00B0
 422#define RTW_IEEE80211_STYPE_QOS_NULLFUNC        0x00C0
 423#define RTW_IEEE80211_STYPE_QOS_CFACK           0x00D0
 424#define RTW_IEEE80211_STYPE_QOS_CFPOLL          0x00E0
 425#define RTW_IEEE80211_STYPE_QOS_CFACKPOLL       0x00F0
 426
 427/* sequence control field */
 428#define RTW_IEEE80211_SCTL_FRAG 0x000F
 429#define RTW_IEEE80211_SCTL_SEQ  0xFFF0
 430
 431
 432#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
 433#define RTW_ERP_INFO_USE_PROTECTION BIT(1)
 434#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
 435
 436/* QoS, QOS */
 437#define NORMAL_ACK                      0
 438#define NO_ACK                          1
 439#define NON_EXPLICIT_ACK                2
 440#define BLOCK_ACK                       3
 441
 442#ifndef ETH_P_PAE
 443#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 444#endif /* ETH_P_PAE */
 445
 446#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
 447
 448#define ETH_P_ECONET    0x0018
 449
 450#ifndef ETH_P_80211_RAW
 451#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
 452#endif
 453
 454/* IEEE 802.11 defines */
 455
 456#define P80211_OUI_LEN 3
 457
 458struct ieee80211_snap_hdr {
 459        u8    dsap;   /* always 0xAA */
 460        u8    ssap;   /* always 0xAA */
 461        u8    ctrl;   /* always 0x03 */
 462        u8    oui[P80211_OUI_LEN];    /* organizational universal id */
 463} __packed;
 464
 465#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
 466
 467#define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
 468#define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
 469
 470#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
 471
 472#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
 473#define WLAN_GET_SEQ_SEQ(seq)  ((seq) & RTW_IEEE80211_SCTL_SEQ)
 474
 475/* Non standard?  Not in <linux/ieee80211.h> */
 476#define WLAN_REASON_EXPIRATION_CHK 65535
 477
 478#define IEEE80211_MGMT_HDR_LEN 24
 479#define IEEE80211_DATA_HDR3_LEN 24
 480#define IEEE80211_DATA_HDR4_LEN 30
 481
 482
 483#define IEEE80211_STATMASK_SIGNAL (1<<0)
 484#define IEEE80211_STATMASK_RSSI (1<<1)
 485#define IEEE80211_STATMASK_NOISE (1<<2)
 486#define IEEE80211_STATMASK_RATE (1<<3)
 487#define IEEE80211_STATMASK_WEMASK 0x7
 488
 489
 490#define IEEE80211_CCK_MODULATION    (1<<0)
 491#define IEEE80211_OFDM_MODULATION   (1<<1)
 492
 493#define IEEE80211_24GHZ_BAND     (1<<0)
 494#define IEEE80211_52GHZ_BAND     (1<<1)
 495
 496#define IEEE80211_CCK_RATE_LEN                  4
 497#define IEEE80211_NUM_OFDM_RATESLEN     8
 498
 499
 500#define IEEE80211_CCK_RATE_1MB                  0x02
 501#define IEEE80211_CCK_RATE_2MB                  0x04
 502#define IEEE80211_CCK_RATE_5MB                  0x0B
 503#define IEEE80211_CCK_RATE_11MB                 0x16
 504#define IEEE80211_OFDM_RATE_LEN                 8
 505#define IEEE80211_OFDM_RATE_6MB                 0x0C
 506#define IEEE80211_OFDM_RATE_9MB                 0x12
 507#define IEEE80211_OFDM_RATE_12MB                0x18
 508#define IEEE80211_OFDM_RATE_18MB                0x24
 509#define IEEE80211_OFDM_RATE_24MB                0x30
 510#define IEEE80211_OFDM_RATE_36MB                0x48
 511#define IEEE80211_OFDM_RATE_48MB                0x60
 512#define IEEE80211_OFDM_RATE_54MB                0x6C
 513#define IEEE80211_BASIC_RATE_MASK               0x80
 514
 515#define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
 516#define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
 517#define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
 518#define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
 519#define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
 520#define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
 521#define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
 522#define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
 523#define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
 524#define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
 525#define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
 526#define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
 527
 528#define IEEE80211_CCK_RATES_MASK                0x0000000F
 529#define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
 530        IEEE80211_CCK_RATE_2MB_MASK)
 531#define IEEE80211_CCK_DEFAULT_RATES_MASK                                \
 532        (IEEE80211_CCK_BASIC_RATES_MASK |                               \
 533        IEEE80211_CCK_RATE_5MB_MASK |                                   \
 534        IEEE80211_CCK_RATE_11MB_MASK)
 535
 536#define IEEE80211_OFDM_RATES_MASK               0x00000FF0
 537#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
 538        IEEE80211_OFDM_RATE_12MB_MASK |                                 \
 539        IEEE80211_OFDM_RATE_24MB_MASK)
 540#define IEEE80211_OFDM_DEFAULT_RATES_MASK                               \
 541        (IEEE80211_OFDM_BASIC_RATES_MASK |                              \
 542        IEEE80211_OFDM_RATE_9MB_MASK  |                                 \
 543        IEEE80211_OFDM_RATE_18MB_MASK |                                 \
 544        IEEE80211_OFDM_RATE_36MB_MASK |                                 \
 545        IEEE80211_OFDM_RATE_48MB_MASK |                                 \
 546        IEEE80211_OFDM_RATE_54MB_MASK)
 547#define IEEE80211_DEFAULT_RATES_MASK                                    \
 548        (IEEE80211_OFDM_DEFAULT_RATES_MASK |                            \
 549         IEEE80211_CCK_DEFAULT_RATES_MASK)
 550
 551#define IEEE80211_NUM_OFDM_RATES        8
 552#define IEEE80211_NUM_CCK_RATES         4
 553#define IEEE80211_OFDM_SHIFT_MASK_A     4
 554
 555/* NOTE: This data is for statistical purposes; not all hardware provides this
 556 *       information for frames received.  Not setting these will not cause
 557 *       any adverse affects. */
 558struct ieee80211_rx_stats {
 559        /* u32 mac_time[2]; */
 560        s8 rssi;
 561        u8 signal;
 562        u8 noise;
 563        u8 received_channel;
 564        u16 rate; /* in 100 kbps */
 565        /* u8 control; */
 566        u8 mask;
 567        u8 freq;
 568        u16 len;
 569};
 570
 571/* IEEE 802.11 requires that STA supports concurrent reception of at least
 572 * three fragmented frames. This define can be increased to support more
 573 * concurrent frames, but it should be noted that each entry can consume about
 574 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
 575#define IEEE80211_FRAG_CACHE_LEN 4
 576
 577struct ieee80211_frag_entry {
 578        u32 first_frag_time;
 579        uint seq;
 580        uint last_frag;
 581        uint qos;   /* jackson */
 582        uint tid;       /* jackson */
 583        struct sk_buff *skb;
 584        u8 src_addr[ETH_ALEN];
 585        u8 dst_addr[ETH_ALEN];
 586};
 587
 588struct ieee80211_stats {
 589        uint tx_unicast_frames;
 590        uint tx_multicast_frames;
 591        uint tx_fragments;
 592        uint tx_unicast_octets;
 593        uint tx_multicast_octets;
 594        uint tx_deferred_transmissions;
 595        uint tx_single_retry_frames;
 596        uint tx_multiple_retry_frames;
 597        uint tx_retry_limit_exceeded;
 598        uint tx_discards;
 599        uint rx_unicast_frames;
 600        uint rx_multicast_frames;
 601        uint rx_fragments;
 602        uint rx_unicast_octets;
 603        uint rx_multicast_octets;
 604        uint rx_fcs_errors;
 605        uint rx_discards_no_buffer;
 606        uint tx_discards_wrong_sa;
 607        uint rx_discards_undecryptable;
 608        uint rx_message_in_msg_fragments;
 609        uint rx_message_in_bad_msg_fragments;
 610};
 611
 612struct ieee80211_softmac_stats {
 613        uint rx_ass_ok;
 614        uint rx_ass_err;
 615        uint rx_probe_rq;
 616        uint tx_probe_rs;
 617        uint tx_beacons;
 618        uint rx_auth_rq;
 619        uint rx_auth_rs_ok;
 620        uint rx_auth_rs_err;
 621        uint tx_auth_rq;
 622        uint no_auth_rs;
 623        uint no_ass_rs;
 624        uint tx_ass_rq;
 625        uint rx_ass_rq;
 626        uint tx_probe_rq;
 627        uint reassoc;
 628        uint swtxstop;
 629        uint swtxawake;
 630};
 631
 632#define SEC_KEY_1       (1<<0)
 633#define SEC_KEY_2       (1<<1)
 634#define SEC_KEY_3       (1<<2)
 635#define SEC_KEY_4       (1<<3)
 636#define SEC_ACTIVE_KEY  (1<<4)
 637#define SEC_AUTH_MODE   (1<<5)
 638#define SEC_UNICAST_GROUP (1<<6)
 639#define SEC_LEVEL       (1<<7)
 640#define SEC_ENABLED     (1<<8)
 641
 642#define SEC_LEVEL_0      0 /* None */
 643#define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
 644#define SEC_LEVEL_2      2 /* Level 1 + TKIP */
 645#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
 646#define SEC_LEVEL_3      4 /* Level 2 + CCMP */
 647
 648#define WEP_KEYS 4
 649#define WEP_KEY_LEN 13
 650
 651struct ieee80211_security {
 652        u16 active_key:2,
 653        enabled:1,
 654        auth_mode:2,
 655        auth_algo:4,
 656        unicast_uses_group:1;
 657        u8 key_sizes[WEP_KEYS];
 658        u8 keys[WEP_KEYS][WEP_KEY_LEN];
 659        u8 level;
 660        u16 flags;
 661} __packed;
 662
 663/*
 664
 665 802.11 data frame from AP
 666
 667      ,-------------------------------------------------------------------.
 668Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
 669      |------|------|---------|---------|---------|------|---------|------|
 670Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
 671      |      | tion | (BSSID) |  |       | ence |  data   |      |
 672      `-------------------------------------------------------------------'
 673
 674Total: 28-2340 bytes
 675
 676*/
 677
 678struct ieee80211_header_data {
 679        u16 frame_ctl;
 680        u16 duration_id;
 681        u8 addr1[6];
 682        u8 addr2[6];
 683        u8 addr3[6];
 684        u16 seq_ctrl;
 685};
 686
 687#define BEACON_PROBE_SSID_ID_POSITION 12
 688
 689/* Management Frame Information Element Types */
 690#define MFIE_TYPE_SSID          0
 691#define MFIE_TYPE_RATES         1
 692#define MFIE_TYPE_FH_SET        2
 693#define MFIE_TYPE_DS_SET        3
 694#define MFIE_TYPE_CF_SET        4
 695#define MFIE_TYPE_TIM           5
 696#define MFIE_TYPE_IBSS_SET      6
 697#define MFIE_TYPE_CHALLENGE     16
 698#define MFIE_TYPE_ERP           42
 699#define MFIE_TYPE_RSN           48
 700#define MFIE_TYPE_RATES_EX      50
 701#define MFIE_TYPE_GENERIC       221
 702
 703struct ieee80211_info_element_hdr {
 704        u8 id;
 705        u8 len;
 706} __packed;
 707
 708struct ieee80211_info_element {
 709        u8 id;
 710        u8 len;
 711        u8 data[0];
 712} __packed;
 713
 714/*
 715 * These are the data types that can make up management packets
 716 *
 717        u16 auth_algorithm;
 718        u16 auth_sequence;
 719        u16 beacon_interval;
 720        u16 capability;
 721        u8 current_ap[ETH_ALEN];
 722        u16 listen_interval;
 723        struct {
 724                u16 association_id:14, reserved:2;
 725        } __packed;
 726        u32 time_stamp[2];
 727        u16 reason;
 728        u16 status;
 729*/
 730
 731#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
 732#define IEEE80211_DEFAULT_BASIC_RATE 10
 733
 734struct ieee80211_authentication {
 735        struct ieee80211_header_data header;
 736        u16 algorithm;
 737        u16 transaction;
 738        u16 status;
 739        /* struct ieee80211_info_element_hdr info_element; */
 740} __packed;
 741
 742struct ieee80211_probe_response {
 743        struct ieee80211_header_data header;
 744        u32 time_stamp[2];
 745        u16 beacon_interval;
 746        u16 capability;
 747        struct ieee80211_info_element info_element;
 748} __packed;
 749
 750struct ieee80211_probe_request {
 751        struct ieee80211_header_data header;
 752} __packed;
 753
 754struct ieee80211_assoc_request_frame {
 755        struct rtw_ieee80211_hdr_3addr header;
 756        u16 capability;
 757        u16 listen_interval;
 758        struct ieee80211_info_element_hdr info_element;
 759} __packed;
 760
 761struct ieee80211_assoc_response_frame {
 762        struct rtw_ieee80211_hdr_3addr header;
 763        u16 capability;
 764        u16 status;
 765        u16 aid;
 766} __packed;
 767
 768struct ieee80211_txb {
 769        u8 nr_frags;
 770        u8 encrypted;
 771        u16 reserved;
 772        u16 frag_size;
 773        u16 payload_size;
 774        struct sk_buff *fragments[0];
 775};
 776
 777
 778/* SWEEP TABLE ENTRIES NUMBER*/
 779#define MAX_SWEEP_TAB_ENTRIES             42
 780#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
 781/* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
 782 * only use 8, and then use extended rates for the remaining supported
 783 * rates.  Other APs, however, stick all of their supported rates on the
 784 * main rates information element... */
 785#define MAX_RATES_LENGTH                ((u8)12)
 786#define MAX_RATES_EX_LENGTH             ((u8)16)
 787#define MAX_NETWORK_COUNT               128
 788#define MAX_CHANNEL_NUMBER              161
 789#define IEEE80211_SOFTMAC_SCAN_TIME     400
 790/* HZ / 2) */
 791#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
 792
 793#define CRC_LENGTH               4U
 794
 795#define MAX_WPA_IE_LEN (256)
 796#define MAX_WPS_IE_LEN (512)
 797#define MAX_P2P_IE_LEN (256)
 798#define MAX_WFD_IE_LEN (128)
 799
 800#define NETWORK_EMPTY_ESSID (1<<0)
 801#define NETWORK_HAS_OFDM    (1<<1)
 802#define NETWORK_HAS_CCK     (1<<2)
 803
 804#define IEEE80211_DTIM_MBCAST 4
 805#define IEEE80211_DTIM_UCAST 2
 806#define IEEE80211_DTIM_VALID 1
 807#define IEEE80211_DTIM_INVALID 0
 808
 809#define IEEE80211_PS_DISABLED 0
 810#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
 811#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
 812#define IW_ESSID_MAX_SIZE 32
 813/*
 814join_res:
 815-1: authentication fail
 816-2: association fail
 817> 0: TID
 818*/
 819
 820enum ieee80211_state {
 821        /* the card is not linked at all */
 822        IEEE80211_NOLINK = 0,
 823
 824        /* IEEE80211_ASSOCIATING* are for BSS client mode
 825         * the driver shall not perform RX filtering unless
 826         * the state is LINKED.
 827         * The driver shall just check for the state LINKED and
 828         * defaults to NOLINK for ALL the other states (including
 829         * LINKED_SCANNING)
 830         */
 831
 832        /* the association procedure will start (wq scheduling)*/
 833        IEEE80211_ASSOCIATING,
 834        IEEE80211_ASSOCIATING_RETRY,
 835
 836        /* the association procedure is sending AUTH request*/
 837        IEEE80211_ASSOCIATING_AUTHENTICATING,
 838
 839        /* the association procedure has successfully authentcated
 840         * and is sending association request
 841         */
 842        IEEE80211_ASSOCIATING_AUTHENTICATED,
 843
 844        /* the link is ok. the card associated to a BSS or linked
 845         * to a ibss cell or acting as an AP and creating the bss
 846         */
 847        IEEE80211_LINKED,
 848
 849        /* same as LINKED, but the driver shall apply RX filter
 850         * rules as we are in NO_LINK mode. As the card is still
 851         * logically linked, but it is doing a syncro site survey
 852         * then it will be back to LINKED state.
 853         */
 854        IEEE80211_LINKED_SCANNING,
 855
 856};
 857
 858#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
 859#define DEFAULT_FTS 2346
 860
 861static inline int is_multicast_mac_addr(const u8 *addr)
 862{
 863        return ((addr[0] != 0xff) && (0x01 & addr[0]));
 864}
 865
 866static inline int is_broadcast_mac_addr(const u8 *addr)
 867{
 868        return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
 869               (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff);
 870}
 871
 872#define CFG_IEEE80211_RESERVE_FCS (1<<0)
 873#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
 874
 875struct tx_pending {
 876        int frag;
 877        struct ieee80211_txb *txb;
 878};
 879
 880#define MAXTID  16
 881
 882#define IEEE_A      (1<<0)
 883#define IEEE_B      (1<<1)
 884#define IEEE_G      (1<<2)
 885#define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
 886
 887/* Baron move to ieee80211.c */
 888int ieee80211_is_empty_essid(const char *essid, int essid_len);
 889int ieee80211_get_hdrlen(u16 fc);
 890
 891/* Action category code */
 892enum rtw_ieee80211_category {
 893        RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
 894        RTW_WLAN_CATEGORY_QOS = 1,
 895        RTW_WLAN_CATEGORY_DLS = 2,
 896        RTW_WLAN_CATEGORY_BACK = 3,
 897        RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
 898        RTW_WLAN_CATEGORY_RADIO_MEASUREMENT  = 5,
 899        RTW_WLAN_CATEGORY_FT = 6,
 900        RTW_WLAN_CATEGORY_HT = 7,
 901        RTW_WLAN_CATEGORY_SA_QUERY = 8,
 902        RTW_WLAN_CATEGORY_TDLS = 12,
 903        RTW_WLAN_CATEGORY_WMM = 17,
 904        RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
 905};
 906
 907/* SPECTRUM_MGMT action code */
 908enum rtw_ieee80211_spectrum_mgmt_actioncode {
 909        RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
 910        RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
 911        RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
 912        RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
 913        RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
 914        RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
 915};
 916
 917enum _PUBLIC_ACTION {
 918        ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
 919        ACT_PUBLIC_DSE_ENABLE = 1,
 920        ACT_PUBLIC_DSE_DEENABLE = 2,
 921        ACT_PUBLIC_DSE_REG_LOCATION = 3,
 922        ACT_PUBLIC_EXT_CHL_SWITCH = 4,
 923        ACT_PUBLIC_DSE_MSR_REQ = 5,
 924        ACT_PUBLIC_DSE_MSR_RPRT = 6,
 925        ACT_PUBLIC_MP = 7, /*  Measurement Pilot */
 926        ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
 927        ACT_PUBLIC_VENDOR = 9, /*  for WIFI_DIRECT */
 928        ACT_PUBLIC_GAS_INITIAL_REQ = 10,
 929        ACT_PUBLIC_GAS_INITIAL_RSP = 11,
 930        ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
 931        ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
 932        ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
 933        ACT_PUBLIC_LOCATION_TRACK = 15,
 934        ACT_PUBLIC_MAX
 935};
 936
 937/* BACK action code */
 938enum rtw_ieee80211_back_actioncode {
 939        RTW_WLAN_ACTION_ADDBA_REQ = 0,
 940        RTW_WLAN_ACTION_ADDBA_RESP = 1,
 941        RTW_WLAN_ACTION_DELBA = 2,
 942};
 943
 944/* HT features action code */
 945enum rtw_ieee80211_ht_actioncode {
 946        RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
 947        RTW_WLAN_ACTION_SM_PS = 1,
 948        RTW_WLAN_ACTION_PSPM = 2,
 949        RTW_WLAN_ACTION_PCO_PHASE = 3,
 950        RTW_WLAN_ACTION_MIMO_CSI_MX = 4,
 951        RTW_WLAN_ACTION_MIMO_NONCP_BF = 5,
 952        RTW_WLAN_ACTION_MIMP_CP_BF = 6,
 953        RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7,
 954        RTW_WLAN_ACTION_HI_INFO_EXCHG = 8,
 955};
 956
 957/* BACK (block-ack) parties */
 958enum rtw_ieee80211_back_parties {
 959        RTW_WLAN_BACK_RECIPIENT = 0,
 960        RTW_WLAN_BACK_INITIATOR = 1,
 961        RTW_WLAN_BACK_TIMER = 2,
 962};
 963
 964#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
 965                                * 00:50:F2 */
 966#define WME_OUI_TYPE 2
 967#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
 968#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
 969#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
 970#define WME_VERSION 1
 971
 972#define WME_ACTION_CODE_SETUP_REQUEST 0
 973#define WME_ACTION_CODE_SETUP_RESPONSE 1
 974#define WME_ACTION_CODE_TEARDOWN 2
 975
 976#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
 977#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
 978#define WME_SETUP_RESPONSE_STATUS_REFUSED 3
 979
 980#define WME_TSPEC_DIRECTION_UPLINK 0
 981#define WME_TSPEC_DIRECTION_DOWNLINK 1
 982#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
 983
 984
 985#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
 986
 987#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
 988
 989/**
 990 * enum rtw_ieee80211_channel_flags - channel flags
 991 *
 992 * Channel flags set by the regulatory control code.
 993 *
 994 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
 995 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
 996 *      on this channel.
 997 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
 998 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
 999 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
1000 *      is not permitted.
1001 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
1002 *      is not permitted.
1003 */
1004enum rtw_ieee80211_channel_flags {
1005        RTW_IEEE80211_CHAN_DISABLED      = 1<<0,
1006        RTW_IEEE80211_CHAN_PASSIVE_SCAN     = 1<<1,
1007        RTW_IEEE80211_CHAN_NO_IBSS        = 1<<2,
1008        RTW_IEEE80211_CHAN_RADAR            = 1<<3,
1009        RTW_IEEE80211_CHAN_NO_HT40PLUS      = 1<<4,
1010        RTW_IEEE80211_CHAN_NO_HT40MINUS     = 1<<5,
1011};
1012
1013#define RTW_IEEE80211_CHAN_NO_HT40 \
1014          (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
1015
1016/* Represent channel details, subset of ieee80211_channel */
1017struct rtw_ieee80211_channel {
1018        u16 hw_value;
1019        u32 flags;
1020};
1021
1022#define CHAN_FMT \
1023        "hw_value:%u, " \
1024        "flags:0x%08x" \
1025
1026#define CHAN_ARG(channel) \
1027        (channel)->hw_value \
1028        , (channel)->flags \
1029
1030/* Parsed Information Elements */
1031struct rtw_ieee802_11_elems {
1032        u8 *ssid;
1033        u8 ssid_len;
1034        u8 *supp_rates;
1035        u8 supp_rates_len;
1036        u8 *fh_params;
1037        u8 fh_params_len;
1038        u8 *ds_params;
1039        u8 ds_params_len;
1040        u8 *cf_params;
1041        u8 cf_params_len;
1042        u8 *tim;
1043        u8 tim_len;
1044        u8 *ibss_params;
1045        u8 ibss_params_len;
1046        u8 *challenge;
1047        u8 challenge_len;
1048        u8 *erp_info;
1049        u8 erp_info_len;
1050        u8 *ext_supp_rates;
1051        u8 ext_supp_rates_len;
1052        u8 *wpa_ie;
1053        u8 wpa_ie_len;
1054        u8 *rsn_ie;
1055        u8 rsn_ie_len;
1056        u8 *wme;
1057        u8 wme_len;
1058        u8 *wme_tspec;
1059        u8 wme_tspec_len;
1060        u8 *wps_ie;
1061        u8 wps_ie_len;
1062        u8 *power_cap;
1063        u8 power_cap_len;
1064        u8 *supp_channels;
1065        u8 supp_channels_len;
1066        u8 *mdie;
1067        u8 mdie_len;
1068        u8 *ftie;
1069        u8 ftie_len;
1070        u8 *timeout_int;
1071        u8 timeout_int_len;
1072        u8 *ht_capabilities;
1073        u8 ht_capabilities_len;
1074        u8 *ht_operation;
1075        u8 ht_operation_len;
1076        u8 *vendor_ht_cap;
1077        u8 vendor_ht_cap_len;
1078};
1079
1080enum parse_res {
1081        ParseOK = 0,
1082        ParseUnknown = 1,
1083        ParseFailed = -1
1084};
1085
1086enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len,
1087                                          struct rtw_ieee802_11_elems *elems,
1088                                          int show_errors);
1089
1090u8 *rtw_set_fixed_ie(void *pbuf, unsigned int len,
1091                     void *source, unsigned int *frlen);
1092u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen);
1093
1094enum secondary_ch_offset {
1095        SCN = 0, /* no secondary channel */
1096        SCA = 1, /* secondary channel above */
1097        SCB = 3,  /* secondary channel below */
1098};
1099u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset);
1100u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset);
1101u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode,
1102                         u8 new_ch, u8 ch_switch_cnt);
1103u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len,
1104                                   u8 secondary_ch_offset);
1105u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl,
1106                                   u8 flags, u16 reason, u16 precedence);
1107
1108u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit);
1109u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui,
1110                  u8 oui_len, u8 *ie, uint *ielen);
1111int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset,
1112                      u8 eid, u8 *oui, u8 oui_len);
1113
1114void rtw_set_supported_rate(u8 *SupportedRates, uint mode);
1115
1116unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1117unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1118int rtw_get_wpa_cipher_suite(u8 *s);
1119int rtw_get_wpa2_cipher_suite(u8 *s);
1120int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1121int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1122                     int *pairwise_cipher, int *is_8021x);
1123int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
1124                      int *pairwise_cipher, int *is_8021x);
1125
1126int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
1127                   u8 *wpa_ie, u16 *wpa_len);
1128
1129u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1130u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1131u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1132                     u8 *buf_attr, u32 *len_attr);
1133u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
1134                             u8 *buf_content, uint *len_content);
1135
1136/**
1137 * for_each_ie - iterate over continuous IEs
1138 * @ie:
1139 * @buf:
1140 * @buf_len:
1141 */
1142#define for_each_ie(ie, buf, buf_len) \
1143        for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len;        \
1144                ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1145
1146void dump_ies(u8 *buf, u32 buf_len);
1147void dump_wps_ie(u8 *ie, u32 ie_len);
1148
1149uint    rtw_get_rateset_len(u8  *rateset);
1150
1151struct registry_priv;
1152int rtw_generate_ie(struct registry_priv *pregistrypriv);
1153
1154
1155int rtw_get_bit_value_from_ieee_value(u8 val);
1156
1157uint    rtw_is_cckrates_included(u8 *rate);
1158
1159uint    rtw_is_cckratesonly_included(u8 *rate);
1160
1161int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1162
1163void rtw_get_bcn_info(struct wlan_network *pnetwork);
1164
1165void rtw_macaddr_cfg(u8 *mac_addr);
1166
1167u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
1168                 unsigned char *MCS_rate);
1169
1170int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category,
1171                           u8 *action);
1172const char *action_public_str(u8 action);
1173
1174#endif /* IEEE80211_H */
1175