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