Commit 8c35024a authored by Benoit PAPILLAULT's avatar Benoit PAPILLAULT Committed by John W. Linville

ath9k: This patch fix RX unpadding for any received frame.

It has been tested with a 802.11 frame generator and by checking the FCS field
of each received frame with the value reported by the Atheros hardware. This
patch is useful if you are trying to analyze non standard 802.11 frame going
over the air.
Signed-off-by: default avatarBenoit PAPILLAULT <benoit.papillault@free.fr>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ac2752c1
...@@ -231,26 +231,35 @@ void ath9k_cmn_rx_skb_postprocess(struct ath_common *common, ...@@ -231,26 +231,35 @@ void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
{ {
struct ath_hw *ah = common->ah; struct ath_hw *ah = common->ah;
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
int hdrlen, padsize; int hdrlen, padpos, padsize;
u8 keyix; u8 keyix;
__le16 fc; __le16 fc;
/* see if any padding is done by the hw and remove it */ /* see if any padding is done by the hw and remove it */
hdr = (struct ieee80211_hdr *) skb->data; hdr = (struct ieee80211_hdr *) skb->data;
hdrlen = ieee80211_get_hdrlen_from_skb(skb); hdrlen = ieee80211_get_hdrlen_from_skb(skb);
padpos = 24;
fc = hdr->frame_control; fc = hdr->frame_control;
if ((fc & cpu_to_le16(IEEE80211_FCTL_FROMDS|IEEE80211_FCTL_TODS)) ==
cpu_to_le16(IEEE80211_FCTL_FROMDS|IEEE80211_FCTL_TODS)) {
padpos += 6; /* ETH_ALEN */
}
if ((fc & cpu_to_le16(IEEE80211_STYPE_QOS_DATA|IEEE80211_FCTL_FTYPE)) ==
cpu_to_le16(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) {
padpos += 2;
}
/* The MAC header is padded to have 32-bit boundary if the /* The MAC header is padded to have 32-bit boundary if the
* packet payload is non-zero. The general calculation for * packet payload is non-zero. The general calculation for
* padsize would take into account odd header lengths: * padsize would take into account odd header lengths:
* padsize = (4 - hdrlen % 4) % 4; However, since only * padsize = (4 - padpos % 4) % 4; However, since only
* even-length headers are used, padding can only be 0 or 2 * even-length headers are used, padding can only be 0 or 2
* bytes and we can optimize this a bit. In addition, we must * bytes and we can optimize this a bit. In addition, we must
* not try to remove padding from short control frames that do * not try to remove padding from short control frames that do
* not have payload. */ * not have payload. */
padsize = hdrlen & 3; padsize = padpos & 3;
if (padsize && hdrlen >= 24) { if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
memmove(skb->data + padsize, skb->data, hdrlen); memmove(skb->data + padsize, skb->data, padpos);
skb_pull(skb, padsize); skb_pull(skb, padsize);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment