ieee80211_ext.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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. #include <drv_conf.h>
  18. #include <osdep_service.h>
  19. #include <drv_types.h>
  20. #define WMM_OUI_TYPE 2
  21. #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  22. #define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  23. #define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2
  24. #define WMM_VERSION 1
  25. #define WPA_PROTO_WPA BIT(0)
  26. #define WPA_PROTO_RSN BIT(1)
  27. #define WPA_KEY_MGMT_IEEE8021X BIT(0)
  28. #define WPA_KEY_MGMT_PSK BIT(1)
  29. #define WPA_KEY_MGMT_NONE BIT(2)
  30. #define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
  31. #define WPA_KEY_MGMT_WPA_NONE BIT(4)
  32. #define WPA_CAPABILITY_PREAUTH BIT(0)
  33. #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6)
  34. #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
  35. #define PMKID_LEN 16
  36. #ifdef PLATFORM_LINUX
  37. struct wpa_ie_hdr {
  38. u8 elem_id;
  39. u8 len;
  40. u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
  41. u8 version[2]; /* little endian */
  42. } __attribute__((packed));
  43. struct rsn_ie_hdr {
  44. u8 elem_id; /* WLAN_EID_RSN */
  45. u8 len;
  46. u8 version[2]; /* little endian */
  47. } __attribute__((packed));
  48. struct wme_ac_parameter {
  49. #if defined(CONFIG_LITTLE_ENDIAN)
  50. /* byte 1 */
  51. u8 aifsn:4,
  52. acm:1,
  53. aci:2,
  54. reserved:1;
  55. /* byte 2 */
  56. u8 eCWmin:4,
  57. eCWmax:4;
  58. #elif defined(CONFIG_BIG_ENDIAN)
  59. /* byte 1 */
  60. u8 reserved:1,
  61. aci:2,
  62. acm:1,
  63. aifsn:4;
  64. /* byte 2 */
  65. u8 eCWmax:4,
  66. eCWmin:4;
  67. #else
  68. #error "Please fix <endian.h>"
  69. #endif
  70. /* bytes 3 & 4 */
  71. u16 txopLimit;
  72. } __attribute__((packed));
  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. } __attribute__((packed));
  83. #endif
  84. #ifdef PLATFORM_WINDOWS
  85. #pragma pack(1)
  86. struct wpa_ie_hdr {
  87. u8 elem_id;
  88. u8 len;
  89. u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */
  90. u8 version[2]; /* little endian */
  91. };
  92. struct rsn_ie_hdr {
  93. u8 elem_id; /* WLAN_EID_RSN */
  94. u8 len;
  95. u8 version[2]; /* little endian */
  96. };
  97. #pragma pack()
  98. #endif
  99. #define WPA_PUT_LE16(a, val) \
  100. do { \
  101. (a)[1] = ((u16) (val)) >> 8; \
  102. (a)[0] = ((u16) (val)) & 0xff; \
  103. } while (0)
  104. #define WPA_PUT_BE32(a, val) \
  105. do { \
  106. (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
  107. (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
  108. (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
  109. (a)[3] = (u8) (((u32) (val)) & 0xff); \
  110. } while (0)
  111. #define WPA_PUT_LE32(a, val) \
  112. do { \
  113. (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
  114. (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
  115. (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
  116. (a)[0] = (u8) (((u32) (val)) & 0xff); \
  117. } while (0)
  118. #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *) (a), (val))
  119. /* #define RSN_SELECTOR_PUT(a, val) WPA_PUT_LE32((u8 *) (a), (val)) */
  120. /* Action category code */
  121. enum ieee80211_category {
  122. WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  123. WLAN_CATEGORY_QOS = 1,
  124. WLAN_CATEGORY_DLS = 2,
  125. WLAN_CATEGORY_BACK = 3,
  126. WLAN_CATEGORY_HT = 7,
  127. WLAN_CATEGORY_WMM = 17,
  128. };
  129. /* SPECTRUM_MGMT action code */
  130. enum ieee80211_spectrum_mgmt_actioncode {
  131. WLAN_ACTION_SPCT_MSR_REQ = 0,
  132. WLAN_ACTION_SPCT_MSR_RPRT = 1,
  133. WLAN_ACTION_SPCT_TPC_REQ = 2,
  134. WLAN_ACTION_SPCT_TPC_RPRT = 3,
  135. WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  136. WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
  137. };
  138. /* BACK action code */
  139. enum ieee80211_back_actioncode {
  140. WLAN_ACTION_ADDBA_REQ = 0,
  141. WLAN_ACTION_ADDBA_RESP = 1,
  142. WLAN_ACTION_DELBA = 2,
  143. };
  144. /* HT features action code */
  145. enum ieee80211_ht_actioncode {
  146. WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
  147. WLAN_ACTION_SM_PS = 1,
  148. WLAN_ACTION_PSPM = 2,
  149. WLAN_ACTION_PCO_PHASE = 3,
  150. WLAN_ACTION_MIMO_CSI_MX = 4,
  151. WLAN_ACTION_MIMO_NONCP_BF = 5,
  152. WLAN_ACTION_MIMP_CP_BF = 6,
  153. WLAN_ACTION_ASEL_INDICATES_FB = 7,
  154. WLAN_ACTION_HI_INFO_EXCHG = 8,
  155. };
  156. /* BACK (block-ack) parties */
  157. enum ieee80211_back_parties {
  158. WLAN_BACK_RECIPIENT = 0,
  159. WLAN_BACK_INITIATOR = 1,
  160. WLAN_BACK_TIMER = 2,
  161. };
  162. #ifdef PLATFORM_LINUX
  163. struct ieee80211_mgmt {
  164. u16 frame_control;
  165. u16 duration;
  166. u8 da[6];
  167. u8 sa[6];
  168. u8 bssid[6];
  169. u16 seq_ctrl;
  170. union {
  171. struct {
  172. u16 auth_alg;
  173. u16 auth_transaction;
  174. u16 status_code;
  175. /* possibly followed by Challenge text */
  176. u8 variable[0];
  177. } __attribute__((packed)) auth;
  178. struct {
  179. u16 reason_code;
  180. } __attribute__((packed)) deauth;
  181. struct {
  182. u16 capab_info;
  183. u16 listen_interval;
  184. /* followed by SSID and Supported rates */
  185. u8 variable[0];
  186. } __attribute__((packed)) assoc_req;
  187. struct {
  188. u16 capab_info;
  189. u16 status_code;
  190. u16 aid;
  191. /* followed by Supported rates */
  192. u8 variable[0];
  193. } __attribute__((packed)) assoc_resp, reassoc_resp;
  194. struct {
  195. u16 capab_info;
  196. u16 listen_interval;
  197. u8 current_ap[6];
  198. /* followed by SSID and Supported rates */
  199. u8 variable[0];
  200. } __attribute__((packed)) reassoc_req;
  201. struct {
  202. u16 reason_code;
  203. } __attribute__((packed)) disassoc;
  204. struct {
  205. __le64 timestamp;
  206. u16 beacon_int;
  207. u16 capab_info;
  208. /* followed by some of SSID, Supported rates,
  209. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  210. u8 variable[0];
  211. } __attribute__((packed)) beacon;
  212. struct {
  213. /* only variable items: SSID, Supported rates */
  214. u8 variable[0];
  215. } __attribute__((packed)) probe_req;
  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 */
  222. u8 variable[0];
  223. } __attribute__((packed)) probe_resp;
  224. struct {
  225. u8 category;
  226. union {
  227. struct {
  228. u8 action_code;
  229. u8 dialog_token;
  230. u8 status_code;
  231. u8 variable[0];
  232. } __attribute__((packed)) wme_action;
  233. #if 0
  234. struct {
  235. u8 action_code;
  236. u8 element_id;
  237. u8 length;
  238. struct ieee80211_channel_sw_ie sw_elem;
  239. } __attribute__((packed)) chan_switch;
  240. struct {
  241. u8 action_code;
  242. u8 dialog_token;
  243. u8 element_id;
  244. u8 length;
  245. struct ieee80211_msrment_ie msr_elem;
  246. } __attribute__((packed)) measurement;
  247. #endif
  248. struct {
  249. u8 action_code;
  250. u8 dialog_token;
  251. u16 capab;
  252. u16 timeout;
  253. u16 start_seq_num;
  254. } __attribute__((packed)) addba_req;
  255. struct {
  256. u8 action_code;
  257. u8 dialog_token;
  258. u16 status;
  259. u16 capab;
  260. u16 timeout;
  261. } __attribute__((packed)) addba_resp;
  262. struct {
  263. u8 action_code;
  264. u16 params;
  265. u16 reason_code;
  266. } __attribute__((packed)) delba;
  267. struct {
  268. u8 action_code;
  269. /* capab_info for open and confirm,
  270. * reason for close
  271. */
  272. u16 aux;
  273. /* Followed in plink_confirm by status
  274. * code, AID and supported rates,
  275. * and directly by supported rates in
  276. * plink_open and plink_close
  277. */
  278. u8 variable[0];
  279. } __attribute__((packed)) plink_action;
  280. struct {
  281. u8 action_code;
  282. u8 variable[0];
  283. } __attribute__((packed)) mesh_action;
  284. } __attribute__((packed)) u;
  285. } __attribute__((packed)) action;
  286. } __attribute__((packed)) u;
  287. } __attribute__((packed));
  288. #endif
  289. #ifdef PLATFORM_WINDOWS
  290. #pragma pack(1)
  291. struct ieee80211_mgmt {
  292. u16 frame_control;
  293. u16 duration;
  294. u8 da[6];
  295. u8 sa[6];
  296. u8 bssid[6];
  297. u16 seq_ctrl;
  298. union {
  299. struct {
  300. u16 auth_alg;
  301. u16 auth_transaction;
  302. u16 status_code;
  303. /* possibly followed by Challenge text */
  304. u8 variable[0];
  305. } auth;
  306. struct {
  307. u16 reason_code;
  308. } deauth;
  309. struct {
  310. u16 capab_info;
  311. u16 listen_interval;
  312. /* followed by SSID and Supported rates */
  313. u8 variable[0];
  314. } assoc_req;
  315. struct {
  316. u16 capab_info;
  317. u16 status_code;
  318. u16 aid;
  319. /* followed by Supported rates */
  320. u8 variable[0];
  321. } assoc_resp, reassoc_resp;
  322. struct {
  323. u16 capab_info;
  324. u16 listen_interval;
  325. u8 current_ap[6];
  326. /* followed by SSID and Supported rates */
  327. u8 variable[0];
  328. } reassoc_req;
  329. struct {
  330. u16 reason_code;
  331. } disassoc;
  332. #if 0
  333. struct {
  334. __le64 timestamp;
  335. u16 beacon_int;
  336. u16 capab_info;
  337. /* followed by some of SSID, Supported rates,
  338. * FH Params, DS Params, CF Params, IBSS Params, TIM */
  339. u8 variable[0];
  340. } beacon;
  341. struct {
  342. /* only variable items: SSID, Supported rates */
  343. u8 variable[0];
  344. } probe_req;
  345. struct {
  346. __le64 timestamp;
  347. u16 beacon_int;
  348. u16 capab_info;
  349. /* followed by some of SSID, Supported rates,
  350. * FH Params, DS Params, CF Params, IBSS Params */
  351. u8 variable[0];
  352. } probe_resp;
  353. #endif
  354. struct {
  355. u8 category;
  356. union {
  357. struct {
  358. u8 action_code;
  359. u8 dialog_token;
  360. u8 status_code;
  361. u8 variable[0];
  362. } wme_action;
  363. #if 0
  364. struct{
  365. u8 action_code;
  366. u8 element_id;
  367. u8 length;
  368. struct ieee80211_channel_sw_ie sw_elem;
  369. } chan_switch;
  370. struct{
  371. u8 action_code;
  372. u8 dialog_token;
  373. u8 element_id;
  374. u8 length;
  375. struct ieee80211_msrment_ie msr_elem;
  376. } measurement;
  377. #endif
  378. struct {
  379. u8 action_code;
  380. u8 dialog_token;
  381. u16 capab;
  382. u16 timeout;
  383. u16 start_seq_num;
  384. } addba_req;
  385. struct {
  386. u8 action_code;
  387. u8 dialog_token;
  388. u16 status;
  389. u16 capab;
  390. u16 timeout;
  391. } addba_resp;
  392. struct {
  393. u8 action_code;
  394. u16 params;
  395. u16 reason_code;
  396. } delba;
  397. struct {
  398. u8 action_code;
  399. /* capab_info for open and confirm,
  400. * reason for close
  401. */
  402. u16 aux;
  403. /* Followed in plink_confirm by status
  404. * code, AID and supported rates,
  405. * and directly by supported rates in
  406. * plink_open and plink_close
  407. */
  408. u8 variable[0];
  409. } plink_action;
  410. struct {
  411. u8 action_code;
  412. u8 variable[0];
  413. } mesh_action;
  414. } u;
  415. } action;
  416. } u;
  417. } ;
  418. #pragma pack()
  419. #endif
  420. /* mgmt header + 1 byte category code */
  421. #define IEEE80211_MIN_ACTION_SIZE FIELD_OFFSET(struct ieee80211_mgmt, u.action.u)
  422. #endif