linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Fertser <fercerpav@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: "Thomas d'Otreppe" <tdotreppe@gmail.com>,
	Richard Farina <sidhayn@gmail.com>,
	Paul Fertser <fercerpav@gmail.com>
Subject: [RFC][PATCH] cfg80211: report monitor interface channel via wext when possible
Date: Sat, 22 Jan 2011 03:11:38 +0300	[thread overview]
Message-ID: <1295655098-17534-1-git-send-email-fercerpav@gmail.com> (raw)

This makes it possible to retrieve the channel for the monitor interface
in cases when it can be determined unambigously. Tested with ath5k.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
---
 net/wireless/chan.c        |    5 +++--
 net/wireless/wext-compat.c |   12 ++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 17cd0c0..869e764 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -81,6 +81,7 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 		      enum nl80211_channel_type channel_type)
 {
 	struct ieee80211_channel *chan;
+	struct wireless_dev *passed_wdev = wdev;
 	int result;
 
 	if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR)
@@ -128,8 +129,8 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 	if (result)
 		return result;
 
-	if (wdev)
-		wdev->channel = chan;
+	if (passed_wdev)
+		passed_wdev->channel = chan;
 
 	return 0;
 }
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 3e5dbd4..aa637e6 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -819,6 +819,8 @@ int cfg80211_wext_giwfreq(struct net_device *dev,
 			  struct iw_freq *freq, char *extra)
 {
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+	int result;
 
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_STATION:
@@ -828,6 +830,16 @@ int cfg80211_wext_giwfreq(struct net_device *dev,
 	default:
 		if (!wdev->channel)
 			return -EINVAL;
+		/* The actual working channel might have been changed, verify it
+		 * by re-setting pretending we want to set channel for a monitor
+		 * interface */
+		result = rdev->ops->set_channel(&rdev->wiphy, NULL,
+						wdev->channel,
+						NL80211_CHAN_NO_HT);
+		if (result) {
+			wdev->channel = NULL;
+			return -EINVAL;
+		}
 		freq->m = wdev->channel->center_freq;
 		freq->e = 6;
 		return 0;
-- 
1.7.2.2


             reply	other threads:[~2011-01-22  0:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22  0:11 Paul Fertser [this message]
2011-01-23  9:06 ` [RFC][PATCH] cfg80211: report monitor interface channel via wext when possible Johannes Berg
2011-01-23  9:41   ` Paul Fertser
2011-01-24 11:47     ` Johannes Berg
2011-01-24  1:10   ` Bruno Randolf
2011-01-24  7:46     ` Paul Fertser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1295655098-17534-1-git-send-email-fercerpav@gmail.com \
    --to=fercerpav@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=sidhayn@gmail.com \
    --cc=tdotreppe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).