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