developer | dc05614 | 2023-10-08 15:44:59 +0800 | [diff] [blame] | 1 | From c515d269b08190aede080b9c59bf758f5d65e5a5 Mon Sep 17 00:00:00 2001 |
| 2 | From: "fancy.liu" <fancy.liu@mediatek.com> |
| 3 | Date: Sun, 8 Oct 2023 11:50:06 +0800 |
| 4 | Subject: [PATCH] hostapd: mtk: Add ACS chanlist info in get_config |
| 5 | |
| 6 | This patch is used to add ACS chanlist info displaying |
| 7 | for upper layer application obtaining. |
| 8 | |
| 9 | Command format: |
| 10 | hostapd_cli -i phy0-ap0 get_config |
| 11 | |
| 12 | Signed-off-by: fancy.liu <fancy.liu@mediatek.com> |
| 13 | --- |
| 14 | hostapd/ctrl_iface.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ |
| 15 | 1 file changed, 59 insertions(+) |
| 16 | |
| 17 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 18 | index 537d5cf..2108198 100644 |
| 19 | --- a/hostapd/ctrl_iface.c |
| 20 | +++ b/hostapd/ctrl_iface.c |
| 21 | @@ -1120,6 +1120,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd, |
| 22 | { |
| 23 | int ret; |
| 24 | char *pos, *end; |
| 25 | + int i; |
| 26 | |
| 27 | pos = buf; |
| 28 | end = buf + buflen; |
| 29 | @@ -1299,6 +1300,64 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd, |
| 30 | pos += ret; |
| 31 | } |
| 32 | |
| 33 | + /* dump chanlist */ |
| 34 | + if (hapd->iface->conf->acs_ch_list.num > 0) { |
| 35 | + ret = os_snprintf(pos, end - pos, "chanlist="); |
| 36 | + if (os_snprintf_error(end - pos, ret)) |
| 37 | + return pos - buf; |
| 38 | + pos += ret; |
| 39 | + |
| 40 | + for (i = 0; i < hapd->iface->conf->acs_ch_list.num; i++) { |
| 41 | + if (i > 0) { |
| 42 | + ret = os_snprintf(pos, end - pos, ", "); |
| 43 | + if (os_snprintf_error(end - pos, ret)) |
| 44 | + return pos - buf; |
| 45 | + pos += ret; |
| 46 | + } |
| 47 | + |
| 48 | + ret = os_snprintf(pos, end - pos, "%d-%d", |
| 49 | + hapd->iface->conf->acs_ch_list.range[i].min, |
| 50 | + hapd->iface->conf->acs_ch_list.range[i].max); |
| 51 | + if (os_snprintf_error(end - pos, ret)) |
| 52 | + return pos - buf; |
| 53 | + pos += ret; |
| 54 | + } |
| 55 | + |
| 56 | + ret = os_snprintf(pos, end - pos, "\n"); |
| 57 | + if (os_snprintf_error(end - pos, ret)) |
| 58 | + return pos - buf; |
| 59 | + pos += ret; |
| 60 | + } |
| 61 | + |
| 62 | + /* dump freqlist */ |
| 63 | + if (hapd->iface->conf->acs_freq_list.num > 0) { |
| 64 | + ret = os_snprintf(pos, end - pos, "freqlist="); |
| 65 | + if (os_snprintf_error(end - pos, ret)) |
| 66 | + return pos - buf; |
| 67 | + pos += ret; |
| 68 | + |
| 69 | + for (i = 0; i < hapd->iface->conf->acs_freq_list.num; i++) { |
| 70 | + if (i > 0) { |
| 71 | + ret = os_snprintf(pos, end - pos, ", "); |
| 72 | + if (os_snprintf_error(end - pos, ret)) |
| 73 | + return pos - buf; |
| 74 | + pos += ret; |
| 75 | + } |
| 76 | + |
| 77 | + ret = os_snprintf(pos, end - pos, "%d-%d", |
| 78 | + hapd->iface->conf->acs_freq_list.range[i].min, |
| 79 | + hapd->iface->conf->acs_freq_list.range[i].max); |
| 80 | + if (os_snprintf_error(end - pos, ret)) |
| 81 | + return pos - buf; |
| 82 | + pos += ret; |
| 83 | + } |
| 84 | + |
| 85 | + ret = os_snprintf(pos, end - pos, "\n"); |
| 86 | + if (os_snprintf_error(end - pos, ret)) |
| 87 | + return pos - buf; |
| 88 | + pos += ret; |
| 89 | + } |
| 90 | + |
| 91 | return pos - buf; |
| 92 | } |
| 93 | |
| 94 | -- |
| 95 | 2.18.0 |
| 96 | |