hostapd: enter DFS state if no available channel is found
[openwrt/staging/dedeckeh.git] / package / network / services / hostapd / patches / 340-reload_freq_change.patch
1 --- a/src/ap/hostapd.c
2 +++ b/src/ap/hostapd.c
3 @@ -114,6 +114,28 @@ 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->enable_edmg,
11 + hapd->iconf->edmg_channel,
12 + hapd->iconf->ieee80211n,
13 + hapd->iconf->ieee80211ac,
14 + hapd->iconf->ieee80211ax,
15 + hapd->iconf->secondary_channel,
16 + hostapd_get_oper_chwidth(hapd->iconf),
17 + hostapd_get_oper_centr_freq_seg0_idx(hapd->iconf),
18 + hostapd_get_oper_centr_freq_seg1_idx(hapd->iconf));
19 +
20 + if (hapd->iface->current_mode) {
21 + if (hostapd_prepare_rates(hapd->iface, hapd->iface->current_mode)) {
22 + wpa_printf(MSG_ERROR, "Failed to prepare rates table.");
23 + hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
24 + HOSTAPD_LEVEL_WARNING,
25 + "Failed to prepare rates table.");
26 + }
27 + }
28 +
29 if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next &&
30 ssid->wpa_passphrase_set && ssid->wpa_passphrase) {
31 /*
32 @@ -215,6 +237,7 @@ int hostapd_reload_config(struct hostapd
33 struct hostapd_data *hapd = iface->bss[0];
34 struct hostapd_config *newconf, *oldconf;
35 size_t j;
36 + int i;
37
38 if (iface->config_fname == NULL) {
39 /* Only in-memory config in use - assume it has been updated */
40 @@ -265,24 +288,20 @@ int hostapd_reload_config(struct hostapd
41 }
42 iface->conf = newconf;
43
44 + for (i = 0; i < iface->num_hw_features; i++) {
45 + struct hostapd_hw_modes *mode = &iface->hw_features[i];
46 + if (mode->mode == iface->conf->hw_mode) {
47 + iface->current_mode = mode;
48 + break;
49 + }
50 + }
51 +
52 + if (iface->conf->channel)
53 + iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel);
54 +
55 for (j = 0; j < iface->num_bss; j++) {
56 hapd = iface->bss[j];
57 hapd->iconf = newconf;
58 - hapd->iconf->channel = oldconf->channel;
59 - hapd->iconf->acs = oldconf->acs;
60 - hapd->iconf->secondary_channel = oldconf->secondary_channel;
61 - hapd->iconf->ieee80211n = oldconf->ieee80211n;
62 - hapd->iconf->ieee80211ac = oldconf->ieee80211ac;
63 - hapd->iconf->ht_capab = oldconf->ht_capab;
64 - hapd->iconf->vht_capab = oldconf->vht_capab;
65 - hostapd_set_oper_chwidth(hapd->iconf,
66 - hostapd_get_oper_chwidth(oldconf));
67 - hostapd_set_oper_centr_freq_seg0_idx(
68 - hapd->iconf,
69 - hostapd_get_oper_centr_freq_seg0_idx(oldconf));
70 - hostapd_set_oper_centr_freq_seg1_idx(
71 - hapd->iconf,
72 - hostapd_get_oper_centr_freq_seg1_idx(oldconf));
73 hapd->conf = newconf->bss[j];
74 hostapd_reload_bss(hapd);
75 }