Browse Source

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 <jouni@qca.qualcomm.com>
Jouni Malinen 12 years ago
parent
commit
74df9ecd4a
4 changed files with 17 additions and 2 deletions
  1. 1 0
      src/common/wpa_ctrl.h
  2. 3 1
      src/p2p/p2p.c
  3. 2 1
      src/p2p/p2p.h
  4. 11 0
      wpa_supplicant/p2p_supplicant.c

+ 1 - 0
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: <PMF enabled> <timeout in ms> <Session Information URL> */
 #define ESS_DISASSOC_IMMINENT "ESS-DISASSOC-IMMINENT "

+ 3 - 1
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;

+ 2 - 1
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 +

+ 11 - 0
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, &params);