[PATCH v2 09/10] wpa_supplicant: use p2p device wrappers for p2p device flows

David Spinadel dvdspndl
Sun Mar 17 13:57:19 PDT 2013


From: David Spinadel <david.spinadel at intel.com>

Signed-off-by: David Spinadel <david.spinadel at intel.com>
---
 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 bbcde8f..518e8e4 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -202,7 +202,7 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
 		break;
 	}
 
-	ret = wpa_drv_scan(wpa_s, &params);
+	ret = wpa_drv_p2p_scan(wpa_s, &params);
 
 	wpabuf_free(ies);
 
@@ -764,14 +764,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);
 }
 
 
@@ -1104,7 +1104,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;
 	}
@@ -1238,7 +1238,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);
@@ -1256,7 +1256,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;
 	}
@@ -1268,7 +1268,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);
 }
 
 
@@ -3548,7 +3549,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, &params);
+	ret = wpa_drv_p2p_scan(wpa_s, &params);
 	if (!ret)
 		wpa_s->scan_res_handler = wpas_p2p_scan_res_join;
 
@@ -3636,7 +3637,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;
 	}
@@ -5682,7 +5683,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");
-- 
1.7.10.msysgit.1




More information about the Hostap mailing list