From 2aeb1ad361356c6eca3101b00cd323490ad7d55a Mon Sep 17 00:00:00 2001 From: Patrick Walther Date: Fri, 24 Jul 2020 14:41:09 +0200 --- wpa_supplicant/ap.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 52b537e62..f21b8713f 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -1803,15 +1803,35 @@ int ap_switch_channel(struct wpa_supplicant *wpa_s, #ifdef CONFIG_CTRL_IFACE + +static int __ap_ctrl_iface_chanswitch(struct hostapd_iface *iface, + struct csa_settings *settings) +{ +#ifdef NEED_AP_MLME + if (!iface || !iface->bss[0]) + return 0; + + return hostapd_switch_channel(iface->bss[0], settings); +#else + return -1; +#endif +} + + int ap_ctrl_iface_chanswitch(struct wpa_supplicant *wpa_s, const char *pos) { struct csa_settings settings; int ret = hostapd_parse_csa_settings(pos, &settings); + if (!(wpa_s->ap_iface && wpa_s->ap_iface->bss[0]) && + !(wpa_s->ifmsh && wpa_s->ifmsh->bss[0])) + return -1; + + ret = __ap_ctrl_iface_chanswitch(wpa_s->ap_iface, &settings); if (ret) return ret; - return ap_switch_channel(wpa_s, &settings); + return __ap_ctrl_iface_chanswitch(wpa_s->ifmsh, &settings); } #endif /* CONFIG_CTRL_IFACE */