From 9fe2590f82a6e74d8f4502ba562e339caebdd288 Mon Sep 17 00:00:00 2001 From: Ahmad Kholaif Date: Fri, 24 Jul 2015 00:39:45 +0000 Subject: P2P: Use preferred frequency list from the local driver If the driver supports the preferred frequency list extension, use this information from the driver when no explicitly configured preference list (p2p_pref_chan) is present for P2P operating channel selection. This commit adds this for GO Negotiation and Invitation use cases. Signed-off-by: Jouni Malinen Git-commit: 370017d968e071522357ea88c0c6aaed02853222 Git-repo : git://w1.fi/srv/git/hostap.git Change-Id: Idd39a8276daaf450b8d720a9fdf617f6427f5e48 CRs-fixed: 842468 --- src/p2p/p2p.c | 17 +++++++++++++++++ src/p2p/p2p.h | 9 +++++++++ src/p2p/p2p_i.h | 3 +++ 3 files changed, 29 insertions(+) (limited to 'src') diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 99bd402a..fb4c0aec 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -5390,3 +5390,20 @@ void p2p_go_neg_wait_timeout(void *eloop_ctx, void *timeout_ctx) "Timeout on waiting peer to become ready for GO Negotiation"); p2p_go_neg_failed(p2p, -1); } + + +void p2p_set_own_pref_freq_list(struct p2p_data *p2p, + const unsigned int *pref_freq_list, + unsigned int size) +{ + unsigned int i; + + if (size > P2P_MAX_PREF_CHANNELS) + size = P2P_MAX_PREF_CHANNELS; + p2p->num_pref_freq = size; + for (i = 0; i < size; i++) { + p2p->pref_freq_list[i] = pref_freq_list[i]; + p2p_dbg(p2p, "Own preferred frequency list[%u]=%u MHz", + i, p2p->pref_freq_list[i]); + } +} diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 67b8bdb6..f12419fb 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -22,6 +22,11 @@ #define P2PS_HASH_LEN 6 #define P2P_MAX_QUERY_HASH 6 +/** + * P2P_MAX_PREF_CHANNELS - Maximum number of preferred channels + */ +#define P2P_MAX_PREF_CHANNELS 100 + /** * P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */ @@ -2253,4 +2258,8 @@ int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id); void p2p_service_flush_asp(struct p2p_data *p2p); struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p); +void p2p_set_own_pref_freq_list(struct p2p_data *p2p, + const unsigned int *pref_freq_list, + unsigned int size); + #endif /* P2P_H */ diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h index 78e52c93..407316fc 100644 --- a/src/p2p/p2p_i.h +++ b/src/p2p/p2p_i.h @@ -535,6 +535,9 @@ struct p2p_data { u16 authorized_oob_dev_pw_id; struct wpabuf **vendor_elem; + + unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS]; + unsigned int num_pref_freq; }; /** -- cgit v1.2.3