@@ -282,22 +282,15 @@ static const char *dpp_akm_to_string(enum ie_rsn_akm_suite akm_suite)
}
}
-char *dpp_configuration_to_json(struct dpp_configuration *config)
+static char *dpp_configuration_to_json(struct dpp_configuration *config,
+ const char *creds)
{
- _auto_(l_free) char *pass_or_psk;
_auto_(l_free) char *ssid;
ssid = l_malloc(config->ssid_len + 1);
memcpy(ssid, config->ssid, config->ssid_len);
ssid[config->ssid_len] = '\0';
- if (config->passphrase)
- pass_or_psk = l_strdup_printf("\"pass\":\"%s\"",
- config->passphrase);
- else
- pass_or_psk = l_strdup_printf("\"psk\":\"%s\"",
- config->psk);
-
return l_strdup_printf("{\"wi-fi_tech\":\"infra\","
"\"discovery\":{"
"\"ssid\":\"%s\""
@@ -310,11 +303,25 @@ char *dpp_configuration_to_json(struct dpp_configuration *config)
"\"hidden\":%s}"
"}",
ssid, dpp_akm_to_string(config->akm_suites),
- pass_or_psk,
+ creds,
config->send_hostname ? "true" : "false",
config->hidden ? "true" : "false");
}
+char *dpp_psk_config_to_json(struct dpp_configuration *config)
+{
+ _auto_(l_free) char *pass_or_psk;
+
+ if (config->passphrase)
+ pass_or_psk = l_strdup_printf("\"pass\":\"%s\"",
+ config->passphrase);
+ else
+ pass_or_psk = l_strdup_printf("\"psk\":\"%s\"",
+ config->psk);
+
+ return dpp_configuration_to_json(config, pass_or_psk);
+}
+
static struct dpp_configuration *dpp_configuration_new_psk(
const struct l_settings *settings)
{
@@ -132,7 +132,7 @@ struct dpp_configuration *dpp_configuration_new(
const struct l_settings *settings,
const char *ssid,
enum ie_rsn_akm_suite akm_suite);
-char *dpp_configuration_to_json(struct dpp_configuration *config);
+char *dpp_psk_config_to_json(struct dpp_configuration *config);
void dpp_configuration_free(struct dpp_configuration *conf);
struct dpp_attr_iter {
@@ -1212,7 +1212,7 @@ static void dpp_send_config_response(struct dpp_sm *dpp, uint8_t status)
* STATUS_CONFIGURE_FAILURE which only includes the E-Nonce.
*/
if (status == DPP_STATUS_OK) {
- json = dpp_configuration_to_json(dpp->config);
+ json = dpp_psk_config_to_json(dpp->config);
json_len = strlen(json);
ptr += dpp_append_wrapped_data(attrs + 2, ptr - attrs - 2,