]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Use operating frequency from peer table as backup for join
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 4 Aug 2010 23:00:21 +0000 (16:00 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:23 +0000 (07:17 -0700)
The scan operation before Provision Discovery Request may not include
the GO. However, we are likely to have the GO in our P2P peer table,
so use that information to figure out the operating channel if BSS
table entry is not available.

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

index ab2f4e5d8b25c089b3279d876c7e1612164d75db..608f834fc395b91dfc71b65e3743b2231cfa9b25 100644 (file)
@@ -498,6 +498,8 @@ static int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
                        msg.ds_params ? *msg.ds_params : -1);
        }
        dev->listen_freq = freq;
+       if (msg.group_info)
+               dev->oper_freq = freq;
        dev->level = level;
 
        if (msg.pri_dev_type)
@@ -3005,3 +3007,14 @@ void p2p_set_cross_connect(struct p2p_data *p2p, int enabled)
        p2p->cross_connect = enabled;
        /* TODO: may need to tear down any action group where we are GO(?) */
 }
+
+
+int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr)
+{
+       struct p2p_device *dev = p2p_get_device_interface(p2p, iface_addr);
+       if (dev == NULL)
+               return -1;
+       if (dev->oper_freq <= 0)
+               return -1;
+       return dev->oper_freq;
+}
index a5e7ac128950f6ba19620458530d424bd06c887f..c34c97be2644d9c20c3cecb52b567a96f3867986 100644 (file)
@@ -1233,4 +1233,6 @@ void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
  */
 void p2p_set_cross_connect(struct p2p_data *p2p, int enabled);
 
+int p2p_get_oper_freq(struct p2p_data *p2p, const u8 *iface_addr);
+
 #endif /* P2P_H */
index a27d58ff89dcae510ddd4c44d8601a181c34eb3b..71b08ad436b8239c5a7b1256197d9c684b41becb 100644 (file)
@@ -2316,6 +2316,7 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
                                   struct wpa_scan_results *scan_res)
 {
        struct wpa_bss *bss;
+       int freq;
 
        eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL);
 
@@ -2328,14 +2329,25 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
        if (scan_res)
                wpas_p2p_scan_res_handler(wpa_s, scan_res);
 
+       freq = p2p_get_oper_freq(wpa_s->global->p2p,
+                                wpa_s->pending_join_iface_addr);
+       if (freq >= 0) {
+               wpa_printf(MSG_DEBUG, "P2P: Target GO operating frequency "
+                          "from P2P peer table: %d MHz", freq);
+       }
        bss = wpa_bss_get_bssid(wpa_s, wpa_s->pending_join_iface_addr);
        if (bss) {
+               freq = bss->freq;
+               wpa_printf(MSG_DEBUG, "P2P: Target GO operating frequency "
+                          "from BSS table: %d MHz", freq);
+       }
+       if (freq > 0) {
                u16 method;
 
                wpa_printf(MSG_DEBUG, "P2P: Send Provision Discovery Request "
                           "prior to joining an existing group (GO " MACSTR
                           " freq=%u MHz)",
-                          MAC2STR(wpa_s->pending_join_dev_addr), bss->freq);
+                          MAC2STR(wpa_s->pending_join_dev_addr), freq);
                wpa_s->pending_pd_before_join = 1;
 
                switch (wpa_s->pending_join_wps_method) {