ieee80211.h 62 KB

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