Advertisement
v1999430

Untitled

Oct 30th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
  2. {
  3. struct sk_buff *skb = NULL;
  4. struct ieee80211_hdr_3addr *BAReq = NULL;
  5. u8 *tag = NULL;
  6. u16 tmp = 0;
  7. u16 len = ieee->tx_headroom + 9;
  8. //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
  9. IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev);
  10. if (pBA == NULL||ieee == NULL)
  11. {
  12. IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee);
  13. return NULL;
  14. }
  15. skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
  16. if (skb == NULL)
  17. {
  18. IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
  19. return NULL;
  20. }
  21.  
  22. memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
  23. skb_reserve(skb, ieee->tx_headroom);
  24.  
  25. BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
  26.  
  27. memcpy(BAReq->addr1, Dst, ETH_ALEN);
  28. memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
  29.  
  30. memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
  31.  
  32. BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
  33.  
  34. //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field
  35. tag = (u8 *)skb_put(skb, 9);
  36. *tag ++= ACT_CAT_BA;
  37. *tag ++= type;
  38. // Dialog Token
  39. *tag ++= pBA->DialogToken;
  40.  
  41. if (ACT_ADDBARSP == type)
  42. {
  43. // Status Code
  44. printk("=====>to send ADDBARSP\n");
  45. tmp = cpu_to_le16(StatusCode);
  46. memcpy(tag, (u8 *)&tmp, 2);
  47. tag += 2;
  48. }
  49. // BA Parameter Set
  50. tmp = cpu_to_le16(pBA->BaParamSet.shortData);
  51. memcpy(tag, (u8 *)&tmp, 2);
  52. tag += 2;
  53. // BA Timeout Value
  54. tmp = cpu_to_le16(pBA->BaTimeoutValue);
  55. memcpy(tag, (u8 *)&tmp, 2);
  56. tag += 2;
  57.  
  58. if (ACT_ADDBAREQ == type)
  59. {
  60. // BA Start SeqCtrl
  61. memcpy(tag, (u8 *)&(pBA->BaStartSeqCtrl), 2);
  62. tag += 2;
  63. }
  64.  
  65. IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
  66. return skb;
  67. //return NULL;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement