blob: f92c996bfafe4f835860e4787fec03e3b10b34e4 [file] [log] [blame]
developerd3f02932023-03-21 14:55:54 +08001From 55d35cf2ac29b250494916d33768b9e52e989e31 Mon Sep 17 00:00:00 2001
2From: Michael Lee <michael-cy.lee@mediatek.com>
3Date: Wed, 22 Mar 2023 13:59:29 +0800
4Subject: [PATCH] hostapd: mtk: Add channel information for hostapd reload
5
6Add center channel, operating class, and bandwidth into the UPDATE
7command when wpa_supplciant reloads hostapd.
8Hostapd can correctly update its channel information.
9
10Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com>
11---
12 hostapd/ctrl_iface.c | 11 +++++++++++
13 wpa_supplicant/wpa_supplicant.c | 17 ++++++++++++++---
14 2 files changed, 25 insertions(+), 3 deletions(-)
15
16diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
17index 61c9e80..e2c9e43 100644
18--- a/hostapd/ctrl_iface.c
19+++ b/hostapd/ctrl_iface.c
20@@ -170,6 +170,17 @@ static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
21 conf->hw_mode = atoi(val);
22 else if ((val = get_option(opt, "ieee80211n=")))
23 conf->ieee80211n = atoi(val);
24+ else if ((val = get_option(opt, "center_segment0=")))
25+ hostapd_set_oper_centr_freq_seg0_idx(conf, atoi(val));
26+ else if ((val = get_option(opt, "center_segment1=")))
27+ hostapd_set_oper_centr_freq_seg1_idx(conf, atoi(val));
28+ else if ((val = get_option(opt, "op_class="))) {
29+ enum oper_chan_width ch_width;
30+
31+ conf->op_class = atoi(val);
32+ ch_width = op_class_to_ch_width(conf->op_class);
33+ hostapd_set_oper_chwidth(conf, ch_width);
34+ }
35 else
36 break;
37 }
38diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
39index 616e00d..ca6612a 100644
40--- a/wpa_supplicant/wpa_supplicant.c
41+++ b/wpa_supplicant/wpa_supplicant.c
42@@ -150,9 +150,10 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
43 char buf[256];
44 size_t len = sizeof(buf);
45 enum hostapd_hw_mode hw_mode;
46- u8 channel;
47+ u8 channel, center_segment0, center_segment1, op_class;
48 int sec_chan = 0;
49 int ret;
50+ struct wpa_channel_info ci;
51
52 if (!bss)
53 return -1;
54@@ -165,9 +166,19 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
55 sec_chan = -1;
56 }
57
58+ ret = wpa_drv_channel_info(wpa_s, &ci);
59+ if (ret)
60+ return -1;
61+
62+ ieee80211_freq_to_chan(ci.center_frq1, &center_segment0);
63+ ieee80211_freq_to_chan(ci.center_frq2, &center_segment1);
64+ ieee80211_chaninfo_to_channel(ci.frequency, ci.chanwidth, sec_chan,
65+ &op_class, &channel);
66 hw_mode = ieee80211_freq_to_chan(bss->freq, &channel);
67- if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d",
68- channel, sec_chan, hw_mode) < 0)
69+ if (asprintf(&cmd, "UPDATE channel=%d center_segment0=%d "
70+ "center_segment1=%d sec_chan=%d hw_mode=%d op_class=%d",
71+ channel, center_segment0, center_segment1, sec_chan,
72+ hw_mode, op_class) < 0)
73 return -1;
74
75 ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL);
76--
772.25.1
78