ieee80211.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. /*
  2. * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
  3. * remains copyright by the original authors
  4. *
  5. * Portions of the merged code are based on Host AP (software wireless
  6. * LAN access point) driver for Intersil Prism2/2.5/3.
  7. *
  8. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  9. * <j@w1.fi>
  10. * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
  11. *
  12. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  13. * <jketreno@linux.intel.com>
  14. * Copyright (c) 2004-2005, Intel Corporation
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation. See README and COPYING for
  19. * more details.
  20. *
  21. * API Version History
  22. * 1.0.x -- Initial version
  23. * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs,
  24. * various structure changes, and crypto API init method
  25. */
  26. #ifndef IEEE80211_H
  27. #define IEEE80211_H
  28. #include <linux/if_ether.h> /* ETH_ALEN */
  29. #include <linux/kernel.h> /* ARRAY_SIZE */
  30. #include <linux/wireless.h>
  31. #include <linux/ieee80211.h>
  32. #define IEEE80211_VERSION "git-1.1.13"
  33. #define IEEE80211_DATA_LEN 2304
  34. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  35. 6.2.1.1.2.
  36. The figure in section 7.1.2 suggests a body size of up to 2312
  37. bytes is allowed, which is a bit confusing, I suspect this
  38. represents the 2304 bytes of real data, plus a possible 8 bytes of
  39. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  40. #define IEEE80211_1ADDR_LEN 10
  41. #define IEEE80211_2ADDR_LEN 16
  42. #define IEEE80211_3ADDR_LEN 24
  43. #define IEEE80211_4ADDR_LEN 30
  44. #define IEEE80211_FCS_LEN 4
  45. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  46. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  47. #define MIN_FRAG_THRESHOLD 256U
  48. #define MAX_FRAG_THRESHOLD 2346U
  49. /* Frame control field constants */
  50. #define IEEE80211_FCTL_VERS 0x0003
  51. #define IEEE80211_FCTL_FTYPE 0x000c
  52. #define IEEE80211_FCTL_STYPE 0x00f0
  53. #define IEEE80211_FCTL_TODS 0x0100
  54. #define IEEE80211_FCTL_FROMDS 0x0200
  55. #define IEEE80211_FCTL_MOREFRAGS 0x0400
  56. #define IEEE80211_FCTL_RETRY 0x0800
  57. #define IEEE80211_FCTL_PM 0x1000
  58. #define IEEE80211_FCTL_MOREDATA 0x2000
  59. #define IEEE80211_FCTL_PROTECTED 0x4000
  60. #define IEEE80211_FCTL_ORDER 0x8000
  61. #define IEEE80211_FTYPE_MGMT 0x0000
  62. #define IEEE80211_FTYPE_CTL 0x0004
  63. #define IEEE80211_FTYPE_DATA 0x0008
  64. /* management */
  65. #define IEEE80211_STYPE_ASSOC_REQ 0x0000
  66. #define IEEE80211_STYPE_ASSOC_RESP 0x0010
  67. #define IEEE80211_STYPE_REASSOC_REQ 0x0020
  68. #define IEEE80211_STYPE_REASSOC_RESP 0x0030
  69. #define IEEE80211_STYPE_PROBE_REQ 0x0040
  70. #define IEEE80211_STYPE_PROBE_RESP 0x0050
  71. #define IEEE80211_STYPE_BEACON 0x0080
  72. #define IEEE80211_STYPE_ATIM 0x0090
  73. #define IEEE80211_STYPE_DISASSOC 0x00A0
  74. #define IEEE80211_STYPE_AUTH 0x00B0
  75. #define IEEE80211_STYPE_DEAUTH 0x00C0
  76. #define IEEE80211_STYPE_ACTION 0x00D0
  77. /* control */
  78. #define IEEE80211_STYPE_PSPOLL 0x00A0
  79. #define IEEE80211_STYPE_RTS 0x00B0
  80. #define IEEE80211_STYPE_CTS 0x00C0
  81. #define IEEE80211_STYPE_ACK 0x00D0
  82. #define IEEE80211_STYPE_CFEND 0x00E0
  83. #define IEEE80211_STYPE_CFENDACK 0x00F0
  84. /* data */
  85. #define IEEE80211_STYPE_DATA 0x0000
  86. #define IEEE80211_STYPE_DATA_CFACK 0x0010
  87. #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
  88. #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
  89. #define IEEE80211_STYPE_NULLFUNC 0x0040
  90. #define IEEE80211_STYPE_CFACK 0x0050
  91. #define IEEE80211_STYPE_CFPOLL 0x0060
  92. #define IEEE80211_STYPE_CFACKPOLL 0x0070
  93. #define IEEE80211_STYPE_QOS_DATA 0x0080
  94. #define IEEE80211_SCTL_FRAG 0x000F
  95. #define IEEE80211_SCTL_SEQ 0xFFF0
  96. /* QOS control */
  97. #define IEEE80211_QCTL_TID 0x000F
  98. /* debug macros */
  99. #ifdef CONFIG_IEEE80211_DEBUG
  100. extern u32 ieee80211_debug_level;
  101. #define IEEE80211_DEBUG(level, fmt, args...) \
  102. do { if (ieee80211_debug_level & (level)) \
  103. printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
  104. in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
  105. static inline bool ieee80211_ratelimit_debug(u32 level)
  106. {
  107. return (ieee80211_debug_level & level) && net_ratelimit();
  108. }
  109. #else
  110. #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
  111. static inline bool ieee80211_ratelimit_debug(u32 level)
  112. {
  113. return false;
  114. }
  115. #endif /* CONFIG_IEEE80211_DEBUG */
  116. /*
  117. * To use the debug system:
  118. *
  119. * If you are defining a new debug classification, simply add it to the #define
  120. * list here in the form of:
  121. *
  122. * #define IEEE80211_DL_xxxx VALUE
  123. *
  124. * shifting value to the left one bit from the previous entry. xxxx should be
  125. * the name of the classification (for example, WEP)
  126. *
  127. * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
  128. * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
  129. * to send output to that classification.
  130. *
  131. * To add your debug level to the list of levels seen when you perform
  132. *
  133. * % cat /proc/net/ieee80211/debug_level
  134. *
  135. * you simply need to add your entry to the ieee80211_debug_level array.
  136. *
  137. * If you do not see debug_level in /proc/net/ieee80211 then you do not have
  138. * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
  139. *
  140. */
  141. #define IEEE80211_DL_INFO (1<<0)
  142. #define IEEE80211_DL_WX (1<<1)
  143. #define IEEE80211_DL_SCAN (1<<2)
  144. #define IEEE80211_DL_STATE (1<<3)
  145. #define IEEE80211_DL_MGMT (1<<4)
  146. #define IEEE80211_DL_FRAG (1<<5)
  147. #define IEEE80211_DL_DROP (1<<7)
  148. #define IEEE80211_DL_TX (1<<8)
  149. #define IEEE80211_DL_RX (1<<9)
  150. #define IEEE80211_DL_QOS (1<<31)
  151. #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
  152. #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
  153. #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
  154. #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
  155. #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
  156. #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
  157. #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
  158. #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
  159. #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
  160. #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
  161. #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
  162. #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
  163. #include <linux/netdevice.h>
  164. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  165. #ifndef WIRELESS_SPY
  166. #define WIRELESS_SPY /* enable iwspy support */
  167. #endif
  168. #include <net/iw_handler.h> /* new driver API */
  169. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  170. #ifndef ETH_P_80211_RAW
  171. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  172. #endif
  173. /* IEEE 802.11 defines */
  174. #define P80211_OUI_LEN 3
  175. struct ieee80211_snap_hdr {
  176. u8 dsap; /* always 0xAA */
  177. u8 ssap; /* always 0xAA */
  178. u8 ctrl; /* always 0x03 */
  179. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  180. } __attribute__ ((packed));
  181. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  182. #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
  183. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  184. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  185. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  186. #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  187. /* Action categories - 802.11h */
  188. enum ieee80211_actioncategories {
  189. WLAN_ACTION_SPECTRUM_MGMT = 0,
  190. /* Reserved 1-127 */
  191. /* Error 128-255 */
  192. };
  193. /* Action details - 802.11h */
  194. enum ieee80211_actiondetails {
  195. WLAN_ACTION_CATEGORY_MEASURE_REQUEST = 0,
  196. WLAN_ACTION_CATEGORY_MEASURE_REPORT = 1,
  197. WLAN_ACTION_CATEGORY_TPC_REQUEST = 2,
  198. WLAN_ACTION_CATEGORY_TPC_REPORT = 3,
  199. WLAN_ACTION_CATEGORY_CHANNEL_SWITCH = 4,
  200. /* 5 - 255 Reserved */
  201. };
  202. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  203. #define IEEE80211_STATMASK_RSSI (1<<1)
  204. #define IEEE80211_STATMASK_NOISE (1<<2)
  205. #define IEEE80211_STATMASK_RATE (1<<3)
  206. #define IEEE80211_STATMASK_WEMASK 0x7
  207. #define IEEE80211_CCK_MODULATION (1<<0)
  208. #define IEEE80211_OFDM_MODULATION (1<<1)
  209. #define IEEE80211_24GHZ_BAND (1<<0)
  210. #define IEEE80211_52GHZ_BAND (1<<1)
  211. #define IEEE80211_CCK_RATE_1MB 0x02
  212. #define IEEE80211_CCK_RATE_2MB 0x04
  213. #define IEEE80211_CCK_RATE_5MB 0x0B
  214. #define IEEE80211_CCK_RATE_11MB 0x16
  215. #define IEEE80211_OFDM_RATE_6MB 0x0C
  216. #define IEEE80211_OFDM_RATE_9MB 0x12
  217. #define IEEE80211_OFDM_RATE_12MB 0x18
  218. #define IEEE80211_OFDM_RATE_18MB 0x24
  219. #define IEEE80211_OFDM_RATE_24MB 0x30
  220. #define IEEE80211_OFDM_RATE_36MB 0x48
  221. #define IEEE80211_OFDM_RATE_48MB 0x60
  222. #define IEEE80211_OFDM_RATE_54MB 0x6C
  223. #define IEEE80211_BASIC_RATE_MASK 0x80
  224. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  225. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  226. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  227. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  228. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  229. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  230. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  231. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  232. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  233. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  234. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  235. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  236. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  237. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  238. IEEE80211_CCK_RATE_2MB_MASK)
  239. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  240. IEEE80211_CCK_RATE_5MB_MASK | \
  241. IEEE80211_CCK_RATE_11MB_MASK)
  242. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  243. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  244. IEEE80211_OFDM_RATE_12MB_MASK | \
  245. IEEE80211_OFDM_RATE_24MB_MASK)
  246. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  247. IEEE80211_OFDM_RATE_9MB_MASK | \
  248. IEEE80211_OFDM_RATE_18MB_MASK | \
  249. IEEE80211_OFDM_RATE_36MB_MASK | \
  250. IEEE80211_OFDM_RATE_48MB_MASK | \
  251. IEEE80211_OFDM_RATE_54MB_MASK)
  252. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  253. IEEE80211_CCK_DEFAULT_RATES_MASK)
  254. #define IEEE80211_NUM_OFDM_RATES 8
  255. #define IEEE80211_NUM_CCK_RATES 4
  256. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  257. /* NOTE: This data is for statistical purposes; not all hardware provides this
  258. * information for frames received.
  259. * For ieee80211_rx_mgt, you need to set at least the 'len' parameter.
  260. */
  261. struct ieee80211_rx_stats {
  262. u32 mac_time;
  263. s8 rssi;
  264. u8 signal;
  265. u8 noise;
  266. u16 rate; /* in 100 kbps */
  267. u8 received_channel;
  268. u8 control;
  269. u8 mask;
  270. u8 freq;
  271. u16 len;
  272. u64 tsf;
  273. u32 beacon_time;
  274. };
  275. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  276. * three fragmented frames. This define can be increased to support more
  277. * concurrent frames, but it should be noted that each entry can consume about
  278. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  279. #define IEEE80211_FRAG_CACHE_LEN 4
  280. struct ieee80211_frag_entry {
  281. unsigned long first_frag_time;
  282. unsigned int seq;
  283. unsigned int last_frag;
  284. struct sk_buff *skb;
  285. u8 src_addr[ETH_ALEN];
  286. u8 dst_addr[ETH_ALEN];
  287. };
  288. struct ieee80211_stats {
  289. unsigned int tx_unicast_frames;
  290. unsigned int tx_multicast_frames;
  291. unsigned int tx_fragments;
  292. unsigned int tx_unicast_octets;
  293. unsigned int tx_multicast_octets;
  294. unsigned int tx_deferred_transmissions;
  295. unsigned int tx_single_retry_frames;
  296. unsigned int tx_multiple_retry_frames;
  297. unsigned int tx_retry_limit_exceeded;
  298. unsigned int tx_discards;
  299. unsigned int rx_unicast_frames;
  300. unsigned int rx_multicast_frames;
  301. unsigned int rx_fragments;
  302. unsigned int rx_unicast_octets;
  303. unsigned int rx_multicast_octets;
  304. unsigned int rx_fcs_errors;
  305. unsigned int rx_discards_no_buffer;
  306. unsigned int tx_discards_wrong_sa;
  307. unsigned int rx_discards_undecryptable;
  308. unsigned int rx_message_in_msg_fragments;
  309. unsigned int rx_message_in_bad_msg_fragments;
  310. };
  311. struct ieee80211_device;
  312. #include "ieee80211_crypt.h"
  313. #define SEC_KEY_1 (1<<0)
  314. #define SEC_KEY_2 (1<<1)
  315. #define SEC_KEY_3 (1<<2)
  316. #define SEC_KEY_4 (1<<3)
  317. #define SEC_ACTIVE_KEY (1<<4)
  318. #define SEC_AUTH_MODE (1<<5)
  319. #define SEC_UNICAST_GROUP (1<<6)
  320. #define SEC_LEVEL (1<<7)
  321. #define SEC_ENABLED (1<<8)
  322. #define SEC_ENCRYPT (1<<9)
  323. #define SEC_LEVEL_0 0 /* None */
  324. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  325. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  326. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  327. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  328. #define SEC_ALG_NONE 0
  329. #define SEC_ALG_WEP 1
  330. #define SEC_ALG_TKIP 2
  331. #define SEC_ALG_CCMP 3
  332. #define WEP_KEYS 4
  333. #define WEP_KEY_LEN 13
  334. #define SCM_KEY_LEN 32
  335. #define SCM_TEMPORAL_KEY_LENGTH 16
  336. struct ieee80211_security {
  337. u16 active_key:2,
  338. enabled:1,
  339. auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
  340. u8 encode_alg[WEP_KEYS];
  341. u8 key_sizes[WEP_KEYS];
  342. u8 keys[WEP_KEYS][SCM_KEY_LEN];
  343. u8 level;
  344. u16 flags;
  345. } __attribute__ ((packed));
  346. /*
  347. 802.11 data frame from AP
  348. ,-------------------------------------------------------------------.
  349. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  350. |------|------|---------|---------|---------|------|---------|------|
  351. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  352. | | tion | (BSSID) | | | ence | data | |
  353. `-------------------------------------------------------------------'
  354. Total: 28-2340 bytes
  355. */
  356. #define BEACON_PROBE_SSID_ID_POSITION 12
  357. /* Management Frame Information Element Types */
  358. enum ieee80211_mfie {
  359. MFIE_TYPE_SSID = 0,
  360. MFIE_TYPE_RATES = 1,
  361. MFIE_TYPE_FH_SET = 2,
  362. MFIE_TYPE_DS_SET = 3,
  363. MFIE_TYPE_CF_SET = 4,
  364. MFIE_TYPE_TIM = 5,
  365. MFIE_TYPE_IBSS_SET = 6,
  366. MFIE_TYPE_COUNTRY = 7,
  367. MFIE_TYPE_HOP_PARAMS = 8,
  368. MFIE_TYPE_HOP_TABLE = 9,
  369. MFIE_TYPE_REQUEST = 10,
  370. MFIE_TYPE_CHALLENGE = 16,
  371. MFIE_TYPE_POWER_CONSTRAINT = 32,
  372. MFIE_TYPE_POWER_CAPABILITY = 33,
  373. MFIE_TYPE_TPC_REQUEST = 34,
  374. MFIE_TYPE_TPC_REPORT = 35,
  375. MFIE_TYPE_SUPP_CHANNELS = 36,
  376. MFIE_TYPE_CSA = 37,
  377. MFIE_TYPE_MEASURE_REQUEST = 38,
  378. MFIE_TYPE_MEASURE_REPORT = 39,
  379. MFIE_TYPE_QUIET = 40,
  380. MFIE_TYPE_IBSS_DFS = 41,
  381. MFIE_TYPE_ERP_INFO = 42,
  382. MFIE_TYPE_RSN = 48,
  383. MFIE_TYPE_RATES_EX = 50,
  384. MFIE_TYPE_GENERIC = 221,
  385. MFIE_TYPE_QOS_PARAMETER = 222,
  386. };
  387. struct ieee80211_hdr_1addr {
  388. __le16 frame_ctl;
  389. __le16 duration_id;
  390. u8 addr1[ETH_ALEN];
  391. u8 payload[0];
  392. } __attribute__ ((packed));
  393. struct ieee80211_hdr_2addr {
  394. __le16 frame_ctl;
  395. __le16 duration_id;
  396. u8 addr1[ETH_ALEN];
  397. u8 addr2[ETH_ALEN];
  398. u8 payload[0];
  399. } __attribute__ ((packed));
  400. struct ieee80211_hdr_3addr {
  401. __le16 frame_ctl;
  402. __le16 duration_id;
  403. u8 addr1[ETH_ALEN];
  404. u8 addr2[ETH_ALEN];
  405. u8 addr3[ETH_ALEN];
  406. __le16 seq_ctl;
  407. u8 payload[0];
  408. } __attribute__ ((packed));
  409. struct ieee80211_hdr_4addr {
  410. __le16 frame_ctl;
  411. __le16 duration_id;
  412. u8 addr1[ETH_ALEN];
  413. u8 addr2[ETH_ALEN];
  414. u8 addr3[ETH_ALEN];
  415. __le16 seq_ctl;
  416. u8 addr4[ETH_ALEN];
  417. u8 payload[0];
  418. } __attribute__ ((packed));
  419. struct ieee80211_hdr_3addrqos {
  420. __le16 frame_ctl;
  421. __le16 duration_id;
  422. u8 addr1[ETH_ALEN];
  423. u8 addr2[ETH_ALEN];
  424. u8 addr3[ETH_ALEN];
  425. __le16 seq_ctl;
  426. u8 payload[0];
  427. __le16 qos_ctl;
  428. } __attribute__ ((packed));
  429. struct ieee80211_info_element {
  430. u8 id;
  431. u8 len;
  432. u8 data[0];
  433. } __attribute__ ((packed));
  434. /*
  435. * These are the data types that can make up management packets
  436. *
  437. u16 auth_algorithm;
  438. u16 auth_sequence;
  439. u16 beacon_interval;
  440. u16 capability;
  441. u8 current_ap[ETH_ALEN];
  442. u16 listen_interval;
  443. struct {
  444. u16 association_id:14, reserved:2;
  445. } __attribute__ ((packed));
  446. u32 time_stamp[2];
  447. u16 reason;
  448. u16 status;
  449. */
  450. struct ieee80211_auth {
  451. struct ieee80211_hdr_3addr header;
  452. __le16 algorithm;
  453. __le16 transaction;
  454. __le16 status;
  455. /* challenge */
  456. struct ieee80211_info_element info_element[0];
  457. } __attribute__ ((packed));
  458. struct ieee80211_channel_switch {
  459. u8 id;
  460. u8 len;
  461. u8 mode;
  462. u8 channel;
  463. u8 count;
  464. } __attribute__ ((packed));
  465. struct ieee80211_action {
  466. struct ieee80211_hdr_3addr header;
  467. u8 category;
  468. u8 action;
  469. union {
  470. struct ieee80211_action_exchange {
  471. u8 token;
  472. struct ieee80211_info_element info_element[0];
  473. } exchange;
  474. struct ieee80211_channel_switch channel_switch;
  475. } format;
  476. } __attribute__ ((packed));
  477. struct ieee80211_disassoc {
  478. struct ieee80211_hdr_3addr header;
  479. __le16 reason;
  480. } __attribute__ ((packed));
  481. /* Alias deauth for disassoc */
  482. #define ieee80211_deauth ieee80211_disassoc
  483. struct ieee80211_probe_request {
  484. struct ieee80211_hdr_3addr header;
  485. /* SSID, supported rates */
  486. struct ieee80211_info_element info_element[0];
  487. } __attribute__ ((packed));
  488. struct ieee80211_probe_response {
  489. struct ieee80211_hdr_3addr header;
  490. __le32 time_stamp[2];
  491. __le16 beacon_interval;
  492. __le16 capability;
  493. /* SSID, supported rates, FH params, DS params,
  494. * CF params, IBSS params, TIM (if beacon), RSN */
  495. struct ieee80211_info_element info_element[0];
  496. } __attribute__ ((packed));
  497. /* Alias beacon for probe_response */
  498. #define ieee80211_beacon ieee80211_probe_response
  499. struct ieee80211_assoc_request {
  500. struct ieee80211_hdr_3addr header;
  501. __le16 capability;
  502. __le16 listen_interval;
  503. /* SSID, supported rates, RSN */
  504. struct ieee80211_info_element info_element[0];
  505. } __attribute__ ((packed));
  506. struct ieee80211_reassoc_request {
  507. struct ieee80211_hdr_3addr header;
  508. __le16 capability;
  509. __le16 listen_interval;
  510. u8 current_ap[ETH_ALEN];
  511. struct ieee80211_info_element info_element[0];
  512. } __attribute__ ((packed));
  513. struct ieee80211_assoc_response {
  514. struct ieee80211_hdr_3addr header;
  515. __le16 capability;
  516. __le16 status;
  517. __le16 aid;
  518. /* supported rates */
  519. struct ieee80211_info_element info_element[0];
  520. } __attribute__ ((packed));
  521. struct ieee80211_txb {
  522. u8 nr_frags;
  523. u8 encrypted;
  524. u8 rts_included;
  525. u8 reserved;
  526. u16 frag_size;
  527. u16 payload_size;
  528. struct sk_buff *fragments[0];
  529. };
  530. /* SWEEP TABLE ENTRIES NUMBER */
  531. #define MAX_SWEEP_TAB_ENTRIES 42
  532. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  533. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  534. * only use 8, and then use extended rates for the remaining supported
  535. * rates. Other APs, however, stick all of their supported rates on the
  536. * main rates information element... */
  537. #define MAX_RATES_LENGTH ((u8)12)
  538. #define MAX_RATES_EX_LENGTH ((u8)16)
  539. #define MAX_NETWORK_COUNT 128
  540. #define CRC_LENGTH 4U
  541. #define MAX_WPA_IE_LEN 64
  542. #define NETWORK_HAS_OFDM (1<<1)
  543. #define NETWORK_HAS_CCK (1<<2)
  544. /* QoS structure */
  545. #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
  546. #define NETWORK_HAS_QOS_INFORMATION (1<<4)
  547. #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
  548. NETWORK_HAS_QOS_INFORMATION)
  549. /* 802.11h */
  550. #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
  551. #define NETWORK_HAS_CSA (1<<6)
  552. #define NETWORK_HAS_QUIET (1<<7)
  553. #define NETWORK_HAS_IBSS_DFS (1<<8)
  554. #define NETWORK_HAS_TPC_REPORT (1<<9)
  555. #define NETWORK_HAS_ERP_VALUE (1<<10)
  556. #define QOS_QUEUE_NUM 4
  557. #define QOS_OUI_LEN 3
  558. #define QOS_OUI_TYPE 2
  559. #define QOS_ELEMENT_ID 221
  560. #define QOS_OUI_INFO_SUB_TYPE 0
  561. #define QOS_OUI_PARAM_SUB_TYPE 1
  562. #define QOS_VERSION_1 1
  563. #define QOS_AIFSN_MIN_VALUE 2
  564. struct ieee80211_qos_information_element {
  565. u8 elementID;
  566. u8 length;
  567. u8 qui[QOS_OUI_LEN];
  568. u8 qui_type;
  569. u8 qui_subtype;
  570. u8 version;
  571. u8 ac_info;
  572. } __attribute__ ((packed));
  573. struct ieee80211_qos_ac_parameter {
  574. u8 aci_aifsn;
  575. u8 ecw_min_max;
  576. __le16 tx_op_limit;
  577. } __attribute__ ((packed));
  578. struct ieee80211_qos_parameter_info {
  579. struct ieee80211_qos_information_element info_element;
  580. u8 reserved;
  581. struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
  582. } __attribute__ ((packed));
  583. struct ieee80211_qos_parameters {
  584. __le16 cw_min[QOS_QUEUE_NUM];
  585. __le16 cw_max[QOS_QUEUE_NUM];
  586. u8 aifs[QOS_QUEUE_NUM];
  587. u8 flag[QOS_QUEUE_NUM];
  588. __le16 tx_op_limit[QOS_QUEUE_NUM];
  589. } __attribute__ ((packed));
  590. struct ieee80211_qos_data {
  591. struct ieee80211_qos_parameters parameters;
  592. int active;
  593. int supported;
  594. u8 param_count;
  595. u8 old_param_count;
  596. };
  597. struct ieee80211_tim_parameters {
  598. u8 tim_count;
  599. u8 tim_period;
  600. } __attribute__ ((packed));
  601. /*******************************************************/
  602. enum { /* ieee80211_basic_report.map */
  603. IEEE80211_BASIC_MAP_BSS = (1 << 0),
  604. IEEE80211_BASIC_MAP_OFDM = (1 << 1),
  605. IEEE80211_BASIC_MAP_UNIDENTIFIED = (1 << 2),
  606. IEEE80211_BASIC_MAP_RADAR = (1 << 3),
  607. IEEE80211_BASIC_MAP_UNMEASURED = (1 << 4),
  608. /* Bits 5-7 are reserved */
  609. };
  610. struct ieee80211_basic_report {
  611. u8 channel;
  612. __le64 start_time;
  613. __le16 duration;
  614. u8 map;
  615. } __attribute__ ((packed));
  616. enum { /* ieee80211_measurement_request.mode */
  617. /* Bit 0 is reserved */
  618. IEEE80211_MEASUREMENT_ENABLE = (1 << 1),
  619. IEEE80211_MEASUREMENT_REQUEST = (1 << 2),
  620. IEEE80211_MEASUREMENT_REPORT = (1 << 3),
  621. /* Bits 4-7 are reserved */
  622. };
  623. enum {
  624. IEEE80211_REPORT_BASIC = 0, /* required */
  625. IEEE80211_REPORT_CCA = 1, /* optional */
  626. IEEE80211_REPORT_RPI = 2, /* optional */
  627. /* 3-255 reserved */
  628. };
  629. struct ieee80211_measurement_params {
  630. u8 channel;
  631. __le64 start_time;
  632. __le16 duration;
  633. } __attribute__ ((packed));
  634. struct ieee80211_measurement_request {
  635. struct ieee80211_info_element ie;
  636. u8 token;
  637. u8 mode;
  638. u8 type;
  639. struct ieee80211_measurement_params params[0];
  640. } __attribute__ ((packed));
  641. struct ieee80211_measurement_report {
  642. struct ieee80211_info_element ie;
  643. u8 token;
  644. u8 mode;
  645. u8 type;
  646. union {
  647. struct ieee80211_basic_report basic[0];
  648. } u;
  649. } __attribute__ ((packed));
  650. struct ieee80211_tpc_report {
  651. u8 transmit_power;
  652. u8 link_margin;
  653. } __attribute__ ((packed));
  654. struct ieee80211_channel_map {
  655. u8 channel;
  656. u8 map;
  657. } __attribute__ ((packed));
  658. struct ieee80211_ibss_dfs {
  659. struct ieee80211_info_element ie;
  660. u8 owner[ETH_ALEN];
  661. u8 recovery_interval;
  662. struct ieee80211_channel_map channel_map[0];
  663. };
  664. struct ieee80211_csa {
  665. u8 mode;
  666. u8 channel;
  667. u8 count;
  668. } __attribute__ ((packed));
  669. struct ieee80211_quiet {
  670. u8 count;
  671. u8 period;
  672. u8 duration;
  673. u8 offset;
  674. } __attribute__ ((packed));
  675. struct ieee80211_network {
  676. /* These entries are used to identify a unique network */
  677. u8 bssid[ETH_ALEN];
  678. u8 channel;
  679. /* Ensure null-terminated for any debug msgs */
  680. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  681. u8 ssid_len;
  682. struct ieee80211_qos_data qos_data;
  683. /* These are network statistics */
  684. struct ieee80211_rx_stats stats;
  685. u16 capability;
  686. u8 rates[MAX_RATES_LENGTH];
  687. u8 rates_len;
  688. u8 rates_ex[MAX_RATES_EX_LENGTH];
  689. u8 rates_ex_len;
  690. unsigned long last_scanned;
  691. u8 mode;
  692. u32 flags;
  693. u32 last_associate;
  694. u32 time_stamp[2];
  695. u16 beacon_interval;
  696. u16 listen_interval;
  697. u16 atim_window;
  698. u8 erp_value;
  699. u8 wpa_ie[MAX_WPA_IE_LEN];
  700. size_t wpa_ie_len;
  701. u8 rsn_ie[MAX_WPA_IE_LEN];
  702. size_t rsn_ie_len;
  703. struct ieee80211_tim_parameters tim;
  704. /* 802.11h info */
  705. /* Power Constraint - mandatory if spctrm mgmt required */
  706. u8 power_constraint;
  707. /* TPC Report - mandatory if spctrm mgmt required */
  708. struct ieee80211_tpc_report tpc_report;
  709. /* IBSS DFS - mandatory if spctrm mgmt required and IBSS
  710. * NOTE: This is variable length and so must be allocated dynamically */
  711. struct ieee80211_ibss_dfs *ibss_dfs;
  712. /* Channel Switch Announcement - optional if spctrm mgmt required */
  713. struct ieee80211_csa csa;
  714. /* Quiet - optional if spctrm mgmt required */
  715. struct ieee80211_quiet quiet;
  716. struct list_head list;
  717. };
  718. enum ieee80211_state {
  719. IEEE80211_UNINITIALIZED = 0,
  720. IEEE80211_INITIALIZED,
  721. IEEE80211_ASSOCIATING,
  722. IEEE80211_ASSOCIATED,
  723. IEEE80211_AUTHENTICATING,
  724. IEEE80211_AUTHENTICATED,
  725. IEEE80211_SHUTDOWN
  726. };
  727. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  728. #define DEFAULT_FTS 2346
  729. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  730. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  731. #define CFG_IEEE80211_RTS (1<<2)
  732. #define IEEE80211_24GHZ_MIN_CHANNEL 1
  733. #define IEEE80211_24GHZ_MAX_CHANNEL 14
  734. #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
  735. IEEE80211_24GHZ_MIN_CHANNEL + 1)
  736. #define IEEE80211_52GHZ_MIN_CHANNEL 34
  737. #define IEEE80211_52GHZ_MAX_CHANNEL 165
  738. #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
  739. IEEE80211_52GHZ_MIN_CHANNEL + 1)
  740. enum {
  741. IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
  742. IEEE80211_CH_80211H_RULES = (1 << 1),
  743. IEEE80211_CH_B_ONLY = (1 << 2),
  744. IEEE80211_CH_NO_IBSS = (1 << 3),
  745. IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
  746. IEEE80211_CH_RADAR_DETECT = (1 << 5),
  747. IEEE80211_CH_INVALID = (1 << 6),
  748. };
  749. struct ieee80211_channel {
  750. u32 freq; /* in MHz */
  751. u8 channel;
  752. u8 flags;
  753. u8 max_power; /* in dBm */
  754. };
  755. struct ieee80211_geo {
  756. u8 name[4];
  757. u8 bg_channels;
  758. u8 a_channels;
  759. struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
  760. struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
  761. };
  762. struct ieee80211_device {
  763. struct net_device *dev;
  764. struct ieee80211_security sec;
  765. /* Bookkeeping structures */
  766. struct net_device_stats stats;
  767. struct ieee80211_stats ieee_stats;
  768. struct ieee80211_geo geo;
  769. /* Probe / Beacon management */
  770. struct list_head network_free_list;
  771. struct list_head network_list;
  772. struct ieee80211_network *networks;
  773. int scans;
  774. int scan_age;
  775. int iw_mode; /* operating mode (IW_MODE_*) */
  776. struct iw_spy_data spy_data; /* iwspy support */
  777. spinlock_t lock;
  778. int tx_headroom; /* Set to size of any additional room needed at front
  779. * of allocated Tx SKBs */
  780. u32 config;
  781. /* WEP and other encryption related settings at the device level */
  782. int open_wep; /* Set to 1 to allow unencrypted frames */
  783. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  784. * WEP key changes */
  785. /* If the host performs {en,de}cryption, then set to 1 */
  786. int host_encrypt;
  787. int host_encrypt_msdu;
  788. int host_decrypt;
  789. /* host performs multicast decryption */
  790. int host_mc_decrypt;
  791. /* host should strip IV and ICV from protected frames */
  792. /* meaningful only when hardware decryption is being used */
  793. int host_strip_iv_icv;
  794. int host_open_frag;
  795. int host_build_iv;
  796. int ieee802_1x; /* is IEEE 802.1X used */
  797. /* WPA data */
  798. int wpa_enabled;
  799. int drop_unencrypted;
  800. int privacy_invoked;
  801. size_t wpa_ie_len;
  802. u8 *wpa_ie;
  803. struct list_head crypt_deinit_list;
  804. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  805. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  806. struct timer_list crypt_deinit_timer;
  807. int crypt_quiesced;
  808. int bcrx_sta_key; /* use individual keys to override default keys even
  809. * with RX of broad/multicast frames */
  810. /* Fragmentation structures */
  811. struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
  812. unsigned int frag_next_idx;
  813. u16 fts; /* Fragmentation Threshold */
  814. u16 rts; /* RTS threshold */
  815. /* Association info */
  816. u8 bssid[ETH_ALEN];
  817. enum ieee80211_state state;
  818. int mode; /* A, B, G */
  819. int modulation; /* CCK, OFDM */
  820. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  821. int abg_true; /* ABG flag */
  822. int perfect_rssi;
  823. int worst_rssi;
  824. u16 prev_seq_ctl; /* used to drop duplicate frames */
  825. /* Callback functions */
  826. void (*set_security) (struct net_device * dev,
  827. struct ieee80211_security * sec);
  828. int (*hard_start_xmit) (struct ieee80211_txb * txb,
  829. struct net_device * dev, int pri);
  830. int (*reset_port) (struct net_device * dev);
  831. int (*is_queue_full) (struct net_device * dev, int pri);
  832. int (*handle_management) (struct net_device * dev,
  833. struct ieee80211_network * network, u16 type);
  834. int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
  835. /* Typical STA methods */
  836. int (*handle_auth) (struct net_device * dev,
  837. struct ieee80211_auth * auth);
  838. int (*handle_deauth) (struct net_device * dev,
  839. struct ieee80211_deauth * auth);
  840. int (*handle_action) (struct net_device * dev,
  841. struct ieee80211_action * action,
  842. struct ieee80211_rx_stats * stats);
  843. int (*handle_disassoc) (struct net_device * dev,
  844. struct ieee80211_disassoc * assoc);
  845. int (*handle_beacon) (struct net_device * dev,
  846. struct ieee80211_beacon * beacon,
  847. struct ieee80211_network * network);
  848. int (*handle_probe_response) (struct net_device * dev,
  849. struct ieee80211_probe_response * resp,
  850. struct ieee80211_network * network);
  851. int (*handle_probe_request) (struct net_device * dev,
  852. struct ieee80211_probe_request * req,
  853. struct ieee80211_rx_stats * stats);
  854. int (*handle_assoc_response) (struct net_device * dev,
  855. struct ieee80211_assoc_response * resp,
  856. struct ieee80211_network * network);
  857. /* Typical AP methods */
  858. int (*handle_assoc_request) (struct net_device * dev);
  859. int (*handle_reassoc_request) (struct net_device * dev,
  860. struct ieee80211_reassoc_request * req);
  861. /* This must be the last item so that it points to the data
  862. * allocated beyond this structure by alloc_ieee80211 */
  863. u8 priv[0];
  864. };
  865. #define IEEE_A (1<<0)
  866. #define IEEE_B (1<<1)
  867. #define IEEE_G (1<<2)
  868. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  869. static inline void *ieee80211_priv(struct net_device *dev)
  870. {
  871. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  872. }
  873. static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
  874. int mode)
  875. {
  876. /*
  877. * It is possible for both access points and our device to support
  878. * combinations of modes, so as long as there is one valid combination
  879. * of ap/device supported modes, then return success
  880. *
  881. */
  882. if ((mode & IEEE_A) &&
  883. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  884. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  885. return 1;
  886. if ((mode & IEEE_G) &&
  887. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  888. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  889. return 1;
  890. if ((mode & IEEE_B) &&
  891. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  892. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  893. return 1;
  894. return 0;
  895. }
  896. static inline int ieee80211_get_hdrlen(u16 fc)
  897. {
  898. int hdrlen = IEEE80211_3ADDR_LEN;
  899. u16 stype = WLAN_FC_GET_STYPE(fc);
  900. switch (WLAN_FC_GET_TYPE(fc)) {
  901. case IEEE80211_FTYPE_DATA:
  902. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  903. hdrlen = IEEE80211_4ADDR_LEN;
  904. if (stype & IEEE80211_STYPE_QOS_DATA)
  905. hdrlen += 2;
  906. break;
  907. case IEEE80211_FTYPE_CTL:
  908. switch (WLAN_FC_GET_STYPE(fc)) {
  909. case IEEE80211_STYPE_CTS:
  910. case IEEE80211_STYPE_ACK:
  911. hdrlen = IEEE80211_1ADDR_LEN;
  912. break;
  913. default:
  914. hdrlen = IEEE80211_2ADDR_LEN;
  915. break;
  916. }
  917. break;
  918. }
  919. return hdrlen;
  920. }
  921. static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
  922. {
  923. switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control))) {
  924. case IEEE80211_1ADDR_LEN:
  925. return ((struct ieee80211_hdr_1addr *)hdr)->payload;
  926. case IEEE80211_2ADDR_LEN:
  927. return ((struct ieee80211_hdr_2addr *)hdr)->payload;
  928. case IEEE80211_3ADDR_LEN:
  929. return ((struct ieee80211_hdr_3addr *)hdr)->payload;
  930. case IEEE80211_4ADDR_LEN:
  931. return ((struct ieee80211_hdr_4addr *)hdr)->payload;
  932. }
  933. return NULL;
  934. }
  935. static inline int ieee80211_is_ofdm_rate(u8 rate)
  936. {
  937. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  938. case IEEE80211_OFDM_RATE_6MB:
  939. case IEEE80211_OFDM_RATE_9MB:
  940. case IEEE80211_OFDM_RATE_12MB:
  941. case IEEE80211_OFDM_RATE_18MB:
  942. case IEEE80211_OFDM_RATE_24MB:
  943. case IEEE80211_OFDM_RATE_36MB:
  944. case IEEE80211_OFDM_RATE_48MB:
  945. case IEEE80211_OFDM_RATE_54MB:
  946. return 1;
  947. }
  948. return 0;
  949. }
  950. static inline int ieee80211_is_cck_rate(u8 rate)
  951. {
  952. switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
  953. case IEEE80211_CCK_RATE_1MB:
  954. case IEEE80211_CCK_RATE_2MB:
  955. case IEEE80211_CCK_RATE_5MB:
  956. case IEEE80211_CCK_RATE_11MB:
  957. return 1;
  958. }
  959. return 0;
  960. }
  961. /* ieee80211.c */
  962. extern void free_ieee80211(struct net_device *dev);
  963. extern struct net_device *alloc_ieee80211(int sizeof_priv);
  964. extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
  965. /* ieee80211_tx.c */
  966. extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
  967. extern void ieee80211_txb_free(struct ieee80211_txb *);
  968. /* ieee80211_rx.c */
  969. extern void ieee80211_rx_any(struct ieee80211_device *ieee,
  970. struct sk_buff *skb, struct ieee80211_rx_stats *stats);
  971. extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  972. struct ieee80211_rx_stats *rx_stats);
  973. /* make sure to set stats->len */
  974. extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  975. struct ieee80211_hdr_4addr *header,
  976. struct ieee80211_rx_stats *stats);
  977. extern void ieee80211_network_reset(struct ieee80211_network *network);
  978. /* ieee80211_geo.c */
  979. extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
  980. *ieee);
  981. extern int ieee80211_set_geo(struct ieee80211_device *ieee,
  982. const struct ieee80211_geo *geo);
  983. extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
  984. u8 channel);
  985. extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
  986. u8 channel);
  987. extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
  988. extern u8 ieee80211_get_channel_flags(struct ieee80211_device *ieee,
  989. u8 channel);
  990. extern const struct ieee80211_channel *ieee80211_get_channel(struct
  991. ieee80211_device
  992. *ieee, u8 channel);
  993. extern u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee,
  994. u8 channel);
  995. /* ieee80211_wx.c */
  996. extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  997. struct iw_request_info *info,
  998. union iwreq_data *wrqu, char *key);
  999. extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  1000. struct iw_request_info *info,
  1001. union iwreq_data *wrqu, char *key);
  1002. extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  1003. struct iw_request_info *info,
  1004. union iwreq_data *wrqu, char *key);
  1005. extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
  1006. struct iw_request_info *info,
  1007. union iwreq_data *wrqu, char *extra);
  1008. extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
  1009. struct iw_request_info *info,
  1010. union iwreq_data *wrqu, char *extra);
  1011. static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  1012. {
  1013. ieee->scans++;
  1014. }
  1015. static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  1016. {
  1017. return ieee->scans;
  1018. }
  1019. #endif /* IEEE80211_H */