WPS 2.0: Provide (Re)Association Response WPS IE to driver
[libeap.git] / src / drivers / driver_atheros.c
index 149805f..c0dd731 100644 (file)
 #endif
 #endif /* _BYTE_ORDER */
 
+/*
+ * Note, the ATH_WPS_IE setting must match with the driver build.. If the
+ * driver does not include this, the IEEE80211_IOCTL_GETWPAIE ioctl will fail.
+ */
+#define ATH_WPS_IE
+
 #include "os/linux/include/ieee80211_external.h"
 
 
@@ -68,6 +74,7 @@ struct madwifi_driver_data {
 
 static int madwifi_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
                              int reason_code);
+static int madwifi_set_privacy(void *priv, int enabled);
 
 static const char * athr_get_ioctl_name(int op)
 {
@@ -337,8 +344,11 @@ madwifi_set_ieee8021x(void *priv, struct wpa_bss_params *params)
 
        if (!params->enabled) {
                /* XXX restore state */
-               return set80211param(priv, IEEE80211_PARAM_AUTHMODE,
-                       IEEE80211_AUTH_AUTO);
+               if (set80211param(priv, IEEE80211_PARAM_AUTHMODE,
+                                 IEEE80211_AUTH_AUTO) < 0)
+                       return -1;
+               /* IEEE80211_AUTH_AUTO ends up enabling Privacy; clear that */
+               return madwifi_set_privacy(drv, 0);
        }
        if (!params->wpa && !params->ieee802_1x) {
                hostapd_logger(drv->hapd, NULL, HOSTAPD_MODULE_DRIVER,
@@ -727,7 +737,7 @@ static int
 madwifi_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
 {
        struct madwifi_driver_data *drv = priv;
-       u8 buf[256];
+       u8 buf[500];
        struct ieee80211req_getset_appiebuf *beac_ie;
 
        wpa_printf(MSG_DEBUG, "%s buflen = %lu", __func__,
@@ -744,8 +754,12 @@ madwifi_set_wps_ie(void *priv, const u8 *ie, size_t len, u32 frametype)
 
 static int
 madwifi_set_ap_wps_ie(void *priv, const struct wpabuf *beacon,
-                     const struct wpabuf *proberesp)
+                     const struct wpabuf *proberesp,
+                     const struct wpabuf *assocresp)
 {
+       madwifi_set_wps_ie(priv, assocresp ? wpabuf_head(assocresp) : NULL,
+                          assocresp ? wpabuf_len(assocresp) : 0,
+                          IEEE80211_APPIE_FRAME_ASSOC_RESP);
        if (madwifi_set_wps_ie(priv, beacon ? wpabuf_head(beacon) : NULL,
                               beacon ? wpabuf_len(beacon) : 0,
                               IEEE80211_APPIE_FRAME_BEACON))
@@ -1178,6 +1192,8 @@ madwifi_init(struct hostapd_data *hapd, struct wpa_init_params *params)
 
        return drv;
 bad:
+       if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
+               l2_packet_deinit(drv->sock_recv);
        if (drv->sock_xmit != NULL)
                l2_packet_deinit(drv->sock_xmit);
        if (drv->ioctl_sock >= 0)
@@ -1265,7 +1281,7 @@ madwifi_commit(void *priv)
 const struct wpa_driver_ops wpa_driver_atheros_ops = {
        .name                   = "atheros",
        .hapd_init              = madwifi_init,
-       .deinit                 = madwifi_deinit,
+       .hapd_deinit            = madwifi_deinit,
        .set_ieee8021x          = madwifi_set_ieee8021x,
        .set_privacy            = madwifi_set_privacy,
        .set_key                = madwifi_set_key,