From 231bbd0375584754c76baa2c3a6ec180f0a7959e Mon Sep 17 00:00:00 2001 From: Sudhakar Swaminathan Date: Fri, 17 Dec 2010 15:05:35 +0200 Subject: [PATCH] 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. --- src/p2p/p2p.c | 8 ++++++++ src/p2p/p2p.h | 2 ++ wpa_supplicant/p2p_supplicant.c | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index a088826b6..7e0ccf39e 100644 --- a/src/p2p/p2p.c +++ b/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; +} diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index bab4939a2..ba88f74f4 100644 --- a/src/p2p/p2p.h +++ b/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 */ diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 94f8cec1a..42c2a397b 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/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) {