Extend hw_mode to support any band for offloaded ACS case
[mech_eap.git] / src / ap / drv_callbacks.c
index 80e4c2e..6ecd094 100644 (file)
@@ -532,7 +532,7 @@ void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
 static void hostapd_acs_channel_selected(struct hostapd_data *hapd,
                                         struct acs_selected_channels *acs_res)
 {
-       int ret;
+       int ret, i;
 
        if (hapd->iconf->channel) {
                wpa_printf(MSG_INFO, "ACS: Channel was already set to %d",
@@ -540,6 +540,24 @@ static void hostapd_acs_channel_selected(struct hostapd_data *hapd,
                return;
        }
 
+       if (!hapd->iface->current_mode) {
+               for (i = 0; i < hapd->iface->num_hw_features; i++) {
+                       struct hostapd_hw_modes *mode =
+                               &hapd->iface->hw_features[i];
+
+                       if (mode->mode == acs_res->hw_mode) {
+                               hapd->iface->current_mode = mode;
+                               break;
+                       }
+               }
+               if (!hapd->iface->current_mode) {
+                       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+                                      HOSTAPD_LEVEL_WARNING,
+                                      "driver selected to bad hw_mode");
+                       return;
+               }
+       }
+
        hapd->iface->freq = hostapd_hw_get_freq(hapd, acs_res->pri_channel);
 
        if (!acs_res->pri_channel) {