WPS ER: Add preliminary PBC support

This will need some additional code in wps_er_pbc() to handle PBC mode
enabling for a single AP only. For now, this can only be expected to work
when the ER is connected to a single AP.
This commit is contained in:
Jouni Malinen 2009-11-15 18:46:03 +02:00
parent 5d34ab644d
commit 564cd7fa2c
6 changed files with 58 additions and 0 deletions

View file

@ -676,5 +676,6 @@ struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname);
void wps_er_deinit(struct wps_er *er);
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);
#endif /* WPS_H */

View file

@ -1319,3 +1319,21 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
wpabuf_free(msg);
}
int wps_er_pbc(struct wps_er *er, const u8 *uuid)
{
if (er == NULL || er->wps == NULL)
return -1;
/*
* TODO: Should enable PBC mode only in a single AP based on which AP
* the Enrollee (uuid) is using. Now, we may end up enabling multiple
* APs in PBC mode which could result in session overlap at the
* Enrollee.
*/
if (wps_registrar_button_pushed(er->wps->registrar))
return -1;
return 0;
}

View file

@ -1657,6 +1657,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
} else if (os_strncmp(buf, "WPS_ER_PIN ", 11) == 0) {
if (wpa_supplicant_ctrl_iface_wps_er_pin(wpa_s, buf + 11))
reply_len = -1;
} else if (os_strncmp(buf, "WPS_ER_PBC ", 11) == 0) {
if (wpas_wps_er_pbc(wpa_s, buf + 11))
reply_len = -1;
#endif /* CONFIG_WPS_ER */
#endif /* CONFIG_WPS */
#ifdef CONFIG_IBSS_RSN

View file

@ -572,6 +572,28 @@ static int wpa_cli_cmd_wps_er_pin(struct wpa_ctrl *ctrl, int argc,
}
static int wpa_cli_cmd_wps_er_pbc(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
char cmd[256];
int res;
if (argc != 1) {
printf("Invalid WPS_ER_PBC command: need one argument:\n"
"- UUID: Specify the Enrollee\n");
return -1;
}
res = os_snprintf(cmd, sizeof(cmd), "WPS_ER_PBC %s",
argv[0]);
if (res < 0 || (size_t) res >= sizeof(cmd) - 1) {
printf("Too long WPS_ER_PBC command.\n");
return -1;
}
return wpa_ctrl_command(ctrl, cmd);
}
static int wpa_cli_cmd_ibss_rsn(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
char cmd[256];
@ -1445,6 +1467,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
{ "wps_er_pin", wpa_cli_cmd_wps_er_pin,
cli_cmd_flag_sensitive,
"<UUID> <PIN> = add an Enrollee PIN to External Registrar" },
{ "wps_er_pbc", wpa_cli_cmd_wps_er_pbc,
cli_cmd_flag_none,
"<UUID> = accept an Enrollee PBC using External Registrar" },
{ "ibss_rsn", wpa_cli_cmd_ibss_rsn,
cli_cmd_flag_none,
"<addr> = request RSN authentication with <addr> in IBSS" },

View file

@ -1161,4 +1161,14 @@ int wpas_wps_er_add_pin(struct wpa_supplicant *wpa_s, const char *uuid,
return wps_registrar_add_pin(wpa_s->wps->registrar, any ? NULL : u,
(const u8 *) pin, os_strlen(pin), 300);
}
int wpas_wps_er_pbc(struct wpa_supplicant *wpa_s, const char *uuid)
{
u8 u[UUID_LEN];
if (uuid_str2bin(uuid, u))
return -1;
return wps_er_pbc(wpa_s->wps_er, u);
}
#endif /* CONFIG_WPS_ER */

View file

@ -53,6 +53,7 @@ int wpas_wps_er_start(struct wpa_supplicant *wpa_s);
int wpas_wps_er_stop(struct wpa_supplicant *wpa_s);
int wpas_wps_er_add_pin(struct wpa_supplicant *wpa_s, const char *uuid,
const char *pin);
int wpas_wps_er_pbc(struct wpa_supplicant *wpa_s, const char *uuid);
#else /* CONFIG_WPS */