hostap_80211_rx.c 31 KB

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