wpa_supplicant: Enable Automatic Channel Selection support for AP mode
[mech_eap.git] / src / ap / drv_callbacks.c
index 00bc49c..aad0d81 100644 (file)
@@ -22,6 +22,7 @@
 #include "wnm_ap.h"
 #include "hostapd.h"
 #include "ieee802_11.h"
+#include "ieee802_11_auth.h"
 #include "sta_info.h"
 #include "accounting.h"
 #include "tkip_countermeasures.h"
@@ -43,10 +44,10 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
        struct ieee802_11_elems elems;
        const u8 *ie;
        size_t ielen;
-#ifdef CONFIG_IEEE80211R
+#if defined(CONFIG_IEEE80211R) || defined(CONFIG_IEEE80211W)
        u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
        u8 *p = buf;
-#endif /* CONFIG_IEEE80211R */
+#endif /* CONFIG_IEEE80211R || CONFIG_IEEE80211W */
        u16 reason = WLAN_REASON_UNSPECIFIED;
        u16 status = WLAN_STATUS_SUCCESS;
        const u8 *p2p_dev_addr = NULL;
@@ -114,6 +115,14 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
        }
        sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2);
 
+       res = hostapd_check_acl(hapd, addr, NULL);
+       if (res != HOSTAPD_ACL_ACCEPT) {
+               wpa_printf(MSG_INFO, "STA " MACSTR " not allowed to connect",
+                          MAC2STR(addr));
+               reason = WLAN_REASON_UNSPECIFIED;
+               goto fail;
+       }
+
 #ifdef CONFIG_P2P
        if (elems.p2p) {
                wpabuf_free(sta->p2p_ie);
@@ -256,14 +265,12 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
                        if (sta->sa_query_count == 0)
                                ap_sta_start_sa_query(hapd, sta);
 
-#ifdef CONFIG_IEEE80211R
                        status = WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
 
                        p = hostapd_eid_assoc_comeback_time(hapd, sta, p);
 
                        hostapd_sta_assoc(hapd, addr, reassoc, status, buf,
                                          p - buf);
-#endif /* CONFIG_IEEE80211R */
                        return 0;
                }
 
@@ -449,7 +456,8 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
                             int offset, int width, int cf1, int cf2)
 {
 #ifdef NEED_AP_MLME
-       int channel, chwidth, seg0_idx = 0, seg1_idx = 0, is_dfs;
+       int channel, chwidth, is_dfs;
+       u8 seg0_idx = 0, seg1_idx = 0;
 
        hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
                       HOSTAPD_LEVEL_INFO,
@@ -493,8 +501,8 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
                        seg1_idx = (cf2 - 5000) / 5;
                break;
        default:
-               seg0_idx = hostapd_hw_get_channel(hapd, cf1);
-               seg1_idx = hostapd_hw_get_channel(hapd, cf2);
+               ieee80211_freq_to_chan(cf1, &seg0_idx);
+               ieee80211_freq_to_chan(cf2, &seg1_idx);
                break;
        }
 
@@ -541,8 +549,8 @@ void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
 
 
 #ifdef CONFIG_ACS
-static void hostapd_acs_channel_selected(struct hostapd_data *hapd,
-                                        struct acs_selected_channels *acs_res)
+void hostapd_acs_channel_selected(struct hostapd_data *hapd,
+                                 struct acs_selected_channels *acs_res)
 {
        int ret, i;
 
@@ -937,6 +945,8 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
        ieee802_1x_receive(hapd, src, data, data_len);
 }
 
+#endif /* HOSTAPD */
+
 
 static struct hostapd_channel_data * hostapd_get_mode_channel(
        struct hostapd_iface *iface, unsigned int freq)
@@ -1011,10 +1021,9 @@ static void hostapd_single_channel_get_survey(struct hostapd_iface *iface,
 }
 
 
-static void hostapd_event_get_survey(struct hostapd_data *hapd,
-                                    struct survey_results *survey_results)
+void hostapd_event_get_survey(struct hostapd_iface *iface,
+                             struct survey_results *survey_results)
 {
-       struct hostapd_iface *iface = hapd->iface;
        struct freq_survey *survey, *tmp;
        struct hostapd_channel_data *chan;
 
@@ -1046,6 +1055,7 @@ static void hostapd_event_get_survey(struct hostapd_data *hapd,
 }
 
 
+#ifdef HOSTAPD
 #ifdef NEED_AP_MLME
 
 static void hostapd_event_iface_unavailable(struct hostapd_data *hapd)
@@ -1253,7 +1263,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                        data->connect_failed_reason.code);
                break;
        case EVENT_SURVEY:
-               hostapd_event_get_survey(hapd, &data->survey_results);
+               hostapd_event_get_survey(hapd->iface, &data->survey_results);
                break;
 #ifdef NEED_AP_MLME
        case EVENT_INTERFACE_UNAVAILABLE: