blob: 6664eb55316de36549daa346e660832e0da15bb6 [file] [log] [blame]
From ddd08f7066b80646d6ed5cfe1e80364ca3d4dfb4 Mon Sep 17 00:00:00 2001
From: Michael Lee <michael-cy.lee@mediatek.com>
Date: Wed, 22 Mar 2023 13:59:29 +0800
Subject: [PATCH 23/25] hostapd: mtk: Add channel information for hostapd
reload
Add center channel, operating class, and bandwidth into the UPDATE
command when wpa_supplciant reloads hostapd.
Hostapd can correctly update its channel information.
Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com>
---
hostapd/ctrl_iface.c | 11 +++++++++++
wpa_supplicant/wpa_supplicant.c | 17 ++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index e1e9270..4c5d494 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -170,6 +170,17 @@ static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
conf->hw_mode = atoi(val);
else if ((val = get_option(opt, "ieee80211n=")))
conf->ieee80211n = atoi(val);
+ else if ((val = get_option(opt, "center_segment0=")))
+ hostapd_set_oper_centr_freq_seg0_idx(conf, atoi(val));
+ else if ((val = get_option(opt, "center_segment1=")))
+ hostapd_set_oper_centr_freq_seg1_idx(conf, atoi(val));
+ else if ((val = get_option(opt, "op_class="))) {
+ enum oper_chan_width ch_width;
+
+ conf->op_class = atoi(val);
+ ch_width = op_class_to_ch_width(conf->op_class);
+ hostapd_set_oper_chwidth(conf, ch_width);
+ }
else
break;
}
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 270da46..04c37b1 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -150,9 +150,10 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
char buf[256];
size_t len = sizeof(buf);
enum hostapd_hw_mode hw_mode;
- u8 channel;
+ u8 channel, center_segment0, center_segment1 = 0, op_class;
int sec_chan = 0;
int ret;
+ struct wpa_channel_info ci;
if (!bss)
return -1;
@@ -165,9 +166,19 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
sec_chan = -1;
}
+ ret = wpa_drv_channel_info(wpa_s, &ci);
+ if (ret)
+ return -1;
+
+ ieee80211_freq_to_chan(ci.center_frq1, &center_segment0);
+ ieee80211_freq_to_chan(ci.center_frq2, &center_segment1);
+ ieee80211_chaninfo_to_channel(ci.frequency, ci.chanwidth, sec_chan,
+ &op_class, &channel);
hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
- if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d",
- channel, sec_chan, hw_mode) < 0)
+ if (asprintf(&cmd, "UPDATE channel=%d center_segment0=%d "
+ "center_segment1=%d sec_chan=%d hw_mode=%d op_class=%d",
+ channel, center_segment0, center_segment1, sec_chan,
+ hw_mode, op_class) < 0)
return -1;
ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
--
2.18.0