From patchwork Tue Feb 19 10:39:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dvdspndl@gmail.com X-Patchwork-Id: 221657 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 3873B2C0293 for ; Tue, 19 Feb 2013 21:40:11 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D86DF9D1F8; Tue, 19 Feb 2013 05:40:08 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hXZlxk+vxAMa; Tue, 19 Feb 2013 05:40:08 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 13ADF9D21E; Tue, 19 Feb 2013 05:39:50 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E585E9D218 for ; Tue, 19 Feb 2013 05:39:48 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sPSm-twZU+ni for ; Tue, 19 Feb 2013 05:39:39 -0500 (EST) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id C0D059D1F6 for ; Tue, 19 Feb 2013 05:39:38 -0500 (EST) Received: by mail-ee0-f49.google.com with SMTP id d4so3354902eek.36 for ; Tue, 19 Feb 2013 02:39:37 -0800 (PST) X-Received: by 10.14.207.200 with SMTP id n48mr55940867eeo.4.1361270377660; Tue, 19 Feb 2013 02:39:37 -0800 (PST) Received: from localhost (93-172-7-6.bb.netvision.net.il. [93.172.7.6]) by mx.google.com with ESMTPS id r4sm58764583eeo.12.2013.02.19.02.39.35 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Feb 2013 02:39:36 -0800 (PST) From: dvdspndl@gmail.com To: hostap@lists.shmoo.com Subject: [PATCH 2/3] wpa_supplicant: use p2p device wrappers for p2p device flows Date: Tue, 19 Feb 2013 12:39:25 +0200 Message-Id: <1361270366-10576-2-git-send-email-dvdspndl@gmail.com> X-Mailer: git-send-email 1.7.10.msysgit.1 In-Reply-To: <1361270366-10576-1-git-send-email-dvdspndl@gmail.com> References: <1361270366-10576-1-git-send-email-dvdspndl@gmail.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: David Spinadel Signed-off-by: David Spinadel --- wpa_supplicant/gas_query.c | 4 +-- wpa_supplicant/offchannel.c | 58 ++++++++++++++++++++++++++++++--------- wpa_supplicant/offchannel.h | 4 +-- wpa_supplicant/p2p_supplicant.c | 21 +++++++------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/wpa_supplicant/gas_query.c b/wpa_supplicant/gas_query.c index 27bcc7a..43bd87a 100644 --- a/wpa_supplicant/gas_query.c +++ b/wpa_supplicant/gas_query.c @@ -82,7 +82,7 @@ static void gas_query_done(struct gas_query *gas, enum gas_query_result result) { if (query->offchannel_tx_started) - offchannel_send_action_done(gas->wpa_s); + offchannel_send_action_done(gas->wpa_s, 0); eloop_cancel_timeout(gas_query_tx_comeback_timeout, gas, query); eloop_cancel_timeout(gas_query_timeout, gas, query); dl_list_del(&query->list); @@ -148,7 +148,7 @@ static int gas_query_tx(struct gas_query *gas, struct gas_query_pending *query, res = offchannel_send_action(gas->wpa_s, query->freq, query->addr, gas->wpa_s->own_addr, query->addr, wpabuf_head(req), wpabuf_len(req), 1000, - NULL, 0); + NULL, 0, 0); if (res == 0) query->offchannel_tx_started = 1; return res; diff --git a/wpa_supplicant/offchannel.c b/wpa_supplicant/offchannel.c index 856eca7..0e0a111 100644 --- a/wpa_supplicant/offchannel.c +++ b/wpa_supplicant/offchannel.c @@ -205,8 +205,9 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, const u8 *data, size_t data_len, enum offchannel_send_action_result result), - int no_cck) + int no_cck, int p2p_dev) { + int ret; wpa_printf(MSG_DEBUG, "Off-channel: Send action frame: freq=%d dst=" MACSTR " src=" MACSTR " bssid=" MACSTR " len=%d", freq, MAC2STR(dst), MAC2STR(src), MAC2STR(bssid), @@ -241,13 +242,26 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, wpa_s->pending_action_src); wpa_s->action_tx_wait_time = wait_time; - return wpa_drv_send_action( - iface, wpa_s->pending_action_freq, - wait_time, wpa_s->pending_action_dst, - wpa_s->pending_action_src, wpa_s->pending_action_bssid, - wpabuf_head(wpa_s->pending_action_tx), - wpabuf_len(wpa_s->pending_action_tx), - wpa_s->pending_action_no_cck); +#ifdef CONFIG_P2P + if (p2p_dev) + return wpa_drv_p2p_send_action( + iface, wpa_s->pending_action_freq, + wait_time, wpa_s->pending_action_dst, + wpa_s->pending_action_src, + wpa_s->pending_action_bssid, + wpabuf_head(wpa_s->pending_action_tx), + wpabuf_len(wpa_s->pending_action_tx), + wpa_s->pending_action_no_cck); + else +#endif + return wpa_drv_send_action( + iface, wpa_s->pending_action_freq, + wait_time, wpa_s->pending_action_dst, + wpa_s->pending_action_src, + wpa_s->pending_action_bssid, + wpabuf_head(wpa_s->pending_action_tx), + wpabuf_len(wpa_s->pending_action_tx), + wpa_s->pending_action_no_cck); } if (freq) { @@ -285,7 +299,14 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, "channel"); if (wait_time > wpa_s->max_remain_on_chan) wait_time = wpa_s->max_remain_on_chan; - if (wpa_drv_remain_on_channel(wpa_s, freq, wait_time) < 0) { + +#ifdef CONFIG_P2P + if (p2p_dev) + ret = wpa_drv_p2p_remain_on_channel(wpa_s, freq, wait_time); + else +#endif + ret = wpa_drv_remain_on_channel(wpa_s, freq, wait_time); + if (ret < 0) { wpa_printf(MSG_DEBUG, "Off-channel: Failed to request driver " "to remain on channel (%u MHz) for Action " "Frame TX", freq); @@ -305,18 +326,29 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, * This function can be used to cancel a wait for additional response frames on * the channel that was used with offchannel_send_action(). */ -void offchannel_send_action_done(struct wpa_supplicant *wpa_s) +void offchannel_send_action_done(struct wpa_supplicant *wpa_s, int p2p_dev) { wpa_printf(MSG_DEBUG, "Off-channel: Action frame sequence done " "notification"); wpabuf_free(wpa_s->pending_action_tx); wpa_s->pending_action_tx = NULL; if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX && - wpa_s->action_tx_wait_time) - wpa_drv_send_action_cancel_wait(wpa_s); + wpa_s->action_tx_wait_time) { +#ifdef CONFIG_P2P + if (p2p_dev) + wpa_drv_p2p_send_action_cancel_wait(wpa_s); + else +#endif + wpa_drv_send_action_cancel_wait(wpa_s); + } if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); +#ifdef CONFIG_P2P + if (p2p_dev) + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); + else +#endif + wpa_drv_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } diff --git a/wpa_supplicant/offchannel.h b/wpa_supplicant/offchannel.h index 0ad7e18..0dcc398 100644 --- a/wpa_supplicant/offchannel.h +++ b/wpa_supplicant/offchannel.h @@ -19,8 +19,8 @@ int offchannel_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, const u8 *data, size_t data_len, enum offchannel_send_action_result result), - int no_cck); -void offchannel_send_action_done(struct wpa_supplicant *wpa_s); + int no_cck, int p2p_dev); +void offchannel_send_action_done(struct wpa_supplicant *wpa_s, int p2p_dev); void offchannel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, unsigned int freq, unsigned int duration); void offchannel_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index d6015b9..592777a 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -189,7 +189,7 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq, break; } - ret = wpa_drv_scan(wpa_s, ¶ms); + ret = wpa_drv_p2p_scan(wpa_s, ¶ms); wpabuf_free(ies); @@ -749,14 +749,14 @@ static int wpas_send_action(void *ctx, unsigned int freq, const u8 *dst, struct wpa_supplicant *wpa_s = ctx; return offchannel_send_action(wpa_s, freq, dst, src, bssid, buf, len, wait_time, - wpas_p2p_send_action_tx_status, 1); + wpas_p2p_send_action_tx_status, 1, 1); } static void wpas_send_action_done(void *ctx) { struct wpa_supplicant *wpa_s = ctx; - offchannel_send_action_done(wpa_s); + offchannel_send_action_done(wpa_s, 1); } @@ -1089,7 +1089,7 @@ void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res) struct wpa_supplicant *wpa_s = ctx; if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -1223,7 +1223,7 @@ static int wpas_start_listen(void *ctx, unsigned int freq, wpa_s->pending_listen_freq = freq; wpa_s->pending_listen_duration = duration; - if (wpa_drv_remain_on_channel(wpa_s, freq, duration) < 0) { + if (wpa_drv_p2p_remain_on_channel(wpa_s, freq, duration) < 0) { wpa_printf(MSG_DEBUG, "P2P: Failed to request the driver " "to remain on channel (%u MHz) for Listen " "state", freq); @@ -1241,7 +1241,7 @@ static void wpas_stop_listen(void *ctx) { struct wpa_supplicant *wpa_s = ctx; if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -1253,7 +1253,8 @@ static void wpas_stop_listen(void *ctx) static int wpas_send_probe_resp(void *ctx, const struct wpabuf *buf) { struct wpa_supplicant *wpa_s = ctx; - return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1); + return wpa_drv_p2p_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), + 1); } @@ -3442,7 +3443,7 @@ static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq) * Run a scan to update BSS table and start Provision Discovery once * the new scan results become available. */ - ret = wpa_drv_scan(wpa_s, ¶ms); + ret = wpa_drv_p2p_scan(wpa_s, ¶ms); if (!ret) wpa_s->scan_res_handler = wpas_p2p_scan_res_join; @@ -3530,7 +3531,7 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s) if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) { wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel prior to " "starting client"); - wpa_drv_cancel_remain_on_channel(wpa_s); + wpa_drv_p2p_cancel_remain_on_channel(wpa_s); wpa_s->off_channel_freq = 0; wpa_s->roc_waiting_drv_freq = 0; } @@ -5457,7 +5458,7 @@ static void wpas_p2p_fallback_to_go_neg(struct wpa_supplicant *wpa_s, if (wpa_s->global->p2p_group_formation) group = wpa_s->global->p2p_group_formation; wpa_s = wpa_s->parent; - offchannel_send_action_done(wpa_s); + offchannel_send_action_done(wpa_s, 1); if (group_added) wpas_p2p_group_delete(group, P2P_GROUP_REMOVAL_SILENT); wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Fall back to GO Negotiation");