hostapd: Update to version 2.9 (2019-08-08)
[oweals/openwrt.git] / package / network / services / hostapd / patches / 340-reload_freq_change.patch
1 --- a/src/ap/hostapd.c
2 +++ b/src/ap/hostapd.c
3 @@ -108,6 +108,26 @@ static void hostapd_reload_bss(struct ho
4  #endif /* CONFIG_NO_RADIUS */
5  
6         ssid = &hapd->conf->ssid;
7 +
8 +       hostapd_set_freq(hapd, hapd->iconf->hw_mode, hapd->iface->freq,
9 +                        hapd->iconf->channel,
10 +                        hapd->iconf->ieee80211n,
11 +                        hapd->iconf->ieee80211ac,
12 +                        hapd->iconf->ieee80211ax,
13 +                        hapd->iconf->secondary_channel,
14 +                        hostapd_get_oper_chwidth(hapd->iconf),
15 +                        hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf),
16 +                        hostapd_get_oper_centr_freq_seg1_idx(hapd->iconf));
17 +
18 +       if (hapd->iface->current_mode) {
19 +               if (hostapd_prepare_rates(hapd->iface, hapd->iface->current_mode)) {
20 +                       wpa_printf(MSG_ERROR, "Failed to prepare rates table.");
21 +                       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
22 +                                      HOSTAPD_LEVEL_WARNING,
23 +                                      "Failed to prepare rates table.");
24 +               }
25 +       }
26 +
27         if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next &&
28             ssid->wpa_passphrase_set && ssid->wpa_passphrase) {
29                 /*
30 @@ -205,6 +225,7 @@ int hostapd_reload_config(struct hostapd
31         struct hostapd_data *hapd = iface->bss[0];
32         struct hostapd_config *newconf, *oldconf;
33         size_t j;
34 +       int i;
35  
36         if (iface->config_fname == NULL) {
37                 /* Only in-memory config in use - assume it has been updated */
38 @@ -255,24 +276,20 @@ int hostapd_reload_config(struct hostapd
39         }
40         iface->conf = newconf;
41  
42 +       for (i = 0; i < iface->num_hw_features; i++) {
43 +               struct hostapd_hw_modes *mode = &iface->hw_features[i];
44 +               if (mode->mode == iface->conf->hw_mode) {
45 +                       iface->current_mode = mode;
46 +                       break;
47 +               }
48 +       }
49 +
50 +       if (iface->conf->channel)
51 +               iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel);
52 +
53         for (j = 0; j < iface->num_bss; j++) {
54                 hapd = iface->bss[j];
55                 hapd->iconf = newconf;
56 -               hapd->iconf->channel = oldconf->channel;
57 -               hapd->iconf->acs = oldconf->acs;
58 -               hapd->iconf->secondary_channel = oldconf->secondary_channel;
59 -               hapd->iconf->ieee80211n = oldconf->ieee80211n;
60 -               hapd->iconf->ieee80211ac = oldconf->ieee80211ac;
61 -               hapd->iconf->ht_capab = oldconf->ht_capab;
62 -               hapd->iconf->vht_capab = oldconf->vht_capab;
63 -               hostapd_set_oper_chwidth(hapd->iconf,
64 -                                        hostapd_get_oper_chwidth(oldconf));
65 -               hostapd_set_oper_centr_freq_seg0_idx(
66 -                       hapd->iconf,
67 -                       hostapd_get_oper_centr_freq_seg0_idx(oldconf));
68 -               hostapd_set_oper_centr_freq_seg1_idx(
69 -                       hapd->iconf,
70 -                       hostapd_get_oper_centr_freq_seg1_idx(oldconf));
71                 hapd->conf = newconf->bss[j];
72                 hostapd_reload_bss(hapd);
73         }