Skip to contentSkip to conversation

Cannot use ioctl SIOCGIWFREQ

DISCUSSION C. McPherson 1 participant 1 message Mar 9, 2013

lore
Share & tools
lore
#0 lore raw

Hello:
I am running my compat-wireless with version 3.8-1 and found that when I issue ghe SIOCGIWFREQ ioctl while in monitor mode returns with a -ENODATA. I have found that the ieee80211_cfg_get_channel function in net/wireless/cfg.c does not account for any channel context when the interface is in monitor mode and any attepmpt to use the SIOCGIWFREQ function will error out. I have modified my local version to include a check for a monitor interfaces The code block below fixes the problem:

static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
struct wireless_dev *wdev, struct cfg80211_chan_def *chandef)

{
        struct ieee80211_sub_if_data *sdata = 
IEEE80211_WDEV_TO_SUB_IF(wdev);
        struct ieee80211_chanctx_conf *chanctx_conf;
        struct ieee80211_local *local = wiphy_priv(wiphy);
        int ret = -ENODATA;


        if (!wdev)
                return -EOPNOTSUPP;

        switch (wdev->iftype) {
                case NL80211_IFTYPE_MONITOR:
                        *chandef = local->monitor_chandef;
                        ret = 0;
                        break;
                default:
                        rcu_read_lock();
                        chanctx_conf = 
rcu_dereference(sdata->vif.chanctx_conf);
                        if (chanctx_conf) {
                                *chandef = chanctx_conf->def;
                                ret = 0;
                        }
                        rcu_read_unlock();
        }
        return ret;
}

Thanks
Clyde