From: Max Stepanov Date: Wed, 10 Jun 2015 08:43:33 +0000 (+0300) Subject: P2P: Fix return value of p2p_reply_probe() and p2p_probe_req_rx() X-Git-Tag: hostap_2_5~637 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5143e7ee6e9d34d7715de57cb9ea2e658c3fa319;p=thirdparty%2Fhostap.git P2P: Fix return value of p2p_reply_probe() and p2p_probe_req_rx() Return P2P_PREQ_PROCESSED instead of P2P_PREQ_NOT_PROCESSED on a successful Probe Request frame handling in p2p_reply_probe(). Verify a return value of p2p_reply_probe() in p2p_probe_req_rx() and continue a pending invitation/connection flow only if the Probe Request frame is from an expected P2P peer. Signed-off-by: Max Stepanov Reviewed-by: Ilan Peer --- diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index c9dd7fc91..a450d92ea 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -2444,7 +2444,7 @@ p2p_reply_probe(struct p2p_data *p2p, const u8 *addr, const u8 *dst, wpabuf_free(buf); - return P2P_PREQ_NOT_PROCESSED; + return P2P_PREQ_PROCESSED; } @@ -2460,6 +2460,17 @@ p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, res = p2p_reply_probe(p2p, addr, dst, bssid, ie, ie_len, rx_freq); p2p->query_count = 0; + if (res != P2P_PREQ_PROCESSED && res != P2P_PREQ_NOT_PROCESSED) + return res; + + /* + * Activate a pending GO Negotiation/Invite flow if a received Probe + * Request frame is from an expected peer. Some devices may share the + * same address for P2P and non-P2P STA running simultaneously. The + * P2P_PREQ_PROCESSED and P2P_PREQ_NOT_PROCESSED p2p_reply_probe() + * return values verified above ensure we are handling a Probe Request + * frame from a P2P peer. + */ if ((p2p->state == P2P_CONNECT || p2p->state == P2P_CONNECT_LISTEN) && p2p->go_neg_peer && os_memcmp(addr, p2p->go_neg_peer->info.p2p_device_addr, ETH_ALEN) @@ -2469,7 +2480,7 @@ p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, p2p_dbg(p2p, "Found GO Negotiation peer - try to start GO negotiation from timeout"); eloop_cancel_timeout(p2p_go_neg_start, p2p, NULL); eloop_register_timeout(0, 0, p2p_go_neg_start, p2p, NULL); - return P2P_PREQ_PROCESSED; + return res; } if ((p2p->state == P2P_INVITE || p2p->state == P2P_INVITE_LISTEN) && @@ -2481,7 +2492,7 @@ p2p_probe_req_rx(struct p2p_data *p2p, const u8 *addr, const u8 *dst, p2p_dbg(p2p, "Found Invite peer - try to start Invite from timeout"); eloop_cancel_timeout(p2p_invite_start, p2p, NULL); eloop_register_timeout(0, 0, p2p_invite_start, p2p, NULL); - return P2P_PREQ_PROCESSED; + return res; } return res;