From fc71f7d99db620097296720af1d46b1b94afb0f8 Mon Sep 17 00:00:00 2001 From: Ahmad Kholaif Date: Fri, 24 Jul 2015 01:23:24 -0700 Subject: [PATCH] P2P: Expose driver preferred frequency list fetch to P2P This adds a callback function that can be used from the P2P module to request the current preferred list of operating channels from the driver. Signed-off-by: Jouni Malinen --- src/p2p/p2p.h | 14 ++++++++++++++ wpa_supplicant/p2p_supplicant.c | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 15b093ae8..edfcc8a4b 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1073,6 +1073,20 @@ struct p2p_config { * P2PS_SETUP_* bitmap is used as the parameters and return value. */ u8 (*p2ps_group_capability)(void *ctx, u8 incoming, u8 role); + + /** + * get_pref_freq_list - Get preferred frequency list for an interface + * @ctx: Callback context from cb_ctx + * @go: Whether the use if for GO role + * @len: Length of freq_list in entries (both IN and OUT) + * @freq_list: Buffer for returning the preferred frequencies (MHz) + * Returns: 0 on success, -1 on failure + * + * This function can be used to query the preferred frequency list from + * the driver specific to a particular interface type. + */ + int (*get_pref_freq_list)(void *ctx, int go, + unsigned int *len, unsigned int *freq_list); }; diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 9c11b9ab4..5bf612e3c 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3949,6 +3949,17 @@ static int wpas_prov_disc_resp_cb(void *ctx) } +static int wpas_p2p_get_pref_freq_list(void *ctx, int go, + unsigned int *len, + unsigned int *freq_list) +{ + struct wpa_supplicant *wpa_s = ctx; + + return wpa_drv_get_pref_freq_list(wpa_s, go ? WPA_IF_P2P_GO : + WPA_IF_P2P_CLIENT, len, freq_list); +} + + /** * wpas_p2p_init - Initialize P2P module for %wpa_supplicant * @global: Pointer to global data from wpa_supplicant_init() @@ -4002,6 +4013,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) p2p.p2ps_prov_complete = wpas_p2ps_prov_complete; p2p.prov_disc_resp_cb = wpas_prov_disc_resp_cb; p2p.p2ps_group_capability = p2ps_group_capability; + p2p.get_pref_freq_list = wpas_p2p_get_pref_freq_list; os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN); os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);