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