]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add callback for provision discovery failure
authorJayant Sane <jayant.sane@intel.com>
Sun, 12 Jun 2011 21:26:22 +0000 (14:26 -0700)
committerJouni Malinen <j@w1.fi>
Sun, 12 Jun 2011 21:26:22 +0000 (14:26 -0700)
When provision discovery fails, this new callback will be called
so P2P users can react to the failure.

Signed-off-by: Jayant Sane <jayant.sane@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_pd.c

index d16d555d9e86047bf027ec25a3e68193953985f4..016a121f1ec02555ce749b5918b5ed495e12035a 100644 (file)
@@ -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);
        }
 }
index 954f562bf1ec25af321588268c2335c5e838e987..1a9ecaea907b9e88691925a80f0200b02700d65e 100644 (file)
@@ -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
index 443e37d259e33e4d45b64f552a13db433dbbea8d..f7ff06c0e6972619e8d72bf3a4cb297e9c4e0db0 100644 (file)
@@ -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;
        }