From 306aaf49f83a5f94eab20b9d5a79e29590873d40 Mon Sep 17 00:00:00 2001 From: Krishna Vamsi Date: Mon, 15 Dec 2014 17:10:31 +0530 Subject: [PATCH] P2PS: Start WPS registrar upon GO formation If P2PS config method is used for provisioning, upon forming a new GO, start WPS registrar for the provisioned peer automatically. Signed-off-by: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 23 +++++++++++++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 81b1d6d81..643a82314 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1665,6 +1665,16 @@ static void p2p_go_configured(void *ctx, void *data) params->persistent_group, ""); wpa_s->group_formation_reported = 1; + if (wpa_s->parent->p2ps_join_addr_valid) { + wpa_dbg(wpa_s, MSG_DEBUG, + "P2PS: Setting default PIN for " MACSTR, + MAC2STR(wpa_s->parent->p2ps_join_addr)); + wpa_supplicant_ap_wps_pin(wpa_s, + wpa_s->parent->p2ps_join_addr, + "12345670", NULL, 0, 0); + wpa_s->parent->p2ps_join_addr_valid = 0; + } + os_get_reltime(&wpa_s->global->p2p_go_wait_client); if (params->persistent_group) { network_id = wpas_p2p_store_persistent_group( @@ -4939,6 +4949,14 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, } else if (response_done) { wpas_p2p_group_add(wpa_s, 1, 0, 0, 0); } + + if (passwd_id == DEV_PW_P2PS_DEFAULT) { + os_memcpy(wpa_s->p2ps_join_addr, dev, ETH_ALEN); + wpa_s->p2ps_join_addr_valid = 1; + wpa_dbg(wpa_s, MSG_DEBUG, + "P2PS: Saving PIN for " MACSTR, + MAC2STR(dev)); + } } else if (passwd_id == DEV_PW_P2PS_DEFAULT) { go_ifname = go_wpa_s->ifname; @@ -4946,6 +4964,11 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, "P2P: Setting PIN-1 For " MACSTR, MAC2STR(dev)); wpa_supplicant_ap_wps_pin(go_wpa_s, dev, "12345670", NULL, 0, 0); + + os_memcpy(wpa_s->p2ps_join_addr, dev, ETH_ALEN); + wpa_s->p2ps_join_addr_valid = 1; + wpa_dbg(wpa_s, MSG_DEBUG, + "P2PS: Saving PIN for " MACSTR, MAC2STR(dev)); } wpa_msg_global(wpa_s, MSG_INFO, diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0a94ba81a..80dda09ce 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -811,6 +811,7 @@ struct wpa_supplicant { unsigned int p2p_nfc_tag_enabled:1; unsigned int p2p_peer_oob_pk_hash_known:1; unsigned int p2p_disable_ip_addr_req:1; + unsigned int p2ps_join_addr_valid:1; int p2p_persistent_go_freq; int p2p_persistent_id; int p2p_go_intent; @@ -830,6 +831,7 @@ struct wpa_supplicant { /* group common frequencies */ int *p2p_group_common_freqs; unsigned int p2p_group_common_freqs_num; + u8 p2ps_join_addr[ETH_ALEN]; #endif /* CONFIG_P2P */ struct wpa_ssid *bgscan_ssid;