| | 121 | |
|---|
| | 122 | static void |
|---|
| | 123 | preempt_scan(struct net_device *dev, int max_grace, int max_wait) |
|---|
| | 124 | { |
|---|
| | 125 | struct ieee80211vap *vap = dev->priv; |
|---|
| | 126 | struct ieee80211com *ic = vap->iv_ic; |
|---|
| | 127 | int total_delay = 0; |
|---|
| | 128 | int cancelled = 0, ready = 0; |
|---|
| | 129 | while (!ready && total_delay < max_grace + max_wait) { |
|---|
| | 130 | if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) { |
|---|
| | 131 | ready = 1; |
|---|
| | 132 | } else { |
|---|
| | 133 | if (!cancelled && total_delay > max_grace) { |
|---|
| | 134 | /* |
|---|
| | 135 | Cancel any existing active scan, so that any new parameters |
|---|
| | 136 | in this scan ioctl (or the defaults) can be honored, then |
|---|
| | 137 | wait around a while to see if the scan cancels properly. |
|---|
| | 138 | */ |
|---|
| | 139 | IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, |
|---|
| | 140 | "%s: cancel pending scan request\n", __func__); |
|---|
| | 141 | (void) ieee80211_cancel_scan(vap); |
|---|
| | 142 | cancelled = 1; |
|---|
| | 143 | } |
|---|
| | 144 | mdelay (1); |
|---|
| | 145 | total_delay += 1; |
|---|
| | 146 | } |
|---|
| | 147 | } |
|---|
| | 148 | if (!ready) { |
|---|
| | 149 | IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, |
|---|
| | 150 | "%s: Timeout cancelling current scan.\n", |
|---|
| | 151 | __func__); |
|---|
| | 152 | } |
|---|
| | 153 | } |
|---|
| | 1435 | preempt_scan(dev, 100, 100); |
|---|
| | 1436 | #if WIRELESS_EXT > 17 |
|---|
| | 1437 | if (data && (data->flags & IW_SCAN_THIS_ESSID)) { |
|---|
| | 1438 | struct iw_scan_req req; |
|---|
| | 1439 | struct ieee80211_scan_ssid ssid; |
|---|
| | 1440 | int copyLength; |
|---|
| | 1441 | IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, |
|---|
| | 1442 | "%s: SCAN_THIS_ESSID requested\n", __func__); |
|---|
| | 1443 | if (data->length > sizeof req) { |
|---|
| | 1444 | copyLength = sizeof req; |
|---|
| | 1445 | } else { |
|---|
| | 1446 | copyLength = data->length; |
|---|
| | 1447 | } |
|---|
| | 1448 | memset(&req, 0, sizeof req); |
|---|
| | 1449 | if (copy_from_user(&req, data->pointer, copyLength)) |
|---|
| | 1450 | return -EFAULT; |
|---|
| | 1451 | memcpy(&ssid.ssid, req.essid, sizeof ssid.ssid); |
|---|
| | 1452 | ssid.len = req.essid_len; |
|---|
| | 1453 | IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, |
|---|
| | 1454 | "%s: requesting scan of essid '%s'\n", __func__, ssid.ssid); |
|---|
| | 1455 | (void) ieee80211_start_scan(vap, |
|---|
| | 1456 | IEEE80211_SCAN_ACTIVE | |
|---|
| | 1457 | IEEE80211_SCAN_NOPICK | |
|---|
| | 1458 | IEEE80211_SCAN_ONCE, IEEE80211_SCAN_FOREVER, |
|---|
| | 1459 | 1, &ssid); |
|---|
| | 1460 | return 0; |
|---|
| | 1461 | } |
|---|
| | 1462 | #endif |
|---|