Skip to content

Commit d8cd189

Browse files
Kalle Valolinvjw
authored andcommitted
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>
1 parent 7044cc5 commit d8cd189

File tree

1 file changed

+9
-39
lines changed

1 file changed

+9
-39
lines changed

net/mac80211/mlme.c

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -249,30 +249,15 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
249249
void ieee80211_send_pspoll(struct ieee80211_local *local,
250250
struct ieee80211_sub_if_data *sdata)
251251
{
252-
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
253252
struct ieee80211_pspoll *pspoll;
254253
struct sk_buff *skb;
255-
u16 fc;
256254

257-
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll));
258-
if (!skb) {
259-
printk(KERN_DEBUG "%s: failed to allocate buffer for "
260-
"pspoll frame\n", sdata->name);
255+
skb = ieee80211_pspoll_get(&local->hw, &sdata->vif);
256+
if (!skb)
261257
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);
270258

271-
/* aid in PS-Poll has its two MSBs each set to 1 */
272-
pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14);
273-
274-
memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN);
275-
memcpy(pspoll->ta, sdata->vif.addr, ETH_ALEN);
259+
pspoll = (struct ieee80211_pspoll *) skb->data;
260+
pspoll->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
276261

277262
IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
278263
ieee80211_tx_skb(sdata, skb);
@@ -283,30 +268,15 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
283268
int powersave)
284269
{
285270
struct sk_buff *skb;
286-
struct ieee80211_hdr *nullfunc;
287-
__le16 fc;
271+
struct ieee80211_hdr_3addr *nullfunc;
288272

289-
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
273+
skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif);
274+
if (!skb)
290275
return;
291276

292-
skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24);
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);
277+
nullfunc = (struct ieee80211_hdr_3addr *) skb->data;
304278
if (powersave)
305-
fc |= 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);
279+
nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
310280

311281
IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
312282
ieee80211_tx_skb(sdata, skb);

0 commit comments

Comments
 (0)