From 30ecf0181d346760da2a6c2c2725deff1826a741 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 15 Mar 2022 21:10:31 +0200 Subject: [PATCH] DPP: Update Controller parameters when it was already started dpp_configurator_params changes were taken into use in the non-TCP/Controller case immediately on change, but that was not the case for the Controller where this was updated only when explicitly starting it. Change this to update dpp_configurator_params for the Controller as well even if it is already running. Signed-off-by: Jouni Malinen --- hostapd/ctrl_iface.c | 3 +++ src/common/dpp.h | 2 ++ src/common/dpp_tcp.c | 23 +++++++++++++++++++++++ wpa_supplicant/ctrl_iface.c | 3 +++ 4 files changed, 31 insertions(+) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 29dc38aba..80e4dacb8 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -1519,6 +1519,9 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd) } else if (os_strcasecmp(cmd, "dpp_configurator_params") == 0) { os_free(hapd->dpp_configurator_params); hapd->dpp_configurator_params = os_strdup(value); +#ifdef CONFIG_DPP2 + dpp_controller_set_params(hapd->iface->interfaces->dpp, value); +#endif /* CONFIG_DPP2 */ } else if (os_strcasecmp(cmd, "dpp_init_max_tries") == 0) { hapd->dpp_init_max_tries = atoi(value); } else if (os_strcasecmp(cmd, "dpp_init_retry_time") == 0) { diff --git a/src/common/dpp.h b/src/common/dpp.h index 16d3ca71f..72899f9f9 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -709,6 +709,8 @@ int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data, size_t data_len); int dpp_controller_start(struct dpp_global *dpp, struct dpp_controller_config *config); +int dpp_controller_set_params(struct dpp_global *dpp, + const char *configurator_params); void dpp_controller_stop(struct dpp_global *dpp); void dpp_controller_stop_for_ctx(struct dpp_global *dpp, void *cb_ctx); struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp, diff --git a/src/common/dpp_tcp.c b/src/common/dpp_tcp.c index 5f779934f..a6cca9a13 100644 --- a/src/common/dpp_tcp.c +++ b/src/common/dpp_tcp.c @@ -2084,6 +2084,29 @@ fail: } +int dpp_controller_set_params(struct dpp_global *dpp, + const char *configurator_params) +{ + + if (!dpp || !dpp->controller) + return -1; + + if (configurator_params) { + char *val = os_strdup(configurator_params); + + if (!val) + return -1; + os_free(dpp->controller->configurator_params); + dpp->controller->configurator_params = val; + } else { + os_free(dpp->controller->configurator_params); + dpp->controller->configurator_params = NULL; + } + + return 0; +} + + void dpp_controller_stop(struct dpp_global *dpp) { if (dpp) { diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index f7ca929fe..21d7ec4b0 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -674,6 +674,9 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, } else if (os_strcasecmp(cmd, "dpp_configurator_params") == 0) { os_free(wpa_s->dpp_configurator_params); wpa_s->dpp_configurator_params = os_strdup(value); +#ifdef CONFIG_DPP2 + dpp_controller_set_params(wpa_s->dpp, value); +#endif /* CONFIG_DPP2 */ } else if (os_strcasecmp(cmd, "dpp_init_max_tries") == 0) { wpa_s->dpp_init_max_tries = atoi(value); } else if (os_strcasecmp(cmd, "dpp_init_retry_time") == 0) {