From 349b213cc8babdc0212938714104f7e28d34b335 Mon Sep 17 00:00:00 2001 From: Jayant Sane Date: Sun, 12 Jun 2011 14:26:22 -0700 Subject: [PATCH] P2P: Add callback for provision discovery failure When provision discovery fails, this new callback will be called so P2P users can react to the failure. Signed-off-by: Jayant Sane Signed-off-by: Johannes Berg --- src/p2p/p2p.c | 4 ++++ src/p2p/p2p.h | 21 +++++++++++++++++++++ src/p2p/p2p_pd.c | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index d16d555d9..016a121f1 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -2734,6 +2734,10 @@ static void p2p_timeout_prov_disc_req(struct p2p_data *p2p) p2p->pd_retries--; p2p_retry_pd(p2p); } else { + if (p2p->cfg->prov_disc_fail) + p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, + p2p->pending_pd_devaddr, + P2P_PROV_DISC_TIMEOUT); p2p_reset_pending_pd(p2p); } } diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 954f562bf..1a9ecaea9 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -210,6 +210,12 @@ struct p2p_peer_info { struct wpabuf *wps_vendor_ext[P2P_MAX_WPS_VENDOR_EXT]; }; +enum p2p_prov_disc_status { + P2P_PROV_DISC_SUCCESS, + P2P_PROV_DISC_TIMEOUT, + P2P_PROV_DISC_REJECTED, +}; + /** * struct p2p_config - P2P configuration * @@ -602,6 +608,21 @@ struct p2p_config { */ void (*prov_disc_resp)(void *ctx, const u8 *peer, u16 config_methods); + /** + * prov_disc_fail - Callback on Provision Discovery failure + * @ctx: Callback context from cb_ctx + * @peer: Source address of the response + * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS + * + * This callback is used to indicate either a failure or no response + * to an earlier provision discovery request. + * + * This callback handler can be set to %NULL if provision discovery + * is not used or failures do not need to be indicated. + */ + void (*prov_disc_fail)(void *ctx, const u8 *peer, + enum p2p_prov_disc_status status); + /** * invitation_process - Optional callback for processing Invitations * @ctx: Callback context from cb_ctx diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c index 443e37d25..f7ff06c0e 100644 --- a/src/p2p/p2p_pd.c +++ b/src/p2p/p2p_pd.c @@ -247,6 +247,9 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa, if (msg.wps_config_methods != dev->req_config_methods) { wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer rejected " "our Provisioning Discovery Request"); + if (p2p->cfg->prov_disc_fail) + p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa, + P2P_PROV_DISC_REJECTED); p2p_parse_free(&msg); goto out; }