]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Send rejection for unsupported radio measurements
authorAvraham Stern <avraham.stern@intel.com>
Wed, 28 Dec 2016 13:06:38 +0000 (15:06 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 3 Jan 2017 13:18:29 +0000 (15:18 +0200)
Send measurement report with the mode field set to incapable in response
to measurement requests with unsupported measurement types.

In addition, measurements requests that request parallel measurements
are rejected since these features are not supported.

Measurement request frames with the enable bit set are ignored since
these are not really requesting measurements and are not supported for
now.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
wpa_supplicant/rrm.c

index 1a0572606ef71d9d074c885570235e367938cd0b..78afffb7bc245287753bfada9270d76e8c7127b8 100644 (file)
@@ -279,6 +279,25 @@ int wpas_rrm_send_neighbor_rep_request(struct wpa_supplicant *wpa_s,
 }
 
 
+static int wpas_rrm_report_elem(struct wpabuf *buf, u8 token, u8 mode, u8 type,
+                               const u8 *data, size_t data_len)
+{
+       if (wpabuf_tailroom(buf) < 5 + data_len)
+               return -1;
+
+       wpabuf_put_u8(buf, WLAN_EID_MEASURE_REPORT);
+       wpabuf_put_u8(buf, 3 + data_len);
+       wpabuf_put_u8(buf, token);
+       wpabuf_put_u8(buf, mode);
+       wpabuf_put_u8(buf, type);
+
+       if (data_len)
+               wpabuf_put_data(buf, data, data_len);
+
+       return 0;
+}
+
+
 static struct wpabuf * wpas_rrm_build_lci_report(struct wpa_supplicant *wpa_s,
                                                 const u8 *request, size_t len,
                                                 struct wpabuf *report)
@@ -397,11 +416,25 @@ wpas_rrm_handle_msr_req_element(
        wpa_printf(MSG_DEBUG, "Measurement request type %d token %d",
                   req->type, req->token);
 
+       if (req->mode & MEASUREMENT_REQUEST_MODE_ENABLE) {
+               /* Enable bit is not supported for now */
+               wpa_printf(MSG_DEBUG, "RRM: Enable bit not supported, ignore");
+               return 0;
+       }
+
+       if ((req->mode & MEASUREMENT_REQUEST_MODE_PARALLEL) &&
+           req->type > MEASURE_TYPE_RPI_HIST) {
+               /* Parallel measurements are not supported for now */
+               wpa_printf(MSG_DEBUG,
+                          "RRM: Parallel measurements are not supported, reject");
+               goto reject;
+       }
+
        switch (req->type) {
        case MEASURE_TYPE_LCI:
                *buf = wpas_rrm_build_lci_report(wpa_s, &req->token, req->len,
                                                 *buf);
-               break;
+               return 0;
        default:
                wpa_printf(MSG_INFO,
                           "RRM: Unsupported radio measurement type %u",
@@ -409,6 +442,19 @@ wpas_rrm_handle_msr_req_element(
                break;
        }
 
+reject:
+       if (wpabuf_resize(buf, sizeof(struct rrm_measurement_report_element))) {
+               wpa_printf(MSG_DEBUG, "RRM: Memory allocation failed");
+               return -1;
+       }
+
+       if (wpas_rrm_report_elem(*buf, req->token,
+                                MEASUREMENT_REPORT_MODE_REJECT_INCAPABLE,
+                                req->type, NULL, 0) < 0) {
+               wpa_printf(MSG_DEBUG, "RRM: Failed to add report element");
+               return -1;
+       }
+
        return 0;
 }