Add own_addr as a parameter to sta_deauth() and sta_disassoc()
[wpasupplicant] / src / drivers / driver_hostap.c
index e22739d..7538b9a 100644 (file)
@@ -31,7 +31,6 @@
 #include "priv_netlink.h"
 #include "ieee802_11_defs.h"
 #include "../../hostapd/hostapd.h"
-#include "../../hostapd/config.h"
 #include "../../hostapd/hw_features.h"
 #include "../../hostapd/sta_flags.h"
 
@@ -58,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)
@@ -293,7 +290,7 @@ static int hostap_init_sockets(struct hostap_driver_data *drv)
 }
 
 
-static int hostap_send_mgmt_frame(void *priv, const void *msg, size_t len)
+static int hostap_send_mlme(void *priv, const u8 *msg, size_t len)
 {
        struct hostap_driver_data *drv = priv;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) msg;
@@ -341,14 +338,13 @@ static int hostap_send_eapol(void *priv, const u8 *addr, const u8 *data,
        pos += 2;
        memcpy(pos, data, data_len);
 
-       res = hostap_send_mgmt_frame(drv, (u8 *) hdr, len);
-       free(hdr);
-
+       res = hostap_send_mlme(drv, (u8 *) hdr, len);
        if (res < 0) {
-               perror("hostapd_send_eapol: send");
-               printf("hostapd_send_eapol - packet len: %lu - failed\n",
-                      (unsigned long) len);
+               wpa_printf(MSG_ERROR, "hostap_send_eapol - packet len: %lu - "
+                          "failed: %d (%s)",
+                          (unsigned long) len, errno, strerror(errno));
        }
+       free(hdr);
 
        return res;
 }
@@ -1072,7 +1068,8 @@ static void hostap_wireless_event_deinit(struct hostap_driver_data *drv)
 }
 
 
-static void * hostap_init(struct hostapd_data *hapd)
+static void * hostap_init(struct hostapd_data *hapd,
+                         struct wpa_init_params *params)
 {
        struct hostap_driver_data *drv;
 
@@ -1084,7 +1081,7 @@ static void * hostap_init(struct hostapd_data *hapd)
 
        drv->hapd = hapd;
        drv->ioctl_sock = drv->sock = -1;
-       memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
+       memcpy(drv->iface, params->ifname, sizeof(drv->iface));
 
        drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
        if (drv->ioctl_sock < 0) {
@@ -1133,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;
@@ -1142,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_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
-                                     sizeof(mgmt.u.deauth));
+       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;
@@ -1159,11 +1158,11 @@ 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_mgmt_frame(drv, &mgmt, IEEE80211_HDRLEN +
-                                      sizeof(mgmt.u.disassoc));
+       return  hostap_send_mlme(drv, (u8 *) &mgmt, IEEE80211_HDRLEN +
+                                sizeof(mgmt.u.disassoc));
 }
 
 
@@ -1711,7 +1710,7 @@ const struct wpa_driver_ops wpa_driver_hostap_ops = {
        .sta_disassoc = hostap_sta_disassoc,
        .sta_remove = hostap_sta_remove,
        .hapd_set_ssid = hostap_set_ssid,
-       .send_mgmt_frame = hostap_send_mgmt_frame,
+       .send_mlme = hostap_send_mlme,
        .sta_add = hostap_sta_add,
        .get_inact_sec = hostap_get_inact_sec,
        .sta_clear_stats = hostap_sta_clear_stats,