mac80211/cfg80211: report monitor channel in wireless extensions
authorJohannes Berg <johannes.berg@intel.com>
Wed, 9 Nov 2011 09:30:21 +0000 (10:30 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 11 Nov 2011 17:32:50 +0000 (12:32 -0500)
Just add API to get the channel & report it. Trivial really.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/cfg80211.h
net/mac80211/cfg.c
net/wireless/wext-compat.c

index e1ee1416631dd571653f5837213be7fb63fd26bc..50e3608f56562a7d88b3f6b05493dd071060ef87 100644 (file)
@@ -1342,6 +1342,9 @@ struct cfg80211_gtk_rekey_data {
  *     doesn't verify much. Note, however, that the passed netdev may be
  *     %NULL as well if the user requested changing the channel for the
  *     device itself, or for a monitor interface.
+ * @get_channel: Get the current operating channel, should return %NULL if
+ *     there's no single defined operating channel if for example the
+ *     device implements channel hopping for multi-channel virtual interfaces.
  *
  * @scan: Request to do a scan. If returning zero, the scan request is given
  *     the driver, and will be valid until passed to cfg80211_scan_done().
@@ -1627,6 +1630,8 @@ struct cfg80211_ops {
 
        int     (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
                                const u8 *peer, u64 *cookie);
+
+       struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy);
 };
 
 /*
index eb54b6cf85c666652f9949641bffbc71b8697627..192f213cf43e9d89745ff53485bf8060f9373c24 100644 (file)
@@ -2590,6 +2590,14 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
        return 0;
 }
 
+static struct ieee80211_channel *
+ieee80211_wiphy_get_channel(struct wiphy *wiphy)
+{
+       struct ieee80211_local *local = wiphy_priv(wiphy);
+
+       return local->oper_channel;
+}
+
 struct cfg80211_ops mac80211_config_ops = {
        .add_virtual_intf = ieee80211_add_iface,
        .del_virtual_intf = ieee80211_del_iface,
@@ -2656,4 +2664,5 @@ struct cfg80211_ops mac80211_config_ops = {
        .tdls_oper = ieee80211_tdls_oper,
        .tdls_mgmt = ieee80211_tdls_mgmt,
        .probe_client = ieee80211_probe_client,
+       .get_channel = ieee80211_wiphy_get_channel,
 };
index 62f121d1d9cbdb833d27990fc36b58f2e3ab22aa..db38c8302b54c1b7591b33e5f2e7dc4026aff208 100644 (file)
@@ -818,12 +818,24 @@ static 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);
+       struct ieee80211_channel *chan;
 
        switch (wdev->iftype) {
        case NL80211_IFTYPE_STATION:
                return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
        case NL80211_IFTYPE_ADHOC:
                return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
+       case NL80211_IFTYPE_MONITOR:
+               if (!rdev->ops->get_channel)
+                       return -EINVAL;
+
+               chan = rdev->ops->get_channel(wdev->wiphy);
+               if (!chan)
+                       return -EINVAL;
+               freq->m = chan->center_freq;
+               freq->e = 6;
+               return 0;
        default:
                if (!wdev->channel)
                        return -EINVAL;