diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-09 04:58:25 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-11 15:53:38 -0400 |
commit | ef422bc0ae934e6a46dfa63f0e27cad83b94234f (patch) | |
tree | 83a1a253efa6ca6704b034e17513fe9f82e11cde | |
parent | 9ac19a9084001695479a6d6dd67443cc5fb1df2f (diff) |
mac80211: consolidate deauth/disassoc
deauth and disassoc frames are completely identical so there's
little point in having two functions to send them rather than
one that gets a parameter. This same a bit of code size.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/mlme.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index e917e1b72631..62357a208851 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -416,17 +416,18 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, | |||
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | static void ieee80211_send_deauth(struct ieee80211_sub_if_data *sdata, | 419 | static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, |
420 | struct ieee80211_if_sta *ifsta, u16 reason) | 420 | u16 stype, u16 reason) |
421 | { | 421 | { |
422 | struct ieee80211_local *local = sdata->local; | 422 | struct ieee80211_local *local = sdata->local; |
423 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
423 | struct sk_buff *skb; | 424 | struct sk_buff *skb; |
424 | struct ieee80211_mgmt *mgmt; | 425 | struct ieee80211_mgmt *mgmt; |
425 | 426 | ||
426 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); | 427 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); |
427 | if (!skb) { | 428 | if (!skb) { |
428 | printk(KERN_DEBUG "%s: failed to allocate buffer for deauth " | 429 | printk(KERN_DEBUG "%s: failed to allocate buffer for " |
429 | "frame\n", sdata->dev->name); | 430 | "deauth/disassoc frame\n", sdata->dev->name); |
430 | return; | 431 | return; |
431 | } | 432 | } |
432 | skb_reserve(skb, local->hw.extra_tx_headroom); | 433 | skb_reserve(skb, local->hw.extra_tx_headroom); |
@@ -436,42 +437,14 @@ static void ieee80211_send_deauth(struct ieee80211_sub_if_data *sdata, | |||
436 | memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); | 437 | memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); |
437 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | 438 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); |
438 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | 439 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); |
439 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | 440 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); |
440 | IEEE80211_STYPE_DEAUTH); | ||
441 | skb_put(skb, 2); | 441 | skb_put(skb, 2); |
442 | /* u.deauth.reason_code == u.disassoc.reason_code */ | ||
442 | mgmt->u.deauth.reason_code = cpu_to_le16(reason); | 443 | mgmt->u.deauth.reason_code = cpu_to_le16(reason); |
443 | 444 | ||
444 | ieee80211_sta_tx(sdata, skb, 0); | 445 | ieee80211_sta_tx(sdata, skb, 0); |
445 | } | 446 | } |
446 | 447 | ||
447 | static void ieee80211_send_disassoc(struct ieee80211_sub_if_data *sdata, | ||
448 | struct ieee80211_if_sta *ifsta, u16 reason) | ||
449 | { | ||
450 | struct ieee80211_local *local = sdata->local; | ||
451 | struct sk_buff *skb; | ||
452 | struct ieee80211_mgmt *mgmt; | ||
453 | |||
454 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); | ||
455 | if (!skb) { | ||
456 | printk(KERN_DEBUG "%s: failed to allocate buffer for disassoc " | ||
457 | "frame\n", sdata->dev->name); | ||
458 | return; | ||
459 | } | ||
460 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
461 | |||
462 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
463 | memset(mgmt, 0, 24); | ||
464 | memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); | ||
465 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
466 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
467 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
468 | IEEE80211_STYPE_DISASSOC); | ||
469 | skb_put(skb, 2); | ||
470 | mgmt->u.disassoc.reason_code = cpu_to_le16(reason); | ||
471 | |||
472 | ieee80211_sta_tx(sdata, skb, 0); | ||
473 | } | ||
474 | |||
475 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, | 448 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, |
476 | u8 dialog_token, u16 status, u16 policy, | 449 | u8 dialog_token, u16 status, u16 policy, |
477 | u16 buf_size, u16 timeout) | 450 | u16 buf_size, u16 timeout) |
@@ -919,9 +892,11 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
919 | 892 | ||
920 | if (self_disconnected) { | 893 | if (self_disconnected) { |
921 | if (deauth) | 894 | if (deauth) |
922 | ieee80211_send_deauth(sdata, ifsta, reason); | 895 | ieee80211_send_deauth_disassoc(sdata, |
896 | IEEE80211_STYPE_DEAUTH, reason); | ||
923 | else | 897 | else |
924 | ieee80211_send_disassoc(sdata, ifsta, reason); | 898 | ieee80211_send_deauth_disassoc(sdata, |
899 | IEEE80211_STYPE_DISASSOC, reason); | ||
925 | } | 900 | } |
926 | 901 | ||
927 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; | 902 | ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; |