diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-06-22 19:45:23 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-27 09:09:17 -0400 |
commit | 70217d7f83a12e0a16c726951ddf8f7f0ba7d1a4 (patch) | |
tree | 5013ba8172b87daf82fb7e8ed0682f99fd59016f /net/mac80211/wep.c | |
parent | 3a078876caee9634dbb9b41e6269262e30e8b535 (diff) |
mac80211: wep.c use new frame control helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/wep.c')
-rw-r--r-- | net/mac80211/wep.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index e7b6344c900a..35b664d00e23 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -84,20 +84,17 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, | |||
84 | struct sk_buff *skb, | 84 | struct sk_buff *skb, |
85 | struct ieee80211_key *key) | 85 | struct ieee80211_key *key) |
86 | { | 86 | { |
87 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 87 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
88 | u16 fc; | 88 | unsigned int hdrlen; |
89 | int hdrlen; | ||
90 | u8 *newhdr; | 89 | u8 *newhdr; |
91 | 90 | ||
92 | fc = le16_to_cpu(hdr->frame_control); | 91 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); |
93 | fc |= IEEE80211_FCTL_PROTECTED; | ||
94 | hdr->frame_control = cpu_to_le16(fc); | ||
95 | 92 | ||
96 | if (WARN_ON(skb_tailroom(skb) < WEP_ICV_LEN || | 93 | if (WARN_ON(skb_tailroom(skb) < WEP_ICV_LEN || |
97 | skb_headroom(skb) < WEP_IV_LEN)) | 94 | skb_headroom(skb) < WEP_IV_LEN)) |
98 | return NULL; | 95 | return NULL; |
99 | 96 | ||
100 | hdrlen = ieee80211_get_hdrlen(fc); | 97 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
101 | newhdr = skb_push(skb, WEP_IV_LEN); | 98 | newhdr = skb_push(skb, WEP_IV_LEN); |
102 | memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); | 99 | memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); |
103 | ieee80211_wep_get_iv(local, key, newhdr + hdrlen); | 100 | ieee80211_wep_get_iv(local, key, newhdr + hdrlen); |
@@ -109,12 +106,10 @@ static void ieee80211_wep_remove_iv(struct ieee80211_local *local, | |||
109 | struct sk_buff *skb, | 106 | struct sk_buff *skb, |
110 | struct ieee80211_key *key) | 107 | struct ieee80211_key *key) |
111 | { | 108 | { |
112 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 109 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
113 | u16 fc; | 110 | unsigned int hdrlen; |
114 | int hdrlen; | ||
115 | 111 | ||
116 | fc = le16_to_cpu(hdr->frame_control); | 112 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
117 | hdrlen = ieee80211_get_hdrlen(fc); | ||
118 | memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen); | 113 | memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen); |
119 | skb_pull(skb, WEP_IV_LEN); | 114 | skb_pull(skb, WEP_IV_LEN); |
120 | } | 115 | } |
@@ -224,17 +219,15 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, | |||
224 | u32 klen; | 219 | u32 klen; |
225 | u8 *rc4key; | 220 | u8 *rc4key; |
226 | u8 keyidx; | 221 | u8 keyidx; |
227 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 222 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
228 | u16 fc; | 223 | unsigned int hdrlen; |
229 | int hdrlen; | ||
230 | size_t len; | 224 | size_t len; |
231 | int ret = 0; | 225 | int ret = 0; |
232 | 226 | ||
233 | fc = le16_to_cpu(hdr->frame_control); | 227 | if (!ieee80211_has_protected(hdr->frame_control)) |
234 | if (!(fc & IEEE80211_FCTL_PROTECTED)) | ||
235 | return -1; | 228 | return -1; |
236 | 229 | ||
237 | hdrlen = ieee80211_get_hdrlen(fc); | 230 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
238 | 231 | ||
239 | if (skb->len < 8 + hdrlen) | 232 | if (skb->len < 8 + hdrlen) |
240 | return -1; | 233 | return -1; |
@@ -281,17 +274,15 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, | |||
281 | 274 | ||
282 | u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) | 275 | u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) |
283 | { | 276 | { |
284 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 277 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
285 | u16 fc; | 278 | unsigned int hdrlen; |
286 | int hdrlen; | ||
287 | u8 *ivpos; | 279 | u8 *ivpos; |
288 | u32 iv; | 280 | u32 iv; |
289 | 281 | ||
290 | fc = le16_to_cpu(hdr->frame_control); | 282 | if (!ieee80211_has_protected(hdr->frame_control)) |
291 | if (!(fc & IEEE80211_FCTL_PROTECTED)) | ||
292 | return NULL; | 283 | return NULL; |
293 | 284 | ||
294 | hdrlen = ieee80211_get_hdrlen(fc); | 285 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
295 | ivpos = skb->data + hdrlen; | 286 | ivpos = skb->data + hdrlen; |
296 | iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; | 287 | iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; |
297 | 288 | ||