diff --git a/src/common/dpp.c b/src/common/dpp.c index c76d87281..a03962fa2 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -4372,6 +4372,7 @@ static int dpp_configuration_parse(struct dpp_authentication *auth, conf_sta = dpp_configuration_alloc(pos + 10); if (!conf_sta) goto fail; + conf_sta->netrole = DPP_NETROLE_STA; conf = conf_sta; } @@ -4380,6 +4381,7 @@ static int dpp_configuration_parse(struct dpp_authentication *auth, conf_ap = dpp_configuration_alloc(pos + 9); if (!conf_ap) goto fail; + conf_ap->netrole = DPP_NETROLE_AP; conf = conf_ap; } @@ -4646,8 +4648,21 @@ static void dpp_build_legacy_cred_params(struct wpabuf *buf, } +static const char * dpp_netrole_str(enum dpp_netrole netrole) +{ + switch (netrole) { + case DPP_NETROLE_STA: + return "sta"; + case DPP_NETROLE_AP: + return "ap"; + default: + return "??"; + } +} + + static struct wpabuf * -dpp_build_conf_obj_dpp(struct dpp_authentication *auth, int ap, +dpp_build_conf_obj_dpp(struct dpp_authentication *auth, struct dpp_configuration *conf) { struct wpabuf *buf = NULL; @@ -4721,7 +4736,8 @@ dpp_build_conf_obj_dpp(struct dpp_authentication *auth, int ap, #endif /* CONFIG_TESTING_OPTIONS */ wpabuf_printf(dppcon, "{\"groups\":[{\"groupId\":\"%s\",", conf->group_id ? conf->group_id : "*"); - wpabuf_printf(dppcon, "\"netRole\":\"%s\"}],", ap ? "ap" : "sta"); + wpabuf_printf(dppcon, "\"netRole\":\"%s\"}],", + dpp_netrole_str(conf->netrole)); #ifdef CONFIG_TESTING_OPTIONS skip_groups: #endif /* CONFIG_TESTING_OPTIONS */ @@ -4861,7 +4877,7 @@ fail: static struct wpabuf * -dpp_build_conf_obj_legacy(struct dpp_authentication *auth, int ap, +dpp_build_conf_obj_legacy(struct dpp_authentication *auth, struct dpp_configuration *conf) { struct wpabuf *buf; @@ -4903,8 +4919,8 @@ dpp_build_conf_obj(struct dpp_authentication *auth, int ap) } if (dpp_akm_dpp(conf->akm)) - return dpp_build_conf_obj_dpp(auth, ap, conf); - return dpp_build_conf_obj_legacy(auth, ap, conf); + return dpp_build_conf_obj_dpp(auth, conf); + return dpp_build_conf_obj_legacy(auth, conf); } diff --git a/src/common/dpp.h b/src/common/dpp.h index 21b58ddcc..d77fa18b1 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -161,10 +161,16 @@ enum dpp_akm { DPP_AKM_PSK_SAE_DPP, }; +enum dpp_netrole { + DPP_NETROLE_STA, + DPP_NETROLE_AP, +}; + struct dpp_configuration { u8 ssid[32]; size_t ssid_len; enum dpp_akm akm; + enum dpp_netrole netrole; /* For DPP configuration (connector) */ os_time_t netaccesskey_expiry;