hostapd: fix multi-ssid and AP+STA, clean up code
authorFelix Fietkau <nbd@openwrt.org>
Sun, 30 Jun 2013 21:01:13 +0000 (21:01 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 30 Jun 2013 21:01:13 +0000 (21:01 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 37111

package/network/services/hostapd/patches/450-reload_freq_change.patch
package/network/services/hostapd/patches/453-ap_sta_support.patch
package/network/services/hostapd/patches/480-terminate_on_setup_failure.patch
package/network/services/hostapd/patches/540-dynamic_20_40_mhz.patch
package/network/services/hostapd/patches/601-wpa_supplicant-add-new-config-params-to-be-used-with.patch
package/network/services/hostapd/patches/604-wpa_s-support-htmode-param.patch
package/network/services/hostapd/patches/700-ubus_support.patch

index ffa757e..5dc2a85 100644 (file)
@@ -1,27 +1,85 @@
 --- a/src/ap/hostapd.c
 +++ b/src/ap/hostapd.c
-@@ -156,6 +156,24 @@ int hostapd_reload_config(struct hostapd
-       oldconf = hapd->iconf;
-       iface->conf = newconf;
+@@ -133,38 +133,51 @@ static void hostapd_clear_old(struct hos
+ int hostapd_reload_config(struct hostapd_iface *iface)
+ {
+       struct hostapd_data *hapd = iface->bss[0];
+-      struct hostapd_config *newconf, *oldconf;
++      struct hostapd_config *conf = hapd->iconf, *oldconf = NULL;
+       size_t j;
  
-+      hostapd_select_hw_mode(iface);
-+      iface->freq = hostapd_hw_get_freq(hapd, newconf->channel);
+-      if (iface->config_fname == NULL) {
+-              /* Only in-memory config in use - assume it has been updated */
++      if (iface->config_fname) {
++              if (iface->interfaces == NULL ||
++                      iface->interfaces->config_read_cb == NULL)
++                      return -1;
++              conf = iface->interfaces->config_read_cb(iface->config_fname);
++              if (conf == NULL)
++                      return -1;
 +
-+      if (hostapd_set_freq(hapd, newconf->hw_mode, iface->freq,
-+                           newconf->channel,
-+                           newconf->ieee80211n,
-+                           newconf->ieee80211ac,
-+                           newconf->secondary_channel,
-+                           newconf->vht_oper_chwidth,
-+                           newconf->vht_oper_centr_freq_seg0_idx,
-+                           newconf->vht_oper_centr_freq_seg1_idx)) {
-+              wpa_printf(MSG_ERROR, "Could not set channel for "
-+                         "kernel driver");
+               hostapd_clear_old(iface);
+-              for (j = 0; j < iface->num_bss; j++)
+-                      hostapd_reload_bss(iface->bss[j]);
+-              return 0;
+-      }
+-      if (iface->interfaces == NULL ||
+-          iface->interfaces->config_read_cb == NULL)
+-              return -1;
+-      newconf = iface->interfaces->config_read_cb(iface->config_fname);
+-      if (newconf == NULL)
+-              return -1;
++              oldconf = hapd->iconf;
++              iface->conf = conf;
 +      }
-+
+-      hostapd_clear_old(iface);
++      hostapd_select_hw_mode(iface);
++      iface->freq = hostapd_hw_get_freq(hapd, conf->channel);
+-      oldconf = hapd->iconf;
+-      iface->conf = newconf;
 +      if (iface->current_mode)
 +              hostapd_prepare_rates(iface, iface->current_mode);
-+
        for (j = 0; j < iface->num_bss; j++) {
                hapd = iface->bss[j];
-               hapd->iconf = newconf;
+-              hapd->iconf = newconf;
+-              hapd->conf = &newconf->bss[j];
++              hapd->iconf = iface->conf;
++              hapd->conf = &iface->conf->bss[j];
++
++              if (hostapd_set_freq(hapd, conf->hw_mode, iface->freq,
++                                       conf->channel,
++                                       conf->ieee80211n,
++                                       conf->ieee80211ac,
++                                       conf->secondary_channel,
++                                       conf->vht_oper_chwidth,
++                                       conf->vht_oper_centr_freq_seg0_idx,
++                                       conf->vht_oper_centr_freq_seg1_idx)) {
++                      wpa_printf(MSG_ERROR, "Could not set channel for "
++                                 "kernel driver");
++              }
++
+               hostapd_reload_bss(hapd);
+       }
+-      hostapd_config_free(oldconf);
+-
++      if (oldconf)
++              hostapd_config_free(oldconf);
+       return 0;
+ }
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6466,7 +6466,7 @@ static int wpa_driver_nl80211_set_freq(s
+       nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_WIPHY);
+-      NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
++      NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
+       NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
+       if (freq->vht_enabled) {
+               switch (freq->bandwidth) {
index 5481529..9ccc3dd 100644 (file)
@@ -47,7 +47,7 @@
  CONFIG_OS=win32
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -109,6 +109,55 @@ extern int wpa_debug_show_keys;
+@@ -109,6 +109,48 @@ extern int wpa_debug_show_keys;
  extern int wpa_debug_timestamp;
  extern struct wpa_driver_ops *wpa_drivers[];
  
 +      char *cmd = NULL;
 +      char buf[256];
 +      int len = sizeof(buf);
-+      int channel, hw_mode;
++      enum hostapd_hw_mode hw_mode;
++      u8 channel;
 +      int ret;
 +
 +      if (!bss)
 +              return;
 +
-+      if (bss->freq < 4000) {
-+              hw_mode = HOSTAPD_MODE_IEEE80211G;
-+              channel = (bss->freq - 2407) / 5;
-+      } else {
-+              hw_mode = HOSTAPD_MODE_IEEE80211A;
-+              channel = (bss->freq - 5000) / 5;
-+      }
-+
++      hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
 +      if (asprintf(&cmd, "UPDATE channel=%d sec_chan=0 hw_mode=%d ieee80211n=%d",
-+                   channel, hw_mode, !!bss->ht_capab) < 0) {
++                   channel, hw_mode, !!bss->ht_capab) < 0)
 +              return -1;
-+      }
 +
 +      ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
 +      free(cmd);
  /* Configure default/group WEP keys for static WEP */
  int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
  {
-@@ -675,8 +724,16 @@ void wpa_supplicant_set_state(struct wpa
+@@ -675,8 +717,16 @@ void wpa_supplicant_set_state(struct wpa
  #endif /* CONFIG_P2P */
  
                sme_sched_obss_scan(wpa_s, 1);
                wpa_s->new_connection = 1;
                wpa_drv_set_operstate(wpa_s, 0);
  #ifndef IEEE8021X_EAPOL
-@@ -2866,6 +2923,21 @@ static int wpa_supplicant_init_iface(str
+@@ -2866,6 +2916,21 @@ static int wpa_supplicant_init_iface(str
                os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
                           sizeof(wpa_s->bridge_ifname));
        }
index 8e042c4..5ba7ec1 100644 (file)
@@ -1,6 +1,6 @@
 --- a/src/ap/hostapd.c
 +++ b/src/ap/hostapd.c
-@@ -979,11 +979,8 @@ int hostapd_setup_interface_complete(str
+@@ -974,11 +974,8 @@ int hostapd_setup_interface_complete(str
        size_t j;
        u8 *prev_addr;
  
@@ -14,7 +14,7 @@
  
        wpa_printf(MSG_DEBUG, "Completing interface initialization");
        if (hapd->iconf->channel) {
-@@ -1003,7 +1000,7 @@ int hostapd_setup_interface_complete(str
+@@ -998,7 +995,7 @@ int hostapd_setup_interface_complete(str
                                     hapd->iconf->vht_oper_centr_freq_seg1_idx)) {
                        wpa_printf(MSG_ERROR, "Could not set channel for "
                                   "kernel driver");
@@ -23,7 +23,7 @@
                }
        }
  
-@@ -1014,7 +1011,7 @@ int hostapd_setup_interface_complete(str
+@@ -1009,7 +1006,7 @@ int hostapd_setup_interface_complete(str
                        hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
                                       HOSTAPD_LEVEL_WARNING,
                                       "Failed to prepare rates table.");
@@ -32,7 +32,7 @@
                }
        }
  
-@@ -1022,14 +1019,14 @@ int hostapd_setup_interface_complete(str
+@@ -1017,14 +1014,14 @@ int hostapd_setup_interface_complete(str
            hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
                wpa_printf(MSG_ERROR, "Could not set RTS threshold for "
                           "kernel driver");
@@ -49,7 +49,7 @@
        }
  
        prev_addr = hapd->own_addr;
-@@ -1039,7 +1036,7 @@ int hostapd_setup_interface_complete(str
+@@ -1034,7 +1031,7 @@ int hostapd_setup_interface_complete(str
                if (j)
                        os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
                if (hostapd_setup_bss(hapd, j == 0))
@@ -58,7 +58,7 @@
                if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
                        prev_addr = hapd->own_addr;
        }
-@@ -1053,7 +1050,7 @@ int hostapd_setup_interface_complete(str
+@@ -1048,7 +1045,7 @@ int hostapd_setup_interface_complete(str
        if (hostapd_driver_commit(hapd) < 0) {
                wpa_printf(MSG_ERROR, "%s: Failed to commit driver "
                           "configuration", __func__);
@@ -67,7 +67,7 @@
        }
  
        /*
-@@ -1074,6 +1071,11 @@ int hostapd_setup_interface_complete(str
+@@ -1069,6 +1066,11 @@ int hostapd_setup_interface_complete(str
                   iface->bss[0]->conf->iface);
  
        return 0;
index d64b206..a71f560 100644 (file)
@@ -31,7 +31,7 @@
  #include "ieee802_11_auth.h"
  #include "vlan_init.h"
  #include "wpa_auth.h"
-@@ -348,6 +349,7 @@ static void hostapd_cleanup_iface_pre(st
+@@ -343,6 +344,7 @@ static void hostapd_cleanup_iface_pre(st
  
  static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface)
  {
index f5fb8cb..e61e85d 100644 (file)
@@ -175,7 +175,7 @@ Signed-hostap: Antonio Quartulli <ordex@autistici.org>
  #endif /* CONFIG_SSID_H */
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -1606,15 +1606,24 @@ void wpa_supplicant_associate(struct wpa
+@@ -1599,15 +1599,24 @@ void wpa_supplicant_associate(struct wpa
                params.ssid_len = ssid->ssid_len;
        }
  
index 2914baa..b068fa9 100644 (file)
@@ -145,7 +145,7 @@ Signed-off-by: Antonio Quartulli <ordex@autistici.org>
  #endif /* CONFIG_SSID_H */
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -1622,6 +1622,8 @@ void wpa_supplicant_associate(struct wpa
+@@ -1615,6 +1615,8 @@ void wpa_supplicant_associate(struct wpa
                        i++;
                }
                params.mcast_rate = ssid->mcast_rate;
index c5ff795..81ada8c 100644 (file)
 +#endif
 --- a/src/ap/hostapd.c
 +++ b/src/ap/hostapd.c
-@@ -270,6 +270,7 @@ static int hostapd_broadcast_wep_set(str
+@@ -265,6 +265,7 @@ static int hostapd_broadcast_wep_set(str
  
  static void hostapd_free_hapd_data(struct hostapd_data *hapd)
  {
        iapp_deinit(hapd->iapp);
        hapd->iapp = NULL;
        accounting_deinit(hapd);
-@@ -834,6 +835,8 @@ static int hostapd_setup_bss(struct host
+@@ -829,6 +830,8 @@ static int hostapd_setup_bss(struct host
        if (hapd->driver && hapd->driver->set_operstate)
                hapd->driver->set_operstate(hapd->drv_priv, 1);
  
        return 0;
  }
  
-@@ -984,6 +987,7 @@ int hostapd_setup_interface_complete(str
+@@ -979,6 +982,7 @@ int hostapd_setup_interface_complete(str
        if (err)
                goto error;
  
        wpa_printf(MSG_DEBUG, "Completing interface initialization");
        if (hapd->iconf->channel) {
                iface->freq = hostapd_hw_get_freq(hapd, hapd->iconf->channel);
-@@ -1076,6 +1080,7 @@ int hostapd_setup_interface_complete(str
+@@ -1071,6 +1075,7 @@ int hostapd_setup_interface_complete(str
  
  error:
        wpa_printf(MSG_ERROR, "Interface initialization failed");
        eloop_terminate();
        return -1;
  }
-@@ -1174,6 +1179,8 @@ void hostapd_interface_deinit_free(struc
+@@ -1169,6 +1174,8 @@ void hostapd_interface_deinit_free(struc
        void *drv_priv;
        if (iface == NULL)
                return;