]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Add bandSupport JSON array into config request
authorJouni Malinen <jouni@codeaurora.org>
Wed, 18 Sep 2019 21:00:46 +0000 (00:00 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 18 Sep 2019 21:21:47 +0000 (00:21 +0300)
Indicate supported global operating classes when wpa_supplicant is
operating as an Enrollee.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/dpp_hostapd.c
src/common/dpp.c
src/common/dpp.h
wpa_supplicant/dpp_supplicant.c
wpa_supplicant/op_classes.c
wpa_supplicant/wpa_supplicant_i.h

index 91bbb01860bed94a67e12c827104c59bb69e402d..effcc7ab1d3a80b87bcb90260bf04ae3d6e0d0b7 100644 (file)
@@ -768,7 +768,7 @@ static void hostapd_dpp_start_gas_client(struct hostapd_data *hapd)
        int res;
 
        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) {
                wpa_printf(MSG_DEBUG,
                           "DPP: No configuration request data available");
index 6d6fbfbaecbe698b681fad8a88945919a0359185..5b8d6a5470cf1d928ddda32eb0e98f1321febc07 100644 (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,
                                          const char *name, int netrole_ap,
-                                         const char *mud_url)
+                                         const char *mud_url, int *opclasses)
 {
        size_t len, nlen;
        const char *tech = "infra";
@@ -2539,7 +2539,7 @@ struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
                return NULL;
        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])
                len += 10 + os_strlen(mud_url);
        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");
        if (mud_url && mud_url[0])
                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, "}");
        os_free(nbuf);
 
@@ -9253,7 +9261,7 @@ static void dpp_controller_start_gas_client(struct dpp_connection *conn)
        struct wpabuf *buf;
        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) {
                wpa_printf(MSG_DEBUG,
                           "DPP: No configuration request data available");
index 9870e3d35634ceb8594809b13f6f5b6f700b13ad..21b58ddcc8f1098141944058a1f9bb827e2c2ca8 100644 (file)
@@ -422,7 +422,7 @@ struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
                                   const char *json);
 struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
                                          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,
                     const u8 *attr_start, size_t attr_len);
 int dpp_notify_new_qr_code(struct dpp_authentication *auth,
index 29a50f3b06113b998f449c80f8afd8fb64a4b1ea..b4341f1870905d2f200eb9941824969fde7b4b26 100644 (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 wpabuf *buf;
        int res;
+       int *supp_op_classes;
 
        wpa_s->dpp_gas_client = 1;
        offchannel_send_action_done(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,
                                        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) {
                wpa_printf(MSG_DEBUG,
                           "DPP: No configuration request data available");
index 6a85af4eaf37d291ae8fa3d8534743b290fff713..5c103ec7ef2d40f6df6229ac2280af9a2aca23d8 100644 (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
         * account here. */
-       if (ssid->freq_list && ssid->freq_list[0]) {
+       if (ssid && ssid->freq_list && ssid->freq_list[0]) {
                for (z = 0; ; z++) {
                        int f = ssid->freq_list[z];
 
@@ -248,7 +248,7 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
                return 0;
 
 #ifdef CONFIG_HT_OVERRIDES
-       if (ssid->disable_ht) {
+       if (ssid && ssid->disable_ht) {
                switch (op_class->op_class) {
                case 83:
                case 84:
@@ -272,7 +272,7 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_HT_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) {
                        /* Disable >= 80 MHz channels if VHT is disabled */
                        return 0;
@@ -385,3 +385,24 @@ size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
        wpabuf_free(buf);
        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;
+}
index 872c19c8427ad201f651c7e4394f40bb2b94f344..63f2f5960c1ea32a11fe2a011a41359f92378fc8 100644 (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,
                             struct wpa_ssid *ssid,
                             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,
                                       unsigned int type, const u8 *addr,