]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HS 2.0R2: Add tracking of provisioning SP
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 2 Aug 2013 16:09:11 +0000 (19:09 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 25 Feb 2014 23:24:23 +0000 (01:24 +0200)
The new provisioning_sp cred field can now be used to track which SP
provisioned the credential. This makes it easier to find the matching
PPS MO from the management tree (./Wi-Fi/<provisioning_sp>).

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/README-HS20
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/ctrl_iface.c
wpa_supplicant/interworking.c
wpa_supplicant/interworking.h
wpa_supplicant/wpa_supplicant.conf

index 33fbc21f9d29d4094abe3cda38ed163ab77dce2f..ec576b921a763bc52dd11d6db3e34b5d2fa5a768 100644 (file)
@@ -223,6 +223,10 @@ Credentials can be pre-configured for automatic network selection:
 # update_identifier: PPS MO ID
 #      (Hotspot 2.0 PerProviderSubscription/UpdateIdentifier)
 #
+# provisioning_sp: FQDN of the SP that provisioned the credential
+#      This optional field can be used to keep track of the SP that provisioned
+#      the credential to find the PPS MO (./Wi-Fi/<provisioning_sp>).
+#
 # for example:
 #
 #cred={
index 6933df96d5a7a3de69b92b47e1b61044ad66f729..b540b00cf0f32aea8ccc8edef2da68d23d7f03be 100644 (file)
@@ -1930,6 +1930,7 @@ void wpa_config_free_cred(struct wpa_cred *cred)
        os_free(cred->phase2);
        os_free(cred->excluded_ssid);
        os_free(cred->roaming_partner);
+       os_free(cred->provisioning_sp);
        os_free(cred);
 }
 
@@ -2660,6 +2661,12 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var,
                return 0;
        }
 
+       if (os_strcmp(var, "provisioning_sp") == 0) {
+               os_free(cred->provisioning_sp);
+               cred->provisioning_sp = val;
+               return 0;
+       }
+
        if (line) {
                wpa_printf(MSG_ERROR, "Line %d: unknown cred field '%s'.",
                           line, var);
index 9e06e70a14535f0bb156a739c09a4984e754737a..6c9b753805e027ca973d4ced642f28dff2744e54 100644 (file)
@@ -246,6 +246,11 @@ struct wpa_cred {
        size_t num_roaming_partner;
 
        int update_identifier;
+
+       /**
+        * provisioning_sp - FQDN of the SP that provisioned the credential
+        */
+       char *provisioning_sp;
 };
 
 
index 7ad3f933155d446721a0123ef7b10291b5c507e2..d8bd3c95967fa66ffa86bc0e383e77ef6307e08e 100644 (file)
@@ -806,6 +806,9 @@ static void wpa_config_write_cred(FILE *f, struct wpa_cred *cred)
        }
        if (cred->update_identifier)
                fprintf(f, "\tupdate_identifier=%d\n", cred->update_identifier);
+
+       if (cred->provisioning_sp)
+               fprintf(f, "\tprovisioning_sp=%s\n", cred->provisioning_sp);
 }
 
 
index 29a0973152b3505509d6b9171b8a613d16088c5a..9f5d4f403b83b7b7101cfd57d1330501b1030599 100644 (file)
@@ -1720,15 +1720,38 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
                        if (wpa_s->current_ssid->parent_cred != cred)
                                continue;
 
-                       for (i = 0; cred->domain && i < cred->num_domain; i++) {
+                       if (cred->provisioning_sp) {
                                ret = os_snprintf(pos, end - pos,
-                                                 "home_sp=%s\n",
-                                                 cred->domain[i]);
+                                                 "provisioning_sp=%s\n",
+                                                 cred->provisioning_sp);
                                if (ret < 0 || ret >= end - pos)
                                        return pos - buf;
                                pos += ret;
                        }
 
+                       if (!cred->domain)
+                               goto no_domain;
+
+                       i = 0;
+                       if (wpa_s->current_bss && wpa_s->current_bss->anqp) {
+                               struct wpabuf *names =
+                                       wpa_s->current_bss->anqp->domain_name;
+                               for (i = 0; names && i < cred->num_domain; i++)
+                               {
+                                       if (domain_name_list_contains(
+                                                   names, cred->domain[i], 1))
+                                               break;
+                               }
+                               if (i == cred->num_domain)
+                                       i = 0; /* show first entry by default */
+                       }
+                       ret = os_snprintf(pos, end - pos, "home_sp=%s\n",
+                                         cred->domain[i]);
+                       if (ret < 0 || ret >= end - pos)
+                               return pos - buf;
+                       pos += ret;
+
+               no_domain:
                        if (wpa_s->current_bss == NULL ||
                            wpa_s->current_bss->anqp == NULL)
                                res = -1;
@@ -2695,7 +2718,8 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
        int id;
        struct wpa_cred *cred, *prev;
 
-       /* cmd: "<cred id>", "all", or "sp_fqdn=<FQDN>" */
+       /* cmd: "<cred id>", "all", "sp_fqdn=<FQDN>", or
+        * "provisioning_sp=<FQDN> */
        if (os_strcmp(cmd, "all") == 0) {
                wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED all");
                cred = wpa_s->conf->cred;
@@ -2728,6 +2752,20 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
                return 0;
        }
 
+       if (os_strncmp(cmd, "provisioning_sp=", 16) == 0) {
+               wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED provisioning SP FQDN '%s'",
+                          cmd + 16);
+               cred = wpa_s->conf->cred;
+               while (cred) {
+                       prev = cred;
+                       cred = cred->next;
+                       if (prev->provisioning_sp &&
+                           os_strcmp(prev->provisioning_sp, cmd + 16) == 0)
+                               wpas_ctrl_remove_cred(wpa_s, prev);
+               }
+               return 0;
+       }
+
        id = atoi(cmd);
        wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED id=%d", id);
 
index 0107ff153107230c3604353b33b556f0d2920072..3bc6fae04e713457d4a3ca9008a9bef987847d87 100644 (file)
@@ -1634,8 +1634,8 @@ static struct wpa_cred * interworking_credentials_available(
 }
 
 
-static int domain_name_list_contains(struct wpabuf *domain_names,
-                                    const char *domain, int exact_match)
+int domain_name_list_contains(struct wpabuf *domain_names,
+                             const char *domain, int exact_match)
 {
        const u8 *pos, *end;
        size_t len;
index c8e70938c1e102e4fefb805d9a4c9b1baf88572c..bb0ceb813f3459b876af326e04e911feacf583aa 100644 (file)
@@ -29,5 +29,7 @@ void interworking_start_fetch_anqp(struct wpa_supplicant *wpa_s);
 int interworking_home_sp_cred(struct wpa_supplicant *wpa_s,
                              struct wpa_cred *cred,
                              struct wpabuf *domain_names);
+int domain_name_list_contains(struct wpabuf *domain_names,
+                             const char *domain, int exact_match);
 
 #endif /* INTERWORKING_H */
index 99d86fe647d952166b20ad4ac6afe3f3bff6d34e..3c90362ff7839e3aa20b01db48e11e7e001fbd40 100644 (file)
@@ -442,6 +442,10 @@ fast_reauth=1
 # update_identifier: PPS MO ID
 #      (Hotspot 2.0 PerProviderSubscription/UpdateIdentifier)
 #
+# provisioning_sp: FQDN of the SP that provisioned the credential
+#      This optional field can be used to keep track of the SP that provisioned
+#      the credential to find the PPS MO (./Wi-Fi/<provisioning_sp>).
+#
 # for example:
 #
 #cred={