P2P: Use operating frequency from peer table as backup for join

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.
This commit is contained in:
Jouni Malinen 2010-08-04 16:00:21 -07:00 committed by Jouni Malinen
parent a482883f63
commit f8d0131a11
3 changed files with 28 additions and 1 deletions

View 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); msg.ds_params ? *msg.ds_params : -1);
} }
dev->listen_freq = freq; dev->listen_freq = freq;
if (msg.group_info)
dev->oper_freq = freq;
dev->level = level; dev->level = level;
if (msg.pri_dev_type) if (msg.pri_dev_type)
@ -3005,3 +3007,14 @@ void p2p_set_cross_connect(struct p2p_data *p2p, int enabled)
p2p->cross_connect = enabled; p2p->cross_connect = enabled;
/* TODO: may need to tear down any action group where we are GO(?) */ /* 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;
}

View 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); 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 */ #endif /* P2P_H */

View 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_scan_results *scan_res)
{ {
struct wpa_bss *bss; struct wpa_bss *bss;
int freq;
eloop_cancel_timeout(wpas_p2p_join_scan, wpa_s, NULL); 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) if (scan_res)
wpas_p2p_scan_res_handler(wpa_s, 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); bss = wpa_bss_get_bssid(wpa_s, wpa_s->pending_join_iface_addr);
if (bss) { 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; u16 method;
wpa_printf(MSG_DEBUG, "P2P: Send Provision Discovery Request " wpa_printf(MSG_DEBUG, "P2P: Send Provision Discovery Request "
"prior to joining an existing group (GO " MACSTR "prior to joining an existing group (GO " MACSTR
" freq=%u MHz)", " 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; wpa_s->pending_pd_before_join = 1;
switch (wpa_s->pending_join_wps_method) { switch (wpa_s->pending_join_wps_method) {