From 731723a5bd3e899173e88732a4ca843d536cc8c4 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 17 Apr 2009 11:37:22 +0300 Subject: [PATCH] Add own_addr as a parameter to sta_deauth() and sta_disassoc() This fixes deauth/disassoc frames in secondary BSSes when using multi-BSSID. In addition, it reduces need to dereference struct hostapd_data inside driver wrappers. --- hostapd/driver_i.h | 6 ++++-- src/drivers/driver.h | 6 ++++-- src/drivers/driver_atheros.c | 12 ++++++++---- src/drivers/driver_bsd.c | 10 ++++++---- src/drivers/driver_hostap.c | 16 ++++++++-------- src/drivers/driver_madwifi.c | 12 ++++++++---- src/drivers/driver_nl80211.c | 17 ++++++++--------- src/drivers/driver_prism54.c | 6 ++++-- src/drivers/driver_test.c | 6 ++++-- 9 files changed, 54 insertions(+), 37 deletions(-) diff --git a/hostapd/driver_i.h b/hostapd/driver_i.h index 1b6cd5e84..dc2ea2b9e 100644 --- a/hostapd/driver_i.h +++ b/hostapd/driver_i.h @@ -154,7 +154,8 @@ hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason) { if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL) return 0; - return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason); + return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr, + reason); } static inline int @@ -162,7 +163,8 @@ hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason) { if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL) return 0; - return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason); + return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr, + reason); } static inline int diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 54c3fe3bd..db87a5813 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1246,8 +1246,10 @@ struct wpa_driver_ops { int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data, size_t data_len, int encrypt, const u8 *own_addr); - int (*sta_deauth)(void *priv, const u8 *addr, int reason); - int (*sta_disassoc)(void *priv, const u8 *addr, int reason); + int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr, + int reason); + int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr, + int reason); int (*sta_remove)(void *priv, const u8 *addr); int (*hapd_get_ssid)(const char *ifname, void *priv, u8 *buf, int len); int (*hapd_set_ssid)(const char *ifname, void *priv, const u8 *buf, diff --git a/src/drivers/driver_atheros.c b/src/drivers/driver_atheros.c index 55ee6133f..96b705197 100644 --- a/src/drivers/driver_atheros.c +++ b/src/drivers/driver_atheros.c @@ -86,7 +86,8 @@ struct madwifi_driver_data { struct l2_packet_data *sock_raw; /* raw 802.11 management frames */ }; -static int madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code); +static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code); static int set80211priv(struct madwifi_driver_data *drv, int op, void *data, int len) @@ -539,7 +540,8 @@ madwifi_flush(void *priv) { u8 allsta[IEEE80211_ADDR_LEN]; memset(allsta, 0xff, IEEE80211_ADDR_LEN); - return madwifi_sta_deauth(priv, allsta, IEEE80211_REASON_AUTH_LEAVE); + return madwifi_sta_deauth(priv, NULL, allsta, + IEEE80211_REASON_AUTH_LEAVE); } @@ -611,7 +613,8 @@ madwifi_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len) } static int -madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code) +madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code) { struct madwifi_driver_data *drv = priv; struct ieee80211req_mlme mlme; @@ -634,7 +637,8 @@ madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code) } static int -madwifi_sta_disassoc(void *priv, const u8 *addr, int reason_code) +madwifi_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code) { struct madwifi_driver_data *drv = priv; struct ieee80211req_mlme mlme; diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c index 135706dce..24f115776 100644 --- a/src/drivers/driver_bsd.c +++ b/src/drivers/driver_bsd.c @@ -59,7 +59,8 @@ struct bsd_driver_data { int wext_sock; /* socket for wireless events */ }; -static int bsd_sta_deauth(void *priv, const u8 *addr, int reason_code); +static int bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code); static int set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len) @@ -449,7 +450,7 @@ bsd_flush(void *priv) u8 allsta[IEEE80211_ADDR_LEN]; memset(allsta, 0xff, IEEE80211_ADDR_LEN); - return bsd_sta_deauth(priv, allsta, IEEE80211_REASON_AUTH_LEAVE); + return bsd_sta_deauth(priv, NULL, allsta, IEEE80211_REASON_AUTH_LEAVE); } @@ -482,7 +483,7 @@ bsd_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len) } static int -bsd_sta_deauth(void *priv, const u8 *addr, int reason_code) +bsd_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, int reason_code) { struct bsd_driver_data *drv = priv; struct ieee80211req_mlme mlme; @@ -497,7 +498,8 @@ bsd_sta_deauth(void *priv, const u8 *addr, int reason_code) } static int -bsd_sta_disassoc(void *priv, const u8 *addr, int reason_code) +bsd_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code) { struct bsd_driver_data *drv = priv; struct ieee80211req_mlme mlme; diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c index ad9fbfef3..7538b9aae 100644 --- a/src/drivers/driver_hostap.c +++ b/src/drivers/driver_hostap.c @@ -57,8 +57,6 @@ struct hostap_driver_data { static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param, int len); static int hostap_set_iface_flags(void *priv, int dev_up); -static int hostap_sta_disassoc(void *priv, const u8 *addr, int reason); -static int hostap_sta_deauth(void *priv, const u8 *addr, int reason); static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len, u16 stype) @@ -1132,7 +1130,8 @@ static void hostap_driver_deinit(void *priv) } -static int hostap_sta_deauth(void *priv, const u8 *addr, int reason) +static int hostap_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct hostap_driver_data *drv = priv; struct ieee80211_mgmt mgmt; @@ -1141,15 +1140,16 @@ static int hostap_sta_deauth(void *priv, const u8 *addr, int reason) mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH); memcpy(mgmt.da, addr, ETH_ALEN); - memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN); - memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN); + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); mgmt.u.deauth.reason_code = host_to_le16(reason); return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + sizeof(mgmt.u.deauth)); } -static int hostap_sta_disassoc(void *priv, const u8 *addr, int reason) +static int hostap_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct hostap_driver_data *drv = priv; struct ieee80211_mgmt mgmt; @@ -1158,8 +1158,8 @@ static int hostap_sta_disassoc(void *priv, const u8 *addr, int reason) mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DISASSOC); memcpy(mgmt.da, addr, ETH_ALEN); - memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN); - memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN); + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); mgmt.u.disassoc.reason_code = host_to_le16(reason); return hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + sizeof(mgmt.u.disassoc)); diff --git a/src/drivers/driver_madwifi.c b/src/drivers/driver_madwifi.c index eb00b0db7..336ce31ec 100644 --- a/src/drivers/driver_madwifi.c +++ b/src/drivers/driver_madwifi.c @@ -91,7 +91,8 @@ struct madwifi_driver_data { struct l2_packet_data *sock_raw; /* raw 802.11 management frames */ }; -static int madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code); +static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code); static int set80211priv(struct madwifi_driver_data *drv, int op, void *data, int len) @@ -575,7 +576,8 @@ madwifi_flush(void *priv) #ifdef MADWIFI_BSD u8 allsta[IEEE80211_ADDR_LEN]; memset(allsta, 0xff, IEEE80211_ADDR_LEN); - return madwifi_sta_deauth(priv, allsta, IEEE80211_REASON_AUTH_LEAVE); + return madwifi_sta_deauth(priv, NULL, allsta, + IEEE80211_REASON_AUTH_LEAVE); #else /* MADWIFI_BSD */ return 0; /* XXX */ #endif /* MADWIFI_BSD */ @@ -703,7 +705,8 @@ madwifi_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len) } static int -madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code) +madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code) { struct madwifi_driver_data *drv = priv; struct ieee80211req_mlme mlme; @@ -726,7 +729,8 @@ madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code) } static int -madwifi_sta_disassoc(void *priv, const u8 *addr, int reason_code) +madwifi_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason_code) { struct madwifi_driver_data *drv = priv; struct ieee80211req_mlme mlme; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 9bf967bb2..6e3a19186 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -3084,9 +3084,6 @@ static int wpa_driver_nl80211_set_operstate(void *priv, int state) static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; -static int i802_sta_deauth(void *priv, const u8 *addr, int reason); -static int i802_sta_disassoc(void *priv, const u8 *addr, int reason); - static struct i802_bss * get_bss(struct wpa_driver_nl80211_data *drv, int ifindex) @@ -3898,7 +3895,8 @@ static int i802_sta_clear_stats(void *priv, const u8 *addr) } -static int i802_sta_deauth(void *priv, const u8 *addr, int reason) +static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct wpa_driver_nl80211_data *drv = priv; struct ieee80211_mgmt mgmt; @@ -3907,8 +3905,8 @@ static int i802_sta_deauth(void *priv, const u8 *addr, int reason) mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DEAUTH); memcpy(mgmt.da, addr, ETH_ALEN); - memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN); - memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN); + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); mgmt.u.deauth.reason_code = host_to_le16(reason); return wpa_driver_nl80211_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + @@ -3916,7 +3914,8 @@ static int i802_sta_deauth(void *priv, const u8 *addr, int reason) } -static int i802_sta_disassoc(void *priv, const u8 *addr, int reason) +static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct wpa_driver_nl80211_data *drv = priv; struct ieee80211_mgmt mgmt; @@ -3925,8 +3924,8 @@ static int i802_sta_disassoc(void *priv, const u8 *addr, int reason) mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_DISASSOC); memcpy(mgmt.da, addr, ETH_ALEN); - memcpy(mgmt.sa, drv->hapd->own_addr, ETH_ALEN); - memcpy(mgmt.bssid, drv->hapd->own_addr, ETH_ALEN); + memcpy(mgmt.sa, own_addr, ETH_ALEN); + memcpy(mgmt.bssid, own_addr, ETH_ALEN); mgmt.u.disassoc.reason_code = host_to_le16(reason); return wpa_driver_nl80211_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN + diff --git a/src/drivers/driver_prism54.c b/src/drivers/driver_prism54.c index cc56d52b4..f2837cc3a 100644 --- a/src/drivers/driver_prism54.c +++ b/src/drivers/driver_prism54.c @@ -461,7 +461,8 @@ static int prism54_flush(void *priv) } -static int prism54_sta_deauth(void *priv, const u8 *addr, int reason) +static int prism54_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct prism54_driver_data *drv = priv; pimdev_hdr *hdr; @@ -486,7 +487,8 @@ static int prism54_sta_deauth(void *priv, const u8 *addr, int reason) } -static int prism54_sta_disassoc(void *priv, const u8 *addr, int reason) +static int prism54_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, + int reason) { struct prism54_driver_data *drv = priv; pimdev_hdr *hdr; diff --git a/src/drivers/driver_test.c b/src/drivers/driver_test.c index 640b33be6..84c383678 100644 --- a/src/drivers/driver_test.c +++ b/src/drivers/driver_test.c @@ -813,7 +813,8 @@ static int test_driver_set_wps_probe_resp_ie(const char *ifname, void *priv, } -static int test_driver_sta_deauth(void *priv, const u8 *addr, int reason) +static int test_driver_sta_deauth(void *priv, const u8 *own_addr, + const u8 *addr, int reason) { struct test_driver_data *drv = priv; struct test_client_socket *cli; @@ -836,7 +837,8 @@ static int test_driver_sta_deauth(void *priv, const u8 *addr, int reason) } -static int test_driver_sta_disassoc(void *priv, const u8 *addr, int reason) +static int test_driver_sta_disassoc(void *priv, const u8 *own_addr, + const u8 *addr, int reason) { struct test_driver_data *drv = priv; struct test_client_socket *cli;