diff options
author | Kalle Valo <kalle.valo@nokia.com> | 2010-01-05 13:16:26 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-12 13:51:24 -0500 |
commit | d8cd189e9b1e050629f545e76b21a321f62c29bf (patch) | |
tree | 66f684beedf3ae374488f0ec7240a8fb049c688d /net/mac80211/mlme.c | |
parent | 7044cc565b45a898c140fb185174a66f2d68a163 (diff) |
mac80211: use PS Poll and Nullfunc templates when sending such frames
To avoid duplicate code, use ieee80211_[pspoll|nullfunc]_get() to get
templates for PS Poll and Nullfunc frames in mlme.c.
Compile-tested only.
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r-- | net/mac80211/mlme.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 97bcf2278bdb..5484cf930a87 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -249,30 +249,15 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
249 | void ieee80211_send_pspoll(struct ieee80211_local *local, | 249 | void ieee80211_send_pspoll(struct ieee80211_local *local, |
250 | struct ieee80211_sub_if_data *sdata) | 250 | struct ieee80211_sub_if_data *sdata) |
251 | { | 251 | { |
252 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
253 | struct ieee80211_pspoll *pspoll; | 252 | struct ieee80211_pspoll *pspoll; |
254 | struct sk_buff *skb; | 253 | struct sk_buff *skb; |
255 | u16 fc; | ||
256 | 254 | ||
257 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); | 255 | skb = ieee80211_pspoll_get(&local->hw, &sdata->vif); |
258 | if (!skb) { | 256 | if (!skb) |
259 | printk(KERN_DEBUG "%s: failed to allocate buffer for " | ||
260 | "pspoll frame\n", sdata->name); | ||
261 | return; | 257 | return; |
262 | } | ||
263 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
264 | |||
265 | pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll)); | ||
266 | memset(pspoll, 0, sizeof(*pspoll)); | ||
267 | fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM; | ||
268 | pspoll->frame_control = cpu_to_le16(fc); | ||
269 | pspoll->aid = cpu_to_le16(ifmgd->aid); | ||
270 | 258 | ||
271 | /* aid in PS-Poll has its two MSBs each set to 1 */ | 259 | pspoll = (struct ieee80211_pspoll *) skb->data; |
272 | pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); | 260 | pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
273 | |||
274 | memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); | ||
275 | memcpy(pspoll->ta, sdata->vif.addr, ETH_ALEN); | ||
276 | 261 | ||
277 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 262 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
278 | ieee80211_tx_skb(sdata, skb); | 263 | ieee80211_tx_skb(sdata, skb); |
@@ -283,30 +268,15 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, | |||
283 | int powersave) | 268 | int powersave) |
284 | { | 269 | { |
285 | struct sk_buff *skb; | 270 | struct sk_buff *skb; |
286 | struct ieee80211_hdr *nullfunc; | 271 | struct ieee80211_hdr_3addr *nullfunc; |
287 | __le16 fc; | ||
288 | 272 | ||
289 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) | 273 | skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif); |
274 | if (!skb) | ||
290 | return; | 275 | return; |
291 | 276 | ||
292 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); | 277 | nullfunc = (struct ieee80211_hdr_3addr *) skb->data; |
293 | if (!skb) { | ||
294 | printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " | ||
295 | "frame\n", sdata->name); | ||
296 | return; | ||
297 | } | ||
298 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
299 | |||
300 | nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); | ||
301 | memset(nullfunc, 0, 24); | ||
302 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | | ||
303 | IEEE80211_FCTL_TODS); | ||
304 | if (powersave) | 278 | if (powersave) |
305 | fc |= cpu_to_le16(IEEE80211_FCTL_PM); | 279 | nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
306 | nullfunc->frame_control = fc; | ||
307 | memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); | ||
308 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); | ||
309 | memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); | ||
310 | 280 | ||
311 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 281 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
312 | ieee80211_tx_skb(sdata, skb); | 282 | ieee80211_tx_skb(sdata, skb); |