From: Jouni Malinen Date: Sun, 15 Nov 2009 16:46:03 +0000 (+0200) Subject: WPS ER: Add preliminary PBC support X-Git-Tag: hostap_0_7_0~44 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=libeap.git;a=commitdiff_plain;h=564cd7fa2c27e2364914669d8e14001ef715047f 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. --- diff --git a/src/wps/wps.h b/src/wps/wps.h index e9aace5..14c6c58 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -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 */ diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c index fb6d5a6..eac31e9 100644 --- a/src/wps/wps_er.c +++ b/src/wps/wps_er.c @@ -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; +} diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 9451bca..d732133 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -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 diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 84dc8c0..11a1e46 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -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, " = add an Enrollee PIN to External Registrar" }, + { "wps_er_pbc", wpa_cli_cmd_wps_er_pbc, + cli_cmd_flag_none, + " = accept an Enrollee PBC using External Registrar" }, { "ibss_rsn", wpa_cli_cmd_ibss_rsn, cli_cmd_flag_none, " = request RSN authentication with in IBSS" }, diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 62d1cd6..a2193d1 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -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 */ diff --git a/wpa_supplicant/wps_supplicant.h b/wpa_supplicant/wps_supplicant.h index 503a4cd..db70edd 100644 --- a/wpa_supplicant/wps_supplicant.h +++ b/wpa_supplicant/wps_supplicant.h @@ -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 */