From patchwork Mon Feb 18 20:30:35 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: 221490 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 8DDA42C0092 for ; Tue, 19 Feb 2013 07:33:27 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A2EA517C017; Mon, 18 Feb 2013 15:33:25 -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 Xk1FYF1vLWvH; Mon, 18 Feb 2013 15:33:25 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B7F7A9D37E; Mon, 18 Feb 2013 15:31: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 9B3BA9D384 for ; Mon, 18 Feb 2013 15:31:49 -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 IzJIve0Tz+PW for ; Mon, 18 Feb 2013 15:31:44 -0500 (EST) Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com [209.85.215.170]) (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 6B5D89D23A for ; Mon, 18 Feb 2013 15:31:03 -0500 (EST) Received: by mail-ea0-f170.google.com with SMTP id a11so2507125eaa.15 for ; Mon, 18 Feb 2013 12:31:02 -0800 (PST) X-Received: by 10.14.182.71 with SMTP id n47mr48665336eem.11.1361219462210; Mon, 18 Feb 2013 12:31:02 -0800 (PST) Received: from localhost (93-172-163-212.bb.netvision.net.il. [93.172.163.212]) by mx.google.com with ESMTPS id d47sm41614830eem.9.2013.02.18.12.31.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 18 Feb 2013 12:31:01 -0800 (PST) From: dvdspndl@gmail.com To: hostap@lists.shmoo.com Subject: [PATCH 09/10] wpa_supplicant: use p2p device wrappers for p2p device flows Date: Mon, 18 Feb 2013 22:30:35 +0200 Message-Id: <1361219436-5840-9-git-send-email-dvdspndl@gmail.com> X-Mailer: git-send-email 1.7.10.msysgit.1 In-Reply-To: <1361219436-5840-1-git-send-email-dvdspndl@gmail.com> References: <1361219436-5840-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 0a09b00..89ebe08 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -183,7 +183,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); @@ -739,14 +739,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); } @@ -1079,7 +1079,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; } @@ -1213,7 +1213,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); @@ -1231,7 +1231,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; } @@ -1243,7 +1243,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); } @@ -3432,7 +3433,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; @@ -3512,7 +3513,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; } @@ -5416,7 +5417,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");