hostap_80211_rx.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/etherdevice.h>
  3. #include <linux/slab.h>
  4. #include <linux/export.h>
  5. #include <net/lib80211.h>
  6. #include <linux/if_arp.h>
  7. #include "hostap_80211.h"
  8. #include "hostap.h"
  9. #include "hostap_ap.h"
  10. /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
  11. /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
  12. static unsigned char rfc1042_header[] =
  13. { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
  14. /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
  15. static unsigned char bridge_tunnel_header[] =
  16. { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
  17. /* No encapsulation header if EtherType < 0x600 (=length) */
  18. void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
  19. struct hostap_80211_rx_status *rx_stats)
  20. {
  21. struct ieee80211_hdr *hdr;
  22. u16 fc;
  23. hdr = (struct ieee80211_hdr *) skb->data;
  24. printk(KERN_DEBUG "%s: RX signal=%d noise=%d rate=%d len=%d "
  25. "jiffies=%ld\n",
  26. name, rx_stats->signal, rx_stats->noise, rx_stats->rate,
  27. skb->len, jiffies);
  28. if (skb->len < 2)
  29. return;
  30. fc = le16_to_cpu(hdr->frame_control);
  31. printk(KERN_DEBUG " FC=0x%04x (type=%d:%d)%s%s",
  32. fc, (fc & IEEE80211_FCTL_FTYPE) >> 2,
  33. (fc & IEEE80211_FCTL_STYPE) >> 4,
  34. fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
  35. fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
  36. if (skb->len < IEEE80211_DATA_HDR3_LEN) {
  37. printk("\n");
  38. return;
  39. }
  40. printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
  41. le16_to_cpu(hdr->seq_ctrl));
  42. printk(KERN_DEBUG " A1=%pM", hdr->addr1);
  43. printk(" A2=%pM", hdr->addr2);
  44. printk(" A3=%pM", hdr->addr3);
  45. if (skb->len >= 30)
  46. printk(" A4=%pM", hdr->addr4);
  47. printk("\n");
  48. }
  49. /* Send RX frame to netif with 802.11 (and possible prism) header.
  50. * Called from hardware or software IRQ context. */
  51. int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
  52. struct hostap_80211_rx_status *rx_stats, int type)
  53. {
  54. struct hostap_interface *iface;
  55. local_info_t *local;
  56. int hdrlen, phdrlen, head_need, tail_need;
  57. u16 fc;
  58. int prism_header, ret;
  59. struct ieee80211_hdr *fhdr;
  60. iface = netdev_priv(dev);
  61. local = iface->local;
  62. if (dev->type == ARPHRD_IEEE80211_PRISM) {
  63. if (local->monitor_type == PRISM2_MONITOR_PRISM) {
  64. prism_header = 1;
  65. phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
  66. } else { /* local->monitor_type == PRISM2_MONITOR_CAPHDR */
  67. prism_header = 2;
  68. phdrlen = sizeof(struct linux_wlan_ng_cap_hdr);
  69. }
  70. } else if (dev->type == ARPHRD_IEEE80211_RADIOTAP) {
  71. prism_header = 3;
  72. phdrlen = sizeof(struct hostap_radiotap_rx);
  73. } else {
  74. prism_header = 0;
  75. phdrlen = 0;
  76. }
  77. fhdr = (struct ieee80211_hdr *) skb->data;
  78. fc = le16_to_cpu(fhdr->frame_control);
  79. if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) {
  80. printk(KERN_DEBUG "%s: dropped management frame with header "
  81. "version %d\n", dev->name, fc & IEEE80211_FCTL_VERS);
  82. dev_kfree_skb_any(skb);
  83. return 0;
  84. }
  85. hdrlen = hostap_80211_get_hdrlen(fhdr->frame_control);
  86. /* check if there is enough room for extra data; if not, expand skb
  87. * buffer to be large enough for the changes */
  88. head_need = phdrlen;
  89. tail_need = 0;
  90. #ifdef PRISM2_ADD_BOGUS_CRC
  91. tail_need += 4;
  92. #endif /* PRISM2_ADD_BOGUS_CRC */
  93. head_need -= skb_headroom(skb);
  94. tail_need -= skb_tailroom(skb);
  95. if (head_need > 0 || tail_need > 0) {
  96. if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
  97. tail_need > 0 ? tail_need : 0,
  98. GFP_ATOMIC)) {
  99. printk(KERN_DEBUG "%s: prism2_rx_80211 failed to "
  100. "reallocate skb buffer\n", dev->name);
  101. dev_kfree_skb_any(skb);
  102. return 0;
  103. }
  104. }
  105. /* We now have an skb with enough head and tail room, so just insert
  106. * the extra data */
  107. #ifdef PRISM2_ADD_BOGUS_CRC
  108. memset(skb_put(skb, 4), 0xff, 4); /* Prism2 strips CRC */
  109. #endif /* PRISM2_ADD_BOGUS_CRC */
  110. if (prism_header == 1) {
  111. struct linux_wlan_ng_prism_hdr *hdr;
  112. hdr = skb_push(skb, phdrlen);
  113. memset(hdr, 0, phdrlen);
  114. hdr->msgcode = LWNG_CAP_DID_BASE;
  115. hdr->msglen = sizeof(*hdr);
  116. memcpy(hdr->devname, dev->name, sizeof(hdr->devname));
  117. #define LWNG_SETVAL(f,i,s,l,d) \
  118. hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
  119. hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
  120. LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
  121. LWNG_SETVAL(mactime, 2, 0, 4, rx_stats->mac_time);
  122. LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
  123. LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
  124. LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
  125. LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
  126. LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
  127. LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
  128. LWNG_SETVAL(istx, 9, 0, 4, 0);
  129. LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
  130. #undef LWNG_SETVAL
  131. } else if (prism_header == 2) {
  132. struct linux_wlan_ng_cap_hdr *hdr;
  133. hdr = skb_push(skb, phdrlen);
  134. memset(hdr, 0, phdrlen);
  135. hdr->version = htonl(LWNG_CAPHDR_VERSION);
  136. hdr->length = htonl(phdrlen);
  137. hdr->mactime = __cpu_to_be64(rx_stats->mac_time);
  138. hdr->hosttime = __cpu_to_be64(jiffies);
  139. hdr->phytype = htonl(4); /* dss_dot11_b */
  140. hdr->channel = htonl(local->channel);
  141. hdr->datarate = htonl(rx_stats->rate);
  142. hdr->antenna = htonl(0); /* unknown */
  143. hdr->priority = htonl(0); /* unknown */
  144. hdr->ssi_type = htonl(3); /* raw */
  145. hdr->ssi_signal = htonl(rx_stats->signal);
  146. hdr->ssi_noise = htonl(rx_stats->noise);
  147. hdr->preamble = htonl(0); /* unknown */
  148. hdr->encoding = htonl(1); /* cck */
  149. } else if (prism_header == 3) {
  150. struct hostap_radiotap_rx *hdr;
  151. hdr = skb_push(skb, phdrlen);
  152. memset(hdr, 0, phdrlen);
  153. hdr->hdr.it_len = cpu_to_le16(phdrlen);
  154. hdr->hdr.it_present =
  155. cpu_to_le32((1 << IEEE80211_RADIOTAP_TSFT) |
  156. (1 << IEEE80211_RADIOTAP_CHANNEL) |
  157. (1 << IEEE80211_RADIOTAP_RATE) |
  158. (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
  159. (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE));
  160. hdr->tsft = cpu_to_le64(rx_stats->mac_time);
  161. hdr->chan_freq = cpu_to_le16(freq_list[local->channel - 1]);
  162. hdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_CCK |
  163. IEEE80211_CHAN_2GHZ);
  164. hdr->rate = rx_stats->rate / 5;
  165. hdr->dbm_antsignal = rx_stats->signal;
  166. hdr->dbm_antnoise = rx_stats->noise;
  167. }
  168. ret = skb->len - phdrlen;
  169. skb->dev = dev;
  170. skb_reset_mac_header(skb);
  171. skb_pull(skb, hdrlen);
  172. if (prism_header)
  173. skb_pull(skb, phdrlen);
  174. skb->pkt_type = PACKET_OTHERHOST;
  175. skb->protocol = cpu_to_be16(ETH_P_802_2);
  176. memset(skb->cb, 0, sizeof(skb->cb));
  177. netif_rx(skb);
  178. return ret;
  179. }
  180. /* Called only as a tasklet (software IRQ) */
  181. static void monitor_rx(struct net_device *dev, struct sk_buff *skb,
  182. struct hostap_80211_rx_status *rx_stats)
  183. {
  184. int len;
  185. len = prism2_rx_80211(dev, skb, rx_stats, PRISM2_RX_MONITOR);
  186. dev->stats.rx_packets++;
  187. dev->stats.rx_bytes += len;
  188. }
  189. /* Called only as a tasklet (software IRQ) */
  190. static struct prism2_frag_entry *
  191. prism2_frag_cache_find(local_info_t *local, unsigned int seq,
  192. unsigned int frag, u8 *src, u8 *dst)
  193. {
  194. struct prism2_frag_entry *entry;
  195. int i;
  196. for (i = 0; i < PRISM2_FRAG_CACHE_LEN; i++) {
  197. entry = &local->frag_cache[i];
  198. if (entry->skb != NULL &&
  199. time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
  200. printk(KERN_DEBUG "%s: expiring fragment cache entry "
  201. "seq=%u last_frag=%u\n",
  202. local->dev->name, entry->seq, entry->last_frag);
  203. dev_kfree_skb(entry->skb);
  204. entry->skb = NULL;
  205. }
  206. if (entry->skb != NULL && entry->seq == seq &&
  207. (entry->last_frag + 1 == frag || frag == -1) &&
  208. memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
  209. memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
  210. return entry;
  211. }
  212. return NULL;
  213. }
  214. /* Called only as a tasklet (software IRQ) */
  215. static struct sk_buff *
  216. prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr)
  217. {
  218. struct sk_buff *skb = NULL;
  219. u16 sc;
  220. unsigned int frag, seq;
  221. struct prism2_frag_entry *entry;
  222. sc = le16_to_cpu(hdr->seq_ctrl);
  223. frag = sc & IEEE80211_SCTL_FRAG;
  224. seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
  225. if (frag == 0) {
  226. /* Reserve enough space to fit maximum frame length */
  227. skb = dev_alloc_skb(local->dev->mtu +
  228. sizeof(struct ieee80211_hdr) +
  229. 8 /* LLC */ +
  230. 2 /* alignment */ +
  231. 8 /* WEP */ + ETH_ALEN /* WDS */);
  232. if (skb == NULL)
  233. return NULL;
  234. entry = &local->frag_cache[local->frag_next_idx];
  235. local->frag_next_idx++;
  236. if (local->frag_next_idx >= PRISM2_FRAG_CACHE_LEN)
  237. local->frag_next_idx = 0;
  238. if (entry->skb != NULL)
  239. dev_kfree_skb(entry->skb);
  240. entry->first_frag_time = jiffies;
  241. entry->seq = seq;
  242. entry->last_frag = frag;
  243. entry->skb = skb;
  244. memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
  245. memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
  246. } else {
  247. /* received a fragment of a frame for which the head fragment
  248. * should have already been received */
  249. entry = prism2_frag_cache_find(local, seq, frag, hdr->addr2,
  250. hdr->addr1);
  251. if (entry != NULL) {
  252. entry->last_frag = frag;
  253. skb = entry->skb;
  254. }
  255. }
  256. return skb;
  257. }
  258. /* Called only as a tasklet (software IRQ) */
  259. static int prism2_frag_cache_invalidate(local_info_t *local,
  260. struct ieee80211_hdr *hdr)
  261. {
  262. u16 sc;
  263. unsigned int seq;
  264. struct prism2_frag_entry *entry;
  265. sc = le16_to_cpu(hdr->seq_ctrl);
  266. seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
  267. entry = prism2_frag_cache_find(local, seq, -1, hdr->addr2, hdr->addr1);
  268. if (entry == NULL) {
  269. printk(KERN_DEBUG "%s: could not invalidate fragment cache "
  270. "entry (seq=%u)\n",
  271. local->dev->name, seq);
  272. return -1;
  273. }
  274. entry->skb = NULL;
  275. return 0;
  276. }
  277. static struct hostap_bss_info *__hostap_get_bss(local_info_t *local, u8 *bssid,
  278. u8 *ssid, size_t ssid_len)
  279. {
  280. struct list_head *ptr;
  281. struct hostap_bss_info *bss;
  282. list_for_each(ptr, &local->bss_list) {
  283. bss = list_entry(ptr, struct hostap_bss_info, list);
  284. if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0 &&
  285. (ssid == NULL ||
  286. (ssid_len == bss->ssid_len &&
  287. memcmp(ssid, bss->ssid, ssid_len) == 0))) {
  288. list_move(&bss->list, &local->bss_list);
  289. return bss;
  290. }
  291. }
  292. return NULL;
  293. }
  294. static struct hostap_bss_info *__hostap_add_bss(local_info_t *local, u8 *bssid,
  295. u8 *ssid, size_t ssid_len)
  296. {
  297. struct hostap_bss_info *bss;
  298. if (local->num_bss_info >= HOSTAP_MAX_BSS_COUNT) {
  299. bss = list_entry(local->bss_list.prev,
  300. struct hostap_bss_info, list);
  301. list_del(&bss->list);
  302. local->num_bss_info--;
  303. } else {
  304. bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
  305. if (bss == NULL)
  306. return NULL;
  307. }
  308. memset(bss, 0, sizeof(*bss));
  309. memcpy(bss->bssid, bssid, ETH_ALEN);
  310. memcpy(bss->ssid, ssid, ssid_len);
  311. bss->ssid_len = ssid_len;
  312. local->num_bss_info++;
  313. list_add(&bss->list, &local->bss_list);
  314. return bss;
  315. }
  316. static void __hostap_expire_bss(local_info_t *local)
  317. {
  318. struct hostap_bss_info *bss;
  319. while (local->num_bss_info > 0) {
  320. bss = list_entry(local->bss_list.prev,
  321. struct hostap_bss_info, list);
  322. if (!time_after(jiffies, bss->last_update + 60 * HZ))
  323. break;
  324. list_del(&bss->list);
  325. local->num_bss_info--;
  326. kfree(bss);
  327. }
  328. }
  329. /* Both IEEE 802.11 Beacon and Probe Response frames have similar structure, so
  330. * the same routine can be used to parse both of them. */
  331. static void hostap_rx_sta_beacon(local_info_t *local, struct sk_buff *skb,
  332. int stype)
  333. {
  334. struct hostap_ieee80211_mgmt *mgmt;
  335. int left, chan = 0;
  336. u8 *pos;
  337. u8 *ssid = NULL, *wpa = NULL, *rsn = NULL;
  338. size_t ssid_len = 0, wpa_len = 0, rsn_len = 0;
  339. struct hostap_bss_info *bss;
  340. if (skb->len < IEEE80211_MGMT_HDR_LEN + sizeof(mgmt->u.beacon))
  341. return;
  342. mgmt = (struct hostap_ieee80211_mgmt *) skb->data;
  343. pos = mgmt->u.beacon.variable;
  344. left = skb->len - (pos - skb->data);
  345. while (left >= 2) {
  346. if (2 + pos[1] > left)
  347. return; /* parse failed */
  348. switch (*pos) {
  349. case WLAN_EID_SSID:
  350. ssid = pos + 2;
  351. ssid_len = pos[1];
  352. break;
  353. case WLAN_EID_VENDOR_SPECIFIC:
  354. if (pos[1] >= 4 &&
  355. pos[2] == 0x00 && pos[3] == 0x50 &&
  356. pos[4] == 0xf2 && pos[5] == 1) {
  357. wpa = pos;
  358. wpa_len = pos[1] + 2;
  359. }
  360. break;
  361. case WLAN_EID_RSN:
  362. rsn = pos;
  363. rsn_len = pos[1] + 2;
  364. break;
  365. case WLAN_EID_DS_PARAMS:
  366. if (pos[1] >= 1)
  367. chan = pos[2];
  368. break;
  369. }
  370. left -= 2 + pos[1];
  371. pos += 2 + pos[1];
  372. }
  373. if (wpa_len > MAX_WPA_IE_LEN)
  374. wpa_len = MAX_WPA_IE_LEN;
  375. if (rsn_len > MAX_WPA_IE_LEN)
  376. rsn_len = MAX_WPA_IE_LEN;
  377. if (ssid_len > sizeof(bss->ssid))
  378. ssid_len = sizeof(bss->ssid);
  379. spin_lock(&local->lock);
  380. bss = __hostap_get_bss(local, mgmt->bssid, ssid, ssid_len);
  381. if (bss == NULL)
  382. bss = __hostap_add_bss(local, mgmt->bssid, ssid, ssid_len);
  383. if (bss) {
  384. bss->last_update = jiffies;
  385. bss->count++;
  386. bss->capab_info = le16_to_cpu(mgmt->u.beacon.capab_info);
  387. if (wpa) {
  388. memcpy(bss->wpa_ie, wpa, wpa_len);
  389. bss->wpa_ie_len = wpa_len;
  390. } else
  391. bss->wpa_ie_len = 0;
  392. if (rsn) {
  393. memcpy(bss->rsn_ie, rsn, rsn_len);
  394. bss->rsn_ie_len = rsn_len;
  395. } else
  396. bss->rsn_ie_len = 0;
  397. bss->chan = chan;
  398. }
  399. __hostap_expire_bss(local);
  400. spin_unlock(&local->lock);
  401. }
  402. static int
  403. hostap_rx_frame_mgmt(local_info_t *local, struct sk_buff *skb,
  404. struct hostap_80211_rx_status *rx_stats, u16 type,
  405. u16 stype)
  406. {
  407. if (local->iw_mode == IW_MODE_MASTER)
  408. hostap_update_sta_ps(local, (struct ieee80211_hdr *) skb->data);
  409. if (local->hostapd && type == IEEE80211_FTYPE_MGMT) {
  410. if (stype == IEEE80211_STYPE_BEACON &&
  411. local->iw_mode == IW_MODE_MASTER) {
  412. struct sk_buff *skb2;
  413. /* Process beacon frames also in kernel driver to
  414. * update STA(AP) table statistics */
  415. skb2 = skb_clone(skb, GFP_ATOMIC);
  416. if (skb2)
  417. hostap_rx(skb2->dev, skb2, rx_stats);
  418. }
  419. /* send management frames to the user space daemon for
  420. * processing */
  421. local->apdevstats.rx_packets++;
  422. local->apdevstats.rx_bytes += skb->len;
  423. if (local->apdev == NULL)
  424. return -1;
  425. prism2_rx_80211(local->apdev, skb, rx_stats, PRISM2_RX_MGMT);
  426. return 0;
  427. }
  428. if (local->iw_mode == IW_MODE_MASTER) {
  429. if (type != IEEE80211_FTYPE_MGMT &&
  430. type != IEEE80211_FTYPE_CTL) {
  431. printk(KERN_DEBUG "%s: unknown management frame "
  432. "(type=0x%02x, stype=0x%02x) dropped\n",
  433. skb->dev->name, type >> 2, stype >> 4);
  434. return -1;
  435. }
  436. hostap_rx(skb->dev, skb, rx_stats);
  437. return 0;
  438. } else if (type == IEEE80211_FTYPE_MGMT &&
  439. (stype == IEEE80211_STYPE_BEACON ||
  440. stype == IEEE80211_STYPE_PROBE_RESP)) {
  441. hostap_rx_sta_beacon(local, skb, stype);
  442. return -1;
  443. } else if (type == IEEE80211_FTYPE_MGMT &&
  444. (stype == IEEE80211_STYPE_ASSOC_RESP ||
  445. stype == IEEE80211_STYPE_REASSOC_RESP)) {
  446. /* Ignore (Re)AssocResp silently since these are not currently
  447. * needed but are still received when WPA/RSN mode is enabled.
  448. */
  449. return -1;
  450. } else {
  451. printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: dropped unhandled"
  452. " management frame in non-Host AP mode (type=%d:%d)\n",
  453. skb->dev->name, type >> 2, stype >> 4);
  454. return -1;
  455. }
  456. }
  457. /* Called only as a tasklet (software IRQ) */
  458. static struct net_device *prism2_rx_get_wds(local_info_t *local,
  459. u8 *addr)
  460. {
  461. struct hostap_interface *iface = NULL;
  462. struct list_head *ptr;
  463. read_lock_bh(&local->iface_lock);
  464. list_for_each(ptr, &local->hostap_interfaces) {
  465. iface = list_entry(ptr, struct hostap_interface, list);
  466. if (iface->type == HOSTAP_INTERFACE_WDS &&
  467. memcmp(iface->u.wds.remote_addr, addr, ETH_ALEN) == 0)
  468. break;
  469. iface = NULL;
  470. }
  471. read_unlock_bh(&local->iface_lock);
  472. return iface ? iface->dev : NULL;
  473. }
  474. static int
  475. hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr, u16 fc,
  476. struct net_device **wds)
  477. {
  478. /* FIX: is this really supposed to accept WDS frames only in Master
  479. * mode? What about Repeater or Managed with WDS frames? */
  480. if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) !=
  481. (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS) &&
  482. (local->iw_mode != IW_MODE_MASTER || !(fc & IEEE80211_FCTL_TODS)))
  483. return 0; /* not a WDS frame */
  484. /* Possible WDS frame: either IEEE 802.11 compliant (if FromDS)
  485. * or own non-standard frame with 4th address after payload */
  486. if (!ether_addr_equal(hdr->addr1, local->dev->dev_addr) &&
  487. (hdr->addr1[0] != 0xff || hdr->addr1[1] != 0xff ||
  488. hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff ||
  489. hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) {
  490. /* RA (or BSSID) is not ours - drop */
  491. PDEBUG(DEBUG_EXTRA2, "%s: received WDS frame with "
  492. "not own or broadcast %s=%pM\n",
  493. local->dev->name,
  494. fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID",
  495. hdr->addr1);
  496. return -1;
  497. }
  498. /* check if the frame came from a registered WDS connection */
  499. *wds = prism2_rx_get_wds(local, hdr->addr2);
  500. if (*wds == NULL && fc & IEEE80211_FCTL_FROMDS &&
  501. (local->iw_mode != IW_MODE_INFRA ||
  502. !(local->wds_type & HOSTAP_WDS_AP_CLIENT) ||
  503. memcmp(hdr->addr2, local->bssid, ETH_ALEN) != 0)) {
  504. /* require that WDS link has been registered with TA or the
  505. * frame is from current AP when using 'AP client mode' */
  506. PDEBUG(DEBUG_EXTRA, "%s: received WDS[4 addr] frame "
  507. "from unknown TA=%pM\n",
  508. local->dev->name, hdr->addr2);
  509. if (local->ap && local->ap->autom_ap_wds)
  510. hostap_wds_link_oper(local, hdr->addr2, WDS_ADD);
  511. return -1;
  512. }
  513. if (*wds && !(fc & IEEE80211_FCTL_FROMDS) && local->ap &&
  514. hostap_is_sta_assoc(local->ap, hdr->addr2)) {
  515. /* STA is actually associated with us even though it has a
  516. * registered WDS link. Assume it is in 'AP client' mode.
  517. * Since this is a 3-addr frame, assume it is not (bogus) WDS
  518. * frame and process it like any normal ToDS frame from
  519. * associated STA. */
  520. *wds = NULL;
  521. }
  522. return 0;
  523. }
  524. static int hostap_is_eapol_frame(local_info_t *local, struct sk_buff *skb)
  525. {
  526. struct net_device *dev = local->dev;
  527. u16 fc, ethertype;
  528. struct ieee80211_hdr *hdr;
  529. u8 *pos;
  530. if (skb->len < 24)
  531. return 0;
  532. hdr = (struct ieee80211_hdr *) skb->data;
  533. fc = le16_to_cpu(hdr->frame_control);
  534. /* check that the frame is unicast frame to us */
  535. if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  536. IEEE80211_FCTL_TODS &&
  537. ether_addr_equal(hdr->addr1, dev->dev_addr) &&
  538. ether_addr_equal(hdr->addr3, dev->dev_addr)) {
  539. /* ToDS frame with own addr BSSID and DA */
  540. } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  541. IEEE80211_FCTL_FROMDS &&
  542. ether_addr_equal(hdr->addr1, dev->dev_addr)) {
  543. /* FromDS frame with own addr as DA */
  544. } else
  545. return 0;
  546. if (skb->len < 24 + 8)
  547. return 0;
  548. /* check for port access entity Ethernet type */
  549. pos = skb->data + 24;
  550. ethertype = (pos[6] << 8) | pos[7];
  551. if (ethertype == ETH_P_PAE)
  552. return 1;
  553. return 0;
  554. }
  555. /* Called only as a tasklet (software IRQ) */
  556. static int
  557. hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
  558. struct lib80211_crypt_data *crypt)
  559. {
  560. struct ieee80211_hdr *hdr;
  561. int res, hdrlen;
  562. if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
  563. return 0;
  564. hdr = (struct ieee80211_hdr *) skb->data;
  565. hdrlen = hostap_80211_get_hdrlen(hdr->frame_control);
  566. if (local->tkip_countermeasures &&
  567. strcmp(crypt->ops->name, "TKIP") == 0) {
  568. if (net_ratelimit()) {
  569. printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
  570. "received packet from %pM\n",
  571. local->dev->name, hdr->addr2);
  572. }
  573. return -1;
  574. }
  575. atomic_inc(&crypt->refcnt);
  576. res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
  577. atomic_dec(&crypt->refcnt);
  578. if (res < 0) {
  579. printk(KERN_DEBUG "%s: decryption failed (SA=%pM) res=%d\n",
  580. local->dev->name, hdr->addr2, res);
  581. local->comm_tallies.rx_discards_wep_undecryptable++;
  582. return -1;
  583. }
  584. return res;
  585. }
  586. /* Called only as a tasklet (software IRQ) */
  587. static int
  588. hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
  589. int keyidx, struct lib80211_crypt_data *crypt)
  590. {
  591. struct ieee80211_hdr *hdr;
  592. int res, hdrlen;
  593. if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
  594. return 0;
  595. hdr = (struct ieee80211_hdr *) skb->data;
  596. hdrlen = hostap_80211_get_hdrlen(hdr->frame_control);
  597. atomic_inc(&crypt->refcnt);
  598. res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
  599. atomic_dec(&crypt->refcnt);
  600. if (res < 0) {
  601. printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
  602. " (SA=%pM keyidx=%d)\n",
  603. local->dev->name, hdr->addr2, keyidx);
  604. return -1;
  605. }
  606. return 0;
  607. }
  608. /* All received frames are sent to this function. @skb contains the frame in
  609. * IEEE 802.11 format, i.e., in the format it was sent over air.
  610. * This function is called only as a tasklet (software IRQ). */
  611. void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
  612. struct hostap_80211_rx_status *rx_stats)
  613. {
  614. struct hostap_interface *iface;
  615. local_info_t *local;
  616. struct ieee80211_hdr *hdr;
  617. size_t hdrlen;
  618. u16 fc, type, stype, sc;
  619. struct net_device *wds = NULL;
  620. unsigned int frag;
  621. u8 *payload;
  622. struct sk_buff *skb2 = NULL;
  623. u16 ethertype;
  624. int frame_authorized = 0;
  625. int from_assoc_ap = 0;
  626. u8 dst[ETH_ALEN];
  627. u8 src[ETH_ALEN];
  628. struct lib80211_crypt_data *crypt = NULL;
  629. void *sta = NULL;
  630. int keyidx = 0;
  631. iface = netdev_priv(dev);
  632. local = iface->local;
  633. iface->stats.rx_packets++;
  634. iface->stats.rx_bytes += skb->len;
  635. /* dev is the master radio device; change this to be the default
  636. * virtual interface (this may be changed to WDS device below) */
  637. dev = local->ddev;
  638. iface = netdev_priv(dev);
  639. hdr = (struct ieee80211_hdr *) skb->data;
  640. if (skb->len < 10)
  641. goto rx_dropped;
  642. fc = le16_to_cpu(hdr->frame_control);
  643. type = fc & IEEE80211_FCTL_FTYPE;
  644. stype = fc & IEEE80211_FCTL_STYPE;
  645. sc = le16_to_cpu(hdr->seq_ctrl);
  646. frag = sc & IEEE80211_SCTL_FRAG;
  647. hdrlen = hostap_80211_get_hdrlen(hdr->frame_control);
  648. /* Put this code here so that we avoid duplicating it in all
  649. * Rx paths. - Jean II */
  650. #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
  651. /* If spy monitoring on */
  652. if (iface->spy_data.spy_number > 0) {
  653. struct iw_quality wstats;
  654. wstats.level = rx_stats->signal;
  655. wstats.noise = rx_stats->noise;
  656. wstats.updated = IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED
  657. | IW_QUAL_QUAL_INVALID | IW_QUAL_DBM;
  658. /* Update spy records */
  659. wireless_spy_update(dev, hdr->addr2, &wstats);
  660. }
  661. #endif /* IW_WIRELESS_SPY */
  662. hostap_update_rx_stats(local->ap, hdr, rx_stats);
  663. if (local->iw_mode == IW_MODE_MONITOR) {
  664. monitor_rx(dev, skb, rx_stats);
  665. return;
  666. }
  667. if (local->host_decrypt) {
  668. int idx = 0;
  669. if (skb->len >= hdrlen + 3)
  670. idx = skb->data[hdrlen + 3] >> 6;
  671. crypt = local->crypt_info.crypt[idx];
  672. sta = NULL;
  673. /* Use station specific key to override default keys if the
  674. * receiver address is a unicast address ("individual RA"). If
  675. * bcrx_sta_key parameter is set, station specific key is used
  676. * even with broad/multicast targets (this is against IEEE
  677. * 802.11, but makes it easier to use different keys with
  678. * stations that do not support WEP key mapping). */
  679. if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
  680. (void) hostap_handle_sta_crypto(local, hdr, &crypt,
  681. &sta);
  682. /* allow NULL decrypt to indicate an station specific override
  683. * for default encryption */
  684. if (crypt && (crypt->ops == NULL ||
  685. crypt->ops->decrypt_mpdu == NULL))
  686. crypt = NULL;
  687. if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
  688. #if 0
  689. /* This seems to be triggered by some (multicast?)
  690. * frames from other than current BSS, so just drop the
  691. * frames silently instead of filling system log with
  692. * these reports. */
  693. printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
  694. " (SA=%pM)\n",
  695. local->dev->name, hdr->addr2);
  696. #endif
  697. local->comm_tallies.rx_discards_wep_undecryptable++;
  698. goto rx_dropped;
  699. }
  700. }
  701. if (type != IEEE80211_FTYPE_DATA) {
  702. if (type == IEEE80211_FTYPE_MGMT &&
  703. stype == IEEE80211_STYPE_AUTH &&
  704. fc & IEEE80211_FCTL_PROTECTED && local->host_decrypt &&
  705. (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
  706. {
  707. printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
  708. "from %pM\n", dev->name, hdr->addr2);
  709. /* TODO: could inform hostapd about this so that it
  710. * could send auth failure report */
  711. goto rx_dropped;
  712. }
  713. if (hostap_rx_frame_mgmt(local, skb, rx_stats, type, stype))
  714. goto rx_dropped;
  715. else
  716. goto rx_exit;
  717. }
  718. /* Data frame - extract src/dst addresses */
  719. if (skb->len < IEEE80211_DATA_HDR3_LEN)
  720. goto rx_dropped;
  721. switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
  722. case IEEE80211_FCTL_FROMDS:
  723. memcpy(dst, hdr->addr1, ETH_ALEN);
  724. memcpy(src, hdr->addr3, ETH_ALEN);
  725. break;
  726. case IEEE80211_FCTL_TODS:
  727. memcpy(dst, hdr->addr3, ETH_ALEN);
  728. memcpy(src, hdr->addr2, ETH_ALEN);
  729. break;
  730. case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
  731. if (skb->len < IEEE80211_DATA_HDR4_LEN)
  732. goto rx_dropped;
  733. memcpy(dst, hdr->addr3, ETH_ALEN);
  734. memcpy(src, hdr->addr4, ETH_ALEN);
  735. break;
  736. default:
  737. memcpy(dst, hdr->addr1, ETH_ALEN);
  738. memcpy(src, hdr->addr2, ETH_ALEN);
  739. break;
  740. }
  741. if (hostap_rx_frame_wds(local, hdr, fc, &wds))
  742. goto rx_dropped;
  743. if (wds)
  744. skb->dev = dev = wds;
  745. if (local->iw_mode == IW_MODE_MASTER && !wds &&
  746. (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  747. IEEE80211_FCTL_FROMDS &&
  748. local->stadev &&
  749. memcmp(hdr->addr2, local->assoc_ap_addr, ETH_ALEN) == 0) {
  750. /* Frame from BSSID of the AP for which we are a client */
  751. skb->dev = dev = local->stadev;
  752. from_assoc_ap = 1;
  753. }
  754. if ((local->iw_mode == IW_MODE_MASTER ||
  755. local->iw_mode == IW_MODE_REPEAT) &&
  756. !from_assoc_ap) {
  757. switch (hostap_handle_sta_rx(local, dev, skb, rx_stats,
  758. wds != NULL)) {
  759. case AP_RX_CONTINUE_NOT_AUTHORIZED:
  760. frame_authorized = 0;
  761. break;
  762. case AP_RX_CONTINUE:
  763. frame_authorized = 1;
  764. break;
  765. case AP_RX_DROP:
  766. goto rx_dropped;
  767. case AP_RX_EXIT:
  768. goto rx_exit;
  769. }
  770. }
  771. /* Nullfunc frames may have PS-bit set, so they must be passed to
  772. * hostap_handle_sta_rx() before being dropped here. */
  773. if (stype != IEEE80211_STYPE_DATA &&
  774. stype != IEEE80211_STYPE_DATA_CFACK &&
  775. stype != IEEE80211_STYPE_DATA_CFPOLL &&
  776. stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
  777. if (stype != IEEE80211_STYPE_NULLFUNC)
  778. printk(KERN_DEBUG "%s: RX: dropped data frame "
  779. "with no data (type=0x%02x, subtype=0x%02x)\n",
  780. dev->name, type >> 2, stype >> 4);
  781. goto rx_dropped;
  782. }
  783. /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
  784. if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
  785. (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
  786. goto rx_dropped;
  787. hdr = (struct ieee80211_hdr *) skb->data;
  788. /* skb: hdr + (possibly fragmented) plaintext payload */
  789. if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
  790. (frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
  791. int flen;
  792. struct sk_buff *frag_skb =
  793. prism2_frag_cache_get(local, hdr);
  794. if (!frag_skb) {
  795. printk(KERN_DEBUG "%s: Rx cannot get skb from "
  796. "fragment cache (morefrag=%d seq=%u frag=%u)\n",
  797. dev->name, (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
  798. (sc & IEEE80211_SCTL_SEQ) >> 4, frag);
  799. goto rx_dropped;
  800. }
  801. flen = skb->len;
  802. if (frag != 0)
  803. flen -= hdrlen;
  804. if (frag_skb->tail + flen > frag_skb->end) {
  805. printk(KERN_WARNING "%s: host decrypted and "
  806. "reassembled frame did not fit skb\n",
  807. dev->name);
  808. prism2_frag_cache_invalidate(local, hdr);
  809. goto rx_dropped;
  810. }
  811. if (frag == 0) {
  812. /* copy first fragment (including full headers) into
  813. * beginning of the fragment cache skb */
  814. skb_copy_from_linear_data(skb, skb_put(frag_skb, flen),
  815. flen);
  816. } else {
  817. /* append frame payload to the end of the fragment
  818. * cache skb */
  819. skb_copy_from_linear_data_offset(skb, hdrlen,
  820. skb_put(frag_skb,
  821. flen), flen);
  822. }
  823. dev_kfree_skb(skb);
  824. skb = NULL;
  825. if (fc & IEEE80211_FCTL_MOREFRAGS) {
  826. /* more fragments expected - leave the skb in fragment
  827. * cache for now; it will be delivered to upper layers
  828. * after all fragments have been received */
  829. goto rx_exit;
  830. }
  831. /* this was the last fragment and the frame will be
  832. * delivered, so remove skb from fragment cache */
  833. skb = frag_skb;
  834. hdr = (struct ieee80211_hdr *) skb->data;
  835. prism2_frag_cache_invalidate(local, hdr);
  836. }
  837. /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
  838. * encrypted/authenticated */
  839. if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
  840. hostap_rx_frame_decrypt_msdu(local, skb, keyidx, crypt))
  841. goto rx_dropped;
  842. hdr = (struct ieee80211_hdr *) skb->data;
  843. if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !local->open_wep) {
  844. if (local->ieee_802_1x &&
  845. hostap_is_eapol_frame(local, skb)) {
  846. /* pass unencrypted EAPOL frames even if encryption is
  847. * configured */
  848. PDEBUG(DEBUG_EXTRA2, "%s: RX: IEEE 802.1X - passing "
  849. "unencrypted EAPOL frame\n", local->dev->name);
  850. } else {
  851. printk(KERN_DEBUG "%s: encryption configured, but RX "
  852. "frame not encrypted (SA=%pM)\n",
  853. local->dev->name, hdr->addr2);
  854. goto rx_dropped;
  855. }
  856. }
  857. if (local->drop_unencrypted && !(fc & IEEE80211_FCTL_PROTECTED) &&
  858. !hostap_is_eapol_frame(local, skb)) {
  859. if (net_ratelimit()) {
  860. printk(KERN_DEBUG "%s: dropped unencrypted RX data "
  861. "frame from %pM (drop_unencrypted=1)\n",
  862. dev->name, hdr->addr2);
  863. }
  864. goto rx_dropped;
  865. }
  866. /* skb: hdr + (possible reassembled) full plaintext payload */
  867. payload = skb->data + hdrlen;
  868. ethertype = (payload[6] << 8) | payload[7];
  869. /* If IEEE 802.1X is used, check whether the port is authorized to send
  870. * the received frame. */
  871. if (local->ieee_802_1x && local->iw_mode == IW_MODE_MASTER) {
  872. if (ethertype == ETH_P_PAE) {
  873. PDEBUG(DEBUG_EXTRA2, "%s: RX: IEEE 802.1X frame\n",
  874. dev->name);
  875. if (local->hostapd && local->apdev) {
  876. /* Send IEEE 802.1X frames to the user
  877. * space daemon for processing */
  878. prism2_rx_80211(local->apdev, skb, rx_stats,
  879. PRISM2_RX_MGMT);
  880. local->apdevstats.rx_packets++;
  881. local->apdevstats.rx_bytes += skb->len;
  882. goto rx_exit;
  883. }
  884. } else if (!frame_authorized) {
  885. printk(KERN_DEBUG "%s: dropped frame from "
  886. "unauthorized port (IEEE 802.1X): "
  887. "ethertype=0x%04x\n",
  888. dev->name, ethertype);
  889. goto rx_dropped;
  890. }
  891. }
  892. /* convert hdr + possible LLC headers into Ethernet header */
  893. if (skb->len - hdrlen >= 8 &&
  894. ((memcmp(payload, rfc1042_header, 6) == 0 &&
  895. ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
  896. memcmp(payload, bridge_tunnel_header, 6) == 0)) {
  897. /* remove RFC1042 or Bridge-Tunnel encapsulation and
  898. * replace EtherType */
  899. skb_pull(skb, hdrlen + 6);
  900. memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
  901. memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
  902. } else {
  903. __be16 len;
  904. /* Leave Ethernet header part of hdr and full payload */
  905. skb_pull(skb, hdrlen);
  906. len = htons(skb->len);
  907. memcpy(skb_push(skb, 2), &len, 2);
  908. memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
  909. memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
  910. }
  911. if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
  912. IEEE80211_FCTL_TODS) &&
  913. skb->len >= ETH_HLEN + ETH_ALEN) {
  914. /* Non-standard frame: get addr4 from its bogus location after
  915. * the payload */
  916. skb_copy_from_linear_data_offset(skb, skb->len - ETH_ALEN,
  917. skb->data + ETH_ALEN,
  918. ETH_ALEN);
  919. skb_trim(skb, skb->len - ETH_ALEN);
  920. }
  921. dev->stats.rx_packets++;
  922. dev->stats.rx_bytes += skb->len;
  923. if (local->iw_mode == IW_MODE_MASTER && !wds &&
  924. local->ap->bridge_packets) {
  925. if (dst[0] & 0x01) {
  926. /* copy multicast frame both to the higher layers and
  927. * to the wireless media */
  928. local->ap->bridged_multicast++;
  929. skb2 = skb_clone(skb, GFP_ATOMIC);
  930. if (skb2 == NULL)
  931. printk(KERN_DEBUG "%s: skb_clone failed for "
  932. "multicast frame\n", dev->name);
  933. } else if (hostap_is_sta_authorized(local->ap, dst)) {
  934. /* send frame directly to the associated STA using
  935. * wireless media and not passing to higher layers */
  936. local->ap->bridged_unicast++;
  937. skb2 = skb;
  938. skb = NULL;
  939. }
  940. }
  941. if (skb2 != NULL) {
  942. /* send to wireless media */
  943. skb2->dev = dev;
  944. skb2->protocol = cpu_to_be16(ETH_P_802_3);
  945. skb_reset_mac_header(skb2);
  946. skb_reset_network_header(skb2);
  947. /* skb2->network_header += ETH_HLEN; */
  948. dev_queue_xmit(skb2);
  949. }
  950. if (skb) {
  951. skb->protocol = eth_type_trans(skb, dev);
  952. memset(skb->cb, 0, sizeof(skb->cb));
  953. netif_rx(skb);
  954. }
  955. rx_exit:
  956. if (sta)
  957. hostap_handle_sta_release(sta);
  958. return;
  959. rx_dropped:
  960. dev_kfree_skb(skb);
  961. dev->stats.rx_dropped++;
  962. goto rx_exit;
  963. }
  964. EXPORT_SYMBOL(hostap_80211_rx);