]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS ER: Allow Enrollee to be specified with MAC address
authorJouni Malinen <j@w1.fi>
Mon, 1 Apr 2013 17:52:44 +0000 (20:52 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 1 Apr 2013 17:52:44 +0000 (20:52 +0300)
wps_er_pbc and wps_er_pin can now be used with both the UUID and MAC
Address of the Enrollee.

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

src/wps/wps.h
src/wps/wps_er.c
wpa_supplicant/README-WPS
wpa_supplicant/wps_supplicant.c

index f52b74f04e582ab2a7324c8603f212134fe9c2d2..6e74a41097302ace2e1fccb91e1de5029aae42b5 100644 (file)
@@ -793,7 +793,8 @@ void wps_er_refresh(struct wps_er *er);
 void wps_er_deinit(struct wps_er *er, void (*cb)(void *ctx), void *ctx);
 void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
                        u16 sel_reg_config_methods);
-int wps_er_pbc(struct wps_er *er, const u8 *uuid);
+int wps_er_pbc(struct wps_er *er, const u8 *uuid, const u8 *addr);
+const u8 * wps_er_get_sta_uuid(struct wps_er *er, const u8 *addr);
 int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *addr,
                 const u8 *pin, size_t pin_len);
 int wps_er_set_config(struct wps_er *er, const u8 *uuid, const u8 *addr,
index d96ae1b80c440e35e8a0c68eeabee91215ba79f6..31ba450e1656f9e9ec9e9d8d88f47b47d1c4d428 100644 (file)
@@ -1558,7 +1558,7 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
 }
 
 
-int wps_er_pbc(struct wps_er *er, const u8 *uuid)
+int wps_er_pbc(struct wps_er *er, const u8 *uuid, const u8 *addr)
 {
        int res;
        struct wps_er_ap *ap;
@@ -1572,11 +1572,14 @@ int wps_er_pbc(struct wps_er *er, const u8 *uuid)
                return -2;
        }
 
-       ap = wps_er_ap_get(er, NULL, uuid, NULL);
+       if (uuid)
+               ap = wps_er_ap_get(er, NULL, uuid, NULL);
+       else
+               ap = NULL;
        if (ap == NULL) {
                struct wps_er_sta *sta = NULL;
                dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) {
-                       sta = wps_er_sta_get(ap, NULL, uuid);
+                       sta = wps_er_sta_get(ap, addr, uuid);
                        if (sta) {
                                uuid = ap->uuid;
                                break;
@@ -1622,6 +1625,19 @@ static void wps_er_ap_settings_cb(void *ctx, const struct wps_credential *cred)
 }
 
 
+const u8 * wps_er_get_sta_uuid(struct wps_er *er, const u8 *addr)
+{
+       struct wps_er_ap *ap;
+       dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) {
+               struct wps_er_sta *sta;
+               sta = wps_er_sta_get(ap, addr, NULL);
+               if (sta)
+                       return sta->uuid;
+       }
+       return NULL;
+}
+
+
 static void wps_er_http_put_message_cb(void *ctx, struct http_client *c,
                                       enum http_client_event event)
 {
index d152d3c613eeee6f6c5e3725b2c9dbb9dd1d1025..06154666a33b447b2bace2366b6edfadcfce9f00 100644 (file)
@@ -277,10 +277,10 @@ wps_er_config <UUID|BSSID> <AP PIN> <new SSID> <auth> <encr> <new key>
 <encr> must be one of the following: NONE WEP TKIP CCMP
 
 
-wps_er_pbc <Enrollee UUID>
+wps_er_pbc <Enrollee UUID|MAC address>
 - accept an Enrollee PBC using External Registrar
 
-wps_er_pin <Enrollee UUID> <PIN> [Enrollee MAC address]
+wps_er_pin <Enrollee UUID|"any"|MAC address> <PIN> [Enrollee MAC address]
 - add an Enrollee PIN to External Registrar
 - if Enrollee UUID is not known, "any" can be used to add a wildcard PIN
 - if the MAC address of the enrollee is known, it should be configured
index 6707b7910aa11ec8d2069fb59e24cfd46544cc3b..d9b1b297e6886f23da46e100ef1008169be53f86 100644 (file)
@@ -1605,25 +1605,36 @@ int wpas_wps_er_add_pin(struct wpa_supplicant *wpa_s, const u8 *addr,
                        const char *uuid, const char *pin)
 {
        u8 u[UUID_LEN];
-       int any = 0;
+       const u8 *use_uuid = NULL;
+       u8 addr_buf[ETH_ALEN];
 
-       if (os_strcmp(uuid, "any") == 0)
-               any = 1;
-       else if (uuid_str2bin(uuid, u))
+       if (os_strcmp(uuid, "any") == 0) {
+       } else if (uuid_str2bin(uuid, u) == 0) {
+               use_uuid = u;
+       } else if (hwaddr_aton(uuid, addr_buf) == 0) {
+               use_uuid = wps_er_get_sta_uuid(wpa_s->wps_er, addr_buf);
+               if (use_uuid == NULL)
+                       return -1;
+       } else
                return -1;
        return wps_registrar_add_pin(wpa_s->wps->registrar, addr,
-                                    any ? NULL : u,
+                                    use_uuid,
                                     (const u8 *) pin, os_strlen(pin), 300);
 }
 
 
 int wpas_wps_er_pbc(struct wpa_supplicant *wpa_s, const char *uuid)
 {
-       u8 u[UUID_LEN];
+       u8 u[UUID_LEN], *use_uuid = NULL;
+       u8 addr[ETH_ALEN], *use_addr = NULL;
 
-       if (uuid_str2bin(uuid, u))
+       if (uuid_str2bin(uuid, u) == 0)
+               use_uuid = u;
+       else if (hwaddr_aton(uuid, addr) == 0)
+               use_addr = addr;
+       else
                return -1;
-       return wps_er_pbc(wpa_s->wps_er, u);
+       return wps_er_pbc(wpa_s->wps_er, use_uuid, use_addr);
 }