]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
STA: Add OCE capability indication attribute
authorAshwini Patil <c_apati@qti.qualcomm.com>
Mon, 10 Jul 2017 12:05:31 +0000 (17:35 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 14 Jul 2017 18:19:53 +0000 (21:19 +0300)
Add OCE capability indication attribute in Probe Request and
(Re)Association Request frames.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/common/defs.h
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/ctrl_iface.c
wpa_supplicant/mbo.c
wpa_supplicant/scan.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant.conf
wpa_supplicant/wpa_supplicant_i.h

index ffe4fecf75095c7ffd32974f29d4b7b340a61c83..f15c5cc3247f90ee60cf7f11d05321303d665a6d 100644 (file)
@@ -389,4 +389,7 @@ enum eap_proxy_sim_state {
        SIM_STATE_ERROR,
 };
 
+#define OCE_STA BIT(0)
+#define OCE_STA_CFON BIT(1)
+
 #endif /* DEFS_H */
index 4bad31f2d1b7b0193ac9b47383008f5c3e4c4672..37489f716e26321a445283d549b9eaf99eb39f81 100644 (file)
@@ -3857,6 +3857,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
        config->mbo_cell_capa = DEFAULT_MBO_CELL_CAPA;
        config->disassoc_imminent_rssi_threshold =
                DEFAULT_DISASSOC_IMMINENT_RSSI_THRESHOLD;
+       config->oce = DEFAULT_OCE_SUPPORT;
 #endif /* CONFIG_MBO */
 
        if (ctrl_interface)
@@ -4571,6 +4572,7 @@ static const struct global_parse_data global_fields[] = {
        { INT_RANGE(mbo_cell_capa, MBO_CELL_CAPA_AVAILABLE,
                    MBO_CELL_CAPA_NOT_SUPPORTED), 0 },
        { INT_RANGE(disassoc_imminent_rssi_threshold, -120, 0), 0 },
+       { INT_RANGE(oce, 0, 3), 0 },
 #endif /* CONFIG_MBO */
        { INT(gas_address3), 0 },
        { INT_RANGE(ftm_responder, 0, 1), 0 },
index 6388a832bc51c560390a80c738902371e7f3904f..6a2c8028d12c8fdf68f6f37be536f514e8587fb1 100644 (file)
@@ -42,6 +42,7 @@
 #define DEFAULT_WPA_RSC_RELAXATION 1
 #define DEFAULT_MBO_CELL_CAPA MBO_CELL_CAPA_NOT_SUPPORTED
 #define DEFAULT_DISASSOC_IMMINENT_RSSI_THRESHOLD -75
+#define DEFAULT_OCE_SUPPORT OCE_STA
 
 #include "config_ssid.h"
 #include "wps/wps.h"
@@ -1314,6 +1315,13 @@ struct wpa_config {
         * when disassociation imminent is set.
         */
        int disassoc_imminent_rssi_threshold;
+
+       /**
+        * oce - Enable OCE in STA and/or STA-CFON mode
+        *  - Set BIT(0) to enable OCE in non-AP STA mode
+        *  - Set BIT(1) to enable OCE in STA-CFON mode
+        */
+       unsigned int oce;
 #endif /* CONFIG_MBO */
 
        /**
index 6558a1b767367cd1ab1ad27f749cc11a276d7e16..692b2005c869c7cbfe22cc7db85ef599c665e670 100644 (file)
@@ -1430,6 +1430,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
            DEFAULT_DISASSOC_IMMINENT_RSSI_THRESHOLD)
                fprintf(f, "disassoc_imminent_rssi_threshold=%d\n",
                        config->disassoc_imminent_rssi_threshold);
+       if (config->oce != DEFAULT_OCE_SUPPORT)
+               fprintf(f, "oce=%u\n", config->oce);
 #endif /* CONFIG_MBO */
 
        if (config->gas_address3)
index a438f6799b94171a57ff04349501be6e869ca730..863dc992f99a6a9b4f77115dd4d2129946f01089 100644 (file)
@@ -669,6 +669,24 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                }
        } else if (os_strcasecmp(cmd, "mbo_cell_capa") == 0) {
                wpas_mbo_update_cell_capa(wpa_s, atoi(value));
+       } else if (os_strcasecmp(cmd, "oce") == 0) {
+               wpa_s->conf->oce = atoi(value);
+               if (wpa_s->conf->oce) {
+                       if ((wpa_s->conf->oce & OCE_STA) &&
+                           (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OCE_STA))
+                               wpa_s->enable_oce = OCE_STA;
+
+                       if ((wpa_s->conf->oce & OCE_STA_CFON) &&
+                           (wpa_s->drv_flags &
+                            WPA_DRIVER_FLAGS_OCE_STA_CFON)) {
+                               /* TODO: Need to add STA-CFON support */
+                               wpa_printf(MSG_ERROR,
+                                          "OCE STA-CFON feature is not yet supported");
+                               return -1;
+                       }
+               } else {
+                       wpa_s->enable_oce = 0;
+               }
 #endif /* CONFIG_MBO */
        } else if (os_strcasecmp(cmd, "lci") == 0) {
                ret = wpas_ctrl_iface_set_lci(wpa_s, value);
index 4bf227dca4e272f65af45644d0ba5f1fab52c482..129d205451bb3a92ab59807bdc4f23c3237fd1c6 100644 (file)
@@ -154,7 +154,8 @@ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len)
        struct wpabuf *mbo;
        int res;
 
-       if (len < MBO_IE_HEADER + 3 + 7)
+       if (len < MBO_IE_HEADER + 3 + 7 +
+           ((wpa_s->enable_oce & OCE_STA) ? 3 : 0))
                return 0;
 
        /* Leave room for the MBO IE header */
@@ -173,9 +174,16 @@ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len)
        wpabuf_put_u8(mbo, 1);
        wpabuf_put_u8(mbo, wpa_s->conf->mbo_cell_capa);
 
+       /* Add OCE capability indication attribute if OCE is enabled */
+       if (wpa_s->enable_oce & OCE_STA) {
+               wpabuf_put_u8(mbo, OCE_ATTR_ID_CAPA_IND);
+               wpabuf_put_u8(mbo, 1);
+               wpabuf_put_u8(mbo, OCE_RELEASE);
+       }
+
        res = mbo_add_ie(buf, len, wpabuf_head_u8(mbo), wpabuf_len(mbo));
        if (!res)
-               wpa_printf(MSG_ERROR, "Failed to add MBO IE");
+               wpa_printf(MSG_ERROR, "Failed to add MBO/OCE IE");
 
        wpabuf_free(mbo);
        return res;
@@ -368,14 +376,23 @@ fail:
 
 void wpas_mbo_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ie)
 {
+       u8 *len;
+
        wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
-       wpabuf_put_u8(ie, 7);
+       len = wpabuf_put(ie, 1);
+
        wpabuf_put_be24(ie, OUI_WFA);
        wpabuf_put_u8(ie, MBO_OUI_TYPE);
 
        wpabuf_put_u8(ie, MBO_ATTR_ID_CELL_DATA_CAPA);
        wpabuf_put_u8(ie, 1);
        wpabuf_put_u8(ie, wpa_s->conf->mbo_cell_capa);
+       if (wpa_s->enable_oce & OCE_STA) {
+               wpabuf_put_u8(ie, OCE_ATTR_ID_CAPA_IND);
+               wpabuf_put_u8(ie, 1);
+               wpabuf_put_u8(ie, OCE_RELEASE);
+       }
+       *len = (u8 *) wpabuf_put(ie, 0) - len - 1;
 }
 
 
index 85b732f93f7091354a5bcadc4598dfcaae57e984..964adba54e29fe71a767319758116e3a0c5198c1 100644 (file)
@@ -471,8 +471,8 @@ void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s)
                wpabuf_put_data(default_ies, ext_capab, ext_capab_len);
 
 #ifdef CONFIG_MBO
-       /* Send cellular capabilities for potential MBO STAs */
-       if (wpabuf_resize(&default_ies, 9) == 0)
+       /* Send MBO and OCE capabilities */
+       if (wpabuf_resize(&default_ies, 12) == 0)
                wpas_mbo_scan_ie(wpa_s, default_ies);
 #endif /* CONFIG_MBO */
 
@@ -553,8 +553,8 @@ static struct wpabuf * wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s)
 #endif /* CONFIG_FST */
 
 #ifdef CONFIG_MBO
-       /* Send cellular capabilities for potential MBO STAs */
-       if (wpabuf_resize(&extra_ie, 9) == 0)
+       /* Send MBO and OCE capabilities */
+       if (wpabuf_resize(&extra_ie, 12) == 0)
                wpas_mbo_scan_ie(wpa_s, extra_ie);
 #endif /* CONFIG_MBO */
 
index 9263d8a1404f2745fdcb1b6cb4319db0c8a557c3..be447874710b56455e108e5a3be006cd8356e1be 100644 (file)
@@ -5323,6 +5323,17 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
        hs20_init(wpa_s);
 #endif /* CONFIG_HS20 */
 #ifdef CONFIG_MBO
+       if (wpa_s->conf->oce) {
+               if ((wpa_s->conf->oce & OCE_STA) &&
+                   (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OCE_STA))
+                       wpa_s->enable_oce = OCE_STA;
+               if ((wpa_s->conf->oce & OCE_STA_CFON) &&
+                   (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON)) {
+                       /* TODO: Need to add STA-CFON support */
+                       wpa_printf(MSG_ERROR,
+                                  "OCE STA-CFON feature is not yet supported");
+               }
+       }
        wpas_mbo_update_non_pref_chan(wpa_s, wpa_s->conf->non_pref_chan);
 #endif /* CONFIG_MBO */
 
index c07badbde07feadbd96a49144692f6bfeab12f87..f69c74eed5013d3dcf5698202d490f708b9544f2 100644 (file)
@@ -702,6 +702,13 @@ fast_reauth=1
 # 3 = Not cellular capable (default)
 #mbo_cell_capa=3
 
+# Optimized Connectivity Experience (OCE)
+# oce: Enable OCE features (bitmap)
+# Set BIT(0) to Enable OCE in non-AP STA mode (default; disabled if the driver
+#      does not indicate support for OCE in STA mode)
+# Set BIT(1) to Enable OCE in STA-CFON mode
+#oce=1
+
 # network block
 #
 # Each network (usually AP's sharing the same SSID) is configured as a separate
index a2b331fb7415ff217cadf3af4e1c57c29459338b..31c9921143e8d99fcce107c9e2c651cf43eaac18 100644 (file)
@@ -1101,6 +1101,14 @@ struct wpa_supplicant {
        } *non_pref_chan;
        size_t non_pref_chan_num;
        u8 mbo_wnm_token;
+       /**
+        * enable_oce - Enable OCE if it is enabled by user and device also
+        *              supports OCE.
+        * User can enable OCE with wpa_config's 'oce' parameter as follows -
+        *  - Set BIT(0) to enable OCE in non-AP STA mode.
+        *  - Set BIT(1) to enable OCE in STA-CFON mode.
+        */
+       u8 enable_oce;
 #endif /* CONFIG_MBO */
 
        /*