]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OCE: Move OCE checks to IE formation from hostapd initialization
authorAnkita Bajaj <bankita@codeaurora.org>
Tue, 16 Oct 2018 14:32:19 +0000 (20:02 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 30 Oct 2018 13:43:01 +0000 (15:43 +0200)
Earlier, the OCE flags were checked during hostapd initialization. This
doesn't address few cases like for example when the interface is added
from control interface. Move the OCE flag checks to the functions that
are forming the MBO/OCE IEs to cover all the different paths for
enabling a BSS. Also use macros as appropriate for readability.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hostapd/main.c
src/ap/ap_drv_ops.c
src/ap/hostapd.h
src/ap/ieee802_11_shared.c

index cbeb6075b07572669cc2d6a715b8923492807c9f..61da9be19477e79051455295d25a8e7ae692a208 100644 (file)
@@ -873,27 +873,8 @@ int main(int argc, char *argv[])
         */
        interfaces.terminate_on_error = interfaces.count;
        for (i = 0; i < interfaces.count; i++) {
-               if (hostapd_driver_init(interfaces.iface[i]))
-                       goto out;
-#ifdef CONFIG_MBO
-               for (j = 0; j < interfaces.iface[i]->num_bss; j++) {
-                       struct hostapd_data *hapd = interfaces.iface[i]->bss[j];
-
-                       if (hapd && (hapd->conf->oce & OCE_STA_CFON) &&
-                           (interfaces.iface[i]->drv_flags &
-                            WPA_DRIVER_FLAGS_OCE_STA_CFON))
-                               hapd->enable_oce = OCE_STA_CFON;
-
-                       if (hapd && (hapd->conf->oce & OCE_AP) &&
-                           (interfaces.iface[i]->drv_flags &
-                            WPA_DRIVER_FLAGS_OCE_STA_CFON)) {
-                               /* TODO: Need to add OCE-AP support */
-                               wpa_printf(MSG_ERROR,
-                                          "OCE-AP feature is not yet supported");
-                       }
-               }
-#endif /* CONFIG_MBO */
-               if (hostapd_setup_interface(interfaces.iface[i]))
+               if (hostapd_driver_init(interfaces.iface[i]) ||
+                   hostapd_setup_interface(interfaces.iface[i]))
                        goto out;
        }
 
index 728d7f0986e3ef4e1611e37c116b2f5408024ffa..067cf863e84c7e6d69a1823f7e3ae6a688030f31 100644 (file)
@@ -176,7 +176,8 @@ int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
 #endif /* CONFIG_HS20 */
 
 #ifdef CONFIG_MBO
-       if (hapd->conf->mbo_enabled || hapd->enable_oce) {
+       if (hapd->conf->mbo_enabled ||
+           OCE_STA_CFON_ENABLED(hapd) || OCE_AP_ENABLED(hapd)) {
                pos = hostapd_eid_mbo(hapd, buf, sizeof(buf));
                if (add_buf_data(&beacon, buf, pos - buf) < 0 ||
                    add_buf_data(&proberesp, buf, pos - buf) < 0 ||
index 9a520f3a94286f4a35b8d96ed44b33b8cc23c299..d304c1171810cf81fba9b94f4272ba82efac71ad 100644 (file)
 #include "ap_config.h"
 #include "drivers/driver.h"
 
+#define OCE_STA_CFON_ENABLED(hapd) \
+       ((hapd->conf->oce & OCE_STA_CFON) && \
+        (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON))
+#define OCE_AP_ENABLED(hapd) \
+       ((hapd->conf->oce & OCE_AP) && \
+        (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_AP))
+
 struct wpa_ctrl_dst;
 struct radius_server_data;
 struct upnp_wps_device_sm;
@@ -324,11 +331,6 @@ struct hostapd_data {
 
 #ifdef CONFIG_MBO
        unsigned int mbo_assoc_disallow;
-       /**
-        * enable_oce - Enable OCE if it is enabled by user and device also
-        *              supports OCE.
-        */
-       u8 enable_oce;
 #endif /* CONFIG_MBO */
 
        struct dl_list nr_db;
index c4813996586b9d9ad03909ea0d659f0e6d707276..49e9bf8cc7c9c0c86f1f8de1c5a97bdcd4eb2457 100644 (file)
@@ -552,7 +552,8 @@ u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len)
        u8 mbo[9], *mbo_pos = mbo;
        u8 *pos = eid;
 
-       if (!hapd->conf->mbo_enabled && !hapd->enable_oce)
+       if (!hapd->conf->mbo_enabled &&
+           !OCE_STA_CFON_ENABLED(hapd) && !OCE_AP_ENABLED(hapd))
                return eid;
 
        if (hapd->conf->mbo_enabled) {
@@ -568,12 +569,11 @@ u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len)
                *mbo_pos++ = hapd->mbo_assoc_disallow;
        }
 
-       if (hapd->enable_oce & (OCE_AP | OCE_STA_CFON)) {
+       if (OCE_STA_CFON_ENABLED(hapd) || OCE_AP_ENABLED(hapd)) {
                u8 ctrl;
 
                ctrl = OCE_RELEASE;
-               if ((hapd->enable_oce & (OCE_AP | OCE_STA_CFON)) ==
-                   OCE_STA_CFON)
+               if (OCE_STA_CFON_ENABLED(hapd) && !OCE_AP_ENABLED(hapd))
                        ctrl |= OCE_IS_STA_CFON;
 
                *mbo_pos++ = OCE_ATTR_ID_CAPA_IND;
@@ -591,7 +591,8 @@ u8 hostapd_mbo_ie_len(struct hostapd_data *hapd)
 {
        u8 len;
 
-       if (!hapd->conf->mbo_enabled && !hapd->enable_oce)
+       if (!hapd->conf->mbo_enabled &&
+           !OCE_STA_CFON_ENABLED(hapd) && !OCE_AP_ENABLED(hapd))
                return 0;
 
        /*
@@ -603,7 +604,7 @@ u8 hostapd_mbo_ie_len(struct hostapd_data *hapd)
                len += 3 + (hapd->mbo_assoc_disallow ? 3 : 0);
 
        /* OCE capability indication attribute (3) */
-       if (hapd->enable_oce & (OCE_AP | OCE_STA_CFON))
+       if (OCE_STA_CFON_ENABLED(hapd) || OCE_AP_ENABLED(hapd))
                len += 3;
 
        return len;