DPP: Add bandSupport JSON array into config request

Indicate supported global operating classes when wpa_supplicant is
operating as an Enrollee.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-09-19 00:00:46 +03:00 committed by Jouni Malinen
parent 6d3dc9ba1e
commit 8f8c423a51
6 changed files with 43 additions and 9 deletions

View file

@ -768,7 +768,7 @@ static void hostapd_dpp_start_gas_client(struct hostapd_data *hapd)
int res; int res;
buf = dpp_build_conf_req_helper(auth, hapd->conf->dpp_name, 1, buf = dpp_build_conf_req_helper(auth, hapd->conf->dpp_name, 1,
hapd->conf->dpp_mud_url); hapd->conf->dpp_mud_url, NULL);
if (!buf) { if (!buf) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"DPP: No configuration request data available"); "DPP: No configuration request data available");

View file

@ -2514,7 +2514,7 @@ struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth, struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
const char *name, int netrole_ap, const char *name, int netrole_ap,
const char *mud_url) const char *mud_url, int *opclasses)
{ {
size_t len, nlen; size_t len, nlen;
const char *tech = "infra"; const char *tech = "infra";
@ -2539,7 +2539,7 @@ struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
return NULL; return NULL;
json_escape_string(nbuf, nlen, dpp_name, len); json_escape_string(nbuf, nlen, dpp_name, len);
len = 100 + os_strlen(nbuf); len = 100 + os_strlen(nbuf) + int_array_len(opclasses) * 4;
if (mud_url && mud_url[0]) if (mud_url && mud_url[0])
len += 10 + os_strlen(mud_url); len += 10 + os_strlen(mud_url);
json = wpabuf_alloc(len); json = wpabuf_alloc(len);
@ -2555,6 +2555,14 @@ struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
nbuf, tech, netrole_ap ? "ap" : "sta"); nbuf, tech, netrole_ap ? "ap" : "sta");
if (mud_url && mud_url[0]) if (mud_url && mud_url[0])
wpabuf_printf(json, ",\"mudurl\":\"%s\"", mud_url); wpabuf_printf(json, ",\"mudurl\":\"%s\"", mud_url);
if (opclasses) {
int i;
wpabuf_put_str(json, ",\"bandSupport\":[");
for (i = 0; opclasses[i]; i++)
wpabuf_printf(json, "%s%u", i ? "," : "", opclasses[i]);
wpabuf_put_str(json, "]");
}
wpabuf_put_str(json, "}"); wpabuf_put_str(json, "}");
os_free(nbuf); os_free(nbuf);
@ -9253,7 +9261,7 @@ static void dpp_controller_start_gas_client(struct dpp_connection *conn)
struct wpabuf *buf; struct wpabuf *buf;
int netrole_ap = 0; /* TODO: make this configurable */ int netrole_ap = 0; /* TODO: make this configurable */
buf = dpp_build_conf_req_helper(auth, "Test", netrole_ap, NULL); buf = dpp_build_conf_req_helper(auth, "Test", netrole_ap, NULL, NULL);
if (!buf) { if (!buf) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"DPP: No configuration request data available"); "DPP: No configuration request data available");

View file

@ -422,7 +422,7 @@ struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
const char *json); const char *json);
struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth, struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
const char *name, int netrole_ap, const char *name, int netrole_ap,
const char *mud_url); const char *mud_url, int *opclasses);
int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
const u8 *attr_start, size_t attr_len); const u8 *attr_start, size_t attr_len);
int dpp_notify_new_qr_code(struct dpp_authentication *auth, int dpp_notify_new_qr_code(struct dpp_authentication *auth,

View file

@ -1252,14 +1252,18 @@ static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s)
struct dpp_authentication *auth = wpa_s->dpp_auth; struct dpp_authentication *auth = wpa_s->dpp_auth;
struct wpabuf *buf; struct wpabuf *buf;
int res; int res;
int *supp_op_classes;
wpa_s->dpp_gas_client = 1; wpa_s->dpp_gas_client = 1;
offchannel_send_action_done(wpa_s); offchannel_send_action_done(wpa_s);
wpas_dpp_listen_stop(wpa_s); wpas_dpp_listen_stop(wpa_s);
supp_op_classes = wpas_supp_op_classes(wpa_s);
buf = dpp_build_conf_req_helper(auth, wpa_s->conf->dpp_name, buf = dpp_build_conf_req_helper(auth, wpa_s->conf->dpp_name,
wpa_s->dpp_netrole_ap, wpa_s->dpp_netrole_ap,
wpa_s->conf->dpp_mud_url); wpa_s->conf->dpp_mud_url,
supp_op_classes);
os_free(supp_op_classes);
if (!buf) { if (!buf) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"DPP: No configuration request data available"); "DPP: No configuration request data available");

View file

@ -225,7 +225,7 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
/* If we are configured to disable certain things, take that into /* If we are configured to disable certain things, take that into
* account here. */ * account here. */
if (ssid->freq_list && ssid->freq_list[0]) { if (ssid && ssid->freq_list && ssid->freq_list[0]) {
for (z = 0; ; z++) { for (z = 0; ; z++) {
int f = ssid->freq_list[z]; int f = ssid->freq_list[z];
@ -248,7 +248,7 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
return 0; return 0;
#ifdef CONFIG_HT_OVERRIDES #ifdef CONFIG_HT_OVERRIDES
if (ssid->disable_ht) { if (ssid && ssid->disable_ht) {
switch (op_class->op_class) { switch (op_class->op_class) {
case 83: case 83:
case 84: case 84:
@ -272,7 +272,7 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_HT_OVERRIDES */ #endif /* CONFIG_HT_OVERRIDES */
#ifdef CONFIG_VHT_OVERRIDES #ifdef CONFIG_VHT_OVERRIDES
if (ssid->disable_vht) { if (ssid && ssid->disable_vht) {
if (op_class->op_class >= 128 && op_class->op_class <= 130) { if (op_class->op_class >= 128 && op_class->op_class <= 130) {
/* Disable >= 80 MHz channels if VHT is disabled */ /* Disable >= 80 MHz channels if VHT is disabled */
return 0; return 0;
@ -385,3 +385,24 @@ size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
wpabuf_free(buf); wpabuf_free(buf);
return res; return res;
} }
int * wpas_supp_op_classes(struct wpa_supplicant *wpa_s)
{
int op;
unsigned int pos, max_num = 0;
int *classes;
for (op = 0; global_op_class[op].op_class; op++)
max_num++;
classes = os_zalloc((max_num + 1) * sizeof(int));
if (!classes)
return NULL;
for (op = 0, pos = 0; global_op_class[op].op_class; op++) {
if (wpas_op_class_supported(wpa_s, NULL, &global_op_class[op]))
classes[pos++] = global_op_class[op].op_class;
}
return classes;
}

View file

@ -1424,6 +1424,7 @@ enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 channel,
size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid, struct wpa_ssid *ssid,
int freq, u8 *pos, size_t len); int freq, u8 *pos, size_t len);
int * wpas_supp_op_classes(struct wpa_supplicant *wpa_s);
int wpas_enable_mac_addr_randomization(struct wpa_supplicant *wpa_s, int wpas_enable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
unsigned int type, const u8 *addr, unsigned int type, const u8 *addr,