[PATCH] Retreive shared frequency when a singly "phy" is shared between multiple interfaces

Jithu Jance jithu
Thu Nov 10 02:08:17 PST 2011


Hi Johannes,

Thanks for your reply. Please correct me, if my understanding is wrong. I am talking about a concurrent scenario where we have a legacy STA on wlan0 interface(primary MAC address) already in connected state. Then we are starting an Autonomous GO by issuing p2p_group_add on wlan1(p2p_device_address) interface.

In wpas_p2p_init_go_params, I could see that the wpa_supplicant invokes wpa_drv_shared_freq to get the shared freq. Since this handler wasn't present, I implemented it to retrieve the freq. Without the below patch, the p2p_group_add was always resulting in a GO on freq 2412. Freq 2412 would be set when there is no known preference as per "wpas_p2p_init_go_params" function. Did I miss something?? 


Sorry for the whitespace issue. I am attaching the corrected patch below. 

Signed-hostap: Jithu Jance <jithu at broadcom.com>

---
 src/drivers/driver_nl80211.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 2ab10ae..e5077e0 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -269,6 +269,7 @@ static int nl80211_send_frame_cmd(struct wpa_driver_nl80211_data *drv,
 				  const u8 *buf, size_t buf_len, u64 *cookie,
 				  int no_cck);
 static int wpa_driver_nl80211_probe_req_report(void *priv, int report);
+static int wpa_driver_nl80211_shared_freq(void *priv);
 
 #ifdef HOSTAPD
 static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx);
@@ -7231,6 +7232,41 @@ static int nl80211_signal_poll(void *priv, struct wpa_signal_info *si)
 	return nl80211_get_link_noise(drv, si);
 }
 
+static int wpa_driver_nl80211_shared_freq(void *priv)
+{
+	struct i802_bss *bss = priv;
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+	struct nl80211_global *global = drv->global;
+	struct wpa_driver_nl80211_data *driver = NULL;
+	int freq = 0;
+
+	/* If the same phy is in connected state with some other interface,
+	 * then retrieve the assoc freq */
+	wpa_printf(MSG_DEBUG, "nl80211: get shared freq for PHY(%s)", drv->phyname);
+
+	dl_list_for_each(driver, &global->interfaces,
+		struct wpa_driver_nl80211_data, list) {
+
+		/* skip, if its the same instance */
+		if(drv == driver)
+			continue;
+
+		if(os_strcmp(drv->phyname, driver->phyname) == 0) {
+			if(driver->associated) {
+				wpa_printf(MSG_DEBUG, "nl80211: Found a match for (%s) "
+					"with macaddr("MACSTR") associated to %s ",
+					driver->phyname, MAC2STR(driver->addr), driver->ssid);
+				freq = nl80211_get_assoc_freq(driver);
+				wpa_printf(MSG_DEBUG, "nl80211: shared freq for PHY(%s):%d ", drv->phyname, freq);
+			}
+		}
+	}
+
+	if(!freq)
+		wpa_printf(MSG_DEBUG, "nl80211: No shared Interface for PHY(%s)", drv->phyname);
+
+	return freq;
+}
 
 static int nl80211_send_frame(void *priv, const u8 *data, size_t data_len,
 			      int encrypt)
@@ -7612,6 +7648,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
 	.signal_monitor = nl80211_signal_monitor,
 	.signal_poll = nl80211_signal_poll,
 	.send_frame = nl80211_send_frame,
+	.shared_freq = wpa_driver_nl80211_shared_freq,
 	.set_param = nl80211_set_param,
 	.get_radio_name = nl80211_get_radio_name,
 	.add_pmkid = nl80211_add_pmkid,
-- 
1.7.4.1
 

- Jithu Jance.

________________________________________
From: Johannes Berg [johannes at sipsolutions.net]
Sent: Thursday, November 10, 2011 1:38 PM
To: Jithu Jance
Cc: hostap at lists.shmoo.com
Subject: Re: [PATCH] Retreive shared frequency when a singly "phy" is shared between multiple interfaces

On Wed, 2011-11-09 at 23:34 -0800, Jithu Jance wrote:
> This patch implements shared_freq handler for driver_nl80211.c If a "p2p_group_add" happens after legacy STA association, then this
> patch will help to start the GO on the same frequency. This is useful when supplicant is started on multiple interface running over
> a singly "PHY".
>
> For e.g wpa_supplicant -iwlan0 ..  -N -iwlan1 ...

Why are you doing that? wpa_supplicant should be creating p2p interfaces
by itself and in that case it knows already.


> +static int wpa_driver_nl80211_shared_freq(void *priv)
> +{
> +     struct i802_bss *bss = priv;
> +     struct wpa_driver_nl80211_data *drv = bss->drv;
> +     struct nl80211_global *global = drv->global;
> +     struct wpa_driver_nl80211_data *driver = NULL;
> +     int freq = 0;

This patch is completely whitespace damaged.

johannes






More information about the Hostap mailing list