hostap_80211_tx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. #include "hostap_80211.h"
  2. #include "hostap_common.h"
  3. #include "hostap_wlan.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_tx_80211(const char *name, struct sk_buff *skb)
  15. {
  16. struct ieee80211_hdr_4addr *hdr;
  17. u16 fc;
  18. DECLARE_MAC_BUF(mac);
  19. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  20. printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n",
  21. name, skb->len, jiffies);
  22. if (skb->len < 2)
  23. return;
  24. fc = le16_to_cpu(hdr->frame_ctl);
  25. printk(KERN_DEBUG " FC=0x%04x (type=%d:%d)%s%s",
  26. fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4,
  27. fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
  28. fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
  29. if (skb->len < IEEE80211_DATA_HDR3_LEN) {
  30. printk("\n");
  31. return;
  32. }
  33. printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id),
  34. le16_to_cpu(hdr->seq_ctl));
  35. printk(KERN_DEBUG " A1=%s", print_mac(mac, hdr->addr1));
  36. printk(" A2=%s", print_mac(mac, hdr->addr2));
  37. printk(" A3=%s", print_mac(mac, hdr->addr3));
  38. if (skb->len >= 30)
  39. printk(" A4=%s", print_mac(mac, hdr->addr4));
  40. printk("\n");
  41. }
  42. /* hard_start_xmit function for data interfaces (wlan#, wlan#wds#, wlan#sta)
  43. * Convert Ethernet header into a suitable IEEE 802.11 header depending on
  44. * device configuration. */
  45. int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
  46. {
  47. struct hostap_interface *iface;
  48. local_info_t *local;
  49. int need_headroom, need_tailroom = 0;
  50. struct ieee80211_hdr_4addr hdr;
  51. u16 fc, ethertype = 0;
  52. enum {
  53. WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
  54. } use_wds = WDS_NO;
  55. u8 *encaps_data;
  56. int hdr_len, encaps_len, skip_header_bytes;
  57. int to_assoc_ap = 0;
  58. struct hostap_skb_tx_data *meta;
  59. iface = netdev_priv(dev);
  60. local = iface->local;
  61. if (skb->len < ETH_HLEN) {
  62. printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb "
  63. "(len=%d)\n", dev->name, skb->len);
  64. kfree_skb(skb);
  65. return 0;
  66. }
  67. if (local->ddev != dev) {
  68. use_wds = (local->iw_mode == IW_MODE_MASTER &&
  69. !(local->wds_type & HOSTAP_WDS_STANDARD_FRAME)) ?
  70. WDS_OWN_FRAME : WDS_COMPLIANT_FRAME;
  71. if (dev == local->stadev) {
  72. to_assoc_ap = 1;
  73. use_wds = WDS_NO;
  74. } else if (dev == local->apdev) {
  75. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  76. "AP device with Ethernet net dev\n", dev->name);
  77. kfree_skb(skb);
  78. return 0;
  79. }
  80. } else {
  81. if (local->iw_mode == IW_MODE_REPEAT) {
  82. printk(KERN_DEBUG "%s: prism2_tx: trying to use "
  83. "non-WDS link in Repeater mode\n", dev->name);
  84. kfree_skb(skb);
  85. return 0;
  86. } else if (local->iw_mode == IW_MODE_INFRA &&
  87. (local->wds_type & HOSTAP_WDS_AP_CLIENT) &&
  88. memcmp(skb->data + ETH_ALEN, dev->dev_addr,
  89. ETH_ALEN) != 0) {
  90. /* AP client mode: send frames with foreign src addr
  91. * using 4-addr WDS frames */
  92. use_wds = WDS_COMPLIANT_FRAME;
  93. }
  94. }
  95. /* Incoming skb->data: dst_addr[6], src_addr[6], proto[2], payload
  96. * ==>
  97. * Prism2 TX frame with 802.11 header:
  98. * txdesc (address order depending on used mode; includes dst_addr and
  99. * src_addr), possible encapsulation (RFC1042/Bridge-Tunnel;
  100. * proto[2], payload {, possible addr4[6]} */
  101. ethertype = (skb->data[12] << 8) | skb->data[13];
  102. memset(&hdr, 0, sizeof(hdr));
  103. /* Length of data after IEEE 802.11 header */
  104. encaps_data = NULL;
  105. encaps_len = 0;
  106. skip_header_bytes = ETH_HLEN;
  107. if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
  108. encaps_data = bridge_tunnel_header;
  109. encaps_len = sizeof(bridge_tunnel_header);
  110. skip_header_bytes -= 2;
  111. } else if (ethertype >= 0x600) {
  112. encaps_data = rfc1042_header;
  113. encaps_len = sizeof(rfc1042_header);
  114. skip_header_bytes -= 2;
  115. }
  116. fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
  117. hdr_len = IEEE80211_DATA_HDR3_LEN;
  118. if (use_wds != WDS_NO) {
  119. /* Note! Prism2 station firmware has problems with sending real
  120. * 802.11 frames with four addresses; until these problems can
  121. * be fixed or worked around, 4-addr frames needed for WDS are
  122. * using incompatible format: FromDS flag is not set and the
  123. * fourth address is added after the frame payload; it is
  124. * assumed, that the receiving station knows how to handle this
  125. * frame format */
  126. if (use_wds == WDS_COMPLIANT_FRAME) {
  127. fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
  128. /* From&To DS: Addr1 = RA, Addr2 = TA, Addr3 = DA,
  129. * Addr4 = SA */
  130. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  131. &hdr.addr4, ETH_ALEN);
  132. hdr_len += ETH_ALEN;
  133. } else {
  134. /* bogus 4-addr format to workaround Prism2 station
  135. * f/w bug */
  136. fc |= IEEE80211_FCTL_TODS;
  137. /* From DS: Addr1 = DA (used as RA),
  138. * Addr2 = BSSID (used as TA), Addr3 = SA (used as DA),
  139. */
  140. /* SA from skb->data + ETH_ALEN will be added after
  141. * frame payload; use hdr.addr4 as a temporary buffer
  142. */
  143. skb_copy_from_linear_data_offset(skb, ETH_ALEN,
  144. &hdr.addr4, ETH_ALEN);
  145. need_tailroom += ETH_ALEN;
  146. }
  147. /* send broadcast and multicast frames to broadcast RA, if
  148. * configured; otherwise, use unicast RA of the WDS link */
  149. if ((local->wds_type & HOSTAP_WDS_BROADCAST_RA) &&
  150. skb->data[0] & 0x01)
  151. memset(&hdr.addr1, 0xff, ETH_ALEN);
  152. else if (iface->type == HOSTAP_INTERFACE_WDS)
  153. memcpy(&hdr.addr1, iface->u.wds.remote_addr,
  154. ETH_ALEN);
  155. else
  156. memcpy(&hdr.addr1, local->bssid, ETH_ALEN);
  157. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  158. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  159. } else if (local->iw_mode == IW_MODE_MASTER && !to_assoc_ap) {
  160. fc |= IEEE80211_FCTL_FROMDS;
  161. /* From DS: Addr1 = DA, Addr2 = BSSID, Addr3 = SA */
  162. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  163. memcpy(&hdr.addr2, dev->dev_addr, ETH_ALEN);
  164. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr3,
  165. ETH_ALEN);
  166. } else if (local->iw_mode == IW_MODE_INFRA || to_assoc_ap) {
  167. fc |= IEEE80211_FCTL_TODS;
  168. /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */
  169. memcpy(&hdr.addr1, to_assoc_ap ?
  170. local->assoc_ap_addr : local->bssid, ETH_ALEN);
  171. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  172. ETH_ALEN);
  173. skb_copy_from_linear_data(skb, &hdr.addr3, ETH_ALEN);
  174. } else if (local->iw_mode == IW_MODE_ADHOC) {
  175. /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */
  176. skb_copy_from_linear_data(skb, &hdr.addr1, ETH_ALEN);
  177. skb_copy_from_linear_data_offset(skb, ETH_ALEN, &hdr.addr2,
  178. ETH_ALEN);
  179. memcpy(&hdr.addr3, local->bssid, ETH_ALEN);
  180. }
  181. hdr.frame_ctl = cpu_to_le16(fc);
  182. skb_pull(skb, skip_header_bytes);
  183. need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len;
  184. if (skb_tailroom(skb) < need_tailroom) {
  185. skb = skb_unshare(skb, GFP_ATOMIC);
  186. if (skb == NULL) {
  187. iface->stats.tx_dropped++;
  188. return 0;
  189. }
  190. if (pskb_expand_head(skb, need_headroom, need_tailroom,
  191. GFP_ATOMIC)) {
  192. kfree_skb(skb);
  193. iface->stats.tx_dropped++;
  194. return 0;
  195. }
  196. } else if (skb_headroom(skb) < need_headroom) {
  197. struct sk_buff *tmp = skb;
  198. skb = skb_realloc_headroom(skb, need_headroom);
  199. kfree_skb(tmp);
  200. if (skb == NULL) {
  201. iface->stats.tx_dropped++;
  202. return 0;
  203. }
  204. } else {
  205. skb = skb_unshare(skb, GFP_ATOMIC);
  206. if (skb == NULL) {
  207. iface->stats.tx_dropped++;
  208. return 0;
  209. }
  210. }
  211. if (encaps_data)
  212. memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
  213. memcpy(skb_push(skb, hdr_len), &hdr, hdr_len);
  214. if (use_wds == WDS_OWN_FRAME) {
  215. memcpy(skb_put(skb, ETH_ALEN), &hdr.addr4, ETH_ALEN);
  216. }
  217. iface->stats.tx_packets++;
  218. iface->stats.tx_bytes += skb->len;
  219. skb_reset_mac_header(skb);
  220. meta = (struct hostap_skb_tx_data *) skb->cb;
  221. memset(meta, 0, sizeof(*meta));
  222. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  223. if (use_wds)
  224. meta->flags |= HOSTAP_TX_FLAGS_WDS;
  225. meta->ethertype = ethertype;
  226. meta->iface = iface;
  227. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  228. skb->dev = local->dev;
  229. dev_queue_xmit(skb);
  230. return 0;
  231. }
  232. /* hard_start_xmit function for hostapd wlan#ap interfaces */
  233. int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
  234. {
  235. struct hostap_interface *iface;
  236. local_info_t *local;
  237. struct hostap_skb_tx_data *meta;
  238. struct ieee80211_hdr_4addr *hdr;
  239. u16 fc;
  240. iface = netdev_priv(dev);
  241. local = iface->local;
  242. if (skb->len < 10) {
  243. printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb "
  244. "(len=%d)\n", dev->name, skb->len);
  245. kfree_skb(skb);
  246. return 0;
  247. }
  248. iface->stats.tx_packets++;
  249. iface->stats.tx_bytes += skb->len;
  250. meta = (struct hostap_skb_tx_data *) skb->cb;
  251. memset(meta, 0, sizeof(*meta));
  252. meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
  253. meta->iface = iface;
  254. if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
  255. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  256. fc = le16_to_cpu(hdr->frame_ctl);
  257. if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
  258. WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) {
  259. u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
  260. sizeof(rfc1042_header)];
  261. meta->ethertype = (pos[0] << 8) | pos[1];
  262. }
  263. }
  264. /* Send IEEE 802.11 encapsulated frame using the master radio device */
  265. skb->dev = local->dev;
  266. dev_queue_xmit(skb);
  267. return 0;
  268. }
  269. /* Called only from software IRQ */
  270. static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
  271. struct ieee80211_crypt_data *crypt)
  272. {
  273. struct hostap_interface *iface;
  274. local_info_t *local;
  275. struct ieee80211_hdr_4addr *hdr;
  276. u16 fc;
  277. int prefix_len, postfix_len, hdr_len, res;
  278. iface = netdev_priv(skb->dev);
  279. local = iface->local;
  280. if (skb->len < IEEE80211_DATA_HDR3_LEN) {
  281. kfree_skb(skb);
  282. return NULL;
  283. }
  284. if (local->tkip_countermeasures &&
  285. strcmp(crypt->ops->name, "TKIP") == 0) {
  286. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  287. if (net_ratelimit()) {
  288. printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
  289. "TX packet to " MAC_FMT "\n",
  290. local->dev->name,
  291. hdr->addr1[0], hdr->addr1[1], hdr->addr1[2],
  292. hdr->addr1[3], hdr->addr1[4], hdr->addr1[5]);
  293. }
  294. kfree_skb(skb);
  295. return NULL;
  296. }
  297. skb = skb_unshare(skb, GFP_ATOMIC);
  298. if (skb == NULL)
  299. return NULL;
  300. prefix_len = crypt->ops->extra_mpdu_prefix_len +
  301. crypt->ops->extra_msdu_prefix_len;
  302. postfix_len = crypt->ops->extra_mpdu_postfix_len +
  303. crypt->ops->extra_msdu_postfix_len;
  304. if ((skb_headroom(skb) < prefix_len ||
  305. skb_tailroom(skb) < postfix_len) &&
  306. pskb_expand_head(skb, prefix_len, postfix_len, GFP_ATOMIC)) {
  307. kfree_skb(skb);
  308. return NULL;
  309. }
  310. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  311. fc = le16_to_cpu(hdr->frame_ctl);
  312. hdr_len = hostap_80211_get_hdrlen(fc);
  313. /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
  314. * call both MSDU and MPDU encryption functions from here. */
  315. atomic_inc(&crypt->refcnt);
  316. res = 0;
  317. if (crypt->ops->encrypt_msdu)
  318. res = crypt->ops->encrypt_msdu(skb, hdr_len, crypt->priv);
  319. if (res == 0 && crypt->ops->encrypt_mpdu)
  320. res = crypt->ops->encrypt_mpdu(skb, hdr_len, crypt->priv);
  321. atomic_dec(&crypt->refcnt);
  322. if (res < 0) {
  323. kfree_skb(skb);
  324. return NULL;
  325. }
  326. return skb;
  327. }
  328. /* hard_start_xmit function for master radio interface wifi#.
  329. * AP processing (TX rate control, power save buffering, etc.).
  330. * Use hardware TX function to send the frame. */
  331. int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
  332. {
  333. struct hostap_interface *iface;
  334. local_info_t *local;
  335. int ret = 1;
  336. u16 fc;
  337. struct hostap_tx_data tx;
  338. ap_tx_ret tx_ret;
  339. struct hostap_skb_tx_data *meta;
  340. int no_encrypt = 0;
  341. struct ieee80211_hdr_4addr *hdr;
  342. iface = netdev_priv(dev);
  343. local = iface->local;
  344. tx.skb = skb;
  345. tx.sta_ptr = NULL;
  346. meta = (struct hostap_skb_tx_data *) skb->cb;
  347. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  348. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  349. "expected 0x%08x)\n",
  350. dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC);
  351. ret = 0;
  352. iface->stats.tx_dropped++;
  353. goto fail;
  354. }
  355. if (local->host_encrypt) {
  356. /* Set crypt to default algorithm and key; will be replaced in
  357. * AP code if STA has own alg/key */
  358. tx.crypt = local->crypt[local->tx_keyidx];
  359. tx.host_encrypt = 1;
  360. } else {
  361. tx.crypt = NULL;
  362. tx.host_encrypt = 0;
  363. }
  364. if (skb->len < 24) {
  365. printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb "
  366. "(len=%d)\n", dev->name, skb->len);
  367. ret = 0;
  368. iface->stats.tx_dropped++;
  369. goto fail;
  370. }
  371. /* FIX (?):
  372. * Wi-Fi 802.11b test plan suggests that AP should ignore power save
  373. * bit in authentication and (re)association frames and assume tha
  374. * STA remains awake for the response. */
  375. tx_ret = hostap_handle_sta_tx(local, &tx);
  376. skb = tx.skb;
  377. meta = (struct hostap_skb_tx_data *) skb->cb;
  378. hdr = (struct ieee80211_hdr_4addr *) skb->data;
  379. fc = le16_to_cpu(hdr->frame_ctl);
  380. switch (tx_ret) {
  381. case AP_TX_CONTINUE:
  382. break;
  383. case AP_TX_CONTINUE_NOT_AUTHORIZED:
  384. if (local->ieee_802_1x &&
  385. WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
  386. meta->ethertype != ETH_P_PAE &&
  387. !(meta->flags & HOSTAP_TX_FLAGS_WDS)) {
  388. printk(KERN_DEBUG "%s: dropped frame to unauthorized "
  389. "port (IEEE 802.1X): ethertype=0x%04x\n",
  390. dev->name, meta->ethertype);
  391. hostap_dump_tx_80211(dev->name, skb);
  392. ret = 0; /* drop packet */
  393. iface->stats.tx_dropped++;
  394. goto fail;
  395. }
  396. break;
  397. case AP_TX_DROP:
  398. ret = 0; /* drop packet */
  399. iface->stats.tx_dropped++;
  400. goto fail;
  401. case AP_TX_RETRY:
  402. goto fail;
  403. case AP_TX_BUFFERED:
  404. /* do not free skb here, it will be freed when the
  405. * buffered frame is sent/timed out */
  406. ret = 0;
  407. goto tx_exit;
  408. }
  409. /* Request TX callback if protocol version is 2 in 802.11 header;
  410. * this version 2 is a special case used between hostapd and kernel
  411. * driver */
  412. if (((fc & IEEE80211_FCTL_VERS) == BIT(1)) &&
  413. local->ap && local->ap->tx_callback_idx && meta->tx_cb_idx == 0) {
  414. meta->tx_cb_idx = local->ap->tx_callback_idx;
  415. /* remove special version from the frame header */
  416. fc &= ~IEEE80211_FCTL_VERS;
  417. hdr->frame_ctl = cpu_to_le16(fc);
  418. }
  419. if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_DATA) {
  420. no_encrypt = 1;
  421. tx.crypt = NULL;
  422. }
  423. if (local->ieee_802_1x && meta->ethertype == ETH_P_PAE && tx.crypt &&
  424. !(fc & IEEE80211_FCTL_PROTECTED)) {
  425. no_encrypt = 1;
  426. PDEBUG(DEBUG_EXTRA2, "%s: TX: IEEE 802.1X - passing "
  427. "unencrypted EAPOL frame\n", dev->name);
  428. tx.crypt = NULL; /* no encryption for IEEE 802.1X frames */
  429. }
  430. if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
  431. tx.crypt = NULL;
  432. else if ((tx.crypt || local->crypt[local->tx_keyidx]) && !no_encrypt) {
  433. /* Add ISWEP flag both for firmware and host based encryption
  434. */
  435. fc |= IEEE80211_FCTL_PROTECTED;
  436. hdr->frame_ctl = cpu_to_le16(fc);
  437. } else if (local->drop_unencrypted &&
  438. WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
  439. meta->ethertype != ETH_P_PAE) {
  440. if (net_ratelimit()) {
  441. printk(KERN_DEBUG "%s: dropped unencrypted TX data "
  442. "frame (drop_unencrypted=1)\n", dev->name);
  443. }
  444. iface->stats.tx_dropped++;
  445. ret = 0;
  446. goto fail;
  447. }
  448. if (tx.crypt) {
  449. skb = hostap_tx_encrypt(skb, tx.crypt);
  450. if (skb == NULL) {
  451. printk(KERN_DEBUG "%s: TX - encryption failed\n",
  452. dev->name);
  453. ret = 0;
  454. goto fail;
  455. }
  456. meta = (struct hostap_skb_tx_data *) skb->cb;
  457. if (meta->magic != HOSTAP_SKB_TX_DATA_MAGIC) {
  458. printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, "
  459. "expected 0x%08x) after hostap_tx_encrypt\n",
  460. dev->name, meta->magic,
  461. HOSTAP_SKB_TX_DATA_MAGIC);
  462. ret = 0;
  463. iface->stats.tx_dropped++;
  464. goto fail;
  465. }
  466. }
  467. if (local->func->tx == NULL || local->func->tx(skb, dev)) {
  468. ret = 0;
  469. iface->stats.tx_dropped++;
  470. } else {
  471. ret = 0;
  472. iface->stats.tx_packets++;
  473. iface->stats.tx_bytes += skb->len;
  474. }
  475. fail:
  476. if (!ret && skb)
  477. dev_kfree_skb(skb);
  478. tx_exit:
  479. if (tx.sta_ptr)
  480. hostap_handle_sta_release(tx.sta_ptr);
  481. return ret;
  482. }
  483. EXPORT_SYMBOL(hostap_master_start_xmit);