ieee80211_rx.c 50 KB

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