Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
0005  *
0006  * Modifications for inclusion into the Linux staging tree are
0007  * Copyright(c) 2010 Larry Finger. All rights reserved.
0008  *
0009  * Contact information:
0010  * WLAN FAE <wlanfae@realtek.com>
0011  * Larry Finger <Larry.Finger@lwfinger.net>
0012  *
0013  ******************************************************************************/
0014 #ifndef __IEEE80211_H
0015 #define __IEEE80211_H
0016 
0017 #include <linux/ieee80211.h>
0018 
0019 #define IEEE_CMD_SET_WPA_PARAM          1
0020 #define IEEE_CMD_SET_WPA_IE         2
0021 #define IEEE_CMD_SET_ENCRYPTION         3
0022 #define IEEE_CMD_MLME               4
0023 
0024 #define IEEE_PARAM_WPA_ENABLED          1
0025 #define IEEE_PARAM_TKIP_COUNTERMEASURES     2
0026 #define IEEE_PARAM_DROP_UNENCRYPTED     3
0027 #define IEEE_PARAM_PRIVACY_INVOKED      4
0028 #define IEEE_PARAM_AUTH_ALGS            5
0029 #define IEEE_PARAM_IEEE_802_1X          6
0030 #define IEEE_PARAM_WPAX_SELECT          7
0031 
0032 #define AUTH_ALG_OPEN_SYSTEM            0x1
0033 #define AUTH_ALG_SHARED_KEY         0x2
0034 #define AUTH_ALG_LEAP               0x00000004
0035 
0036 #define IEEE_MLME_STA_DEAUTH            1
0037 #define IEEE_MLME_STA_DISASSOC          2
0038 
0039 #define IEEE_CRYPT_ERR_UNKNOWN_ALG      2
0040 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR     3
0041 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED    4
0042 #define IEEE_CRYPT_ERR_KEY_SET_FAILED       5
0043 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED    6
0044 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED     7
0045 
0046 #define IEEE_CRYPT_ALG_NAME_LEN         16
0047 
0048 #define WPA_CIPHER_NONE             BIT(0)
0049 #define WPA_CIPHER_WEP40            BIT(1)
0050 #define WPA_CIPHER_WEP104           BIT(2)
0051 #define WPA_CIPHER_TKIP             BIT(3)
0052 #define WPA_CIPHER_CCMP             BIT(4)
0053 
0054 #define WPA_SELECTOR_LEN            4
0055 #define RSN_HEADER_LEN              4
0056 
0057 #define RSN_SELECTOR_LEN 4
0058 
0059 enum NETWORK_TYPE {
0060     WIRELESS_INVALID    = 0,
0061     WIRELESS_11B        = 1,
0062     WIRELESS_11G        = 2,
0063     WIRELESS_11BG       = (WIRELESS_11B | WIRELESS_11G),
0064     WIRELESS_11A        = 4,
0065     WIRELESS_11N        = 8,
0066     WIRELESS_11GN       = (WIRELESS_11G | WIRELESS_11N),
0067     WIRELESS_11BGN      = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
0068 };
0069 
0070 struct ieee_param {
0071     u32 cmd;
0072     u8 sta_addr[ETH_ALEN];
0073     union {
0074         struct {
0075             u8 name;
0076             u32 value;
0077         } wpa_param;
0078         struct {
0079             u32 len;
0080             u8 reserved[32];
0081             u8 data[];
0082         } wpa_ie;
0083         struct {
0084             int command;
0085             int reason_code;
0086         } mlme;
0087         struct {
0088             u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
0089             u8 set_tx;
0090             u32 err;
0091             u8 idx;
0092             u8 seq[8]; /* sequence counter (set: RX, get: TX) */
0093             u16 key_len;
0094             u8 key[];
0095         } crypt;
0096     } u;
0097 };
0098 
0099 #define MIN_FRAG_THRESHOLD     256U
0100 #define MAX_FRAG_THRESHOLD     2346U
0101 
0102 /* QoS,QOS */
0103 #define NORMAL_ACK          0
0104 
0105 /* IEEE 802.11 defines */
0106 
0107 #define P80211_OUI_LEN 3
0108 
0109 struct ieee80211_snap_hdr {
0110     u8    dsap;   /* always 0xAA */
0111     u8    ssap;   /* always 0xAA */
0112     u8    ctrl;   /* always 0x03 */
0113     u8    oui[P80211_OUI_LEN];    /* organizational universal id */
0114 } __packed;
0115 
0116 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
0117 
0118 #define IEEE80211_CCK_RATE_LEN          4
0119 #define IEEE80211_NUM_OFDM_RATESLEN 8
0120 
0121 #define IEEE80211_CCK_RATE_1MB              0x02
0122 #define IEEE80211_CCK_RATE_2MB              0x04
0123 #define IEEE80211_CCK_RATE_5MB              0x0B
0124 #define IEEE80211_CCK_RATE_11MB             0x16
0125 #define IEEE80211_OFDM_RATE_6MB             0x0C
0126 #define IEEE80211_OFDM_RATE_9MB             0x12
0127 #define IEEE80211_OFDM_RATE_12MB        0x18
0128 #define IEEE80211_OFDM_RATE_18MB        0x24
0129 #define IEEE80211_OFDM_RATE_24MB        0x30
0130 #define IEEE80211_OFDM_RATE_36MB        0x48
0131 #define IEEE80211_OFDM_RATE_48MB        0x60
0132 #define IEEE80211_OFDM_RATE_54MB        0x6C
0133 #define IEEE80211_BASIC_RATE_MASK       0x80
0134 
0135 #define WEP_KEYS 4
0136 
0137 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
0138  * only use 8, and then use extended rates for the remaining supported
0139  * rates.  Other APs, however, stick all of their supported rates on the
0140  * main rates information element...
0141  */
0142 #define MAX_RATES_LENGTH                  ((u8)12)
0143 #define MAX_WPA_IE_LEN 128
0144 
0145 struct registry_priv;
0146 
0147 u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
0148 u8 *r8712_get_ie(u8 *pbuf, sint index, uint *len, sint limit);
0149 unsigned char *r8712_get_wpa_ie(unsigned char *pie, uint *rsn_ie_len,
0150                 int limit);
0151 unsigned char *r8712_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len,
0152                  int limit);
0153 int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
0154                int *pairwise_cipher);
0155 int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
0156             int *pairwise_cipher);
0157 int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
0158              u8 *wpa_ie, u16 *wpa_len);
0159 int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
0160 int r8712_generate_ie(struct registry_priv *pregistrypriv);
0161 uint r8712_is_cckrates_included(u8 *rate);
0162 uint r8712_is_cckratesonly_included(u8 *rate);
0163 
0164 #endif /* IEEE80211_H */
0165