ieee80211.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671
  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_H
  21. #define __IEEE80211_H
  22. #ifndef CONFIG_RTL8711FW
  23. #if defined PLATFORM_OS_XP
  24. #include <ntstrsafe.h>
  25. #endif
  26. #else
  27. #endif
  28. #define MGMT_QUEUE_NUM 5
  29. #define ETH_ALEN 6
  30. #define ETH_TYPE_LEN 2
  31. #define PAYLOAD_TYPE_LEN 1
  32. #ifdef CONFIG_AP_MODE
  33. #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
  34. /* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
  35. enum {
  36. RTL871X_HOSTAPD_FLUSH = 1,
  37. RTL871X_HOSTAPD_ADD_STA = 2,
  38. RTL871X_HOSTAPD_REMOVE_STA = 3,
  39. RTL871X_HOSTAPD_GET_INFO_STA = 4,
  40. /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
  41. RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
  42. RTL871X_SET_ENCRYPTION = 6,
  43. RTL871X_GET_ENCRYPTION = 7,
  44. RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
  45. RTL871X_HOSTAPD_GET_RID = 9,
  46. RTL871X_HOSTAPD_SET_RID = 10,
  47. RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
  48. RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
  49. RTL871X_HOSTAPD_MLME = 13,
  50. RTL871X_HOSTAPD_SCAN_REQ = 14,
  51. RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
  52. RTL871X_HOSTAPD_SET_BEACON=16,
  53. RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
  54. RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
  55. RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
  56. RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
  57. RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
  58. RTL871X_HOSTAPD_ACL_ADD_STA = 22,
  59. RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
  60. };
  61. /* STA flags */
  62. #define WLAN_STA_AUTH BIT(0)
  63. #define WLAN_STA_ASSOC BIT(1)
  64. #define WLAN_STA_PS BIT(2)
  65. #define WLAN_STA_TIM BIT(3)
  66. #define WLAN_STA_PERM BIT(4)
  67. #define WLAN_STA_AUTHORIZED BIT(5)
  68. #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  69. #define WLAN_STA_SHORT_PREAMBLE BIT(7)
  70. #define WLAN_STA_PREAUTH BIT(8)
  71. #define WLAN_STA_WME BIT(9)
  72. #define WLAN_STA_MFP BIT(10)
  73. #define WLAN_STA_HT BIT(11)
  74. #define WLAN_STA_WPS BIT(12)
  75. #define WLAN_STA_MAYBE_WPS BIT(13)
  76. #define WLAN_STA_VHT BIT(14)
  77. #define WLAN_STA_NONERP BIT(31)
  78. #endif
  79. #define IEEE_CMD_SET_WPA_PARAM 1
  80. #define IEEE_CMD_SET_WPA_IE 2
  81. #define IEEE_CMD_SET_ENCRYPTION 3
  82. #define IEEE_CMD_MLME 4
  83. #define IEEE_PARAM_WPA_ENABLED 1
  84. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  85. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  86. #define IEEE_PARAM_PRIVACY_INVOKED 4
  87. #define IEEE_PARAM_AUTH_ALGS 5
  88. #define IEEE_PARAM_IEEE_802_1X 6
  89. #define IEEE_PARAM_WPAX_SELECT 7
  90. #define AUTH_ALG_OPEN_SYSTEM 0x1
  91. #define AUTH_ALG_SHARED_KEY 0x2
  92. #define AUTH_ALG_LEAP 0x00000004
  93. #define IEEE_MLME_STA_DEAUTH 1
  94. #define IEEE_MLME_STA_DISASSOC 2
  95. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  96. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  97. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  98. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  99. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  100. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  101. #define IEEE_CRYPT_ALG_NAME_LEN 16
  102. #define WPA_CIPHER_NONE BIT(0)
  103. #define WPA_CIPHER_WEP40 BIT(1)
  104. #define WPA_CIPHER_WEP104 BIT(2)
  105. #define WPA_CIPHER_TKIP BIT(3)
  106. #define WPA_CIPHER_CCMP BIT(4)
  107. #define WPA_SELECTOR_LEN 4
  108. extern u8 RTW_WPA_OUI_TYPE[] ;
  109. extern u16 RTW_WPA_VERSION ;
  110. extern u8 WPA_AUTH_KEY_MGMT_NONE[];
  111. extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
  112. extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
  113. extern u8 WPA_CIPHER_SUITE_NONE[];
  114. extern u8 WPA_CIPHER_SUITE_WEP40[];
  115. extern u8 WPA_CIPHER_SUITE_TKIP[];
  116. extern u8 WPA_CIPHER_SUITE_WRAP[];
  117. extern u8 WPA_CIPHER_SUITE_CCMP[];
  118. extern u8 WPA_CIPHER_SUITE_WEP104[];
  119. #define RSN_HEADER_LEN 4
  120. #define RSN_SELECTOR_LEN 4
  121. extern u16 RSN_VERSION_BSD;
  122. extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
  123. extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
  124. extern u8 RSN_CIPHER_SUITE_NONE[];
  125. extern u8 RSN_CIPHER_SUITE_WEP40[];
  126. extern u8 RSN_CIPHER_SUITE_TKIP[];
  127. extern u8 RSN_CIPHER_SUITE_WRAP[];
  128. extern u8 RSN_CIPHER_SUITE_CCMP[];
  129. extern u8 RSN_CIPHER_SUITE_WEP104[];
  130. typedef enum _RATEID_IDX_ {
  131. RATEID_IDX_BGN_40M_2SS = 0,
  132. RATEID_IDX_BGN_40M_1SS = 1,
  133. RATEID_IDX_BGN_20M_2SS_BN = 2,
  134. RATEID_IDX_BGN_20M_1SS_BN = 3,
  135. RATEID_IDX_GN_N2SS = 4,
  136. RATEID_IDX_GN_N1SS = 5,
  137. RATEID_IDX_BG = 6,
  138. RATEID_IDX_G = 7,
  139. RATEID_IDX_B = 8,
  140. RATEID_IDX_VHT_2SS = 9,
  141. RATEID_IDX_VHT_1SS = 10,
  142. } RATEID_IDX, *PRATEID_IDX;
  143. typedef enum _RATR_TABLE_MODE{
  144. RATR_INX_WIRELESS_NGB = 0, // BGN 40 Mhz 2SS 1SS
  145. RATR_INX_WIRELESS_NG = 1, // GN or N
  146. RATR_INX_WIRELESS_NB = 2, // BGN 20 Mhz 2SS 1SS or BN
  147. RATR_INX_WIRELESS_N = 3,
  148. RATR_INX_WIRELESS_GB = 4,
  149. RATR_INX_WIRELESS_G = 5,
  150. RATR_INX_WIRELESS_B = 6,
  151. RATR_INX_WIRELESS_MC = 7,
  152. RATR_INX_WIRELESS_AC_N = 8,
  153. }RATR_TABLE_MODE, *PRATR_TABLE_MODE;
  154. enum NETWORK_TYPE
  155. {
  156. WIRELESS_INVALID = 0,
  157. //Sub-Element
  158. WIRELESS_11B = BIT(0), // tx: cck only , rx: cck only, hw: cck
  159. WIRELESS_11G = BIT(1), // tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm
  160. WIRELESS_11A = BIT(2), // tx: ofdm only, rx: ofdm only, hw: ofdm only
  161. WIRELESS_11_24N = BIT(3), // tx: MCS only, rx: MCS & cck, hw: MCS & cck
  162. WIRELESS_11_5N = BIT(4), // tx: MCS only, rx: MCS & ofdm, hw: ofdm only
  163. WIRELESS_AUTO = BIT(5),
  164. WIRELESS_11AC = BIT(6),
  165. //Combination
  166. //Type for current wireless mode
  167. WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), // tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm
  168. WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), // tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm
  169. WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), // tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only
  170. WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N), // tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck
  171. WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), // tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck
  172. WIRELESS_11_24AC = (WIRELESS_11G|WIRELESS_11AC),
  173. WIRELESS_11_5AC = (WIRELESS_11A|WIRELESS_11AC),
  174. //Type for registry default wireless mode
  175. WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), // tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only
  176. WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
  177. WIRELESS_MODE_24G = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11AC),
  178. WIRELESS_MODE_5G = (WIRELESS_11A|WIRELESS_11_5N|WIRELESS_11AC),
  179. WIRELESS_MODE_MAX = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N|WIRELESS_11AC),
  180. };
  181. #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
  182. #define SUPPORTED_5G_NETTYPE_MSK (WIRELESS_11A | WIRELESS_11_5N)
  183. #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? _TRUE : _FALSE)
  184. #define IsSupported5G(NetType) ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? _TRUE : _FALSE)
  185. #define IsEnableHWCCK(NetType) IsSupported24G(NetType)
  186. #define IsEnableHWOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? _TRUE : _FALSE)
  187. #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
  188. #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
  189. #define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType)
  190. #define IsSupportedTxCCK(NetType) ((NetType) & (WIRELESS_11B) ? _TRUE : _FALSE)
  191. #define IsSupportedTxOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? _TRUE : _FALSE)
  192. #define IsSupportedTxHT(NetType) ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? _TRUE : _FALSE)
  193. #define IsSupportedVHT(NetType) ((NetType) & (WIRELESS_11AC) ? _TRUE : _FALSE)
  194. typedef struct ieee_param {
  195. u32 cmd;
  196. u8 sta_addr[ETH_ALEN];
  197. union {
  198. struct {
  199. u8 name;
  200. u32 value;
  201. } wpa_param;
  202. struct {
  203. u32 len;
  204. u8 reserved[32];
  205. u8 data[0];
  206. } wpa_ie;
  207. struct{
  208. int command;
  209. int reason_code;
  210. } mlme;
  211. struct {
  212. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  213. u8 set_tx;
  214. u32 err;
  215. u8 idx;
  216. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  217. u16 key_len;
  218. u8 key[0];
  219. } crypt;
  220. #ifdef CONFIG_AP_MODE
  221. struct {
  222. u16 aid;
  223. u16 capability;
  224. int flags;
  225. u8 tx_supp_rates[16];
  226. struct rtw_ieee80211_ht_cap ht_cap;
  227. } add_sta;
  228. struct {
  229. u8 reserved[2];//for set max_num_sta
  230. u8 buf[0];
  231. } bcn_ie;
  232. #endif
  233. } u;
  234. }ieee_param;
  235. #ifdef CONFIG_AP_MODE
  236. typedef struct ieee_param_ex {
  237. u32 cmd;
  238. u8 sta_addr[ETH_ALEN];
  239. u8 data[0];
  240. }ieee_param_ex;
  241. struct sta_data{
  242. u16 aid;
  243. u16 capability;
  244. int flags;
  245. u32 sta_set;
  246. u8 tx_supp_rates[16];
  247. u32 tx_supp_rates_len;
  248. struct rtw_ieee80211_ht_cap ht_cap;
  249. u64 rx_pkts;
  250. u64 rx_bytes;
  251. u64 rx_drops;
  252. u64 tx_pkts;
  253. u64 tx_bytes;
  254. u64 tx_drops;
  255. };
  256. #endif
  257. #if WIRELESS_EXT < 17
  258. #define IW_QUAL_QUAL_INVALID 0x10
  259. #define IW_QUAL_LEVEL_INVALID 0x20
  260. #define IW_QUAL_NOISE_INVALID 0x40
  261. #define IW_QUAL_QUAL_UPDATED 0x1
  262. #define IW_QUAL_LEVEL_UPDATED 0x2
  263. #define IW_QUAL_NOISE_UPDATED 0x4
  264. #endif
  265. #define IEEE80211_DATA_LEN 2304
  266. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  267. 6.2.1.1.2.
  268. The figure in section 7.1.2 suggests a body size of up to 2312
  269. bytes is allowed, which is a bit confusing, I suspect this
  270. represents the 2304 bytes of real data, plus a possible 8 bytes of
  271. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  272. #define IEEE80211_HLEN 30
  273. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  274. /* this is stolen from ipw2200 driver */
  275. #define IEEE_IBSS_MAC_HASH_SIZE 31
  276. struct ieee_ibss_seq {
  277. u8 mac[ETH_ALEN];
  278. u16 seq_num;
  279. u16 frag_num;
  280. unsigned long packet_time;
  281. _list list;
  282. };
  283. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)||defined(PLATFORM_FREEBSD)
  284. struct rtw_ieee80211_hdr {
  285. u16 frame_ctl;
  286. u16 duration_id;
  287. u8 addr1[ETH_ALEN];
  288. u8 addr2[ETH_ALEN];
  289. u8 addr3[ETH_ALEN];
  290. u16 seq_ctl;
  291. u8 addr4[ETH_ALEN];
  292. } __attribute__ ((packed));
  293. struct rtw_ieee80211_hdr_3addr {
  294. u16 frame_ctl;
  295. u16 duration_id;
  296. u8 addr1[ETH_ALEN];
  297. u8 addr2[ETH_ALEN];
  298. u8 addr3[ETH_ALEN];
  299. u16 seq_ctl;
  300. } __attribute__ ((packed));
  301. struct rtw_ieee80211_hdr_qos {
  302. u16 frame_ctl;
  303. u16 duration_id;
  304. u8 addr1[ETH_ALEN];
  305. u8 addr2[ETH_ALEN];
  306. u8 addr3[ETH_ALEN];
  307. u16 seq_ctl;
  308. u8 addr4[ETH_ALEN];
  309. u16 qc;
  310. } __attribute__ ((packed));
  311. struct rtw_ieee80211_hdr_3addr_qos {
  312. u16 frame_ctl;
  313. u16 duration_id;
  314. u8 addr1[ETH_ALEN];
  315. u8 addr2[ETH_ALEN];
  316. u8 addr3[ETH_ALEN];
  317. u16 seq_ctl;
  318. u16 qc;
  319. } __attribute__ ((packed));
  320. struct eapol {
  321. u8 snap[6];
  322. u16 ethertype;
  323. u8 version;
  324. u8 type;
  325. u16 length;
  326. } __attribute__ ((packed));
  327. #endif
  328. #ifdef PLATFORM_WINDOWS
  329. #pragma pack(1)
  330. struct rtw_ieee80211_hdr {
  331. u16 frame_ctl;
  332. u16 duration_id;
  333. u8 addr1[ETH_ALEN];
  334. u8 addr2[ETH_ALEN];
  335. u8 addr3[ETH_ALEN];
  336. u16 seq_ctl;
  337. u8 addr4[ETH_ALEN];
  338. };
  339. struct rtw_ieee80211_hdr_3addr {
  340. u16 frame_ctl;
  341. u16 duration_id;
  342. u8 addr1[ETH_ALEN];
  343. u8 addr2[ETH_ALEN];
  344. u8 addr3[ETH_ALEN];
  345. u16 seq_ctl;
  346. };
  347. struct rtw_ieee80211_hdr_qos {
  348. struct rtw_ieee80211_hdr wlan_hdr;
  349. u16 qc;
  350. };
  351. struct rtw_ieee80211_hdr_3addr_qos {
  352. struct rtw_ieee80211_hdr_3addr wlan_hdr;
  353. u16 qc;
  354. };
  355. struct eapol {
  356. u8 snap[6];
  357. u16 ethertype;
  358. u8 version;
  359. u8 type;
  360. u16 length;
  361. };
  362. #pragma pack()
  363. #endif
  364. enum eap_type {
  365. EAP_PACKET = 0,
  366. EAPOL_START,
  367. EAPOL_LOGOFF,
  368. EAPOL_KEY,
  369. EAPOL_ENCAP_ASF_ALERT
  370. };
  371. #define IEEE80211_3ADDR_LEN 24
  372. #define IEEE80211_4ADDR_LEN 30
  373. #define IEEE80211_FCS_LEN 4
  374. #define MIN_FRAG_THRESHOLD 256U
  375. #define MAX_FRAG_THRESHOLD 2346U
  376. /* Frame control field constants */
  377. #define RTW_IEEE80211_FCTL_VERS 0x0003
  378. #define RTW_IEEE80211_FCTL_FTYPE 0x000c
  379. #define RTW_IEEE80211_FCTL_STYPE 0x00f0
  380. #define RTW_IEEE80211_FCTL_TODS 0x0100
  381. #define RTW_IEEE80211_FCTL_FROMDS 0x0200
  382. #define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400
  383. #define RTW_IEEE80211_FCTL_RETRY 0x0800
  384. #define RTW_IEEE80211_FCTL_PM 0x1000
  385. #define RTW_IEEE80211_FCTL_MOREDATA 0x2000
  386. #define RTW_IEEE80211_FCTL_PROTECTED 0x4000
  387. #define RTW_IEEE80211_FCTL_ORDER 0x8000
  388. #define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00
  389. #define RTW_IEEE80211_FTYPE_MGMT 0x0000
  390. #define RTW_IEEE80211_FTYPE_CTL 0x0004
  391. #define RTW_IEEE80211_FTYPE_DATA 0x0008
  392. #define RTW_IEEE80211_FTYPE_EXT 0x000c
  393. /* management */
  394. #define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000
  395. #define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010
  396. #define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
  397. #define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030
  398. #define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040
  399. #define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050
  400. #define RTW_IEEE80211_STYPE_BEACON 0x0080
  401. #define RTW_IEEE80211_STYPE_ATIM 0x0090
  402. #define RTW_IEEE80211_STYPE_DISASSOC 0x00A0
  403. #define RTW_IEEE80211_STYPE_AUTH 0x00B0
  404. #define RTW_IEEE80211_STYPE_DEAUTH 0x00C0
  405. #define RTW_IEEE80211_STYPE_ACTION 0x00D0
  406. /* control */
  407. #define RTW_IEEE80211_STYPE_CTL_EXT 0x0060
  408. #define RTW_IEEE80211_STYPE_BACK_REQ 0x0080
  409. #define RTW_IEEE80211_STYPE_BACK 0x0090
  410. #define RTW_IEEE80211_STYPE_PSPOLL 0x00A0
  411. #define RTW_IEEE80211_STYPE_RTS 0x00B0
  412. #define RTW_IEEE80211_STYPE_CTS 0x00C0
  413. #define RTW_IEEE80211_STYPE_ACK 0x00D0
  414. #define RTW_IEEE80211_STYPE_CFEND 0x00E0
  415. #define RTW_IEEE80211_STYPE_CFENDACK 0x00F0
  416. /* data */
  417. #define RTW_IEEE80211_STYPE_DATA 0x0000
  418. #define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010
  419. #define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
  420. #define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  421. #define RTW_IEEE80211_STYPE_NULLFUNC 0x0040
  422. #define RTW_IEEE80211_STYPE_CFACK 0x0050
  423. #define RTW_IEEE80211_STYPE_CFPOLL 0x0060
  424. #define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070
  425. #define RTW_IEEE80211_STYPE_QOS_DATA 0x0080
  426. #define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
  427. #define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
  428. #define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
  429. #define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
  430. #define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0
  431. #define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0
  432. #define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
  433. /* sequence control field */
  434. #define RTW_IEEE80211_SCTL_FRAG 0x000F
  435. #define RTW_IEEE80211_SCTL_SEQ 0xFFF0
  436. #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
  437. #define RTW_ERP_INFO_USE_PROTECTION BIT(1)
  438. #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
  439. /* QoS,QOS */
  440. #define NORMAL_ACK 0
  441. #define NO_ACK 1
  442. #define NON_EXPLICIT_ACK 2
  443. #define BLOCK_ACK 3
  444. #ifndef ETH_P_PAE
  445. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  446. #endif /* ETH_P_PAE */
  447. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  448. #define ETH_P_ECONET 0x0018
  449. #ifndef ETH_P_80211_RAW
  450. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  451. #endif
  452. /* IEEE 802.11 defines */
  453. #define P80211_OUI_LEN 3
  454. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW) || defined(PLATFORM_FREEBSD)
  455. struct ieee80211_snap_hdr {
  456. u8 dsap; /* always 0xAA */
  457. u8 ssap; /* always 0xAA */
  458. u8 ctrl; /* always 0x03 */
  459. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  460. } __attribute__ ((packed));
  461. #endif
  462. #ifdef PLATFORM_WINDOWS
  463. #pragma pack(1)
  464. struct ieee80211_snap_hdr {
  465. u8 dsap; /* always 0xAA */
  466. u8 ssap; /* always 0xAA */
  467. u8 ctrl; /* always 0x03 */
  468. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  469. };
  470. #pragma pack()
  471. #endif
  472. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  473. #define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
  474. #define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
  475. #define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
  476. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
  477. #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ)
  478. /* Authentication algorithms */
  479. #define WLAN_AUTH_OPEN 0
  480. #define WLAN_AUTH_SHARED_KEY 1
  481. #define WLAN_AUTH_CHALLENGE_LEN 128
  482. #define WLAN_CAPABILITY_BSS (1<<0)
  483. #define WLAN_CAPABILITY_IBSS (1<<1)
  484. #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
  485. #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
  486. #define WLAN_CAPABILITY_PRIVACY (1<<4)
  487. #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
  488. #define WLAN_CAPABILITY_PBCC (1<<6)
  489. #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
  490. #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
  491. /* Status codes */
  492. #define WLAN_STATUS_SUCCESS 0
  493. #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  494. #define WLAN_STATUS_CAPS_UNSUPPORTED 10
  495. #define WLAN_STATUS_REASSOC_NO_ASSOC 11
  496. #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
  497. #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
  498. #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
  499. #define WLAN_STATUS_CHALLENGE_FAIL 15
  500. #define WLAN_STATUS_AUTH_TIMEOUT 16
  501. #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
  502. #define WLAN_STATUS_ASSOC_DENIED_RATES 18
  503. /* 802.11b */
  504. #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
  505. #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
  506. #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
  507. /* Reason codes */
  508. #define WLAN_REASON_UNSPECIFIED 1
  509. #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
  510. #define WLAN_REASON_DEAUTH_LEAVING 3
  511. #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
  512. #define WLAN_REASON_DISASSOC_AP_BUSY 5
  513. #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
  514. #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
  515. #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
  516. #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
  517. #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
  518. #define WLAN_REASON_EXPIRATION_CHK 65535
  519. /* Information Element IDs */
  520. #define WLAN_EID_SSID 0
  521. #define WLAN_EID_SUPP_RATES 1
  522. #define WLAN_EID_FH_PARAMS 2
  523. #define WLAN_EID_DS_PARAMS 3
  524. #define WLAN_EID_CF_PARAMS 4
  525. #define WLAN_EID_TIM 5
  526. #define WLAN_EID_IBSS_PARAMS 6
  527. #define WLAN_EID_CHALLENGE 16
  528. /* EIDs defined by IEEE 802.11h - START */
  529. #define WLAN_EID_PWR_CONSTRAINT 32
  530. #define WLAN_EID_PWR_CAPABILITY 33
  531. #define WLAN_EID_TPC_REQUEST 34
  532. #define WLAN_EID_TPC_REPORT 35
  533. #define WLAN_EID_SUPPORTED_CHANNELS 36
  534. #define WLAN_EID_CHANNEL_SWITCH 37
  535. #define WLAN_EID_MEASURE_REQUEST 38
  536. #define WLAN_EID_MEASURE_REPORT 39
  537. #define WLAN_EID_QUITE 40
  538. #define WLAN_EID_IBSS_DFS 41
  539. /* EIDs defined by IEEE 802.11h - END */
  540. #define WLAN_EID_ERP_INFO 42
  541. #define WLAN_EID_HT_CAP 45
  542. #define WLAN_EID_RSN 48
  543. #define WLAN_EID_EXT_SUPP_RATES 50
  544. #define WLAN_EID_MOBILITY_DOMAIN 54
  545. #define WLAN_EID_FAST_BSS_TRANSITION 55
  546. #define WLAN_EID_TIMEOUT_INTERVAL 56
  547. #define WLAN_EID_RIC_DATA 57
  548. #define WLAN_EID_HT_OPERATION 61
  549. #define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
  550. #define WLAN_EID_20_40_BSS_COEXISTENCE 72
  551. #define WLAN_EID_20_40_BSS_INTOLERANT 73
  552. #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
  553. #define WLAN_EID_MMIE 76
  554. #define WLAN_EID_VENDOR_SPECIFIC 221
  555. #define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
  556. #define WLAN_EID_VHT_CAPABILITY 191
  557. #define WLAN_EID_VHT_OPERATION 192
  558. #define WLAN_EID_VHT_OP_MODE_NOTIFY 193
  559. #define IEEE80211_MGMT_HDR_LEN 24
  560. #define IEEE80211_DATA_HDR3_LEN 24
  561. #define IEEE80211_DATA_HDR4_LEN 30
  562. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  563. #define IEEE80211_STATMASK_RSSI (1<<1)
  564. #define IEEE80211_STATMASK_NOISE (1<<2)
  565. #define IEEE80211_STATMASK_RATE (1<<3)
  566. #define IEEE80211_STATMASK_WEMASK 0x7
  567. #define IEEE80211_CCK_MODULATION (1<<0)
  568. #define IEEE80211_OFDM_MODULATION (1<<1)
  569. #define IEEE80211_24GHZ_BAND (1<<0)
  570. #define IEEE80211_52GHZ_BAND (1<<1)
  571. #define IEEE80211_CCK_RATE_LEN 4
  572. #define IEEE80211_NUM_OFDM_RATESLEN 8
  573. #define IEEE80211_CCK_RATE_1MB 0x02
  574. #define IEEE80211_CCK_RATE_2MB 0x04
  575. #define IEEE80211_CCK_RATE_5MB 0x0B
  576. #define IEEE80211_CCK_RATE_11MB 0x16
  577. #define IEEE80211_OFDM_RATE_LEN 8
  578. #define IEEE80211_OFDM_RATE_6MB 0x0C
  579. #define IEEE80211_OFDM_RATE_9MB 0x12
  580. #define IEEE80211_OFDM_RATE_12MB 0x18
  581. #define IEEE80211_OFDM_RATE_18MB 0x24
  582. #define IEEE80211_OFDM_RATE_24MB 0x30
  583. #define IEEE80211_OFDM_RATE_36MB 0x48
  584. #define IEEE80211_OFDM_RATE_48MB 0x60
  585. #define IEEE80211_OFDM_RATE_54MB 0x6C
  586. #define IEEE80211_BASIC_RATE_MASK 0x80
  587. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  588. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  589. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  590. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  591. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  592. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  593. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  594. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  595. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  596. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  597. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  598. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  599. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  600. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  601. IEEE80211_CCK_RATE_2MB_MASK)
  602. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  603. IEEE80211_CCK_RATE_5MB_MASK | \
  604. IEEE80211_CCK_RATE_11MB_MASK)
  605. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  606. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  607. IEEE80211_OFDM_RATE_12MB_MASK | \
  608. IEEE80211_OFDM_RATE_24MB_MASK)
  609. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  610. IEEE80211_OFDM_RATE_9MB_MASK | \
  611. IEEE80211_OFDM_RATE_18MB_MASK | \
  612. IEEE80211_OFDM_RATE_36MB_MASK | \
  613. IEEE80211_OFDM_RATE_48MB_MASK | \
  614. IEEE80211_OFDM_RATE_54MB_MASK)
  615. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  616. IEEE80211_CCK_DEFAULT_RATES_MASK)
  617. #define IEEE80211_NUM_OFDM_RATES 8
  618. #define IEEE80211_NUM_CCK_RATES 4
  619. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  620. /* BIT 7 HT Rate*/
  621. // TxHT = 0
  622. #define MGN_1M 0x02
  623. #define MGN_2M 0x04
  624. #define MGN_5_5M 0x0b
  625. #define MGN_11M 0x16
  626. #define MGN_6M 0x0c
  627. #define MGN_9M 0x12
  628. #define MGN_12M 0x18
  629. #define MGN_18M 0x24
  630. #define MGN_24M 0x30
  631. #define MGN_36M 0x48
  632. #define MGN_48M 0x60
  633. #define MGN_54M 0x6c
  634. // TxHT = 1
  635. #define MGN_MCS0 0x80
  636. #define MGN_MCS1 0x81
  637. #define MGN_MCS2 0x82
  638. #define MGN_MCS3 0x83
  639. #define MGN_MCS4 0x84
  640. #define MGN_MCS5 0x85
  641. #define MGN_MCS6 0x86
  642. #define MGN_MCS7 0x87
  643. #define MGN_MCS8 0x88
  644. #define MGN_MCS9 0x89
  645. #define MGN_MCS10 0x8a
  646. #define MGN_MCS11 0x8b
  647. #define MGN_MCS12 0x8c
  648. #define MGN_MCS13 0x8d
  649. #define MGN_MCS14 0x8e
  650. #define MGN_MCS15 0x8f
  651. #define MGN_VHT1SS_MCS0 0x90
  652. #define MGN_VHT1SS_MCS1 0x91
  653. #define MGN_VHT1SS_MCS2 0x92
  654. #define MGN_VHT1SS_MCS3 0x93
  655. #define MGN_VHT1SS_MCS4 0x94
  656. #define MGN_VHT1SS_MCS5 0x95
  657. #define MGN_VHT1SS_MCS6 0x96
  658. #define MGN_VHT1SS_MCS7 0x97
  659. #define MGN_VHT1SS_MCS8 0x98
  660. #define MGN_VHT1SS_MCS9 0x99
  661. #define MGN_VHT2SS_MCS0 0x9a
  662. #define MGN_VHT2SS_MCS1 0x9b
  663. #define MGN_VHT2SS_MCS2 0x9c
  664. #define MGN_VHT2SS_MCS3 0x9d
  665. #define MGN_VHT2SS_MCS4 0x9e
  666. #define MGN_VHT2SS_MCS5 0x9f
  667. #define MGN_VHT2SS_MCS6 0xa0
  668. #define MGN_VHT2SS_MCS7 0xa1
  669. #define MGN_VHT2SS_MCS8 0xa2
  670. #define MGN_VHT2SS_MCS9 0xa3
  671. #define MGN_MCS0_SG 0xc0
  672. #define MGN_MCS1_SG 0xc1
  673. #define MGN_MCS2_SG 0xc2
  674. #define MGN_MCS3_SG 0xc3
  675. #define MGN_MCS4_SG 0xc4
  676. #define MGN_MCS5_SG 0xc5
  677. #define MGN_MCS6_SG 0xc6
  678. #define MGN_MCS7_SG 0xc7
  679. #define MGN_MCS8_SG 0xc8
  680. #define MGN_MCS9_SG 0xc9
  681. #define MGN_MCS10_SG 0xca
  682. #define MGN_MCS11_SG 0xcb
  683. #define MGN_MCS12_SG 0xcc
  684. #define MGN_MCS13_SG 0xcd
  685. #define MGN_MCS14_SG 0xce
  686. #define MGN_MCS15_SG 0xcf
  687. #define IS_HT_RATE(rate) (((rate) & 0x80) ? _TRUE : _FALSE)
  688. #define IS_CCK_RATE(_rate) (_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
  689. /* NOTE: This data is for statistical purposes; not all hardware provides this
  690. * information for frames received. Not setting these will not cause
  691. * any adverse affects. */
  692. struct ieee80211_rx_stats {
  693. //u32 mac_time[2];
  694. s8 rssi;
  695. u8 signal;
  696. u8 noise;
  697. u8 received_channel;
  698. u16 rate; /* in 100 kbps */
  699. //u8 control;
  700. u8 mask;
  701. u8 freq;
  702. u16 len;
  703. };
  704. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  705. * three fragmented frames. This define can be increased to support more
  706. * concurrent frames, but it should be noted that each entry can consume about
  707. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  708. #define IEEE80211_FRAG_CACHE_LEN 4
  709. struct ieee80211_frag_entry {
  710. u32 first_frag_time;
  711. uint seq;
  712. uint last_frag;
  713. uint qos; //jackson
  714. uint tid; //jackson
  715. struct sk_buff *skb;
  716. u8 src_addr[ETH_ALEN];
  717. u8 dst_addr[ETH_ALEN];
  718. };
  719. #ifndef PLATFORM_FREEBSD //Baron BSD has already defined
  720. struct ieee80211_stats {
  721. uint tx_unicast_frames;
  722. uint tx_multicast_frames;
  723. uint tx_fragments;
  724. uint tx_unicast_octets;
  725. uint tx_multicast_octets;
  726. uint tx_deferred_transmissions;
  727. uint tx_single_retry_frames;
  728. uint tx_multiple_retry_frames;
  729. uint tx_retry_limit_exceeded;
  730. uint tx_discards;
  731. uint rx_unicast_frames;
  732. uint rx_multicast_frames;
  733. uint rx_fragments;
  734. uint rx_unicast_octets;
  735. uint rx_multicast_octets;
  736. uint rx_fcs_errors;
  737. uint rx_discards_no_buffer;
  738. uint tx_discards_wrong_sa;
  739. uint rx_discards_undecryptable;
  740. uint rx_message_in_msg_fragments;
  741. uint rx_message_in_bad_msg_fragments;
  742. };
  743. #endif //PLATFORM_FREEBSD
  744. struct ieee80211_softmac_stats{
  745. uint rx_ass_ok;
  746. uint rx_ass_err;
  747. uint rx_probe_rq;
  748. uint tx_probe_rs;
  749. uint tx_beacons;
  750. uint rx_auth_rq;
  751. uint rx_auth_rs_ok;
  752. uint rx_auth_rs_err;
  753. uint tx_auth_rq;
  754. uint no_auth_rs;
  755. uint no_ass_rs;
  756. uint tx_ass_rq;
  757. uint rx_ass_rq;
  758. uint tx_probe_rq;
  759. uint reassoc;
  760. uint swtxstop;
  761. uint swtxawake;
  762. };
  763. #define SEC_KEY_1 (1<<0)
  764. #define SEC_KEY_2 (1<<1)
  765. #define SEC_KEY_3 (1<<2)
  766. #define SEC_KEY_4 (1<<3)
  767. #define SEC_ACTIVE_KEY (1<<4)
  768. #define SEC_AUTH_MODE (1<<5)
  769. #define SEC_UNICAST_GROUP (1<<6)
  770. #define SEC_LEVEL (1<<7)
  771. #define SEC_ENABLED (1<<8)
  772. #define SEC_LEVEL_0 0 /* None */
  773. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  774. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  775. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  776. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  777. #define WEP_KEYS 4
  778. #define WEP_KEY_LEN 13
  779. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  780. struct ieee80211_security {
  781. u16 active_key:2,
  782. enabled:1,
  783. auth_mode:2,
  784. auth_algo:4,
  785. unicast_uses_group:1;
  786. u8 key_sizes[WEP_KEYS];
  787. u8 keys[WEP_KEYS][WEP_KEY_LEN];
  788. u8 level;
  789. u16 flags;
  790. } __attribute__ ((packed));
  791. #endif
  792. #ifdef PLATFORM_WINDOWS
  793. #pragma pack(1)
  794. struct ieee80211_security {
  795. u16 active_key:2,
  796. enabled:1,
  797. auth_mode:2,
  798. auth_algo:4,
  799. unicast_uses_group:1;
  800. u8 key_sizes[WEP_KEYS];
  801. u8 keys[WEP_KEYS][WEP_KEY_LEN];
  802. u8 level;
  803. u16 flags;
  804. } ;
  805. #pragma pack()
  806. #endif
  807. /*
  808. 802.11 data frame from AP
  809. ,-------------------------------------------------------------------.
  810. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  811. |------|------|---------|---------|---------|------|---------|------|
  812. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  813. | | tion | (BSSID) | | | ence | data | |
  814. `-------------------------------------------------------------------'
  815. Total: 28-2340 bytes
  816. */
  817. struct ieee80211_header_data {
  818. u16 frame_ctl;
  819. u16 duration_id;
  820. u8 addr1[6];
  821. u8 addr2[6];
  822. u8 addr3[6];
  823. u16 seq_ctrl;
  824. };
  825. #define BEACON_PROBE_SSID_ID_POSITION 12
  826. /* Management Frame Information Element Types */
  827. #define MFIE_TYPE_SSID 0
  828. #define MFIE_TYPE_RATES 1
  829. #define MFIE_TYPE_FH_SET 2
  830. #define MFIE_TYPE_DS_SET 3
  831. #define MFIE_TYPE_CF_SET 4
  832. #define MFIE_TYPE_TIM 5
  833. #define MFIE_TYPE_IBSS_SET 6
  834. #define MFIE_TYPE_CHALLENGE 16
  835. #define MFIE_TYPE_ERP 42
  836. #define MFIE_TYPE_RSN 48
  837. #define MFIE_TYPE_RATES_EX 50
  838. #define MFIE_TYPE_GENERIC 221
  839. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  840. struct ieee80211_info_element_hdr {
  841. u8 id;
  842. u8 len;
  843. } __attribute__ ((packed));
  844. struct ieee80211_info_element {
  845. u8 id;
  846. u8 len;
  847. u8 data[0];
  848. } __attribute__ ((packed));
  849. #endif
  850. #ifdef PLATFORM_WINDOWS
  851. #pragma pack(1)
  852. struct ieee80211_info_element_hdr {
  853. u8 id;
  854. u8 len;
  855. } ;
  856. struct ieee80211_info_element {
  857. u8 id;
  858. u8 len;
  859. u8 data[0];
  860. } ;
  861. #pragma pack()
  862. #endif
  863. /*
  864. * These are the data types that can make up management packets
  865. *
  866. u16 auth_algorithm;
  867. u16 auth_sequence;
  868. u16 beacon_interval;
  869. u16 capability;
  870. u8 current_ap[ETH_ALEN];
  871. u16 listen_interval;
  872. struct {
  873. u16 association_id:14, reserved:2;
  874. } __attribute__ ((packed));
  875. u32 time_stamp[2];
  876. u16 reason;
  877. u16 status;
  878. */
  879. #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
  880. #define IEEE80211_DEFAULT_BASIC_RATE 10
  881. #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8711FW)
  882. struct ieee80211_authentication {
  883. struct ieee80211_header_data header;
  884. u16 algorithm;
  885. u16 transaction;
  886. u16 status;
  887. //struct ieee80211_info_element_hdr info_element;
  888. } __attribute__ ((packed));
  889. struct ieee80211_probe_response {
  890. struct ieee80211_header_data header;
  891. u32 time_stamp[2];
  892. u16 beacon_interval;
  893. u16 capability;
  894. struct ieee80211_info_element info_element;
  895. } __attribute__ ((packed));
  896. struct ieee80211_probe_request {
  897. struct ieee80211_header_data header;
  898. /*struct ieee80211_info_element info_element;*/
  899. } __attribute__ ((packed));
  900. struct ieee80211_assoc_request_frame {
  901. struct rtw_ieee80211_hdr_3addr header;
  902. u16 capability;
  903. u16 listen_interval;
  904. //u8 current_ap[ETH_ALEN];
  905. struct ieee80211_info_element_hdr info_element;
  906. } __attribute__ ((packed));
  907. struct ieee80211_assoc_response_frame {
  908. struct rtw_ieee80211_hdr_3addr header;
  909. u16 capability;
  910. u16 status;
  911. u16 aid;
  912. // struct ieee80211_info_element info_element; /* supported rates */
  913. } __attribute__ ((packed));
  914. #endif
  915. #ifdef PLATFORM_WINDOWS
  916. #pragma pack(1)
  917. struct ieee80211_authentication {
  918. struct ieee80211_header_data header;
  919. u16 algorithm;
  920. u16 transaction;
  921. u16 status;
  922. //struct ieee80211_info_element_hdr info_element;
  923. } ;
  924. struct ieee80211_probe_response {
  925. struct ieee80211_header_data header;
  926. u32 time_stamp[2];
  927. u16 beacon_interval;
  928. u16 capability;
  929. struct ieee80211_info_element info_element;
  930. } ;
  931. struct ieee80211_probe_request {
  932. struct ieee80211_header_data header;
  933. /*struct ieee80211_info_element info_element;*/
  934. } ;
  935. struct ieee80211_assoc_request_frame {
  936. struct rtw_ieee80211_hdr_3addr header;
  937. u16 capability;
  938. u16 listen_interval;
  939. //u8 current_ap[ETH_ALEN];
  940. struct ieee80211_info_element_hdr info_element;
  941. } ;
  942. struct ieee80211_assoc_response_frame {
  943. struct rtw_ieee80211_hdr_3addr header;
  944. u16 capability;
  945. u16 status;
  946. u16 aid;
  947. // struct ieee80211_info_element info_element; /* supported rates */
  948. };
  949. #pragma pack()
  950. #endif
  951. struct ieee80211_txb {
  952. u8 nr_frags;
  953. u8 encrypted;
  954. u16 reserved;
  955. u16 frag_size;
  956. u16 payload_size;
  957. struct sk_buff *fragments[0];
  958. };
  959. /* SWEEP TABLE ENTRIES NUMBER*/
  960. #define MAX_SWEEP_TAB_ENTRIES 42
  961. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  962. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  963. * only use 8, and then use extended rates for the remaining supported
  964. * rates. Other APs, however, stick all of their supported rates on the
  965. * main rates information element... */
  966. #define MAX_RATES_LENGTH ((u8)12)
  967. #define MAX_RATES_EX_LENGTH ((u8)16)
  968. #define MAX_NETWORK_COUNT 128
  969. #define MAX_CHANNEL_NUMBER 161
  970. #define IEEE80211_SOFTMAC_SCAN_TIME 400
  971. //(HZ / 2)
  972. #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  973. #define CRC_LENGTH 4U
  974. #define MAX_WPA_IE_LEN (256)
  975. #define MAX_WPS_IE_LEN (512)
  976. #define MAX_P2P_IE_LEN (256)
  977. #define MAX_WFD_IE_LEN (128)
  978. #define NETWORK_EMPTY_ESSID (1<<0)
  979. #define NETWORK_HAS_OFDM (1<<1)
  980. #define NETWORK_HAS_CCK (1<<2)
  981. #define IEEE80211_DTIM_MBCAST 4
  982. #define IEEE80211_DTIM_UCAST 2
  983. #define IEEE80211_DTIM_VALID 1
  984. #define IEEE80211_DTIM_INVALID 0
  985. #define IEEE80211_PS_DISABLED 0
  986. #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
  987. #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
  988. #define IW_ESSID_MAX_SIZE 32
  989. #if 0
  990. struct ieee80211_network {
  991. /* These entries are used to identify a unique network */
  992. u8 bssid[ETH_ALEN];
  993. u8 channel;
  994. /* Ensure null-terminated for any debug msgs */
  995. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  996. u8 ssid_len;
  997. u8 rssi; //relative signal strength
  998. u8 sq; //signal quality
  999. /* These are network statistics */
  1000. //struct ieee80211_rx_stats stats;
  1001. u16 capability;
  1002. u16 aid;
  1003. u8 rates[MAX_RATES_LENGTH];
  1004. u8 rates_len;
  1005. u8 rates_ex[MAX_RATES_EX_LENGTH];
  1006. u8 rates_ex_len;
  1007. u8 edca_parmsets[18];
  1008. u8 mode;
  1009. u8 flags;
  1010. u8 time_stamp[8];
  1011. u16 beacon_interval;
  1012. u16 listen_interval;
  1013. u16 atim_window;
  1014. u8 wpa_ie[MAX_WPA_IE_LEN];
  1015. size_t wpa_ie_len;
  1016. u8 rsn_ie[MAX_WPA_IE_LEN];
  1017. size_t rsn_ie_len;
  1018. u8 country[6];
  1019. u8 dtim_period;
  1020. u8 dtim_data;
  1021. u8 power_constraint;
  1022. u8 qosinfo;
  1023. u8 qbssload[5];
  1024. u8 network_type;
  1025. int join_res;
  1026. unsigned long last_scanned;
  1027. };
  1028. #endif
  1029. /*
  1030. join_res:
  1031. -1: authentication fail
  1032. -2: association fail
  1033. > 0: TID
  1034. */
  1035. #ifndef PLATFORM_FREEBSD //Baron BSD has already defined
  1036. enum ieee80211_state {
  1037. /* the card is not linked at all */
  1038. IEEE80211_NOLINK = 0,
  1039. /* IEEE80211_ASSOCIATING* are for BSS client mode
  1040. * the driver shall not perform RX filtering unless
  1041. * the state is LINKED.
  1042. * The driver shall just check for the state LINKED and
  1043. * defaults to NOLINK for ALL the other states (including
  1044. * LINKED_SCANNING)
  1045. */
  1046. /* the association procedure will start (wq scheduling)*/
  1047. IEEE80211_ASSOCIATING,
  1048. IEEE80211_ASSOCIATING_RETRY,
  1049. /* the association procedure is sending AUTH request*/
  1050. IEEE80211_ASSOCIATING_AUTHENTICATING,
  1051. /* the association procedure has successfully authentcated
  1052. * and is sending association request
  1053. */
  1054. IEEE80211_ASSOCIATING_AUTHENTICATED,
  1055. /* the link is ok. the card associated to a BSS or linked
  1056. * to a ibss cell or acting as an AP and creating the bss
  1057. */
  1058. IEEE80211_LINKED,
  1059. /* same as LINKED, but the driver shall apply RX filter
  1060. * rules as we are in NO_LINK mode. As the card is still
  1061. * logically linked, but it is doing a syncro site survey
  1062. * then it will be back to LINKED state.
  1063. */
  1064. IEEE80211_LINKED_SCANNING,
  1065. };
  1066. #endif //PLATFORM_FREEBSD
  1067. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  1068. #define DEFAULT_FTS 2346
  1069. #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
  1070. #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
  1071. #ifdef PLATFORM_FREEBSD //Baron change func to macro
  1072. #define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff))
  1073. #define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \
  1074. (((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \
  1075. (((Addr[5]) & 0xff) == 0xff))
  1076. #else
  1077. static __inline int is_multicast_mac_addr(const u8 *addr)
  1078. {
  1079. return ((addr[0] != 0xff) && (0x01 & addr[0]));
  1080. }
  1081. static __inline int is_broadcast_mac_addr(const u8 *addr)
  1082. {
  1083. return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
  1084. (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
  1085. }
  1086. #endif //PLATFORM_FREEBSD
  1087. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  1088. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  1089. typedef struct tx_pending_t{
  1090. int frag;
  1091. struct ieee80211_txb *txb;
  1092. }tx_pending_t;
  1093. #define MAXTID 16
  1094. #define IEEE_A (1<<0)
  1095. #define IEEE_B (1<<1)
  1096. #define IEEE_G (1<<2)
  1097. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  1098. //Baron move to ieee80211.c
  1099. int ieee80211_is_empty_essid(const char *essid, int essid_len);
  1100. int ieee80211_get_hdrlen(u16 fc);
  1101. #if 0
  1102. /* Action frame categories (IEEE 802.11-2007, 7.3.1.11, Table 7-24) */
  1103. #define WLAN_ACTION_SPECTRUM_MGMT 0
  1104. #define WLAN_ACTION_QOS 1
  1105. #define WLAN_ACTION_DLS 2
  1106. #define WLAN_ACTION_BLOCK_ACK 3
  1107. #define WLAN_ACTION_RADIO_MEASUREMENT 5
  1108. #define WLAN_ACTION_FT 6
  1109. #define WLAN_ACTION_SA_QUERY 8
  1110. #define WLAN_ACTION_WMM 17
  1111. #endif
  1112. /* Action category code */
  1113. enum rtw_ieee80211_category {
  1114. RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
  1115. RTW_WLAN_CATEGORY_QOS = 1,
  1116. RTW_WLAN_CATEGORY_DLS = 2,
  1117. RTW_WLAN_CATEGORY_BACK = 3,
  1118. RTW_WLAN_CATEGORY_PUBLIC = 4, //IEEE 802.11 public action frames
  1119. RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5,
  1120. RTW_WLAN_CATEGORY_FT = 6,
  1121. RTW_WLAN_CATEGORY_HT = 7,
  1122. RTW_WLAN_CATEGORY_SA_QUERY = 8,
  1123. RTW_WLAN_CATEGORY_TDLS = 12,
  1124. RTW_WLAN_CATEGORY_WMM = 17,
  1125. RTW_WLAN_CATEGORY_P2P = 0x7f,//P2P action frames
  1126. };
  1127. /* SPECTRUM_MGMT action code */
  1128. enum rtw_ieee80211_spectrum_mgmt_actioncode {
  1129. RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
  1130. RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
  1131. RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
  1132. RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
  1133. RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
  1134. RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
  1135. };
  1136. enum _PUBLIC_ACTION{
  1137. ACT_PUBLIC_BSSCOEXIST = 0, // 20/40 BSS Coexistence
  1138. ACT_PUBLIC_DSE_ENABLE = 1,
  1139. ACT_PUBLIC_DSE_DEENABLE = 2,
  1140. ACT_PUBLIC_DSE_REG_LOCATION = 3,
  1141. ACT_PUBLIC_EXT_CHL_SWITCH = 4,
  1142. ACT_PUBLIC_DSE_MSR_REQ = 5,
  1143. ACT_PUBLIC_DSE_MSR_RPRT = 6,
  1144. ACT_PUBLIC_MP = 7, // Measurement Pilot
  1145. ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
  1146. ACT_PUBLIC_VENDOR = 9, // for WIFI_DIRECT
  1147. ACT_PUBLIC_GAS_INITIAL_REQ = 10,
  1148. ACT_PUBLIC_GAS_INITIAL_RSP = 11,
  1149. ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
  1150. ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
  1151. ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
  1152. ACT_PUBLIC_LOCATION_TRACK = 15,
  1153. ACT_PUBLIC_MAX
  1154. };
  1155. #ifdef CONFIG_TDLS
  1156. enum TDLS_ACTION_FIELD{
  1157. TDLS_SETUP_REQUEST = 0,
  1158. TDLS_SETUP_RESPONSE = 1,
  1159. TDLS_SETUP_CONFIRM = 2,
  1160. TDLS_TEARDOWN = 3,
  1161. TDLS_PEER_TRAFFIC_INDICATION = 4,
  1162. TDLS_CHANNEL_SWITCH_REQUEST = 5,
  1163. TDLS_CHANNEL_SWITCH_RESPONSE = 6,
  1164. TDLS_PEER_PSM_REQUEST = 7,
  1165. TDLS_PEER_PSM_RESPONSE = 8,
  1166. TDLS_PEER_TRAFFIC_RESPONSE = 9,
  1167. TDLS_DISCOVERY_REQUEST = 10,
  1168. TDLS_DISCOVERY_RESPONSE = 14, //it's used in public action frame
  1169. };
  1170. #define TUNNELED_PROBE_REQ 15
  1171. #define TUNNELED_PROBE_RSP 16
  1172. #endif //CONFIG_TDLS
  1173. /* BACK action code */
  1174. enum rtw_ieee80211_back_actioncode {
  1175. RTW_WLAN_ACTION_ADDBA_REQ = 0,
  1176. RTW_WLAN_ACTION_ADDBA_RESP = 1,
  1177. RTW_WLAN_ACTION_DELBA = 2,
  1178. };
  1179. /* HT features action code */
  1180. enum rtw_ieee80211_ht_actioncode {
  1181. RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0,
  1182. RTW_WLAN_ACTION_SM_PS = 1,
  1183. RTW_WLAN_ACTION_PSPM = 2,
  1184. RTW_WLAN_ACTION_PCO_PHASE = 3,
  1185. RTW_WLAN_ACTION_MIMO_CSI_MX = 4,
  1186. RTW_WLAN_ACTION_MIMO_NONCP_BF = 5,
  1187. RTW_WLAN_ACTION_MIMP_CP_BF = 6,
  1188. RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7,
  1189. RTW_WLAN_ACTION_HI_INFO_EXCHG = 8,
  1190. };
  1191. /* BACK (block-ack) parties */
  1192. enum rtw_ieee80211_back_parties {
  1193. RTW_WLAN_BACK_RECIPIENT = 0,
  1194. RTW_WLAN_BACK_INITIATOR = 1,
  1195. RTW_WLAN_BACK_TIMER = 2,
  1196. };
  1197. #define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
  1198. * 00:50:F2 */
  1199. #ifndef PLATFORM_FREEBSD //Baron BSD has defined
  1200. #define WME_OUI_TYPE 2
  1201. #endif //PLATFORM_FREEBSD
  1202. #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
  1203. #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
  1204. #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
  1205. #define WME_VERSION 1
  1206. #define WME_ACTION_CODE_SETUP_REQUEST 0
  1207. #define WME_ACTION_CODE_SETUP_RESPONSE 1
  1208. #define WME_ACTION_CODE_TEARDOWN 2
  1209. #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
  1210. #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
  1211. #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
  1212. #define WME_TSPEC_DIRECTION_UPLINK 0
  1213. #define WME_TSPEC_DIRECTION_DOWNLINK 1
  1214. #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
  1215. #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
  1216. #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
  1217. /**
  1218. * enum rtw_ieee80211_channel_flags - channel flags
  1219. *
  1220. * Channel flags set by the regulatory control code.
  1221. *
  1222. * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
  1223. * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
  1224. * on this channel.
  1225. * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
  1226. * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  1227. * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
  1228. * is not permitted.
  1229. * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
  1230. * is not permitted.
  1231. */
  1232. enum rtw_ieee80211_channel_flags {
  1233. RTW_IEEE80211_CHAN_DISABLED = 1<<0,
  1234. RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
  1235. RTW_IEEE80211_CHAN_NO_IBSS = 1<<2,
  1236. RTW_IEEE80211_CHAN_RADAR = 1<<3,
  1237. RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
  1238. RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
  1239. };
  1240. #define RTW_IEEE80211_CHAN_NO_HT40 \
  1241. (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
  1242. /* Represent channel details, subset of ieee80211_channel */
  1243. struct rtw_ieee80211_channel {
  1244. //enum ieee80211_band band;
  1245. //u16 center_freq;
  1246. u16 hw_value;
  1247. u32 flags;
  1248. //int max_antenna_gain;
  1249. //int max_power;
  1250. //int max_reg_power;
  1251. //bool beacon_found;
  1252. //u32 orig_flags;
  1253. //int orig_mag;
  1254. //int orig_mpwr;
  1255. };
  1256. #define CHAN_FMT \
  1257. /*"band:%d, "*/ \
  1258. /*"center_freq:%u, "*/ \
  1259. "hw_value:%u, " \
  1260. "flags:0x%08x" \
  1261. /*"max_antenna_gain:%d\n"*/ \
  1262. /*"max_power:%d\n"*/ \
  1263. /*"max_reg_power:%d\n"*/ \
  1264. /*"beacon_found:%u\n"*/ \
  1265. /*"orig_flags:0x%08x\n"*/ \
  1266. /*"orig_mag:%d\n"*/ \
  1267. /*"orig_mpwr:%d\n"*/
  1268. #define CHAN_ARG(channel) \
  1269. /*(channel)->band*/ \
  1270. /*, (channel)->center_freq*/ \
  1271. (channel)->hw_value \
  1272. , (channel)->flags \
  1273. /*, (channel)->max_antenna_gain*/ \
  1274. /*, (channel)->max_power*/ \
  1275. /*, (channel)->max_reg_power*/ \
  1276. /*, (channel)->beacon_found*/ \
  1277. /*, (channel)->orig_flags*/ \
  1278. /*, (channel)->orig_mag*/ \
  1279. /*, (channel)->orig_mpwr*/ \
  1280. /* Parsed Information Elements */
  1281. struct rtw_ieee802_11_elems {
  1282. u8 *ssid;
  1283. u8 ssid_len;
  1284. u8 *supp_rates;
  1285. u8 supp_rates_len;
  1286. u8 *fh_params;
  1287. u8 fh_params_len;
  1288. u8 *ds_params;
  1289. u8 ds_params_len;
  1290. u8 *cf_params;
  1291. u8 cf_params_len;
  1292. u8 *tim;
  1293. u8 tim_len;
  1294. u8 *ibss_params;
  1295. u8 ibss_params_len;
  1296. u8 *challenge;
  1297. u8 challenge_len;
  1298. u8 *erp_info;
  1299. u8 erp_info_len;
  1300. u8 *ext_supp_rates;
  1301. u8 ext_supp_rates_len;
  1302. u8 *wpa_ie;
  1303. u8 wpa_ie_len;
  1304. u8 *rsn_ie;
  1305. u8 rsn_ie_len;
  1306. u8 *wme;
  1307. u8 wme_len;
  1308. u8 *wme_tspec;
  1309. u8 wme_tspec_len;
  1310. u8 *wps_ie;
  1311. u8 wps_ie_len;
  1312. u8 *power_cap;
  1313. u8 power_cap_len;
  1314. u8 *supp_channels;
  1315. u8 supp_channels_len;
  1316. u8 *mdie;
  1317. u8 mdie_len;
  1318. u8 *ftie;
  1319. u8 ftie_len;
  1320. u8 *timeout_int;
  1321. u8 timeout_int_len;
  1322. u8 *ht_capabilities;
  1323. u8 ht_capabilities_len;
  1324. u8 *ht_operation;
  1325. u8 ht_operation_len;
  1326. u8 *vendor_ht_cap;
  1327. u8 vendor_ht_cap_len;
  1328. u8 *vht_capabilities;
  1329. u8 vht_capabilities_len;
  1330. u8 *vht_operation;
  1331. u8 vht_operation_len;
  1332. u8 *vht_op_mode_notify;
  1333. u8 vht_op_mode_notify_len;
  1334. };
  1335. typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
  1336. ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
  1337. struct rtw_ieee802_11_elems *elems,
  1338. int show_errors);
  1339. u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
  1340. u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
  1341. enum secondary_ch_offset {
  1342. SCN = 0, /* no secondary channel */
  1343. SCA = 1, /* secondary channel above */
  1344. SCB = 3, /* secondary channel below */
  1345. };
  1346. u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset);
  1347. u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset);
  1348. u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt);
  1349. u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset);
  1350. u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence);
  1351. u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
  1352. u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
  1353. int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
  1354. void rtw_set_supported_rate(u8* SupportedRates, uint mode) ;
  1355. unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
  1356. unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
  1357. int rtw_get_wpa_cipher_suite(u8 *s);
  1358. int rtw_get_wpa2_cipher_suite(u8 *s);
  1359. int rtw_get_wapi_ie(u8 *in_ie,uint in_len,u8 *wapi_ie,u16 *wapi_len);
  1360. int rtw_parse_wpa_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
  1361. int rtw_parse_wpa2_ie(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
  1362. int rtw_get_sec_ie(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len);
  1363. u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
  1364. u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
  1365. u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr);
  1366. u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content);
  1367. /**
  1368. * for_each_ie - iterate over continuous IEs
  1369. * @ie:
  1370. * @buf:
  1371. * @buf_len:
  1372. */
  1373. #define for_each_ie(ie, buf, buf_len) \
  1374. for (ie = (void*)buf; (((u8*)ie) - ((u8*)buf) + 1) < buf_len; ie = (void*)(((u8*)ie) + *(((u8*)ie)+1) + 2))
  1375. void dump_ies(u8 *buf, u32 buf_len);
  1376. void dump_wps_ie(u8 *ie, u32 ie_len);
  1377. #ifdef CONFIG_P2P
  1378. void dump_p2p_ie(u8 *ie, u32 ie_len);
  1379. u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen);
  1380. u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr, u32 *len_attr);
  1381. u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_content, uint *len_content);
  1382. u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr);
  1383. void rtw_WLAN_BSSID_EX_remove_p2p_attr(WLAN_BSSID_EX *bss_ex, u8 attr_id);
  1384. #endif
  1385. #ifdef CONFIG_WFD
  1386. int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen);
  1387. int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen);
  1388. #endif // CONFIG_WFD
  1389. uint rtw_get_rateset_len(u8 *rateset);
  1390. struct registry_priv;
  1391. int rtw_generate_ie(struct registry_priv *pregistrypriv);
  1392. int rtw_get_bit_value_from_ieee_value(u8 val);
  1393. uint rtw_is_cckrates_included(u8 *rate);
  1394. uint rtw_is_cckratesonly_included(u8 *rate);
  1395. int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
  1396. void rtw_get_bcn_info(struct wlan_network *pnetwork);
  1397. void rtw_macaddr_cfg(u8 *mac_addr);
  1398. u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char * MCS_rate);
  1399. int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8* category, u8 *action);
  1400. const char *action_public_str(u8 action);
  1401. #endif /* IEEE80211_H */