developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame^] | 1 | From 84337cd7cc25c227b19f8dde3138c40fdbf863b4 Mon Sep 17 00:00:00 2001 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 2 | From: Michael Lee <michael-cy.lee@mediatek.com> |
| 3 | Date: Wed, 22 Mar 2023 13:59:29 +0800 |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 21/32] hostapd: mtk: Add channel information for hostapd |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 5 | reload |
| 6 | |
| 7 | Add center channel, operating class, and bandwidth into the UPDATE |
| 8 | command when wpa_supplciant reloads hostapd. |
| 9 | Hostapd can correctly update its channel information. |
| 10 | |
| 11 | Signed-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 | |
| 17 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame^] | 18 | index 997b50aad..3abf06a09 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 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 | } |
| 39 | diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame^] | 40 | index deb14632c..2ca2bd263 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 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, ¢er_segment0); |
| 64 | + ieee80211_freq_to_chan(ci.center_frq2, ¢er_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 | -- |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame^] | 78 | 2.39.2 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 79 | |