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 * You should have received a copy of the GNU General Public License along with 15 * this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 17 * 18 * 19 ******************************************************************************/ 20 #ifndef __IEEE80211_EXT_H 21 #define __IEEE80211_EXT_H 22 23 #include <osdep_service.h> 24 #include <drv_types.h> 25 26 #define WMM_OUI_TYPE 2 27 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0 28 #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1 29 #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2 30 #define WMM_VERSION 1 31 32 #define WPA_PROTO_WPA BIT(0) 33 #define WPA_PROTO_RSN BIT(1) 34 35 #define WPA_KEY_MGMT_IEEE8021X BIT(0) 36 #define WPA_KEY_MGMT_PSK BIT(1) 37 #define WPA_KEY_MGMT_NONE BIT(2) 38 #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3) 39 #define WPA_KEY_MGMT_WPA_NONE BIT(4) 40 41 42 #define WPA_CAPABILITY_PREAUTH BIT(0) 43 #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6) 44 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9) 45 46 47 #define PMKID_LEN 16 48 49 50 struct wpa_ie_hdr { 51 u8 elem_id; 52 u8 len; 53 u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */ 54 u8 version[2]; /* little endian */ 55 } __packed; 56 57 struct rsn_ie_hdr { 58 u8 elem_id; /* WLAN_EID_RSN */ 59 u8 len; 60 u8 version[2]; /* little endian */ 61 } __packed; 62 63 struct wme_ac_parameter { 64 #if defined(__LITTLE_ENDIAN) 65 /* byte 1 */ 66 u8 aifsn:4, 67 acm:1, 68 aci:2, 69 reserved:1; 70 71 /* byte 2 */ 72 u8 eCWmin:4, 73 eCWmax:4; 74 #elif defined(__BIG_ENDIAN) 75 /* byte 1 */ 76 u8 reserved:1, 77 aci:2, 78 acm:1, 79 aifsn:4; 80 81 /* byte 2 */ 82 u8 eCWmax:4, 83 eCWmin:4; 84 #else 85 #error "Please fix <endian.h>" 86 #endif 87 88 /* bytes 3 & 4 */ 89 u16 txopLimit; 90 } __packed; 91 92 struct wme_parameter_element { 93 /* required fields for WME version 1 */ 94 u8 oui[3]; 95 u8 oui_type; 96 u8 oui_subtype; 97 u8 version; 98 u8 acInfo; 99 u8 reserved; 100 struct wme_ac_parameter ac[4]; 101 102 } __packed; 103 104 #define WPA_PUT_LE16(a, val) \ 105 do { \ 106 (a)[1] = ((u16) (val)) >> 8; \ 107 (a)[0] = ((u16) (val)) & 0xff; \ 108 } while (0) 109 110 #define WPA_PUT_BE32(a, val) \ 111 do { \ 112 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ 113 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ 114 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ 115 (a)[3] = (u8) (((u32) (val)) & 0xff); \ 116 } while (0) 117 118 #define WPA_PUT_LE32(a, val) \ 119 do { \ 120 (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ 121 (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ 122 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ 123 (a)[0] = (u8) (((u32) (val)) & 0xff); \ 124 } while (0) 125 126 #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *)(a), (val)) 127 128 /* Action category code */ 129 enum ieee80211_category { 130 WLAN_CATEGORY_SPECTRUM_MGMT = 0, 131 WLAN_CATEGORY_QOS = 1, 132 WLAN_CATEGORY_DLS = 2, 133 WLAN_CATEGORY_BACK = 3, 134 WLAN_CATEGORY_HT = 7, 135 WLAN_CATEGORY_WMM = 17, 136 }; 137 138 /* SPECTRUM_MGMT action code */ 139 enum ieee80211_spectrum_mgmt_actioncode { 140 WLAN_ACTION_SPCT_MSR_REQ = 0, 141 WLAN_ACTION_SPCT_MSR_RPRT = 1, 142 WLAN_ACTION_SPCT_TPC_REQ = 2, 143 WLAN_ACTION_SPCT_TPC_RPRT = 3, 144 WLAN_ACTION_SPCT_CHL_SWITCH = 4, 145 WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, 146 }; 147 148 /* BACK action code */ 149 enum ieee80211_back_actioncode { 150 WLAN_ACTION_ADDBA_REQ = 0, 151 WLAN_ACTION_ADDBA_RESP = 1, 152 WLAN_ACTION_DELBA = 2, 153 }; 154 155 /* HT features action code */ 156 enum ieee80211_ht_actioncode { 157 WLAN_ACTION_NOTIFY_CH_WIDTH = 0, 158 WLAN_ACTION_SM_PS = 1, 159 WLAN_ACTION_PSPM = 2, 160 WLAN_ACTION_PCO_PHASE = 3, 161 WLAN_ACTION_MIMO_CSI_MX = 4, 162 WLAN_ACTION_MIMO_NONCP_BF = 5, 163 WLAN_ACTION_MIMP_CP_BF = 6, 164 WLAN_ACTION_ASEL_INDICATES_FB = 7, 165 WLAN_ACTION_HI_INFO_EXCHG = 8, 166 }; 167 168 /* BACK (block-ack) parties */ 169 enum ieee80211_back_parties { 170 WLAN_BACK_RECIPIENT = 0, 171 WLAN_BACK_INITIATOR = 1, 172 WLAN_BACK_TIMER = 2, 173 }; 174 175 struct ieee80211_mgmt { 176 u16 frame_control; 177 u16 duration; 178 u8 da[6]; 179 u8 sa[6]; 180 u8 bssid[6]; 181 u16 seq_ctrl; 182 union { 183 struct { 184 u16 auth_alg; 185 u16 auth_transaction; 186 u16 status_code; 187 /* possibly followed by Challenge text */ 188 u8 variable[0]; 189 } __packed auth; 190 struct { 191 u16 reason_code; 192 } __packed deauth; 193 struct { 194 u16 capab_info; 195 u16 listen_interval; 196 /* followed by SSID and Supported rates */ 197 u8 variable[0]; 198 } __packed assoc_req; 199 struct { 200 u16 capab_info; 201 u16 status_code; 202 u16 aid; 203 /* followed by Supported rates */ 204 u8 variable[0]; 205 } __packed assoc_resp, reassoc_resp; 206 struct { 207 u16 capab_info; 208 u16 listen_interval; 209 u8 current_ap[6]; 210 /* followed by SSID and Supported rates */ 211 u8 variable[0]; 212 } __packed reassoc_req; 213 struct { 214 u16 reason_code; 215 } __packed disassoc; 216 struct { 217 __le64 timestamp; 218 u16 beacon_int; 219 u16 capab_info; 220 /* followed by some of SSID, Supported rates, 221 * FH Params, DS Params, CF Params, IBSS Params, TIM */ 222 u8 variable[0]; 223 } __packed beacon; 224 struct { 225 /* only variable items: SSID, Supported rates */ 226 u8 variable[0]; 227 } __packed probe_req; 228 struct { 229 __le64 timestamp; 230 u16 beacon_int; 231 u16 capab_info; 232 /* followed by some of SSID, Supported rates, 233 * FH Params, DS Params, CF Params, IBSS Params */ 234 u8 variable[0]; 235 } __packed probe_resp; 236 struct { 237 u8 category; 238 union { 239 struct { 240 u8 action_code; 241 u8 dialog_token; 242 u8 status_code; 243 u8 variable[0]; 244 } __packed wme_action; 245 struct { 246 u8 action_code; 247 u8 dialog_token; 248 u16 capab; 249 u16 timeout; 250 u16 start_seq_num; 251 } __packed addba_req; 252 struct { 253 u8 action_code; 254 u8 dialog_token; 255 u16 status; 256 u16 capab; 257 u16 timeout; 258 } __packed addba_resp; 259 struct { 260 u8 action_code; 261 u16 params; 262 u16 reason_code; 263 } __packed delba; 264 structi { 265 u8 action_code; 266 /* capab_info for open and confirm, 267 * reason for close 268 */ 269 u16 aux; 270 /* Followed in plink_confirm by status 271 * code, AID and supported rates, 272 * and directly by supported rates in 273 * plink_open and plink_close 274 */ 275 u8 variable[0]; 276 } __packed plink_action; 277 struct{ 278 u8 action_code; 279 u8 variable[0]; 280 } __packed mesh_action; 281 } __packed u; 282 } __packed action; 283 } __packed u; 284 } __packed; 285 286 /* mgmt header + 1 byte category code */ 287 #define IEEE80211_MIN_ACTION_SIZE \ 288 FIELD_OFFSET(struct ieee80211_mgmt, u.action.u) 289 290 #endif 291