ieee80211_rx.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. /*
  2. * Original code based Host AP (software wireless LAN access point) driver
  3. * for Intersil Prism2/2.5/3 - hostap.o module, common routines
  4. *
  5. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  6. * <jkmaline@cc.hut.fi>
  7. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  8. * Copyright (c) 2004-2005, Intel Corporation
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation. See README and COPYING for
  13. * more details.
  14. */
  15. #include <linux/compiler.h>
  16. #include <linux/config.h>
  17. #include <linux/errno.h>
  18. #include <linux/if_arp.h>
  19. #include <linux/in6.h>
  20. #include <linux/in.h>
  21. #include <linux/ip.h>
  22. #include <linux/kernel.h>
  23. #include <linux/module.h>
  24. #include <linux/netdevice.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/skbuff.h>
  27. #include <linux/slab.h>
  28. #include <linux/tcp.h>
  29. #include <linux/types.h>
  30. #include <linux/wireless.h>
  31. #include <linux/etherdevice.h>
  32. #include <asm/uaccess.h>
  33. #include <linux/ctype.h>
  34. #include <net/ieee80211.h>
  35. static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
  36. struct sk_buff *skb,
  37. struct ieee80211_rx_stats *rx_stats)
  38. {
  39. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  40. u16 fc = le16_to_cpu(hdr->frame_ctl);
  41. skb->dev = ieee->dev;
  42. skb->mac.raw = skb->data;
  43. skb_pull(skb, ieee80211_get_hdrlen(fc));
  44. skb->pkt_type = PACKET_OTHERHOST;
  45. skb->protocol = __constant_htons(ETH_P_80211_RAW);
  46. memset(skb->cb, 0, sizeof(skb->cb));
  47. netif_rx(skb);
  48. }
  49. /* Called only as a tasklet (software IRQ) */
  50. static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct
  51. ieee80211_device
  52. *ieee,
  53. unsigned int seq,
  54. unsigned int frag,
  55. u8 * src,
  56. u8 * dst)
  57. {
  58. struct ieee80211_frag_entry *entry;
  59. int i;
  60. for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
  61. entry = &ieee->frag_cache[i];
  62. if (entry->skb != NULL &&
  63. time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
  64. IEEE80211_DEBUG_FRAG("expiring fragment cache entry "
  65. "seq=%u last_frag=%u\n",
  66. entry->seq, entry->last_frag);
  67. dev_kfree_skb_any(entry->skb);
  68. entry->skb = NULL;
  69. }
  70. if (entry->skb != NULL && entry->seq == seq &&
  71. (entry->last_frag + 1 == frag || frag == -1) &&
  72. !compare_ether_addr(entry->src_addr, src) &&
  73. !compare_ether_addr(entry->dst_addr, dst))
  74. return entry;
  75. }
  76. return NULL;
  77. }
  78. /* Called only as a tasklet (software IRQ) */
  79. static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
  80. struct ieee80211_hdr_4addr *hdr)
  81. {
  82. struct sk_buff *skb = NULL;
  83. u16 sc;
  84. unsigned int frag, seq;
  85. struct ieee80211_frag_entry *entry;
  86. sc = le16_to_cpu(hdr->seq_ctl);
  87. frag = WLAN_GET_SEQ_FRAG(sc);
  88. seq = WLAN_GET_SEQ_SEQ(sc);
  89. if (frag == 0) {
  90. /* Reserve enough space to fit maximum frame length */
  91. skb = dev_alloc_skb(ieee->dev->mtu +
  92. sizeof(struct ieee80211_hdr_4addr) +
  93. 8 /* LLC */ +
  94. 2 /* alignment */ +
  95. 8 /* WEP */ + ETH_ALEN /* WDS */ );
  96. if (skb == NULL)
  97. return NULL;
  98. entry = &ieee->frag_cache[ieee->frag_next_idx];
  99. ieee->frag_next_idx++;
  100. if (ieee->frag_next_idx >= IEEE80211_FRAG_CACHE_LEN)
  101. ieee->frag_next_idx = 0;
  102. if (entry->skb != NULL)
  103. dev_kfree_skb_any(entry->skb);
  104. entry->first_frag_time = jiffies;
  105. entry->seq = seq;
  106. entry->last_frag = frag;
  107. entry->skb = skb;
  108. memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
  109. memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
  110. } else {
  111. /* received a fragment of a frame for which the head fragment
  112. * should have already been received */
  113. entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
  114. hdr->addr1);
  115. if (entry != NULL) {
  116. entry->last_frag = frag;
  117. skb = entry->skb;
  118. }
  119. }
  120. return skb;
  121. }
  122. /* Called only as a tasklet (software IRQ) */
  123. static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
  124. struct ieee80211_hdr_4addr *hdr)
  125. {
  126. u16 sc;
  127. unsigned int seq;
  128. struct ieee80211_frag_entry *entry;
  129. sc = le16_to_cpu(hdr->seq_ctl);
  130. seq = WLAN_GET_SEQ_SEQ(sc);
  131. entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
  132. hdr->addr1);
  133. if (entry == NULL) {
  134. IEEE80211_DEBUG_FRAG("could not invalidate fragment cache "
  135. "entry (seq=%u)\n", seq);
  136. return -1;
  137. }
  138. entry->skb = NULL;
  139. return 0;
  140. }
  141. #ifdef NOT_YET
  142. /* ieee80211_rx_frame_mgtmt
  143. *
  144. * Responsible for handling management control frames
  145. *
  146. * Called by ieee80211_rx */
  147. static int
  148. ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
  149. struct ieee80211_rx_stats *rx_stats, u16 type,
  150. u16 stype)
  151. {
  152. if (ieee->iw_mode == IW_MODE_MASTER) {
  153. printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
  154. ieee->dev->name);
  155. return 0;
  156. /*
  157. hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
  158. skb->data);*/
  159. }
  160. if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
  161. if (stype == WLAN_FC_STYPE_BEACON &&
  162. ieee->iw_mode == IW_MODE_MASTER) {
  163. struct sk_buff *skb2;
  164. /* Process beacon frames also in kernel driver to
  165. * update STA(AP) table statistics */
  166. skb2 = skb_clone(skb, GFP_ATOMIC);
  167. if (skb2)
  168. hostap_rx(skb2->dev, skb2, rx_stats);
  169. }
  170. /* send management frames to the user space daemon for
  171. * processing */
  172. ieee->apdevstats.rx_packets++;
  173. ieee->apdevstats.rx_bytes += skb->len;
  174. prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
  175. return 0;
  176. }
  177. if (ieee->iw_mode == IW_MODE_MASTER) {
  178. if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
  179. printk(KERN_DEBUG "%s: unknown management frame "
  180. "(type=0x%02x, stype=0x%02x) dropped\n",
  181. skb->dev->name, type, stype);
  182. return -1;
  183. }
  184. hostap_rx(skb->dev, skb, rx_stats);
  185. return 0;
  186. }
  187. printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
  188. "received in non-Host AP mode\n", skb->dev->name);
  189. return -1;
  190. }
  191. #endif
  192. /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
  193. /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
  194. static unsigned char rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
  195. /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
  196. static unsigned char bridge_tunnel_header[] =
  197. { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
  198. /* No encapsulation header if EtherType < 0x600 (=length) */
  199. /* Called by ieee80211_rx_frame_decrypt */
  200. static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
  201. struct sk_buff *skb)
  202. {
  203. struct net_device *dev = ieee->dev;
  204. u16 fc, ethertype;
  205. struct ieee80211_hdr_3addr *hdr;
  206. u8 *pos;
  207. if (skb->len < 24)
  208. return 0;
  209. hdr = (struct ieee80211_hdr_3addr *)skb->data;
  210. fc = le16_to_cpu(hdr->frame_ctl);
  211. /* check that the frame is unicast frame to us */
  212. if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  213. IEEE80211_FCTL_TODS &&
  214. !compare_ether_addr(hdr->addr1, dev->dev_addr) &&
  215. !compare_ether_addr(hdr->addr3, dev->dev_addr)) {
  216. /* ToDS frame with own addr BSSID and DA */
  217. } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  218. IEEE80211_FCTL_FROMDS &&
  219. !compare_ether_addr(hdr->addr1, dev->dev_addr)) {
  220. /* FromDS frame with own addr as DA */
  221. } else
  222. return 0;
  223. if (skb->len < 24 + 8)
  224. return 0;
  225. /* check for port access entity Ethernet type */
  226. pos = skb->data + 24;
  227. ethertype = (pos[6] << 8) | pos[7];
  228. if (ethertype == ETH_P_PAE)
  229. return 1;
  230. return 0;
  231. }
  232. /* Called only as a tasklet (software IRQ), by ieee80211_rx */
  233. static int
  234. ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
  235. struct ieee80211_crypt_data *crypt)
  236. {
  237. struct ieee80211_hdr_3addr *hdr;
  238. int res, hdrlen;
  239. if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
  240. return 0;
  241. hdr = (struct ieee80211_hdr_3addr *)skb->data;
  242. hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
  243. atomic_inc(&crypt->refcnt);
  244. res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
  245. atomic_dec(&crypt->refcnt);
  246. if (res < 0) {
  247. IEEE80211_DEBUG_DROP("decryption failed (SA=" MAC_FMT
  248. ") res=%d\n", MAC_ARG(hdr->addr2), res);
  249. if (res == -2)
  250. IEEE80211_DEBUG_DROP("Decryption failed ICV "
  251. "mismatch (key %d)\n",
  252. skb->data[hdrlen + 3] >> 6);
  253. ieee->ieee_stats.rx_discards_undecryptable++;
  254. return -1;
  255. }
  256. return res;
  257. }
  258. /* Called only as a tasklet (software IRQ), by ieee80211_rx */
  259. static int
  260. ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
  261. struct sk_buff *skb, int keyidx,
  262. struct ieee80211_crypt_data *crypt)
  263. {
  264. struct ieee80211_hdr_3addr *hdr;
  265. int res, hdrlen;
  266. if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
  267. return 0;
  268. hdr = (struct ieee80211_hdr_3addr *)skb->data;
  269. hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
  270. atomic_inc(&crypt->refcnt);
  271. res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
  272. atomic_dec(&crypt->refcnt);
  273. if (res < 0) {
  274. printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
  275. " (SA=" MAC_FMT " keyidx=%d)\n",
  276. ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
  277. return -1;
  278. }
  279. return 0;
  280. }
  281. /* All received frames are sent to this function. @skb contains the frame in
  282. * IEEE 802.11 format, i.e., in the format it was sent over air.
  283. * This function is called only as a tasklet (software IRQ). */
  284. int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  285. struct ieee80211_rx_stats *rx_stats)
  286. {
  287. struct net_device *dev = ieee->dev;
  288. struct ieee80211_hdr_4addr *hdr;
  289. size_t hdrlen;
  290. u16 fc, type, stype, sc;
  291. struct net_device_stats *stats;
  292. unsigned int frag;
  293. u8 *payload;
  294. u16 ethertype;
  295. #ifdef NOT_YET
  296. struct net_device *wds = NULL;
  297. struct sk_buff *skb2 = NULL;
  298. struct net_device *wds = NULL;
  299. int frame_authorized = 0;
  300. int from_assoc_ap = 0;
  301. void *sta = NULL;
  302. #endif
  303. u8 dst[ETH_ALEN];
  304. u8 src[ETH_ALEN];
  305. struct ieee80211_crypt_data *crypt = NULL;
  306. int keyidx = 0;
  307. int can_be_decrypted = 0;
  308. hdr = (struct ieee80211_hdr_4addr *)skb->data;
  309. stats = &ieee->stats;
  310. if (skb->len < 10) {
  311. printk(KERN_INFO "%s: SKB length < 10\n", dev->name);
  312. goto rx_dropped;
  313. }
  314. fc = le16_to_cpu(hdr->frame_ctl);
  315. type = WLAN_FC_GET_TYPE(fc);
  316. stype = WLAN_FC_GET_STYPE(fc);
  317. sc = le16_to_cpu(hdr->seq_ctl);
  318. frag = WLAN_GET_SEQ_FRAG(sc);
  319. hdrlen = ieee80211_get_hdrlen(fc);
  320. /* Put this code here so that we avoid duplicating it in all
  321. * Rx paths. - Jean II */
  322. #ifdef CONFIG_WIRELESS_EXT
  323. #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
  324. /* If spy monitoring on */
  325. if (ieee->spy_data.spy_number > 0) {
  326. struct iw_quality wstats;
  327. wstats.updated = 0;
  328. if (rx_stats->mask & IEEE80211_STATMASK_RSSI) {
  329. wstats.level = rx_stats->rssi;
  330. wstats.updated |= IW_QUAL_LEVEL_UPDATED;
  331. } else
  332. wstats.updated |= IW_QUAL_LEVEL_INVALID;
  333. if (rx_stats->mask & IEEE80211_STATMASK_NOISE) {
  334. wstats.noise = rx_stats->noise;
  335. wstats.updated |= IW_QUAL_NOISE_UPDATED;
  336. } else
  337. wstats.updated |= IW_QUAL_NOISE_INVALID;
  338. if (rx_stats->mask & IEEE80211_STATMASK_SIGNAL) {
  339. wstats.qual = rx_stats->signal;
  340. wstats.updated |= IW_QUAL_QUAL_UPDATED;
  341. } else
  342. wstats.updated |= IW_QUAL_QUAL_INVALID;
  343. /* Update spy records */
  344. wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
  345. }
  346. #endif /* IW_WIRELESS_SPY */
  347. #endif /* CONFIG_WIRELESS_EXT */
  348. #ifdef NOT_YET
  349. hostap_update_rx_stats(local->ap, hdr, rx_stats);
  350. #endif
  351. if (ieee->iw_mode == IW_MODE_MONITOR) {
  352. ieee80211_monitor_rx(ieee, skb, rx_stats);
  353. stats->rx_packets++;
  354. stats->rx_bytes += skb->len;
  355. return 1;
  356. }
  357. can_be_decrypted = (is_multicast_ether_addr(hdr->addr1) ||
  358. is_broadcast_ether_addr(hdr->addr2)) ?
  359. ieee->host_mc_decrypt : ieee->host_decrypt;
  360. if (can_be_decrypted) {
  361. int idx = 0;
  362. if (skb->len >= hdrlen + 3) {
  363. /* Top two-bits of byte 3 are the key index */
  364. idx = skb->data[hdrlen + 3] >> 6;
  365. }
  366. /* ieee->crypt[] is WEP_KEY (4) in length. Given that idx
  367. * is only allowed 2-bits of storage, no value of idx can
  368. * be provided via above code that would result in idx
  369. * being out of range */
  370. crypt = ieee->crypt[idx];
  371. #ifdef NOT_YET
  372. sta = NULL;
  373. /* Use station specific key to override default keys if the
  374. * receiver address is a unicast address ("individual RA"). If
  375. * bcrx_sta_key parameter is set, station specific key is used
  376. * even with broad/multicast targets (this is against IEEE
  377. * 802.11, but makes it easier to use different keys with
  378. * stations that do not support WEP key mapping). */
  379. if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
  380. (void)hostap_handle_sta_crypto(local, hdr, &crypt,
  381. &sta);
  382. #endif
  383. /* allow NULL decrypt to indicate an station specific override
  384. * for default encryption */
  385. if (crypt && (crypt->ops == NULL ||
  386. crypt->ops->decrypt_mpdu == NULL))
  387. crypt = NULL;
  388. if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
  389. /* This seems to be triggered by some (multicast?)
  390. * frames from other than current BSS, so just drop the
  391. * frames silently instead of filling system log with
  392. * these reports. */
  393. IEEE80211_DEBUG_DROP("Decryption failed (not set)"
  394. " (SA=" MAC_FMT ")\n",
  395. MAC_ARG(hdr->addr2));
  396. ieee->ieee_stats.rx_discards_undecryptable++;
  397. goto rx_dropped;
  398. }
  399. }
  400. #ifdef NOT_YET
  401. if (type != WLAN_FC_TYPE_DATA) {
  402. if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
  403. fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
  404. (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) {
  405. printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
  406. "from " MAC_FMT "\n", dev->name,
  407. MAC_ARG(hdr->addr2));
  408. /* TODO: could inform hostapd about this so that it
  409. * could send auth failure report */
  410. goto rx_dropped;
  411. }
  412. if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
  413. goto rx_dropped;
  414. else
  415. goto rx_exit;
  416. }
  417. #endif
  418. /* Data frame - extract src/dst addresses */
  419. if (skb->len < IEEE80211_3ADDR_LEN)
  420. goto rx_dropped;
  421. switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
  422. case IEEE80211_FCTL_FROMDS:
  423. memcpy(dst, hdr->addr1, ETH_ALEN);
  424. memcpy(src, hdr->addr3, ETH_ALEN);
  425. break;
  426. case IEEE80211_FCTL_TODS:
  427. memcpy(dst, hdr->addr3, ETH_ALEN);
  428. memcpy(src, hdr->addr2, ETH_ALEN);
  429. break;
  430. case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
  431. if (skb->len < IEEE80211_4ADDR_LEN)
  432. goto rx_dropped;
  433. memcpy(dst, hdr->addr3, ETH_ALEN);
  434. memcpy(src, hdr->addr4, ETH_ALEN);
  435. break;
  436. case 0:
  437. memcpy(dst, hdr->addr1, ETH_ALEN);
  438. memcpy(src, hdr->addr2, ETH_ALEN);
  439. break;
  440. }
  441. #ifdef NOT_YET
  442. if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
  443. goto rx_dropped;
  444. if (wds) {
  445. skb->dev = dev = wds;
  446. stats = hostap_get_stats(dev);
  447. }
  448. if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
  449. (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  450. IEEE80211_FCTL_FROMDS && ieee->stadev
  451. && !compare_ether_addr(hdr->addr2, ieee->assoc_ap_addr)) {
  452. /* Frame from BSSID of the AP for which we are a client */
  453. skb->dev = dev = ieee->stadev;
  454. stats = hostap_get_stats(dev);
  455. from_assoc_ap = 1;
  456. }
  457. #endif
  458. dev->last_rx = jiffies;
  459. #ifdef NOT_YET
  460. if ((ieee->iw_mode == IW_MODE_MASTER ||
  461. ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) {
  462. switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
  463. wds != NULL)) {
  464. case AP_RX_CONTINUE_NOT_AUTHORIZED:
  465. frame_authorized = 0;
  466. break;
  467. case AP_RX_CONTINUE:
  468. frame_authorized = 1;
  469. break;
  470. case AP_RX_DROP:
  471. goto rx_dropped;
  472. case AP_RX_EXIT:
  473. goto rx_exit;
  474. }
  475. }
  476. #endif
  477. /* Nullfunc frames may have PS-bit set, so they must be passed to
  478. * hostap_handle_sta_rx() before being dropped here. */
  479. stype &= ~IEEE80211_STYPE_QOS_DATA;
  480. if (stype != IEEE80211_STYPE_DATA &&
  481. stype != IEEE80211_STYPE_DATA_CFACK &&
  482. stype != IEEE80211_STYPE_DATA_CFPOLL &&
  483. stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
  484. if (stype != IEEE80211_STYPE_NULLFUNC)
  485. IEEE80211_DEBUG_DROP("RX: dropped data frame "
  486. "with no data (type=0x%02x, "
  487. "subtype=0x%02x, len=%d)\n",
  488. type, stype, skb->len);
  489. goto rx_dropped;
  490. }
  491. /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
  492. if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
  493. (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
  494. goto rx_dropped;
  495. hdr = (struct ieee80211_hdr_4addr *)skb->data;
  496. /* skb: hdr + (possibly fragmented) plaintext payload */
  497. // PR: FIXME: hostap has additional conditions in the "if" below:
  498. // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
  499. if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) {
  500. int flen;
  501. struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
  502. IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
  503. if (!frag_skb) {
  504. IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
  505. "Rx cannot get skb from fragment "
  506. "cache (morefrag=%d seq=%u frag=%u)\n",
  507. (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
  508. WLAN_GET_SEQ_SEQ(sc), frag);
  509. goto rx_dropped;
  510. }
  511. flen = skb->len;
  512. if (frag != 0)
  513. flen -= hdrlen;
  514. if (frag_skb->tail + flen > frag_skb->end) {
  515. printk(KERN_WARNING "%s: host decrypted and "
  516. "reassembled frame did not fit skb\n",
  517. dev->name);
  518. ieee80211_frag_cache_invalidate(ieee, hdr);
  519. goto rx_dropped;
  520. }
  521. if (frag == 0) {
  522. /* copy first fragment (including full headers) into
  523. * beginning of the fragment cache skb */
  524. memcpy(skb_put(frag_skb, flen), skb->data, flen);
  525. } else {
  526. /* append frame payload to the end of the fragment
  527. * cache skb */
  528. memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
  529. flen);
  530. }
  531. dev_kfree_skb_any(skb);
  532. skb = NULL;
  533. if (fc & IEEE80211_FCTL_MOREFRAGS) {
  534. /* more fragments expected - leave the skb in fragment
  535. * cache for now; it will be delivered to upper layers
  536. * after all fragments have been received */
  537. goto rx_exit;
  538. }
  539. /* this was the last fragment and the frame will be
  540. * delivered, so remove skb from fragment cache */
  541. skb = frag_skb;
  542. hdr = (struct ieee80211_hdr_4addr *)skb->data;
  543. ieee80211_frag_cache_invalidate(ieee, hdr);
  544. }
  545. /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
  546. * encrypted/authenticated */
  547. if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
  548. ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
  549. goto rx_dropped;
  550. hdr = (struct ieee80211_hdr_4addr *)skb->data;
  551. if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
  552. if ( /*ieee->ieee802_1x && */
  553. ieee80211_is_eapol_frame(ieee, skb)) {
  554. /* pass unencrypted EAPOL frames even if encryption is
  555. * configured */
  556. } else {
  557. IEEE80211_DEBUG_DROP("encryption configured, but RX "
  558. "frame not encrypted (SA=" MAC_FMT
  559. ")\n", MAC_ARG(hdr->addr2));
  560. goto rx_dropped;
  561. }
  562. }
  563. if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
  564. !ieee80211_is_eapol_frame(ieee, skb)) {
  565. IEEE80211_DEBUG_DROP("dropped unencrypted RX data "
  566. "frame from " MAC_FMT
  567. " (drop_unencrypted=1)\n",
  568. MAC_ARG(hdr->addr2));
  569. goto rx_dropped;
  570. }
  571. /* skb: hdr + (possible reassembled) full plaintext payload */
  572. payload = skb->data + hdrlen;
  573. ethertype = (payload[6] << 8) | payload[7];
  574. #ifdef NOT_YET
  575. /* If IEEE 802.1X is used, check whether the port is authorized to send
  576. * the received frame. */
  577. if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
  578. if (ethertype == ETH_P_PAE) {
  579. printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
  580. dev->name);
  581. if (ieee->hostapd && ieee->apdev) {
  582. /* Send IEEE 802.1X frames to the user
  583. * space daemon for processing */
  584. prism2_rx_80211(ieee->apdev, skb, rx_stats,
  585. PRISM2_RX_MGMT);
  586. ieee->apdevstats.rx_packets++;
  587. ieee->apdevstats.rx_bytes += skb->len;
  588. goto rx_exit;
  589. }
  590. } else if (!frame_authorized) {
  591. printk(KERN_DEBUG "%s: dropped frame from "
  592. "unauthorized port (IEEE 802.1X): "
  593. "ethertype=0x%04x\n", dev->name, ethertype);
  594. goto rx_dropped;
  595. }
  596. }
  597. #endif
  598. /* convert hdr + possible LLC headers into Ethernet header */
  599. if (skb->len - hdrlen >= 8 &&
  600. ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
  601. ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
  602. memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
  603. /* remove RFC1042 or Bridge-Tunnel encapsulation and
  604. * replace EtherType */
  605. skb_pull(skb, hdrlen + SNAP_SIZE);
  606. memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
  607. memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
  608. } else {
  609. u16 len;
  610. /* Leave Ethernet header part of hdr and full payload */
  611. skb_pull(skb, hdrlen);
  612. len = htons(skb->len);
  613. memcpy(skb_push(skb, 2), &len, 2);
  614. memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
  615. memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
  616. }
  617. #ifdef NOT_YET
  618. if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  619. IEEE80211_FCTL_TODS) && skb->len >= ETH_HLEN + ETH_ALEN) {
  620. /* Non-standard frame: get addr4 from its bogus location after
  621. * the payload */
  622. memcpy(skb->data + ETH_ALEN,
  623. skb->data + skb->len - ETH_ALEN, ETH_ALEN);
  624. skb_trim(skb, skb->len - ETH_ALEN);
  625. }
  626. #endif
  627. stats->rx_packets++;
  628. stats->rx_bytes += skb->len;
  629. #ifdef NOT_YET
  630. if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) {
  631. if (dst[0] & 0x01) {
  632. /* copy multicast frame both to the higher layers and
  633. * to the wireless media */
  634. ieee->ap->bridged_multicast++;
  635. skb2 = skb_clone(skb, GFP_ATOMIC);
  636. if (skb2 == NULL)
  637. printk(KERN_DEBUG "%s: skb_clone failed for "
  638. "multicast frame\n", dev->name);
  639. } else if (hostap_is_sta_assoc(ieee->ap, dst)) {
  640. /* send frame directly to the associated STA using
  641. * wireless media and not passing to higher layers */
  642. ieee->ap->bridged_unicast++;
  643. skb2 = skb;
  644. skb = NULL;
  645. }
  646. }
  647. if (skb2 != NULL) {
  648. /* send to wireless media */
  649. skb2->protocol = __constant_htons(ETH_P_802_3);
  650. skb2->mac.raw = skb2->nh.raw = skb2->data;
  651. /* skb2->nh.raw = skb2->data + ETH_HLEN; */
  652. skb2->dev = dev;
  653. dev_queue_xmit(skb2);
  654. }
  655. #endif
  656. if (skb) {
  657. skb->protocol = eth_type_trans(skb, dev);
  658. memset(skb->cb, 0, sizeof(skb->cb));
  659. skb->dev = dev;
  660. skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
  661. if (netif_rx(skb) == NET_RX_DROP) {
  662. /* netif_rx always succeeds, but it might drop
  663. * the packet. If it drops the packet, we log that
  664. * in our stats. */
  665. IEEE80211_DEBUG_DROP
  666. ("RX: netif_rx dropped the packet\n");
  667. stats->rx_dropped++;
  668. }
  669. }
  670. rx_exit:
  671. #ifdef NOT_YET
  672. if (sta)
  673. hostap_handle_sta_release(sta);
  674. #endif
  675. return 1;
  676. rx_dropped:
  677. stats->rx_dropped++;
  678. /* Returning 0 indicates to caller that we have not handled the SKB--
  679. * so it is still allocated and can be used again by underlying
  680. * hardware as a DMA target */
  681. return 0;
  682. }
  683. /* Filter out unrelated packets, call ieee80211_rx[_mgt] */
  684. int ieee80211_rx_any(struct ieee80211_device *ieee,
  685. struct sk_buff *skb, struct ieee80211_rx_stats *stats)
  686. {
  687. struct ieee80211_hdr_4addr *hdr;
  688. int is_packet_for_us;
  689. u16 fc;
  690. if (ieee->iw_mode == IW_MODE_MONITOR)
  691. return ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL;
  692. hdr = (struct ieee80211_hdr_4addr *)skb->data;
  693. fc = le16_to_cpu(hdr->frame_ctl);
  694. if ((fc & IEEE80211_FCTL_VERS) != 0)
  695. return -EINVAL;
  696. switch (fc & IEEE80211_FCTL_FTYPE) {
  697. case IEEE80211_FTYPE_MGMT:
  698. ieee80211_rx_mgt(ieee, hdr, stats);
  699. return 0;
  700. case IEEE80211_FTYPE_DATA:
  701. break;
  702. case IEEE80211_FTYPE_CTL:
  703. return 0;
  704. default:
  705. return -EINVAL;
  706. }
  707. is_packet_for_us = 0;
  708. switch (ieee->iw_mode) {
  709. case IW_MODE_ADHOC:
  710. /* our BSS and not from/to DS */
  711. if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0)
  712. if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
  713. /* promisc: get all */
  714. if (ieee->dev->flags & IFF_PROMISC)
  715. is_packet_for_us = 1;
  716. /* to us */
  717. else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
  718. is_packet_for_us = 1;
  719. /* mcast */
  720. else if (is_multicast_ether_addr(hdr->addr1))
  721. is_packet_for_us = 1;
  722. }
  723. break;
  724. case IW_MODE_INFRA:
  725. /* our BSS (== from our AP) and from DS */
  726. if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0)
  727. if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
  728. /* promisc: get all */
  729. if (ieee->dev->flags & IFF_PROMISC)
  730. is_packet_for_us = 1;
  731. /* to us */
  732. else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
  733. is_packet_for_us = 1;
  734. /* mcast */
  735. else if (is_multicast_ether_addr(hdr->addr1)) {
  736. /* not our own packet bcasted from AP */
  737. if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN))
  738. is_packet_for_us = 1;
  739. }
  740. }
  741. break;
  742. default:
  743. /* ? */
  744. break;
  745. }
  746. if (is_packet_for_us)
  747. return (ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL);
  748. return 0;
  749. }
  750. #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
  751. static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
  752. /*
  753. * Make ther structure we read from the beacon packet has
  754. * the right values
  755. */
  756. static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
  757. *info_element, int sub_type)
  758. {
  759. if (info_element->qui_subtype != sub_type)
  760. return -1;
  761. if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
  762. return -1;
  763. if (info_element->qui_type != QOS_OUI_TYPE)
  764. return -1;
  765. if (info_element->version != QOS_VERSION_1)
  766. return -1;
  767. return 0;
  768. }
  769. /*
  770. * Parse a QoS parameter element
  771. */
  772. static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
  773. *element_param, struct ieee80211_info_element
  774. *info_element)
  775. {
  776. int ret = 0;
  777. u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
  778. if ((info_element == NULL) || (element_param == NULL))
  779. return -1;
  780. if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
  781. memcpy(element_param->info_element.qui, info_element->data,
  782. info_element->len);
  783. element_param->info_element.elementID = info_element->id;
  784. element_param->info_element.length = info_element->len;
  785. } else
  786. ret = -1;
  787. if (ret == 0)
  788. ret = ieee80211_verify_qos_info(&element_param->info_element,
  789. QOS_OUI_PARAM_SUB_TYPE);
  790. return ret;
  791. }
  792. /*
  793. * Parse a QoS information element
  794. */
  795. static int ieee80211_read_qos_info_element(struct
  796. ieee80211_qos_information_element
  797. *element_info, struct ieee80211_info_element
  798. *info_element)
  799. {
  800. int ret = 0;
  801. u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
  802. if (element_info == NULL)
  803. return -1;
  804. if (info_element == NULL)
  805. return -1;
  806. if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
  807. memcpy(element_info->qui, info_element->data,
  808. info_element->len);
  809. element_info->elementID = info_element->id;
  810. element_info->length = info_element->len;
  811. } else
  812. ret = -1;
  813. if (ret == 0)
  814. ret = ieee80211_verify_qos_info(element_info,
  815. QOS_OUI_INFO_SUB_TYPE);
  816. return ret;
  817. }
  818. /*
  819. * Write QoS parameters from the ac parameters.
  820. */
  821. static int ieee80211_qos_convert_ac_to_parameters(struct
  822. ieee80211_qos_parameter_info
  823. *param_elm, struct
  824. ieee80211_qos_parameters
  825. *qos_param)
  826. {
  827. int rc = 0;
  828. int i;
  829. struct ieee80211_qos_ac_parameter *ac_params;
  830. u32 txop;
  831. u8 cw_min;
  832. u8 cw_max;
  833. for (i = 0; i < QOS_QUEUE_NUM; i++) {
  834. ac_params = &(param_elm->ac_params_record[i]);
  835. qos_param->aifs[i] = (ac_params->aci_aifsn) & 0x0F;
  836. qos_param->aifs[i] -= (qos_param->aifs[i] < 2) ? 0 : 2;
  837. cw_min = ac_params->ecw_min_max & 0x0F;
  838. qos_param->cw_min[i] = (u16) ((1 << cw_min) - 1);
  839. cw_max = (ac_params->ecw_min_max & 0xF0) >> 4;
  840. qos_param->cw_max[i] = (u16) ((1 << cw_max) - 1);
  841. qos_param->flag[i] =
  842. (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
  843. txop = le16_to_cpu(ac_params->tx_op_limit) * 32;
  844. qos_param->tx_op_limit[i] = (u16) txop;
  845. }
  846. return rc;
  847. }
  848. /*
  849. * we have a generic data element which it may contain QoS information or
  850. * parameters element. check the information element length to decide
  851. * which type to read
  852. */
  853. static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
  854. *info_element,
  855. struct ieee80211_network *network)
  856. {
  857. int rc = 0;
  858. struct ieee80211_qos_parameters *qos_param = NULL;
  859. struct ieee80211_qos_information_element qos_info_element;
  860. rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
  861. if (rc == 0) {
  862. network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
  863. network->flags |= NETWORK_HAS_QOS_INFORMATION;
  864. } else {
  865. struct ieee80211_qos_parameter_info param_element;
  866. rc = ieee80211_read_qos_param_element(&param_element,
  867. info_element);
  868. if (rc == 0) {
  869. qos_param = &(network->qos_data.parameters);
  870. ieee80211_qos_convert_ac_to_parameters(&param_element,
  871. qos_param);
  872. network->flags |= NETWORK_HAS_QOS_PARAMETERS;
  873. network->qos_data.param_count =
  874. param_element.info_element.ac_info & 0x0F;
  875. }
  876. }
  877. if (rc == 0) {
  878. IEEE80211_DEBUG_QOS("QoS is supported\n");
  879. network->qos_data.supported = 1;
  880. }
  881. return rc;
  882. }
  883. #ifdef CONFIG_IEEE80211_DEBUG
  884. #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
  885. static const char *get_info_element_string(u16 id)
  886. {
  887. switch (id) {
  888. MFIE_STRING(SSID);
  889. MFIE_STRING(RATES);
  890. MFIE_STRING(FH_SET);
  891. MFIE_STRING(DS_SET);
  892. MFIE_STRING(CF_SET);
  893. MFIE_STRING(TIM);
  894. MFIE_STRING(IBSS_SET);
  895. MFIE_STRING(COUNTRY);
  896. MFIE_STRING(HOP_PARAMS);
  897. MFIE_STRING(HOP_TABLE);
  898. MFIE_STRING(REQUEST);
  899. MFIE_STRING(CHALLENGE);
  900. MFIE_STRING(POWER_CONSTRAINT);
  901. MFIE_STRING(POWER_CAPABILITY);
  902. MFIE_STRING(TPC_REQUEST);
  903. MFIE_STRING(TPC_REPORT);
  904. MFIE_STRING(SUPP_CHANNELS);
  905. MFIE_STRING(CSA);
  906. MFIE_STRING(MEASURE_REQUEST);
  907. MFIE_STRING(MEASURE_REPORT);
  908. MFIE_STRING(QUIET);
  909. MFIE_STRING(IBSS_DFS);
  910. MFIE_STRING(ERP_INFO);
  911. MFIE_STRING(RSN);
  912. MFIE_STRING(RATES_EX);
  913. MFIE_STRING(GENERIC);
  914. MFIE_STRING(QOS_PARAMETER);
  915. default:
  916. return "UNKNOWN";
  917. }
  918. }
  919. #endif
  920. static int ieee80211_parse_info_param(struct ieee80211_info_element
  921. *info_element, u16 length,
  922. struct ieee80211_network *network)
  923. {
  924. u8 i;
  925. #ifdef CONFIG_IEEE80211_DEBUG
  926. char rates_str[64];
  927. char *p;
  928. #endif
  929. while (length >= sizeof(*info_element)) {
  930. if (sizeof(*info_element) + info_element->len > length) {
  931. IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
  932. "info_element->len + 2 > left : "
  933. "info_element->len+2=%zd left=%d, id=%d.\n",
  934. info_element->len +
  935. sizeof(*info_element),
  936. length, info_element->id);
  937. return 1;
  938. }
  939. switch (info_element->id) {
  940. case MFIE_TYPE_SSID:
  941. if (ieee80211_is_empty_essid(info_element->data,
  942. info_element->len)) {
  943. network->flags |= NETWORK_EMPTY_ESSID;
  944. break;
  945. }
  946. network->ssid_len = min(info_element->len,
  947. (u8) IW_ESSID_MAX_SIZE);
  948. memcpy(network->ssid, info_element->data,
  949. network->ssid_len);
  950. if (network->ssid_len < IW_ESSID_MAX_SIZE)
  951. memset(network->ssid + network->ssid_len, 0,
  952. IW_ESSID_MAX_SIZE - network->ssid_len);
  953. IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
  954. network->ssid, network->ssid_len);
  955. break;
  956. case MFIE_TYPE_RATES:
  957. #ifdef CONFIG_IEEE80211_DEBUG
  958. p = rates_str;
  959. #endif
  960. network->rates_len = min(info_element->len,
  961. MAX_RATES_LENGTH);
  962. for (i = 0; i < network->rates_len; i++) {
  963. network->rates[i] = info_element->data[i];
  964. #ifdef CONFIG_IEEE80211_DEBUG
  965. p += snprintf(p, sizeof(rates_str) -
  966. (p - rates_str), "%02X ",
  967. network->rates[i]);
  968. #endif
  969. if (ieee80211_is_ofdm_rate
  970. (info_element->data[i])) {
  971. network->flags |= NETWORK_HAS_OFDM;
  972. if (info_element->data[i] &
  973. IEEE80211_BASIC_RATE_MASK)
  974. network->flags &=
  975. ~NETWORK_HAS_CCK;
  976. }
  977. }
  978. IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
  979. rates_str, network->rates_len);
  980. break;
  981. case MFIE_TYPE_RATES_EX:
  982. #ifdef CONFIG_IEEE80211_DEBUG
  983. p = rates_str;
  984. #endif
  985. network->rates_ex_len = min(info_element->len,
  986. MAX_RATES_EX_LENGTH);
  987. for (i = 0; i < network->rates_ex_len; i++) {
  988. network->rates_ex[i] = info_element->data[i];
  989. #ifdef CONFIG_IEEE80211_DEBUG
  990. p += snprintf(p, sizeof(rates_str) -
  991. (p - rates_str), "%02X ",
  992. network->rates[i]);
  993. #endif
  994. if (ieee80211_is_ofdm_rate
  995. (info_element->data[i])) {
  996. network->flags |= NETWORK_HAS_OFDM;
  997. if (info_element->data[i] &
  998. IEEE80211_BASIC_RATE_MASK)
  999. network->flags &=
  1000. ~NETWORK_HAS_CCK;
  1001. }
  1002. }
  1003. IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
  1004. rates_str, network->rates_ex_len);
  1005. break;
  1006. case MFIE_TYPE_DS_SET:
  1007. IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
  1008. info_element->data[0]);
  1009. network->channel = info_element->data[0];
  1010. break;
  1011. case MFIE_TYPE_FH_SET:
  1012. IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
  1013. break;
  1014. case MFIE_TYPE_CF_SET:
  1015. IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
  1016. break;
  1017. case MFIE_TYPE_TIM:
  1018. network->tim.tim_count = info_element->data[0];
  1019. network->tim.tim_period = info_element->data[1];
  1020. IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
  1021. break;
  1022. case MFIE_TYPE_ERP_INFO:
  1023. network->erp_value = info_element->data[0];
  1024. IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
  1025. network->erp_value);
  1026. break;
  1027. case MFIE_TYPE_IBSS_SET:
  1028. network->atim_window = info_element->data[0];
  1029. IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
  1030. network->atim_window);
  1031. break;
  1032. case MFIE_TYPE_CHALLENGE:
  1033. IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
  1034. break;
  1035. case MFIE_TYPE_GENERIC:
  1036. IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
  1037. info_element->len);
  1038. if (!ieee80211_parse_qos_info_param_IE(info_element,
  1039. network))
  1040. break;
  1041. if (info_element->len >= 4 &&
  1042. info_element->data[0] == 0x00 &&
  1043. info_element->data[1] == 0x50 &&
  1044. info_element->data[2] == 0xf2 &&
  1045. info_element->data[3] == 0x01) {
  1046. network->wpa_ie_len = min(info_element->len + 2,
  1047. MAX_WPA_IE_LEN);
  1048. memcpy(network->wpa_ie, info_element,
  1049. network->wpa_ie_len);
  1050. }
  1051. break;
  1052. case MFIE_TYPE_RSN:
  1053. IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
  1054. info_element->len);
  1055. network->rsn_ie_len = min(info_element->len + 2,
  1056. MAX_WPA_IE_LEN);
  1057. memcpy(network->rsn_ie, info_element,
  1058. network->rsn_ie_len);
  1059. break;
  1060. case MFIE_TYPE_QOS_PARAMETER:
  1061. printk(KERN_ERR
  1062. "QoS Error need to parse QOS_PARAMETER IE\n");
  1063. break;
  1064. /* 802.11h */
  1065. case MFIE_TYPE_POWER_CONSTRAINT:
  1066. network->power_constraint = info_element->data[0];
  1067. network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
  1068. break;
  1069. case MFIE_TYPE_CSA:
  1070. network->power_constraint = info_element->data[0];
  1071. network->flags |= NETWORK_HAS_CSA;
  1072. break;
  1073. case MFIE_TYPE_QUIET:
  1074. network->quiet.count = info_element->data[0];
  1075. network->quiet.period = info_element->data[1];
  1076. network->quiet.duration = info_element->data[2];
  1077. network->quiet.offset = info_element->data[3];
  1078. network->flags |= NETWORK_HAS_QUIET;
  1079. break;
  1080. case MFIE_TYPE_IBSS_DFS:
  1081. if (network->ibss_dfs)
  1082. break;
  1083. network->ibss_dfs =
  1084. kmalloc(info_element->len, GFP_ATOMIC);
  1085. if (!network->ibss_dfs)
  1086. return 1;
  1087. memcpy(network->ibss_dfs, info_element->data,
  1088. info_element->len);
  1089. network->flags |= NETWORK_HAS_IBSS_DFS;
  1090. break;
  1091. case MFIE_TYPE_TPC_REPORT:
  1092. network->tpc_report.transmit_power =
  1093. info_element->data[0];
  1094. network->tpc_report.link_margin = info_element->data[1];
  1095. network->flags |= NETWORK_HAS_TPC_REPORT;
  1096. break;
  1097. default:
  1098. IEEE80211_DEBUG_MGMT
  1099. ("Unsupported info element: %s (%d)\n",
  1100. get_info_element_string(info_element->id),
  1101. info_element->id);
  1102. break;
  1103. }
  1104. length -= sizeof(*info_element) + info_element->len;
  1105. info_element =
  1106. (struct ieee80211_info_element *)&info_element->
  1107. data[info_element->len];
  1108. }
  1109. return 0;
  1110. }
  1111. static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct ieee80211_assoc_response
  1112. *frame, struct ieee80211_rx_stats *stats)
  1113. {
  1114. struct ieee80211_network network_resp = {
  1115. .ibss_dfs = NULL,
  1116. };
  1117. struct ieee80211_network *network = &network_resp;
  1118. struct net_device *dev = ieee->dev;
  1119. network->flags = 0;
  1120. network->qos_data.active = 0;
  1121. network->qos_data.supported = 0;
  1122. network->qos_data.param_count = 0;
  1123. network->qos_data.old_param_count = 0;
  1124. //network->atim_window = le16_to_cpu(frame->aid) & (0x3FFF);
  1125. network->atim_window = le16_to_cpu(frame->aid);
  1126. network->listen_interval = le16_to_cpu(frame->status);
  1127. memcpy(network->bssid, frame->header.addr3, ETH_ALEN);
  1128. network->capability = le16_to_cpu(frame->capability);
  1129. network->last_scanned = jiffies;
  1130. network->rates_len = network->rates_ex_len = 0;
  1131. network->last_associate = 0;
  1132. network->ssid_len = 0;
  1133. network->erp_value =
  1134. (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
  1135. if (stats->freq == IEEE80211_52GHZ_BAND) {
  1136. /* for A band (No DS info) */
  1137. network->channel = stats->received_channel;
  1138. } else
  1139. network->flags |= NETWORK_HAS_CCK;
  1140. network->wpa_ie_len = 0;
  1141. network->rsn_ie_len = 0;
  1142. if (ieee80211_parse_info_param
  1143. (frame->info_element, stats->len - sizeof(*frame), network))
  1144. return 1;
  1145. network->mode = 0;
  1146. if (stats->freq == IEEE80211_52GHZ_BAND)
  1147. network->mode = IEEE_A;
  1148. else {
  1149. if (network->flags & NETWORK_HAS_OFDM)
  1150. network->mode |= IEEE_G;
  1151. if (network->flags & NETWORK_HAS_CCK)
  1152. network->mode |= IEEE_B;
  1153. }
  1154. if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
  1155. network->flags |= NETWORK_EMPTY_ESSID;
  1156. memcpy(&network->stats, stats, sizeof(network->stats));
  1157. if (ieee->handle_assoc_response != NULL)
  1158. ieee->handle_assoc_response(dev, frame, network);
  1159. return 0;
  1160. }
  1161. /***************************************************/
  1162. static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee80211_probe_response
  1163. *beacon,
  1164. struct ieee80211_network *network,
  1165. struct ieee80211_rx_stats *stats)
  1166. {
  1167. network->qos_data.active = 0;
  1168. network->qos_data.supported = 0;
  1169. network->qos_data.param_count = 0;
  1170. network->qos_data.old_param_count = 0;
  1171. /* Pull out fixed field data */
  1172. memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
  1173. network->capability = le16_to_cpu(beacon->capability);
  1174. network->last_scanned = jiffies;
  1175. network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
  1176. network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
  1177. network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
  1178. /* Where to pull this? beacon->listen_interval; */
  1179. network->listen_interval = 0x0A;
  1180. network->rates_len = network->rates_ex_len = 0;
  1181. network->last_associate = 0;
  1182. network->ssid_len = 0;
  1183. network->flags = 0;
  1184. network->atim_window = 0;
  1185. network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
  1186. 0x3 : 0x0;
  1187. if (stats->freq == IEEE80211_52GHZ_BAND) {
  1188. /* for A band (No DS info) */
  1189. network->channel = stats->received_channel;
  1190. } else
  1191. network->flags |= NETWORK_HAS_CCK;
  1192. network->wpa_ie_len = 0;
  1193. network->rsn_ie_len = 0;
  1194. if (ieee80211_parse_info_param
  1195. (beacon->info_element, stats->len - sizeof(*beacon), network))
  1196. return 1;
  1197. network->mode = 0;
  1198. if (stats->freq == IEEE80211_52GHZ_BAND)
  1199. network->mode = IEEE_A;
  1200. else {
  1201. if (network->flags & NETWORK_HAS_OFDM)
  1202. network->mode |= IEEE_G;
  1203. if (network->flags & NETWORK_HAS_CCK)
  1204. network->mode |= IEEE_B;
  1205. }
  1206. if (network->mode == 0) {
  1207. IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' "
  1208. "network.\n",
  1209. escape_essid(network->ssid,
  1210. network->ssid_len),
  1211. MAC_ARG(network->bssid));
  1212. return 1;
  1213. }
  1214. if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
  1215. network->flags |= NETWORK_EMPTY_ESSID;
  1216. memcpy(&network->stats, stats, sizeof(network->stats));
  1217. return 0;
  1218. }
  1219. static inline int is_same_network(struct ieee80211_network *src,
  1220. struct ieee80211_network *dst)
  1221. {
  1222. /* A network is only a duplicate if the channel, BSSID, and ESSID
  1223. * all match. We treat all <hidden> with the same BSSID and channel
  1224. * as one network */
  1225. return ((src->ssid_len == dst->ssid_len) &&
  1226. (src->channel == dst->channel) &&
  1227. !compare_ether_addr(src->bssid, dst->bssid) &&
  1228. !memcmp(src->ssid, dst->ssid, src->ssid_len));
  1229. }
  1230. static void update_network(struct ieee80211_network *dst,
  1231. struct ieee80211_network *src)
  1232. {
  1233. int qos_active;
  1234. u8 old_param;
  1235. ieee80211_network_reset(dst);
  1236. dst->ibss_dfs = src->ibss_dfs;
  1237. /* We only update the statistics if they were created by receiving
  1238. * the network information on the actual channel the network is on.
  1239. *
  1240. * This keeps beacons received on neighbor channels from bringing
  1241. * down the signal level of an AP. */
  1242. if (dst->channel == src->stats.received_channel)
  1243. memcpy(&dst->stats, &src->stats,
  1244. sizeof(struct ieee80211_rx_stats));
  1245. else
  1246. IEEE80211_DEBUG_SCAN("Network " MAC_FMT " info received "
  1247. "off channel (%d vs. %d)\n", MAC_ARG(src->bssid),
  1248. dst->channel, src->stats.received_channel);
  1249. dst->capability = src->capability;
  1250. memcpy(dst->rates, src->rates, src->rates_len);
  1251. dst->rates_len = src->rates_len;
  1252. memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
  1253. dst->rates_ex_len = src->rates_ex_len;
  1254. dst->mode = src->mode;
  1255. dst->flags = src->flags;
  1256. dst->time_stamp[0] = src->time_stamp[0];
  1257. dst->time_stamp[1] = src->time_stamp[1];
  1258. dst->beacon_interval = src->beacon_interval;
  1259. dst->listen_interval = src->listen_interval;
  1260. dst->atim_window = src->atim_window;
  1261. dst->erp_value = src->erp_value;
  1262. dst->tim = src->tim;
  1263. memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
  1264. dst->wpa_ie_len = src->wpa_ie_len;
  1265. memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
  1266. dst->rsn_ie_len = src->rsn_ie_len;
  1267. dst->last_scanned = jiffies;
  1268. qos_active = src->qos_data.active;
  1269. old_param = dst->qos_data.old_param_count;
  1270. if (dst->flags & NETWORK_HAS_QOS_MASK)
  1271. memcpy(&dst->qos_data, &src->qos_data,
  1272. sizeof(struct ieee80211_qos_data));
  1273. else {
  1274. dst->qos_data.supported = src->qos_data.supported;
  1275. dst->qos_data.param_count = src->qos_data.param_count;
  1276. }
  1277. if (dst->qos_data.supported == 1) {
  1278. if (dst->ssid_len)
  1279. IEEE80211_DEBUG_QOS
  1280. ("QoS the network %s is QoS supported\n",
  1281. dst->ssid);
  1282. else
  1283. IEEE80211_DEBUG_QOS
  1284. ("QoS the network is QoS supported\n");
  1285. }
  1286. dst->qos_data.active = qos_active;
  1287. dst->qos_data.old_param_count = old_param;
  1288. /* dst->last_associate is not overwritten */
  1289. }
  1290. static inline int is_beacon(__le16 fc)
  1291. {
  1292. return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
  1293. }
  1294. static void ieee80211_process_probe_response(struct ieee80211_device
  1295. *ieee, struct
  1296. ieee80211_probe_response
  1297. *beacon, struct ieee80211_rx_stats
  1298. *stats)
  1299. {
  1300. struct net_device *dev = ieee->dev;
  1301. struct ieee80211_network network = {
  1302. .ibss_dfs = NULL,
  1303. };
  1304. struct ieee80211_network *target;
  1305. struct ieee80211_network *oldest = NULL;
  1306. #ifdef CONFIG_IEEE80211_DEBUG
  1307. struct ieee80211_info_element *info_element = beacon->info_element;
  1308. #endif
  1309. unsigned long flags;
  1310. IEEE80211_DEBUG_SCAN("'%s' (" MAC_FMT
  1311. "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
  1312. escape_essid(info_element->data,
  1313. info_element->len),
  1314. MAC_ARG(beacon->header.addr3),
  1315. (beacon->capability & (1 << 0xf)) ? '1' : '0',
  1316. (beacon->capability & (1 << 0xe)) ? '1' : '0',
  1317. (beacon->capability & (1 << 0xd)) ? '1' : '0',
  1318. (beacon->capability & (1 << 0xc)) ? '1' : '0',
  1319. (beacon->capability & (1 << 0xb)) ? '1' : '0',
  1320. (beacon->capability & (1 << 0xa)) ? '1' : '0',
  1321. (beacon->capability & (1 << 0x9)) ? '1' : '0',
  1322. (beacon->capability & (1 << 0x8)) ? '1' : '0',
  1323. (beacon->capability & (1 << 0x7)) ? '1' : '0',
  1324. (beacon->capability & (1 << 0x6)) ? '1' : '0',
  1325. (beacon->capability & (1 << 0x5)) ? '1' : '0',
  1326. (beacon->capability & (1 << 0x4)) ? '1' : '0',
  1327. (beacon->capability & (1 << 0x3)) ? '1' : '0',
  1328. (beacon->capability & (1 << 0x2)) ? '1' : '0',
  1329. (beacon->capability & (1 << 0x1)) ? '1' : '0',
  1330. (beacon->capability & (1 << 0x0)) ? '1' : '0');
  1331. if (ieee80211_network_init(ieee, beacon, &network, stats)) {
  1332. IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
  1333. escape_essid(info_element->data,
  1334. info_element->len),
  1335. MAC_ARG(beacon->header.addr3),
  1336. is_beacon(beacon->header.frame_ctl) ?
  1337. "BEACON" : "PROBE RESPONSE");
  1338. return;
  1339. }
  1340. /* The network parsed correctly -- so now we scan our known networks
  1341. * to see if we can find it in our list.
  1342. *
  1343. * NOTE: This search is definitely not optimized. Once its doing
  1344. * the "right thing" we'll optimize it for efficiency if
  1345. * necessary */
  1346. /* Search for this entry in the list and update it if it is
  1347. * already there. */
  1348. spin_lock_irqsave(&ieee->lock, flags);
  1349. list_for_each_entry(target, &ieee->network_list, list) {
  1350. if (is_same_network(target, &network))
  1351. break;
  1352. if ((oldest == NULL) ||
  1353. (target->last_scanned < oldest->last_scanned))
  1354. oldest = target;
  1355. }
  1356. /* If we didn't find a match, then get a new network slot to initialize
  1357. * with this beacon's information */
  1358. if (&target->list == &ieee->network_list) {
  1359. if (list_empty(&ieee->network_free_list)) {
  1360. /* If there are no more slots, expire the oldest */
  1361. list_del(&oldest->list);
  1362. target = oldest;
  1363. IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from "
  1364. "network list.\n",
  1365. escape_essid(target->ssid,
  1366. target->ssid_len),
  1367. MAC_ARG(target->bssid));
  1368. ieee80211_network_reset(target);
  1369. } else {
  1370. /* Otherwise just pull from the free list */
  1371. target = list_entry(ieee->network_free_list.next,
  1372. struct ieee80211_network, list);
  1373. list_del(ieee->network_free_list.next);
  1374. }
  1375. #ifdef CONFIG_IEEE80211_DEBUG
  1376. IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n",
  1377. escape_essid(network.ssid,
  1378. network.ssid_len),
  1379. MAC_ARG(network.bssid),
  1380. is_beacon(beacon->header.frame_ctl) ?
  1381. "BEACON" : "PROBE RESPONSE");
  1382. #endif
  1383. memcpy(target, &network, sizeof(*target));
  1384. network.ibss_dfs = NULL;
  1385. list_add_tail(&target->list, &ieee->network_list);
  1386. } else {
  1387. IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
  1388. escape_essid(target->ssid,
  1389. target->ssid_len),
  1390. MAC_ARG(target->bssid),
  1391. is_beacon(beacon->header.frame_ctl) ?
  1392. "BEACON" : "PROBE RESPONSE");
  1393. update_network(target, &network);
  1394. network.ibss_dfs = NULL;
  1395. }
  1396. spin_unlock_irqrestore(&ieee->lock, flags);
  1397. if (is_beacon(beacon->header.frame_ctl)) {
  1398. if (ieee->handle_beacon != NULL)
  1399. ieee->handle_beacon(dev, beacon, target);
  1400. } else {
  1401. if (ieee->handle_probe_response != NULL)
  1402. ieee->handle_probe_response(dev, beacon, target);
  1403. }
  1404. }
  1405. void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  1406. struct ieee80211_hdr_4addr *header,
  1407. struct ieee80211_rx_stats *stats)
  1408. {
  1409. switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
  1410. case IEEE80211_STYPE_ASSOC_RESP:
  1411. IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
  1412. WLAN_FC_GET_STYPE(le16_to_cpu
  1413. (header->frame_ctl)));
  1414. ieee80211_handle_assoc_resp(ieee,
  1415. (struct ieee80211_assoc_response *)
  1416. header, stats);
  1417. break;
  1418. case IEEE80211_STYPE_REASSOC_RESP:
  1419. IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
  1420. WLAN_FC_GET_STYPE(le16_to_cpu
  1421. (header->frame_ctl)));
  1422. break;
  1423. case IEEE80211_STYPE_PROBE_REQ:
  1424. IEEE80211_DEBUG_MGMT("received auth (%d)\n",
  1425. WLAN_FC_GET_STYPE(le16_to_cpu
  1426. (header->frame_ctl)));
  1427. if (ieee->handle_probe_request != NULL)
  1428. ieee->handle_probe_request(ieee->dev,
  1429. (struct
  1430. ieee80211_probe_request *)
  1431. header, stats);
  1432. break;
  1433. case IEEE80211_STYPE_PROBE_RESP:
  1434. IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
  1435. WLAN_FC_GET_STYPE(le16_to_cpu
  1436. (header->frame_ctl)));
  1437. IEEE80211_DEBUG_SCAN("Probe response\n");
  1438. ieee80211_process_probe_response(ieee,
  1439. (struct
  1440. ieee80211_probe_response *)
  1441. header, stats);
  1442. break;
  1443. case IEEE80211_STYPE_BEACON:
  1444. IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
  1445. WLAN_FC_GET_STYPE(le16_to_cpu
  1446. (header->frame_ctl)));
  1447. IEEE80211_DEBUG_SCAN("Beacon\n");
  1448. ieee80211_process_probe_response(ieee,
  1449. (struct
  1450. ieee80211_probe_response *)
  1451. header, stats);
  1452. break;
  1453. case IEEE80211_STYPE_AUTH:
  1454. IEEE80211_DEBUG_MGMT("received auth (%d)\n",
  1455. WLAN_FC_GET_STYPE(le16_to_cpu
  1456. (header->frame_ctl)));
  1457. if (ieee->handle_auth != NULL)
  1458. ieee->handle_auth(ieee->dev,
  1459. (struct ieee80211_auth *)header);
  1460. break;
  1461. case IEEE80211_STYPE_DISASSOC:
  1462. if (ieee->handle_disassoc != NULL)
  1463. ieee->handle_disassoc(ieee->dev,
  1464. (struct ieee80211_disassoc *)
  1465. header);
  1466. break;
  1467. case IEEE80211_STYPE_ACTION:
  1468. IEEE80211_DEBUG_MGMT("ACTION\n");
  1469. if (ieee->handle_action)
  1470. ieee->handle_action(ieee->dev,
  1471. (struct ieee80211_action *)
  1472. header, stats);
  1473. break;
  1474. case IEEE80211_STYPE_REASSOC_REQ:
  1475. IEEE80211_DEBUG_MGMT("received reassoc (%d)\n",
  1476. WLAN_FC_GET_STYPE(le16_to_cpu
  1477. (header->frame_ctl)));
  1478. IEEE80211_WARNING("%s: IEEE80211_REASSOC_REQ received\n",
  1479. ieee->dev->name);
  1480. if (ieee->handle_reassoc_request != NULL)
  1481. ieee->handle_reassoc_request(ieee->dev,
  1482. (struct ieee80211_reassoc_request *)
  1483. header);
  1484. break;
  1485. case IEEE80211_STYPE_ASSOC_REQ:
  1486. IEEE80211_DEBUG_MGMT("received assoc (%d)\n",
  1487. WLAN_FC_GET_STYPE(le16_to_cpu
  1488. (header->frame_ctl)));
  1489. IEEE80211_WARNING("%s: IEEE80211_ASSOC_REQ received\n",
  1490. ieee->dev->name);
  1491. if (ieee->handle_assoc_request != NULL)
  1492. ieee->handle_assoc_request(ieee->dev);
  1493. break;
  1494. case IEEE80211_STYPE_DEAUTH:
  1495. IEEE80211_DEBUG_MGMT("DEAUTH\n");
  1496. if (ieee->handle_deauth != NULL)
  1497. ieee->handle_deauth(ieee->dev,
  1498. (struct ieee80211_deauth *)
  1499. header);
  1500. break;
  1501. default:
  1502. IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
  1503. WLAN_FC_GET_STYPE(le16_to_cpu
  1504. (header->frame_ctl)));
  1505. IEEE80211_WARNING("%s: Unknown management packet: %d\n",
  1506. ieee->dev->name,
  1507. WLAN_FC_GET_STYPE(le16_to_cpu
  1508. (header->frame_ctl)));
  1509. break;
  1510. }
  1511. }
  1512. EXPORT_SYMBOL(ieee80211_rx_mgt);
  1513. EXPORT_SYMBOL(ieee80211_rx);