]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OWE: Transition mode information based on BSS ifname
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 9 Oct 2017 10:38:15 +0000 (13:38 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 9 Oct 2017 10:39:23 +0000 (13:39 +0300)
The owe_transition_bssid and owe_transition_ssid parameters can now be
replace with owe_transition_ifname to clone the BSSID/SSID information
automatically in case the same hostapd process manages both the OWE and
open BSS for transition mode.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.h
src/ap/beacon.c
src/ap/hostapd.c
src/ap/hostapd.h

index d80fb082195c5c449c3d63f9700ba2f4023886f3..091437a3bcd0291d2f423a98a22ba884a67a2910 100644 (file)
@@ -3794,6 +3794,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                os_memcpy(bss->owe_transition_ssid, str, slen);
                bss->owe_transition_ssid_len = slen;
                os_free(str);
+       } else if (os_strcmp(buf, "owe_transition_ifname") == 0) {
+               os_strlcpy(bss->owe_transition_ifname, pos,
+                          sizeof(bss->owe_transition_ifname));
+
 #endif /* CONFIG_OWE */
        } else {
                wpa_printf(MSG_ERROR,
index 2c5fa7cb0c17ab0f910b1e7661dfcfa86d77ec23..f0e553ca146735fed4253fcbcabc6c1f5ea292a3 100644 (file)
@@ -1412,6 +1412,9 @@ own_ip_addr=127.0.0.1
 #owe_transition_bssid=<bssid>
 # SSID in same format as ssid2 described above.
 #owe_transition_ssid=<SSID>
+# Alternatively, OWE transition mode BSSID/SSID can be configured with a
+# reference to a BSS operated by this hostapd process.
+#owe_transition_ifname=<ifname>
 
 # DHCP server for FILS HLP
 # If configured, hostapd will act as a DHCP relay for all FILS HLP requests
index 02164e16e717f9383128a2a37488228fbfdd54f8..83f422964f2a344b1494694be9ec129d8f4cfe39 100644 (file)
@@ -649,6 +649,7 @@ struct hostapd_bss_config {
        macaddr owe_transition_bssid;
        u8 owe_transition_ssid[SSID_MAX_LEN];
        size_t owe_transition_ssid_len;
+       char owe_transition_ifname[IFNAMSIZ + 1];
 #endif /* CONFIG_OWE */
 };
 
index 5425758295a63ddffe2c196d562699a704516d4e..3ea28a76e798484c7dcbf09b861dc0bc54d4744e 100644 (file)
@@ -391,6 +391,10 @@ static u8 * hostapd_eid_owe_trans(struct hostapd_data *hapd, u8 *eid,
        u8 *pos = eid;
        size_t elen;
 
+       if (hapd->conf->owe_transition_ifname[0] &&
+           !hostapd_eid_owe_trans_enabled(hapd))
+               hostapd_owe_trans_get_info(hapd);
+
        if (!hostapd_eid_owe_trans_enabled(hapd))
                return pos;
 
index 270e818d9e2b471af30fa3a7be91f4ab4b9b06c1..3ab2e0cee5dbd00d02f6beb23012a8116d15dbda 100644 (file)
@@ -1680,6 +1680,108 @@ static void hostapd_set_own_neighbor_report(struct hostapd_data *hapd)
 }
 
 
+#ifdef CONFIG_OWE
+
+static int hostapd_owe_iface_iter(struct hostapd_iface *iface, void *ctx)
+{
+       struct hostapd_data *hapd = ctx;
+       size_t i;
+
+       for (i = 0; i < iface->num_bss; i++) {
+               struct hostapd_data *bss = iface->bss[i];
+
+               if (os_strcmp(hapd->conf->owe_transition_ifname,
+                             bss->conf->iface) != 0)
+                       continue;
+
+               wpa_printf(MSG_DEBUG,
+                          "OWE: ifname=%s found transition mode ifname=%s BSSID "
+                          MACSTR " SSID %s",
+                          hapd->conf->iface, bss->conf->iface,
+                          MAC2STR(bss->own_addr),
+                          wpa_ssid_txt(bss->conf->ssid.ssid,
+                                       bss->conf->ssid.ssid_len));
+               if (!bss->conf->ssid.ssid_set || !bss->conf->ssid.ssid_len ||
+                   is_zero_ether_addr(bss->own_addr))
+                       continue;
+
+               os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr,
+                         ETH_ALEN);
+               os_memcpy(hapd->conf->owe_transition_ssid,
+                         bss->conf->ssid.ssid, bss->conf->ssid.ssid_len);
+               hapd->conf->owe_transition_ssid_len = bss->conf->ssid.ssid_len;
+               wpa_printf(MSG_DEBUG,
+                          "OWE: Copied transition mode information");
+               return 1;
+       }
+
+       return 0;
+}
+
+
+int hostapd_owe_trans_get_info(struct hostapd_data *hapd)
+{
+       if (hapd->conf->owe_transition_ssid_len > 0 &&
+           !is_zero_ether_addr(hapd->conf->owe_transition_bssid))
+               return 0;
+
+       /* Find transition mode SSID/BSSID information from a BSS operated by
+        * this hostapd instance. */
+       if (!hapd->iface->interfaces ||
+           !hapd->iface->interfaces->for_each_interface)
+               return hostapd_owe_iface_iter(hapd->iface, hapd);
+       else
+               return hapd->iface->interfaces->for_each_interface(
+                       hapd->iface->interfaces, hostapd_owe_iface_iter, hapd);
+}
+
+
+static int hostapd_owe_iface_iter2(struct hostapd_iface *iface, void *ctx)
+{
+       size_t i;
+
+       for (i = 0; i < iface->num_bss; i++) {
+               struct hostapd_data *bss = iface->bss[i];
+               int res;
+
+               wpa_printf(MSG_DEBUG, "JKM:%s:iface=%s trans_ifname=%s",
+                          __func__, bss->conf->iface,
+                          bss->conf->owe_transition_ifname);
+               if (!bss->conf->owe_transition_ifname[0])
+                       continue;
+               res = hostapd_owe_trans_get_info(bss);
+               wpa_printf(MSG_DEBUG, "JKM:%s:iface=%s trans_ifname=%s res=%d",
+                          __func__, bss->conf->iface,
+                          bss->conf->owe_transition_ifname, res);
+               if (res == 0)
+                       continue;
+               wpa_printf(MSG_DEBUG,
+                          "OWE: Matching transition mode interface enabled - update beacon data for %s",
+                          bss->conf->iface);
+               ieee802_11_set_beacon(bss);
+       }
+
+       return 0;
+}
+
+#endif /* CONFIG_OWE */
+
+
+static void hostapd_owe_update_trans(struct hostapd_iface *iface)
+{
+#ifdef CONFIG_OWE
+       /* Check whether the enabled BSS can complete OWE transition mode
+        * configuration for any pending interface. */
+       if (!iface->interfaces ||
+           !iface->interfaces->for_each_interface)
+               hostapd_owe_iface_iter2(iface, NULL);
+       else
+               iface->interfaces->for_each_interface(
+                       iface->interfaces, hostapd_owe_iface_iter2, NULL);
+#endif /* CONFIG_OWE */
+}
+
+
 static int hostapd_setup_interface_complete_sync(struct hostapd_iface *iface,
                                                 int err)
 {
@@ -1855,6 +1957,7 @@ dfs_offload:
 #endif /* CONFIG_FST */
 
        hostapd_set_state(iface, HAPD_IFACE_ENABLED);
+       hostapd_owe_update_trans(iface);
        wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_ENABLED);
        if (hapd->setup_complete_cb)
                hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
@@ -2646,6 +2749,7 @@ int hostapd_add_iface(struct hapd_interfaces *interfaces, char *buf)
                                return -1;
                        }
                }
+               hostapd_owe_update_trans(hapd_iface);
                return 0;
        }
 
index 97e116571500af049e3edbe589c37bc9e0b7cb97..fee413469712995db6299564b00070d7a125c209 100644 (file)
@@ -545,6 +545,7 @@ hostapd_switch_channel_fallback(struct hostapd_iface *iface,
                                const struct hostapd_freq_params *freq_params);
 void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
 void hostapd_periodic_iface(struct hostapd_iface *iface);
+int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
 
 /* utils.c */
 int hostapd_register_probereq_cb(struct hostapd_data *hapd,