blob: 6664eb55316de36549daa346e660832e0da15bb6 [file] [log] [blame]
developer8eb72a32023-03-30 08:32:07 +08001From ddd08f7066b80646d6ed5cfe1e80364ca3d4dfb4 Mon Sep 17 00:00:00 2001
developerd3f02932023-03-21 14:55:54 +08002From: Michael Lee <michael-cy.lee@mediatek.com>
3Date: Wed, 22 Mar 2023 13:59:29 +0800
developer8eb72a32023-03-30 08:32:07 +08004Subject: [PATCH 23/25] hostapd: mtk: Add channel information for hostapd
developer81939a52023-03-25 15:31:11 +08005 reload
developerd3f02932023-03-21 14:55:54 +08006
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
developer81939a52023-03-25 15:31:11 +080018index e1e9270..4c5d494 100644
developerd3f02932023-03-21 14:55:54 +080019--- a/hostapd/ctrl_iface.c
20+++ b/hostapd/ctrl_iface.c
21@@ -170,6 +170,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
developer8eb72a32023-03-30 08:32:07 +080040index 270da46..04c37b1 100644
developerd3f02932023-03-21 14:55:54 +080041--- 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;
developer5eb95ed2023-03-28 10:40:04 +080048+ u8 channel, center_segment0, center_segment1 = 0, op_class;
developerd3f02932023-03-21 14:55:54 +080049 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--
developer81939a52023-03-25 15:31:11 +0800782.18.0
developerd3f02932023-03-21 14:55:54 +080079