From 9fa243b2953e6d46f2b88775ed466b1a3d650439 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 18 Jul 2010 14:30:24 -0700 Subject: [PATCH] P2P: Let WPS code know if it is used in a P2P group --- wpa_supplicant/ctrl_iface.c | 6 +++--- wpa_supplicant/dbus/dbus_new_handlers_wps.c | 4 ++-- wpa_supplicant/dbus/dbus_old_handlers_wps.c | 8 ++++---- wpa_supplicant/wps_supplicant.c | 11 ++++++++--- wpa_supplicant/wps_supplicant.h | 5 +++-- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index e89efe266..60800ce22 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -183,7 +183,7 @@ static int wpa_supplicant_ctrl_iface_wps_pbc(struct wpa_supplicant *wpa_s, return wpa_supplicant_ap_wps_pbc(wpa_s, _bssid); #endif /* CONFIG_AP */ - return wpas_wps_start_pbc(wpa_s, _bssid); + return wpas_wps_start_pbc(wpa_s, _bssid, 0); } @@ -214,7 +214,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s, #endif /* CONFIG_AP */ if (pin) { - ret = wpas_wps_start_pin(wpa_s, _bssid, pin); + ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0); if (ret < 0) return -1; ret = os_snprintf(buf, buflen, "%s", pin); @@ -223,7 +223,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s, return ret; } - ret = wpas_wps_start_pin(wpa_s, _bssid, NULL); + ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0); if (ret < 0) return -1; diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c index dc44a590a..a4715cbb1 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c +++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c @@ -231,11 +231,11 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message, ret = wpas_wps_start_reg(wpa_s, params.bssid, params.pin, NULL); else if (params.type == 1) { - ret = wpas_wps_start_pin(wpa_s, params.bssid, params.pin); + ret = wpas_wps_start_pin(wpa_s, params.bssid, params.pin, 0); if (ret > 0) os_snprintf(npin, sizeof(npin), "%08d", ret); } else - ret = wpas_wps_start_pbc(wpa_s, params.bssid); + ret = wpas_wps_start_pbc(wpa_s, params.bssid, 0); if (ret < 0) { wpa_printf(MSG_DEBUG, "dbus: WPS.Start wpas_wps_failed in " diff --git a/wpa_supplicant/dbus/dbus_old_handlers_wps.c b/wpa_supplicant/dbus/dbus_old_handlers_wps.c index b5879f3ae..4c748bf36 100644 --- a/wpa_supplicant/dbus/dbus_old_handlers_wps.c +++ b/wpa_supplicant/dbus/dbus_old_handlers_wps.c @@ -43,9 +43,9 @@ DBusMessage * wpas_dbus_iface_wps_pbc(DBusMessage *message, return wpas_dbus_new_invalid_opts_error(message, NULL); if (!os_strcmp(arg_bssid, "any")) - ret = wpas_wps_start_pbc(wpa_s, NULL); + ret = wpas_wps_start_pbc(wpa_s, NULL, 0); else if (!hwaddr_aton(arg_bssid, bssid)) - ret = wpas_wps_start_pbc(wpa_s, bssid); + ret = wpas_wps_start_pbc(wpa_s, bssid, 0); else { return wpas_dbus_new_invalid_opts_error(message, "Invalid BSSID"); @@ -94,9 +94,9 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message, } if (os_strlen(pin) > 0) - ret = wpas_wps_start_pin(wpa_s, _bssid, pin); + ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0); else - ret = wpas_wps_start_pin(wpa_s, _bssid, NULL); + ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0); if (ret < 0) { return dbus_message_new_error(message, diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 5e724c668..0a1c6d664 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -665,13 +665,16 @@ static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s, } -int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid) +int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid, + int p2p_group) { struct wpa_ssid *ssid; wpas_clear_wps(wpa_s); ssid = wpas_wps_add_network(wpa_s, 0, bssid); if (ssid == NULL) return -1; + ssid->temporary = 1; + ssid->p2p_group = p2p_group; wpa_config_set(ssid, "phase1", "\"pbc=1\"", 0); if (wpa_s->wps_fragment_size) ssid->eap.fragment_size = wpa_s->wps_fragment_size; @@ -683,7 +686,7 @@ int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid) int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, - const char *pin) + const char *pin, int p2p_group) { struct wpa_ssid *ssid; char val[128]; @@ -693,6 +696,8 @@ int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, ssid = wpas_wps_add_network(wpa_s, 0, bssid); if (ssid == NULL) return -1; + ssid->temporary = 1; + ssid->p2p_group = p2p_group; if (pin) os_snprintf(val, sizeof(val), "\"pin=%s\"", pin); else { @@ -751,7 +756,7 @@ int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type, if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E || wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) && wpas_wps_start_pin(wpa_s, NULL, - wpabuf_head(wps->oob_conf.dev_password)) < 0) + wpabuf_head(wps->oob_conf.dev_password), 0) < 0) return -1; return 0; diff --git a/wpa_supplicant/wps_supplicant.h b/wpa_supplicant/wps_supplicant.h index 4c243eacb..3d1994b28 100644 --- a/wpa_supplicant/wps_supplicant.h +++ b/wpa_supplicant/wps_supplicant.h @@ -35,9 +35,10 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s); void wpas_wps_deinit(struct wpa_supplicant *wpa_s); int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s); enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid); -int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid); +int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid, + int p2p_group); int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, - const char *pin); + const char *pin, int p2p_group); int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type, char *path, char *method, char *name); int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,