]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix Provision Discovery channel for some join-GO cases
authorJouni Malinen <j@w1.fi>
Sun, 18 Dec 2011 15:21:25 +0000 (17:21 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 18 Dec 2011 15:21:25 +0000 (17:21 +0200)
The Provision Discovery Request needs to be sent on the operating
channel of the GO and as such, the frequency from the BSS table
(scan results) need to override the frequency in the P2P peer
table that could be based on the Listen channel of the GO.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_i.h
src/p2p/p2p_pd.c
wpa_supplicant/p2p_supplicant.c

index 2b0c4865e2643396d30d0869d8fa075660e710c8..665b7804bd9c4c053c7e9efad4cb46f669b17782 100644 (file)
@@ -2373,7 +2373,7 @@ void p2p_continue_find(struct p2p_data *p2p)
                                MACSTR " (config methods 0x%x)",
                                MAC2STR(dev->info.p2p_device_addr),
                                dev->req_config_methods);
-                       if (p2p_send_prov_disc_req(p2p, dev, 0) == 0)
+                       if (p2p_send_prov_disc_req(p2p, dev, 0, 0) == 0)
                                return;
                }
        }
@@ -2442,7 +2442,7 @@ static void p2p_retry_pd(struct p2p_data *p2p)
                        MACSTR " (config methods 0x%x)",
                        MAC2STR(dev->info.p2p_device_addr),
                        dev->req_config_methods);
-               p2p_send_prov_disc_req(p2p, dev, 0);
+               p2p_send_prov_disc_req(p2p, dev, 0, 0);
                return;
        }
 }
index 0b24f7f9698f6ff2cf549d7162131e2bd3282bdd..6a640ab70a842f68f6b805f70356a9bcb5e97bb8 100644 (file)
@@ -897,6 +897,7 @@ int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
  * @peer_addr: MAC address of the peer P2P client
  * @config_methods: WPS Config Methods value (only one bit set)
  * @join: Whether this is used by a client joining an active group
+ * @force_freq: Forced TX frequency for the frame (mainly for the join case)
  * Returns: 0 on success, -1 on failure
  *
  * This function can be used to request a discovered P2P peer to display a PIN
@@ -908,7 +909,7 @@ int p2p_reject(struct p2p_data *p2p, const u8 *peer_addr);
  * indicated with the p2p_config::prov_disc_resp() callback.
  */
 int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
-                     u16 config_methods, int join);
+                     u16 config_methods, int join, int force_freq);
 
 /**
  * p2p_sd_request - Schedule a service discovery query
index 4a4751b7f2646adc3ae99c1b3ae30b77988f993b..0dc33e76e5128f97f34d0938c8a6113371c6daaf 100644 (file)
@@ -619,7 +619,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa,
 void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa,
                                const u8 *data, size_t len);
 int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
-                          int join);
+                          int join, int force_freq);
 void p2p_reset_pending_pd(struct p2p_data *p2p);
 
 /* p2p_invitation.c */
index 64094546add340644e3c45bca90815509129cede..790334f6b11edc79e3e8a46e82eb0d4cfb479d46 100644 (file)
@@ -283,12 +283,16 @@ out:
 
 
 int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
-                          int join)
+                          int join, int force_freq)
 {
        struct wpabuf *req;
        int freq;
 
-       freq = dev->listen_freq > 0 ? dev->listen_freq : dev->oper_freq;
+       if (force_freq > 0)
+               freq = force_freq;
+       else
+               freq = dev->listen_freq > 0 ? dev->listen_freq :
+                       dev->oper_freq;
        if (freq <= 0) {
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                        "P2P: No Listen/Operating frequency known for the "
@@ -336,7 +340,7 @@ int p2p_send_prov_disc_req(struct p2p_data *p2p, struct p2p_device *dev,
 
 
 int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
-                     u16 config_methods, int join)
+                     u16 config_methods, int join, int force_freq)
 {
        struct p2p_device *dev;
 
@@ -385,7 +389,7 @@ int p2p_prov_disc_req(struct p2p_data *p2p, const u8 *peer_addr,
        if (p2p->user_initiated_pd && p2p->state == P2P_IDLE)
                p2p->pd_retries = MAX_PROV_DISC_REQ_RETRIES;
 
-       return p2p_send_prov_disc_req(p2p, dev, join);
+       return p2p_send_prov_disc_req(p2p, dev, join, force_freq);
 }
 
 
index 71699e4d701a39b836703b86af77e5df549ea747..aedbf1098b001bf88a1d5dc62d10d060a4cf73a6 100644 (file)
@@ -2549,8 +2549,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
                }
 
                if (p2p_prov_disc_req(wpa_s->global->p2p,
-                                     wpa_s->pending_join_dev_addr, method, 1)
-                   < 0) {
+                                     wpa_s->pending_join_dev_addr, method, 1,
+                                     freq) < 0) {
                        wpa_printf(MSG_DEBUG, "P2P: Failed to send Provision "
                                   "Discovery Request before joining an "
                                   "existing group");
@@ -3359,7 +3359,7 @@ int wpas_p2p_prov_disc(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
                return -1;
 
        return p2p_prov_disc_req(wpa_s->global->p2p, peer_addr,
-                                config_methods, join);
+                                config_methods, join, 0);
 }