From 74df9ecd4ad46dbd9e4a0e6739980d5337f7ba20 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 4 Apr 2013 15:32:09 +0300 Subject: [PATCH] P2P NFC: Do not try to join peer if both devices are already GO Send a P2P-NFC-BOTH-GO event to upper layers to determine what to do in case both devices going through NFC connection handover are already operating as a GO. Signed-hostap: Jouni Malinen --- src/common/wpa_ctrl.h | 1 + src/p2p/p2p.c | 4 +++- src/p2p/p2p.h | 3 ++- wpa_supplicant/p2p_supplicant.c | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 57c38787d..5948ca7b1 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -150,6 +150,7 @@ extern "C" { #define P2P_EVENT_FIND_STOPPED "P2P-FIND-STOPPED " #define P2P_EVENT_PERSISTENT_PSK_FAIL "P2P-PERSISTENT-PSK-FAIL id=" #define P2P_EVENT_PRESENCE_RESPONSE "P2P-PRESENCE-RESPONSE " +#define P2P_EVENT_NFC_BOTH_GO "P2P-NFC-BOTH-GO " /* parameters: */ #define ESS_DISASSOC_IMMINENT "ESS-DISASSOC-IMMINENT " diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 708db4c03..3e9bc1967 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -4516,7 +4516,9 @@ int p2p_process_nfc_connection_handover(struct p2p_data *p2p, dev->flags |= P2P_DEV_REPORTED | P2P_DEV_REPORTED_ONCE; } - if (peer_go) + if (peer_go && p2p->num_groups > 0) + params->next_step = BOTH_GO; + else if (peer_go) params->next_step = JOIN_GROUP; else if (p2p->num_groups > 0) params->next_step = AUTH_JOIN; diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index fcf8cfc55..d5432c0a7 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1910,7 +1910,8 @@ struct p2p_nfc_params { size_t p2p_len; enum { - NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG + NO_ACTION, JOIN_GROUP, AUTH_JOIN, INIT_GO_NEG, RESP_GO_NEG, + BOTH_GO } next_step; struct p2p_peer_info *peer; u8 oob_dev_pw[WPS_OOB_PUBKEY_HASH_LEN + 2 + diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4375d9bbc..fa8c64864 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -7212,6 +7212,15 @@ static int wpas_p2p_nfc_connection_handover(struct wpa_supplicant *wpa_s, if (res) return res; + if (params.next_step == NO_ACTION) + return 0; + + if (params.next_step == BOTH_GO) { + wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_NFC_BOTH_GO "peer=" MACSTR, + MAC2STR(params.peer->p2p_device_addr)); + return 0; + } + wpabuf_free(wpa_s->p2p_oob_dev_pw); wpa_s->p2p_oob_dev_pw = NULL; @@ -7261,6 +7270,8 @@ static int wpas_p2p_nfc_connection_handover(struct wpa_supplicant *wpa_s, switch (params.next_step) { case NO_ACTION: + case BOTH_GO: + /* already covered above */ return 0; case JOIN_GROUP: return wpas_p2p_nfc_join_group(wpa_s, ¶ms);