70fb01b8e52c72c3b16286c0af3e78c8d54d4b07
[oweals/openwrt.git] / package / network / services / hostapd / patches / 341-mesh-ctrl-iface-channel-switch.patch
1 --- a/wpa_supplicant/ap.c
2 +++ b/wpa_supplicant/ap.c
3 @@ -1378,15 +1378,35 @@ int ap_switch_channel(struct wpa_supplic
4  
5  
6  #ifdef CONFIG_CTRL_IFACE
7 +
8 +static int __ap_ctrl_iface_chanswitch(struct hostapd_iface *iface,
9 +                                     struct csa_settings *settings)
10 +{
11 +#ifdef NEED_AP_MLME
12 +       if (!iface || !iface->bss[0])
13 +               return 0;
14 +
15 +       return hostapd_switch_channel(iface->bss[0], settings);
16 +#else
17 +       return -1;
18 +#endif
19 +}
20 +
21 +
22  int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos)
23  {
24         struct csa_settings settings;
25         int ret = hostapd_parse_csa_settings(pos, &settings);
26  
27 +       if (!(wpa_s->ap_iface && wpa_s->ap_iface->bss[0]) &&
28 +           !(wpa_s->ifmsh && wpa_s->ifmsh->bss[0]))
29 +               return -1;
30 +
31 +       ret = __ap_ctrl_iface_chanswitch(wpa_s->ap_iface, &settings);
32         if (ret)
33                 return ret;
34  
35 -       return ap_switch_channel(wpa_s, &settings);
36 +       return __ap_ctrl_iface_chanswitch(wpa_s->ifmsh, &settings);
37  }
38  #endif /* CONFIG_CTRL_IFACE */
39