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>
This commit is contained in:
parent
9ac19a9084
commit
ef422bc0ae
1 changed files with 11 additions and 36 deletions
|
@ -416,17 +416,18 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ieee80211_send_deauth(struct ieee80211_sub_if_data *sdata,
|
static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
|
||||||
struct ieee80211_if_sta *ifsta, u16 reason)
|
u16 stype, u16 reason)
|
||||||
{
|
{
|
||||||
struct ieee80211_local *local = sdata->local;
|
struct ieee80211_local *local = sdata->local;
|
||||||
|
struct ieee80211_if_sta *ifsta = &sdata->u.sta;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct ieee80211_mgmt *mgmt;
|
struct ieee80211_mgmt *mgmt;
|
||||||
|
|
||||||
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
printk(KERN_DEBUG "%s: failed to allocate buffer for deauth "
|
printk(KERN_DEBUG "%s: failed to allocate buffer for "
|
||||||
"frame\n", sdata->dev->name);
|
"deauth/disassoc frame\n", sdata->dev->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||||
|
@ -436,42 +437,14 @@ static void ieee80211_send_deauth(struct ieee80211_sub_if_data *sdata,
|
||||||
memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
|
memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
|
||||||
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
||||||
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
|
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
|
||||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
|
||||||
IEEE80211_STYPE_DEAUTH);
|
|
||||||
skb_put(skb, 2);
|
skb_put(skb, 2);
|
||||||
|
/* u.deauth.reason_code == u.disassoc.reason_code */
|
||||||
mgmt->u.deauth.reason_code = cpu_to_le16(reason);
|
mgmt->u.deauth.reason_code = cpu_to_le16(reason);
|
||||||
|
|
||||||
ieee80211_sta_tx(sdata, skb, 0);
|
ieee80211_sta_tx(sdata, skb, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ieee80211_send_disassoc(struct ieee80211_sub_if_data *sdata,
|
|
||||||
struct ieee80211_if_sta *ifsta, u16 reason)
|
|
||||||
{
|
|
||||||
struct ieee80211_local *local = sdata->local;
|
|
||||||
struct sk_buff *skb;
|
|
||||||
struct ieee80211_mgmt *mgmt;
|
|
||||||
|
|
||||||
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
|
|
||||||
if (!skb) {
|
|
||||||
printk(KERN_DEBUG "%s: failed to allocate buffer for disassoc "
|
|
||||||
"frame\n", sdata->dev->name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
||||||
|
|
||||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
|
||||||
memset(mgmt, 0, 24);
|
|
||||||
memcpy(mgmt->da, ifsta->bssid, ETH_ALEN);
|
|
||||||
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
|
||||||
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
|
|
||||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
|
||||||
IEEE80211_STYPE_DISASSOC);
|
|
||||||
skb_put(skb, 2);
|
|
||||||
mgmt->u.disassoc.reason_code = cpu_to_le16(reason);
|
|
||||||
|
|
||||||
ieee80211_sta_tx(sdata, skb, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid,
|
static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid,
|
||||||
u8 dialog_token, u16 status, u16 policy,
|
u8 dialog_token, u16 status, u16 policy,
|
||||||
u16 buf_size, u16 timeout)
|
u16 buf_size, u16 timeout)
|
||||||
|
@ -919,9 +892,11 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
|
||||||
|
|
||||||
if (self_disconnected) {
|
if (self_disconnected) {
|
||||||
if (deauth)
|
if (deauth)
|
||||||
ieee80211_send_deauth(sdata, ifsta, reason);
|
ieee80211_send_deauth_disassoc(sdata,
|
||||||
|
IEEE80211_STYPE_DEAUTH, reason);
|
||||||
else
|
else
|
||||||
ieee80211_send_disassoc(sdata, ifsta, reason);
|
ieee80211_send_deauth_disassoc(sdata,
|
||||||
|
IEEE80211_STYPE_DISASSOC, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
|
ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
|
||||||
|
|
Loading…
Add table
Reference in a new issue