From ab8ee776b994b2c5d77e08f1fdeda81f1946489b Mon Sep 17 00:00:00 2001 From: Krishna Vamsi Date: Wed, 10 Dec 2014 17:21:09 +0530 Subject: [PATCH] P2PS: Provision Discovery fail event This extends P2P-PROV-DISC-FAILURE with adv_id and deferred_session_resp in P2PS cases. Signed-off-by: Jouni Malinen --- src/p2p/p2p.c | 11 ++++++++++- src/p2p/p2p.h | 7 ++++++- src/p2p/p2p_pd.c | 3 ++- wpa_supplicant/p2p_supplicant.c | 22 ++++++++++++++++++---- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 603585a78..f59e919d2 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -3832,6 +3832,9 @@ static void p2p_timeout_prov_disc_during_find(struct p2p_data *p2p) static void p2p_timeout_prov_disc_req(struct p2p_data *p2p) { + u32 adv_id = 0; + u8 *adv_mac = NULL; + p2p->pending_action_state = P2P_NO_PENDING_ACTION; /* @@ -3860,12 +3863,18 @@ static void p2p_timeout_prov_disc_req(struct p2p_data *p2p) for_join = 1; } + if (p2p->p2ps_prov) { + adv_id = p2p->p2ps_prov->adv_id; + adv_mac = p2p->p2ps_prov->adv_mac; + } + if (p2p->cfg->prov_disc_fail) p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, p2p->pending_pd_devaddr, for_join ? P2P_PROV_DISC_TIMEOUT_JOIN : - P2P_PROV_DISC_TIMEOUT); + P2P_PROV_DISC_TIMEOUT, + adv_id, adv_mac, NULL); p2p_reset_pending_pd(p2p); } } diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index f00e13d98..3e1cbbf35 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -808,6 +808,9 @@ struct p2p_config { * @ctx: Callback context from cb_ctx * @peer: Source address of the response * @status: Cause of failure, will not be %P2P_PROV_DISC_SUCCESS + * @adv_id: If non-zero, then the adv_id of the PD Request + * @adv_mac: P2P Device Address of the advertizer + * @deferred_session_resp: Deferred session response sent by advertizer * * This callback is used to indicate either a failure or no response * to an earlier provision discovery request. @@ -816,7 +819,9 @@ struct p2p_config { * 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); + enum p2p_prov_disc_status status, + u32 adv_id, const u8 *adv_mac, + const char *deferred_session_resp); /** * invitation_process - Optional callback for processing Invitations diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c index 02172ef9b..5c40c1c61 100644 --- a/src/p2p/p2p_pd.c +++ b/src/p2p/p2p_pd.c @@ -841,7 +841,8 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa, msg.wps_config_methods, req_config_methods); if (p2p->cfg->prov_disc_fail) p2p->cfg->prov_disc_fail(p2p->cfg->cb_ctx, sa, - P2P_PROV_DISC_REJECTED); + P2P_PROV_DISC_REJECTED, + 0, NULL, NULL); p2p_parse_free(&msg); goto out; } diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index cf1e29a09..81b1d6d81 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3706,7 +3706,9 @@ static void wpas_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods) static void wpas_prov_disc_fail(void *ctx, const u8 *peer, - enum p2p_prov_disc_status status) + enum p2p_prov_disc_status status, + u32 adv_id, const u8 *adv_mac, + const char *deferred_session_resp) { struct wpa_supplicant *wpa_s = ctx; @@ -3726,9 +3728,21 @@ static void wpas_prov_disc_fail(void *ctx, const u8 *peer, return; } - wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE - " p2p_dev_addr=" MACSTR " status=%d", - MAC2STR(peer), status); + if (adv_id && adv_mac && deferred_session_resp) { + wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE + " p2p_dev_addr=" MACSTR " status=%d adv_id=%x" + " deferred_session_resp='%s'", + MAC2STR(peer), status, adv_id, + deferred_session_resp); + } else if (adv_id && adv_mac) { + wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE + " p2p_dev_addr=" MACSTR " status=%d adv_id=%x", + MAC2STR(peer), status, adv_id); + } else { + wpa_msg_global(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_FAILURE + " p2p_dev_addr=" MACSTR " status=%d", + MAC2STR(peer), status); + } wpas_notify_p2p_provision_discovery(wpa_s, peer, 0 /* response */, status, 0, 0);