Copy config_methods and device_type configuration for AP mode
[libeap.git] / hostapd / hw_features.c
index c29cd19..ef1e174 100644 (file)
 
 #include "includes.h"
 
+#include "common.h"
 #include "hostapd.h"
-#include "ieee802_11_defs.h"
-#include "ieee802_11_common.h"
+#include "common/ieee802_11_defs.h"
+#include "common/ieee802_11_common.h"
 #include "eloop.h"
 #include "hw_features.h"
 #include "driver_i.h"
@@ -134,7 +135,7 @@ static int hostapd_prepare_rates(struct hostapd_data *hapd,
        hapd->iface->num_rates = 0;
 
        hapd->iface->current_rates =
-               os_malloc(mode->num_rates * sizeof(struct hostapd_rate_data));
+               os_zalloc(mode->num_rates * sizeof(struct hostapd_rate_data));
        if (!hapd->iface->current_rates) {
                wpa_printf(MSG_ERROR, "Failed to allocate memory for rate "
                           "table.");
@@ -146,17 +147,15 @@ static int hostapd_prepare_rates(struct hostapd_data *hapd,
 
                if (hapd->iconf->supported_rates &&
                    !hostapd_rate_found(hapd->iconf->supported_rates,
-                                       mode->rates[i].rate))
+                                       mode->rates[i]))
                        continue;
 
                rate = &hapd->iface->current_rates[hapd->iface->num_rates];
-               os_memcpy(rate, &mode->rates[i],
-                         sizeof(struct hostapd_rate_data));
+               rate->rate = mode->rates[i];
                if (hostapd_rate_found(basic_rates, rate->rate)) {
                        rate->flags |= HOSTAPD_RATE_BASIC;
                        num_basic_rates++;
-               } else
-                       rate->flags &= ~HOSTAPD_RATE_BASIC;
+               }
                wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x",
                           hapd->iface->num_rates, rate->rate, rate->flags);
                hapd->iface->num_rates++;
@@ -329,7 +328,8 @@ static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface,
        if (!match) {
                for (i = 0; i < scan_res->num; i++) {
                        struct wpa_scan_res *bss = scan_res->res[i];
-                       ieee80211n_get_pri_sec_chan(bss, &pri_chan, &sec_chan);
+                       ieee80211n_get_pri_sec_chan(bss, &bss_pri_chan,
+                                                   &bss_sec_chan);
                        if (pri_chan == bss_sec_chan &&
                            sec_chan == bss_pri_chan) {
                                wpa_printf(MSG_INFO, "Switch own primary and "
@@ -593,7 +593,7 @@ int hostapd_check_ht_capab(struct hostapd_iface *iface)
  */
 int hostapd_select_hw_mode(struct hostapd_iface *iface)
 {
-       int i, j, ok, ret;
+       int i, j, ok;
 
        if (iface->num_hw_features < 1)
                return -1;
@@ -627,6 +627,13 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface)
                        break;
                }
        }
+       if (iface->conf->channel == 0) {
+               /* TODO: could request a scan of neighboring BSSes and select
+                * the channel automatically */
+               wpa_printf(MSG_ERROR, "Channel not configured "
+                          "(hw_mode/channel in hostapd.conf)");
+               return -1;
+       }
        if (ok == 0 && iface->conf->channel != 0) {
                hostapd_logger(iface->bss[0], NULL,
                               HOSTAPD_MODULE_IEEE80211,
@@ -654,23 +661,7 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface)
                return -1;
        }
 
-       ret = hostapd_passive_scan(iface->bss[0], 0,
-                                  iface->conf->passive_scan_mode,
-                                  iface->conf->passive_scan_interval,
-                                  iface->conf->passive_scan_listen,
-                                  NULL, NULL);
-       if (ret) {
-               if (ret == -1) {
-                       wpa_printf(MSG_DEBUG, "Passive scanning not "
-                                  "supported");
-               } else {
-                       wpa_printf(MSG_ERROR, "Could not set passive "
-                                  "scanning: %s", strerror(ret));
-               }
-               ret = 0;
-       }
-
-       return ret;
+       return 0;
 }