diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-06-11 17:21:57 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-14 12:18:13 -0400 |
commit | 6693be7124cb8e4f15f0d80ed6e3e50678771737 (patch) | |
tree | aadddb7a21250d1e7b76e0f4ba2ca124288515e3 /net/mac80211/util.c | |
parent | c9c6950c14ffc0e30e592fec1ebcb203ad3dff10 (diff) |
mac80211: add utility function to get header length
Take a __le16 directly rather than a host-endian value.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r-- | net/mac80211/util.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index f3c30d00b21e..9f365a3af96f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -133,6 +133,38 @@ int ieee80211_get_hdrlen(u16 fc) | |||
133 | } | 133 | } |
134 | EXPORT_SYMBOL(ieee80211_get_hdrlen); | 134 | EXPORT_SYMBOL(ieee80211_get_hdrlen); |
135 | 135 | ||
136 | unsigned int ieee80211_hdrlen(__le16 fc) | ||
137 | { | ||
138 | unsigned int hdrlen = 24; | ||
139 | |||
140 | if (ieee80211_is_data(fc)) { | ||
141 | if (ieee80211_has_a4(fc)) | ||
142 | hdrlen = 30; | ||
143 | if (ieee80211_is_data_qos(fc)) | ||
144 | hdrlen += IEEE80211_QOS_CTL_LEN; | ||
145 | goto out; | ||
146 | } | ||
147 | |||
148 | if (ieee80211_is_ctl(fc)) { | ||
149 | /* | ||
150 | * ACK and CTS are 10 bytes, all others 16. To see how | ||
151 | * to get this condition consider | ||
152 | * subtype mask: 0b0000000011110000 (0x00F0) | ||
153 | * ACK subtype: 0b0000000011010000 (0x00D0) | ||
154 | * CTS subtype: 0b0000000011000000 (0x00C0) | ||
155 | * bits that matter: ^^^ (0x00E0) | ||
156 | * value of those: 0b0000000011000000 (0x00C0) | ||
157 | */ | ||
158 | if ((fc & cpu_to_le16(0x00E0)) == cpu_to_le16(0x00C0)) | ||
159 | hdrlen = 10; | ||
160 | else | ||
161 | hdrlen = 16; | ||
162 | } | ||
163 | out: | ||
164 | return hdrlen; | ||
165 | } | ||
166 | EXPORT_SYMBOL(ieee80211_hdrlen); | ||
167 | |||
136 | unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) | 168 | unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) |
137 | { | 169 | { |
138 | const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)skb->data; | 170 | const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)skb->data; |