ieee80211_ext.h 11 KB

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