Commit b2e3abdc authored by Holger Schurig's avatar Holger Schurig Committed by John W. Linville

cfg80211: allow scanning on specified frequencies when using wext-compatibility

Handles the case when SIOCSIWSCAN specified iw_scan_req.num_channels and
iw_scan_req.channels[].
Signed-off-by: default avatarHolger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 8c8f9ba7
...@@ -607,6 +607,9 @@ int cfg80211_wext_siwscan(struct net_device *dev, ...@@ -607,6 +607,9 @@ int cfg80211_wext_siwscan(struct net_device *dev,
if (!netif_running(dev)) if (!netif_running(dev))
return -ENETDOWN; return -ENETDOWN;
if (wrqu->data.length == sizeof(struct iw_scan_req))
wreq = (struct iw_scan_req *)extra;
rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex); rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex);
if (IS_ERR(rdev)) if (IS_ERR(rdev))
...@@ -619,9 +622,14 @@ int cfg80211_wext_siwscan(struct net_device *dev, ...@@ -619,9 +622,14 @@ int cfg80211_wext_siwscan(struct net_device *dev,
wiphy = &rdev->wiphy; wiphy = &rdev->wiphy;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) /* Determine number of channels, needed to allocate creq */
if (wiphy->bands[band]) if (wreq && wreq->num_channels)
n_channels += wiphy->bands[band]->n_channels; n_channels = wreq->num_channels;
else {
for (band = 0; band < IEEE80211_NUM_BANDS; band++)
if (wiphy->bands[band])
n_channels += wiphy->bands[band]->n_channels;
}
creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
n_channels * sizeof(void *), n_channels * sizeof(void *),
...@@ -638,22 +646,41 @@ int cfg80211_wext_siwscan(struct net_device *dev, ...@@ -638,22 +646,41 @@ int cfg80211_wext_siwscan(struct net_device *dev,
creq->n_channels = n_channels; creq->n_channels = n_channels;
creq->n_ssids = 1; creq->n_ssids = 1;
/* all channels */ /* translate "Scan on frequencies" request */
i = 0; i = 0;
for (band = 0; band < IEEE80211_NUM_BANDS; band++) { for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
int j; int j;
if (!wiphy->bands[band]) if (!wiphy->bands[band])
continue; continue;
for (j = 0; j < wiphy->bands[band]->n_channels; j++) { for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
/* If we have a wireless request structure and the
* wireless request specifies frequencies, then search
* for the matching hardware channel.
*/
if (wreq && wreq->num_channels) {
int k;
int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
for (k = 0; k < wreq->num_channels; k++) {
int wext_freq = wreq->channel_list[k].m / 100000;
if (wext_freq == wiphy_freq)
goto wext_freq_found;
}
goto wext_freq_not_found;
}
wext_freq_found:
creq->channels[i] = &wiphy->bands[band]->channels[j]; creq->channels[i] = &wiphy->bands[band]->channels[j];
i++; i++;
wext_freq_not_found: ;
} }
} }
/* translate scan request */ /* Set real number of channels specified in creq->channels[] */
if (wrqu->data.length == sizeof(struct iw_scan_req)) { creq->n_channels = i;
wreq = (struct iw_scan_req *)extra;
/* translate "Scan for SSID" request */
if (wreq) {
if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) if (wreq->essid_len > IEEE80211_MAX_SSID_LEN)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment