Browse Source

P2P: Unauthorize pending P2P GO Neg peer on p2p_cancel

If there is a pending GO Negotiation when p2p_cancel is used,
unauthorize the peer to avoid immediate reconnection from being
accepted without a new p2p_connect command.
Sudhakar Swaminathan 14 years ago
parent
commit
231bbd0375
3 changed files with 18 additions and 0 deletions
  1. 8 0
      src/p2p/p2p.c
  2. 2 0
      src/p2p/p2p.h
  3. 8 0
      wpa_supplicant/p2p_supplicant.c

+ 8 - 0
src/p2p/p2p.c

@@ -3211,3 +3211,11 @@ void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
 	p2p->best_freq_5 = freq_5;
 	p2p->best_freq_overall = freq_overall;
 }
+
+
+const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p)
+{
+	if (p2p == NULL || p2p->go_neg_peer == NULL)
+		return NULL;
+	return p2p->go_neg_peer->p2p_device_addr;
+}

+ 2 - 0
src/p2p/p2p.h

@@ -1322,4 +1322,6 @@ void p2p_update_channel_list(struct p2p_data *p2p, struct p2p_channels *chan);
 void p2p_set_best_channels(struct p2p_data *p2p, int freq_24, int freq_5,
 			   int freq_overall);
 
+const u8 * p2p_get_go_neg_peer(struct p2p_data *p2p);
+
 #endif /* P2P_H */

+ 8 - 0
wpa_supplicant/p2p_supplicant.c

@@ -3948,6 +3948,7 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s)
 {
 	struct wpa_global *global = wpa_s->global;
 	int found = 0;
+	const u8 *peer;
 
 	wpa_printf(MSG_DEBUG, "P2P: Request to cancel group formation");
 
@@ -3955,6 +3956,13 @@ int wpas_p2p_cancel(struct wpa_supplicant *wpa_s)
 	    !is_zero_ether_addr(wpa_s->pending_interface_addr))
 		found = 1;
 
+	peer = p2p_get_go_neg_peer(global->p2p);
+	if (peer) {
+		wpa_printf(MSG_DEBUG, "P2P: Unauthorize pending GO Neg peer "
+			   MACSTR, MAC2STR(peer));
+		p2p_unauthorize(global->p2p, peer);
+	}
+
 	wpas_p2p_stop_find(wpa_s);
 
 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {