WPS ER: Add support for using NFC password token from an Enrollee
authorJouni Malinen <j@w1.fi>
Thu, 28 Jun 2012 14:34:46 +0000 (17:34 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 28 Jun 2012 14:34:46 +0000 (17:34 +0300)
WPS_NFC_TAG_READ ctrl_iface command can now be used to add NFC password
tokens to ER.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/wps_supplicant.c

index ae0e1d1..95739f4 100644 (file)
@@ -1897,6 +1897,23 @@ static int wpas_wps_use_cred(struct wpa_supplicant *wpa_s,
 }
 
 
+#ifdef CONFIG_WPS_ER
+static int wpas_wps_add_nfc_password_token(struct wpa_supplicant *wpa_s,
+                                          struct wps_parse_attr *attr)
+{
+       if (wpa_s->wps_er == NULL) {
+               wpa_printf(MSG_DEBUG, "WPS: Ignore NFC password token while "
+                          "ER functionality is disabled");
+               return -1;
+       }
+
+       return wps_registrar_add_nfc_password_token(
+               wpa_s->wps->registrar, attr->oob_dev_password,
+               attr->oob_dev_password_len);
+}
+#endif /* CONFIG_WPS_ER */
+
+
 static int wpas_wps_nfc_tag_process(struct wpa_supplicant *wpa_s,
                                    const struct wpabuf *wps)
 {
@@ -1912,6 +1929,11 @@ static int wpas_wps_nfc_tag_process(struct wpa_supplicant *wpa_s,
        if (attr.num_cred)
                return wpas_wps_use_cred(wpa_s, &attr);
 
+#ifdef CONFIG_WPS_ER
+       if (attr.oob_dev_password)
+               return wpas_wps_add_nfc_password_token(wpa_s, &attr);
+#endif /* CONFIG_WPS_ER */
+
        wpa_printf(MSG_DEBUG, "WPS: Ignore unrecognized NFC tag");
        return -1;
 }