WPS: Add support for setting timeout for PIN
[wpasupplicant] / hostapd / sta_info.c
index bd873f6..7a22e92 100644 (file)
@@ -25,7 +25,7 @@
 #include "wpa.h"
 #include "preauth.h"
 #include "radius/radius_client.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "beacon.h"
 #include "hw_features.h"
 #include "mlme.h"
@@ -128,7 +128,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        ap_sta_list_del(hapd, sta);
 
        if (sta->aid > 0)
-               hapd->sta_aid[sta->aid - 1] = NULL;
+               hapd->sta_aid[(sta->aid - 1) / 32] &=
+                       ~BIT((sta->aid - 1) % 32);
 
        hapd->num_sta--;
        if (sta->nonerp_set) {
@@ -170,8 +171,10 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
                hapd->iface->num_sta_ht_20mhz--;
        }
 
+#ifdef NEED_MLME
        if (hostapd_ht_operation_update(hapd->iface) > 0)
                set_beacon++;
+#endif /* NEED_MLME */
 #endif /* CONFIG_IEEE80211N */
 
        if (set_beacon)
@@ -288,19 +291,30 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
                sta->flags |= WLAN_STA_PENDING_POLL;
 
 #ifndef CONFIG_NATIVE_WINDOWS
-               /* FIX: WLAN_FC_STYPE_NULLFUNC would be more appropriate, but
-                * it is apparently not retried so TX Exc events are not
-                * received for it */
                os_memset(&hdr, 0, sizeof(hdr));
-               hdr.frame_control =
-                       IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
+               if (hapd->driver &&
+                   os_strcmp(hapd->driver->name, "hostap") == 0) {
+                       /*
+                        * WLAN_FC_STYPE_NULLFUNC would be more appropriate,
+                        * but it is apparently not retried so TX Exc events
+                        * are not received for it.
+                        */
+                       hdr.frame_control =
+                               IEEE80211_FC(WLAN_FC_TYPE_DATA,
+                                            WLAN_FC_STYPE_DATA);
+               } else {
+                       hdr.frame_control =
+                               IEEE80211_FC(WLAN_FC_TYPE_DATA,
+                                            WLAN_FC_STYPE_NULLFUNC);
+               }
+
                hdr.frame_control |= host_to_le16(WLAN_FC_FROMDS);
                os_memcpy(hdr.IEEE80211_DA_FROMDS, sta->addr, ETH_ALEN);
                os_memcpy(hdr.IEEE80211_BSSID_FROMDS, hapd->own_addr,
                          ETH_ALEN);
                os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
 
-               if (hostapd_send_mgmt_frame(hapd, &hdr, sizeof(hdr), 0) < 0)
+               if (hostapd_send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0)
                        perror("ap_handle_timer: send");
 #endif /* CONFIG_NATIVE_WINDOWS */
        } else if (sta->timeout_next != STA_REMOVE) {
@@ -518,6 +532,7 @@ void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
                     int old_vlanid)
 {
+#ifndef CONFIG_NO_VLAN
        const char *iface;
        struct hostapd_vlan *vlan = NULL;
 
@@ -616,6 +631,9 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
                wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
 
        return hostapd_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
+#else /* CONFIG_NO_VLAN */
+       return 0;
+#endif /* CONFIG_NO_VLAN */
 }
 
 
@@ -679,7 +697,9 @@ static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
                       HOSTAPD_LEVEL_DEBUG,
                       "association SA Query attempt %d", sta->sa_query_count);
 
+#ifdef NEED_MLME
        ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
+#endif /* NEED_MLME */
 }