]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Add support for building FILS Realm Information ANQP-element
authorJouni Malinen <j@w1.fi>
Sat, 17 Dec 2016 20:02:06 +0000 (22:02 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 18 Dec 2016 09:41:59 +0000 (11:41 +0200)
This allows full list of hashed realm names to be fetched from hostapd.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/gas_serv.c
src/common/ieee802_11_defs.h

index b4306c66925eb06518686a65ec8a81e4834fd998..72b0e6a5250c9888eb10601b9ffcb4e28c5f5ca4 100644 (file)
@@ -261,10 +261,13 @@ static void anqp_add_capab_list(struct hostapd_data *hapd,
                wpabuf_put_le16(buf, ANQP_EMERGENCY_NAI);
        if (get_anqp_elem(hapd, ANQP_NEIGHBOR_REPORT))
                wpabuf_put_le16(buf, ANQP_NEIGHBOR_REPORT);
-       for (id = 273; id < 277; id++) {
-               if (get_anqp_elem(hapd, id))
-                       wpabuf_put_le16(buf, id);
-       }
+#ifdef CONFIG_FILS
+       if (!dl_list_empty(&hapd->conf->fils_realms) ||
+           get_anqp_elem(hapd, ANQP_FILS_REALM_INFO))
+               wpabuf_put_le16(buf, ANQP_FILS_REALM_INFO);
+#endif /* CONFIG_FILS */
+       if (get_anqp_elem(hapd, ANQP_CAG))
+               wpabuf_put_le16(buf, ANQP_CAG);
        if (get_anqp_elem(hapd, ANQP_VENUE_URL))
                wpabuf_put_le16(buf, ANQP_VENUE_URL);
        if (get_anqp_elem(hapd, ANQP_ADVICE_OF_CHARGE))
@@ -554,6 +557,35 @@ static void anqp_add_domain_name(struct hostapd_data *hapd, struct wpabuf *buf)
 }
 
 
+#ifdef CONFIG_FILS
+static void anqp_add_fils_realm_info(struct hostapd_data *hapd,
+                                    struct wpabuf *buf)
+{
+       size_t count;
+
+       if (anqp_add_override(hapd, buf, ANQP_FILS_REALM_INFO))
+               return;
+
+       count = dl_list_len(&hapd->conf->fils_realms);
+       if (count > 10000)
+               count = 10000;
+       if (count) {
+               struct fils_realm *realm;
+
+               wpabuf_put_le16(buf, ANQP_FILS_REALM_INFO);
+               wpabuf_put_le16(buf, 2 * count);
+
+               dl_list_for_each(realm, &hapd->conf->fils_realms,
+                                struct fils_realm, list) {
+                       if (count == 0)
+                               break;
+                       wpabuf_put_data(buf, realm->hash, 2);
+               }
+       }
+}
+#endif /* CONFIG_FILS */
+
+
 #ifdef CONFIG_HS20
 
 static void anqp_add_operator_friendly_name(struct hostapd_data *hapd,
@@ -827,6 +859,10 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
                len += 1000;
        if (request & ANQP_REQ_ICON_REQUEST)
                len += 65536;
+#ifdef CONFIG_FILS
+       if (request & ANQP_FILS_REALM_INFO)
+               len += 2 * dl_list_len(&hapd->conf->fils_realms);
+#endif /* CONFIG_FILS */
        len += anqp_get_required_len(hapd, extra_req, num_extra_req);
 
        buf = wpabuf_alloc(len);
@@ -866,8 +902,15 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
        if (request & ANQP_REQ_EMERGENCY_NAI)
                anqp_add_elem(hapd, buf, ANQP_EMERGENCY_NAI);
 
-       for (i = 0; i < num_extra_req; i++)
+       for (i = 0; i < num_extra_req; i++) {
+#ifdef CONFIG_FILS
+               if (extra_req[i] == ANQP_FILS_REALM_INFO) {
+                       anqp_add_fils_realm_info(hapd, buf);
+                       continue;
+               }
+#endif /* CONFIG_FILS */
                anqp_add_elem(hapd, buf, extra_req[i]);
+       }
 
 #ifdef CONFIG_HS20
        if (request & ANQP_REQ_HS_CAPABILITY_LIST)
@@ -990,6 +1033,13 @@ static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id,
                             get_anqp_elem(hapd, info_id) != NULL, qi);
                break;
        default:
+#ifdef CONFIG_FILS
+               if (info_id == ANQP_FILS_REALM_INFO &&
+                   !dl_list_empty(&hapd->conf->fils_realms)) {
+                       wpa_printf(MSG_DEBUG,
+                                  "ANQP: FILS Realm Information (local)");
+               } else
+#endif /* CONFIG_FILS */
                if (!get_anqp_elem(hapd, info_id)) {
                        wpa_printf(MSG_DEBUG, "ANQP: Unsupported Info Id %u",
                                   info_id);
index afcf5d87b6ee9efc59882d8814c679684adcd7d4..259862de473e57fc7e73cc99c5f752a5b3210b10 100644 (file)
@@ -653,7 +653,7 @@ enum anqp_info_id {
        ANQP_NEIGHBOR_REPORT = 272,
        ANQP_QUERY_AP_LIST = 273,
        ANQP_AP_LIST_RESPONSE = 274,
-       AMQP_FILS_REALM_INFO = 275,
+       ANQP_FILS_REALM_INFO = 275,
        ANQP_CAG = 276,
        ANQP_VENUE_URL = 277,
        ANQP_ADVICE_OF_CHARGE = 278,