hostap_80211_rx.c 32 KB

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