ieee80211.h 55 KB

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