diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index dba7c5816..bb9f26e97 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -577,6 +577,11 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, ret = set_disallow_aps(wpa_s, value); } else if (os_strcasecmp(cmd, "no_keep_alive") == 0) { wpa_s->no_keep_alive = !!atoi(value); +#ifdef CONFIG_DPP + } else if (os_strcasecmp(cmd, "dpp_configurator_params") == 0) { + os_free(wpa_s->dpp_configurator_params); + wpa_s->dpp_configurator_params = os_strdup(value); +#endif /* CONFIG_DPP */ #ifdef CONFIG_TESTING_OPTIONS } else if (os_strcasecmp(cmd, "ext_mgmt_frame_handling") == 0) { wpa_s->ext_mgmt_frame_handling = !!atoi(value); diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 928950c04..b7b50110c 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -387,15 +387,11 @@ static void wpas_dpp_set_testing_options(struct wpa_supplicant *wpa_s, } -int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) +static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s, + struct dpp_authentication *auth, + const char *cmd) { const char *pos, *end; - struct dpp_bootstrap_info *peer_bi, *own_bi = NULL; - struct wpabuf *msg; - const u8 *dst; - int res; - int configurator = 1; - unsigned int wait_time; struct dpp_configuration *conf_sta = NULL, *conf_ap = NULL; struct dpp_configurator *conf = NULL; u8 ssid[32] = { "test" }; @@ -403,54 +399,10 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) char pass[64] = { }; size_t pass_len = 0; - wpa_s->dpp_gas_client = 0; - - pos = os_strstr(cmd, " peer="); - if (!pos) - return -1; - pos += 6; - peer_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); - if (!peer_bi) { - wpa_printf(MSG_INFO, - "DPP: Could not find bootstrapping info for the identified peer"); - return -1; - } - - pos = os_strstr(cmd, " own="); - if (pos) { - pos += 5; - own_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); - if (!own_bi) { - wpa_printf(MSG_INFO, - "DPP: Could not find bootstrapping info for the identified local entry"); - return -1; - } - - if (peer_bi->curve != own_bi->curve) { - wpa_printf(MSG_INFO, - "DPP: Mismatching curves in bootstrapping info (peer=%s own=%s)", - peer_bi->curve->name, own_bi->curve->name); - return -1; - } - } - - pos = os_strstr(cmd, " role="); - if (pos) { - pos += 6; - if (os_strncmp(pos, "configurator", 12) == 0) - configurator = 1; - else if (os_strncmp(pos, "enrollee", 8) == 0) - configurator = 0; - else - goto fail; - } - - pos = os_strstr(cmd, " netrole="); - if (pos) { - pos += 9; - wpa_s->dpp_netrole_ap = os_strncmp(pos, "ap", 2) == 0; - } + if (!cmd) + return; + wpa_printf(MSG_DEBUG, "DPP: Set configurator parameters: %s", cmd); pos = os_strstr(cmd, " ssid="); if (pos) { pos += 6; @@ -533,6 +485,75 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) goto fail; } } + auth->conf_sta = conf_sta; + auth->conf_ap = conf_ap; + auth->conf = conf; + return; + +fail: + wpa_printf(MSG_DEBUG, "DPP: Failed to set configurator parameters"); + dpp_configuration_free(conf_sta); + dpp_configuration_free(conf_ap); +} + + +int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) +{ + const char *pos; + struct dpp_bootstrap_info *peer_bi, *own_bi = NULL; + struct wpabuf *msg; + const u8 *dst; + int res; + int configurator = 1; + unsigned int wait_time; + + wpa_s->dpp_gas_client = 0; + + pos = os_strstr(cmd, " peer="); + if (!pos) + return -1; + pos += 6; + peer_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); + if (!peer_bi) { + wpa_printf(MSG_INFO, + "DPP: Could not find bootstrapping info for the identified peer"); + return -1; + } + + pos = os_strstr(cmd, " own="); + if (pos) { + pos += 5; + own_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); + if (!own_bi) { + wpa_printf(MSG_INFO, + "DPP: Could not find bootstrapping info for the identified local entry"); + return -1; + } + + if (peer_bi->curve != own_bi->curve) { + wpa_printf(MSG_INFO, + "DPP: Mismatching curves in bootstrapping info (peer=%s own=%s)", + peer_bi->curve->name, own_bi->curve->name); + return -1; + } + } + + pos = os_strstr(cmd, " role="); + if (pos) { + pos += 6; + if (os_strncmp(pos, "configurator", 12) == 0) + configurator = 1; + else if (os_strncmp(pos, "enrollee", 8) == 0) + configurator = 0; + else + goto fail; + } + + pos = os_strstr(cmd, " netrole="); + if (pos) { + pos += 9; + wpa_s->dpp_netrole_ap = os_strncmp(pos, "ap", 2) == 0; + } if (wpa_s->dpp_auth) { eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); @@ -543,9 +564,7 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) if (!wpa_s->dpp_auth) goto fail; wpas_dpp_set_testing_options(wpa_s, wpa_s->dpp_auth); - wpa_s->dpp_auth->conf_sta = conf_sta; - wpa_s->dpp_auth->conf_ap = conf_ap; - wpa_s->dpp_auth->conf = conf; + wpas_dpp_set_configurator(wpa_s, wpa_s->dpp_auth, cmd); /* TODO: Support iteration over all frequencies and filtering of * frequencies based on locally enabled channels that allow initiation @@ -584,8 +603,6 @@ int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) return res; fail: - dpp_configuration_free(conf_sta); - dpp_configuration_free(conf_ap); return -1; } @@ -855,6 +872,8 @@ static void wpas_dpp_rx_auth_req(struct wpa_supplicant *wpa_s, const u8 *src, return; } wpas_dpp_set_testing_options(wpa_s, wpa_s->dpp_auth); + wpas_dpp_set_configurator(wpa_s, wpa_s->dpp_auth, + wpa_s->dpp_configurator_params); os_memcpy(wpa_s->dpp_auth->peer_mac_addr, src, ETH_ALEN); msg = dpp_alloc_msg(DPP_PA_AUTHENTICATION_RESP, @@ -2003,4 +2022,6 @@ void wpas_dpp_deinit(struct wpa_supplicant *wpa_s) wpas_dpp_pkex_remove(wpa_s, "*"); wpa_s->dpp_pkex = NULL; os_memset(wpa_s->dpp_intro_bssid, 0, ETH_ALEN); + os_free(wpa_s->dpp_configurator_params); + wpa_s->dpp_configurator_params = NULL; } diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 45fc41b59..a2b331fb7 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1177,6 +1177,7 @@ struct wpa_supplicant { char *dpp_pkex_code; char *dpp_pkex_identifier; char *dpp_pkex_auth_cmd; + char *dpp_configurator_params; #ifdef CONFIG_TESTING_OPTIONS char *dpp_config_obj_override; char *dpp_discovery_override;