diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index ab2f4e5d8..608f834fc 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -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; +} diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index a5e7ac128..c34c97be2 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -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 */ diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index a27d58ff8..71b08ad43 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -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) {