ieee80211_rx.c 49 KB

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