[PATCH 1/7] ap: create hostapd_parse_freq_params()
Benjamin Berg
benjamin at sipsolutions.net
Thu Jul 31 06:56:57 PDT 2025
From: Johannes Berg <johannes.berg at intel.com>
Split out hostapd_parse_freq_params() from hostapd_parse_csa_settings()
to be able to use it separately.
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
Reviewed-by: Peer, Ilan <ilan.peer at intel.com>
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
src/ap/ctrl_iface_ap.c | 67 +++++++++++++++++++++++++-----------------
src/ap/ctrl_iface_ap.h | 3 ++
2 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
index 799aff7659..002e7b4938 100644
--- a/src/ap/ctrl_iface_ap.c
+++ b/src/ap/ctrl_iface_ap.c
@@ -1127,50 +1127,63 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
}
-int hostapd_parse_csa_settings(const char *pos,
- struct csa_settings *settings)
+int hostapd_parse_freq_params(const char *pos,
+ struct hostapd_freq_params *params,
+ unsigned int freq)
{
- char *end;
-
- os_memset(settings, 0, sizeof(*settings));
- settings->cs_count = strtol(pos, &end, 10);
- if (pos == end) {
- wpa_printf(MSG_ERROR, "chanswitch: invalid cs_count provided");
- return -1;
- }
+ if (freq)
+ params->freq = freq;
+ else
+ params->freq = atoi(pos);
- settings->freq_params.freq = atoi(end);
- if (settings->freq_params.freq == 0) {
- wpa_printf(MSG_ERROR, "chanswitch: invalid freq provided");
+ if (params->freq == 0) {
+ wpa_printf(MSG_ERROR, "freq_params: invalid freq provided");
return -1;
}
-#define SET_CSA_SETTING(str) \
+#define SET_FREQ_PARAM(str) \
do { \
const char *pos2 = os_strstr(pos, " " #str "="); \
if (pos2) { \
pos2 += sizeof(" " #str "=") - 1; \
- settings->freq_params.str = atoi(pos2); \
+ params->str = atoi(pos2); \
} \
} while (0)
- SET_CSA_SETTING(center_freq1);
- SET_CSA_SETTING(center_freq2);
- SET_CSA_SETTING(bandwidth);
- SET_CSA_SETTING(sec_channel_offset);
- SET_CSA_SETTING(punct_bitmap);
- settings->freq_params.ht_enabled = !!os_strstr(pos, " ht");
- settings->freq_params.vht_enabled = !!os_strstr(pos, " vht");
- settings->freq_params.eht_enabled = !!os_strstr(pos, " eht");
- settings->freq_params.he_enabled = !!os_strstr(pos, " he") ||
- settings->freq_params.eht_enabled;
- settings->block_tx = !!os_strstr(pos, " blocktx");
-#undef SET_CSA_SETTING
+ SET_FREQ_PARAM(center_freq1);
+ SET_FREQ_PARAM(center_freq2);
+ SET_FREQ_PARAM(bandwidth);
+ SET_FREQ_PARAM(sec_channel_offset);
+ SET_FREQ_PARAM(punct_bitmap);
+ params->ht_enabled = !!os_strstr(pos, " ht");
+ params->vht_enabled = !!os_strstr(pos, " vht");
+ params->eht_enabled = !!os_strstr(pos, " eht");
+ params->he_enabled = !!os_strstr(pos, " he") ||
+ params->eht_enabled;
+#undef SET_FREQ_PARAM
return 0;
}
+int hostapd_parse_csa_settings(const char *pos,
+ struct csa_settings *settings)
+{
+ char *end;
+
+ os_memset(settings, 0, sizeof(*settings));
+ settings->cs_count = strtol(pos, &end, 10);
+ if (pos == end) {
+ wpa_printf(MSG_ERROR, "chanswitch: invalid cs_count provided");
+ return -1;
+ }
+
+ settings->block_tx = !!os_strstr(pos, " blocktx");
+
+ return hostapd_parse_freq_params(end, &settings->freq_params, 0);
+}
+
+
int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
{
return hostapd_drv_stop_ap(hapd);
diff --git a/src/ap/ctrl_iface_ap.h b/src/ap/ctrl_iface_ap.h
index 614f0426c1..926a51f878 100644
--- a/src/ap/ctrl_iface_ap.h
+++ b/src/ap/ctrl_iface_ap.h
@@ -26,6 +26,9 @@ int hostapd_ctrl_iface_poll_sta(struct hostapd_data *hapd,
const char *txtaddr);
int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
size_t buflen);
+int hostapd_parse_freq_params(const char *pos,
+ struct hostapd_freq_params *params,
+ unsigned int freq);
int hostapd_parse_csa_settings(const char *pos,
struct csa_settings *settings);
int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd);
--
2.50.1
More information about the Hostap
mailing list