WPS ER: Allow Enrollee to be specified with MAC address
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>
This commit is contained in:
parent
c44a19c1f9
commit
e205401c72
4 changed files with 42 additions and 14 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue