2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
30 * IEEE 802.11 scanning support.
34 #include <sys/param.h>
35 #include <sys/systm.h>
37 #include <sys/kernel.h>
38 #include <sys/condvar.h>
40 #include <sys/socket.h>
43 #include <net/if_var.h>
44 #include <net/if_media.h>
45 #include <net/ethernet.h>
47 #include <net80211/ieee80211_var.h>
49 /* XXX until it's implemented as attach ops */
50 #include <net80211/ieee80211_scan_sw.h>
55 * Roaming-related defaults. RSSI thresholds are as returned by the
56 * driver (.5dBm). Transmit rate thresholds are IEEE rate codes (i.e
60 #define ROAM_RSSI_11A_DEFAULT 14 /* 11a bss */
61 #define ROAM_RSSI_11B_DEFAULT 14 /* 11b bss */
62 #define ROAM_RSSI_11BONLY_DEFAULT 14 /* 11b-only bss */
63 /* transmit rate thresholds */
64 #define ROAM_RATE_11A_DEFAULT 2*12 /* 11a bss */
65 #define ROAM_RATE_11B_DEFAULT 2*5 /* 11b bss */
66 #define ROAM_RATE_11BONLY_DEFAULT 2*1 /* 11b-only bss */
67 #define ROAM_RATE_HALF_DEFAULT 2*6 /* half-width 11a/g bss */
68 #define ROAM_RATE_QUARTER_DEFAULT 2*3 /* quarter-width 11a/g bss */
69 #define ROAM_MCS_11N_DEFAULT (1 | IEEE80211_RATE_MCS) /* 11n bss */
72 ieee80211_scan_attach(struct ieee80211com *ic)
76 * For now, the swscan module does both the
77 * allocation (so it can pad it) and sets up the net80211
80 * I'll split this stuff later.
82 ieee80211_swscan_attach(ic);
86 ieee80211_scan_detach(struct ieee80211com *ic)
90 * Ideally we'd do the ss_ops detach call here;
91 * but then ieee80211_swscan_detach would need
96 ieee80211_swscan_detach(ic);
99 static const struct ieee80211_roamparam defroam[IEEE80211_MODE_MAX] = {
100 [IEEE80211_MODE_11A] = { .rssi = ROAM_RSSI_11A_DEFAULT,
101 .rate = ROAM_RATE_11A_DEFAULT },
102 [IEEE80211_MODE_11G] = { .rssi = ROAM_RSSI_11B_DEFAULT,
103 .rate = ROAM_RATE_11B_DEFAULT },
104 [IEEE80211_MODE_11B] = { .rssi = ROAM_RSSI_11BONLY_DEFAULT,
105 .rate = ROAM_RATE_11BONLY_DEFAULT },
106 [IEEE80211_MODE_TURBO_A]= { .rssi = ROAM_RSSI_11A_DEFAULT,
107 .rate = ROAM_RATE_11A_DEFAULT },
108 [IEEE80211_MODE_TURBO_G]= { .rssi = ROAM_RSSI_11A_DEFAULT,
109 .rate = ROAM_RATE_11A_DEFAULT },
110 [IEEE80211_MODE_STURBO_A]={ .rssi = ROAM_RSSI_11A_DEFAULT,
111 .rate = ROAM_RATE_11A_DEFAULT },
112 [IEEE80211_MODE_HALF] = { .rssi = ROAM_RSSI_11A_DEFAULT,
113 .rate = ROAM_RATE_HALF_DEFAULT },
114 [IEEE80211_MODE_QUARTER]= { .rssi = ROAM_RSSI_11A_DEFAULT,
115 .rate = ROAM_RATE_QUARTER_DEFAULT },
116 [IEEE80211_MODE_11NA] = { .rssi = ROAM_RSSI_11A_DEFAULT,
117 .rate = ROAM_MCS_11N_DEFAULT },
118 [IEEE80211_MODE_11NG] = { .rssi = ROAM_RSSI_11B_DEFAULT,
119 .rate = ROAM_MCS_11N_DEFAULT },
123 ieee80211_scan_vattach(struct ieee80211vap *vap)
125 vap->iv_bgscanidle = (IEEE80211_BGSCAN_IDLE_DEFAULT*1000)/hz;
126 vap->iv_bgscanintvl = IEEE80211_BGSCAN_INTVAL_DEFAULT*hz;
127 vap->iv_scanvalid = IEEE80211_SCAN_VALID_DEFAULT*hz;
129 vap->iv_roaming = IEEE80211_ROAMING_AUTO;
130 memcpy(vap->iv_roamparms, defroam, sizeof(defroam));
132 ieee80211_swscan_vattach(vap);
136 ieee80211_scan_vdetach(struct ieee80211vap *vap)
138 struct ieee80211com *ic = vap->iv_ic;
139 struct ieee80211_scan_state *ss;
144 ieee80211_swscan_vdetach(vap);
146 if (ss != NULL && ss->ss_vap == vap) {
147 if (ss->ss_ops != NULL) {
148 ss->ss_ops->scan_detach(ss);
153 IEEE80211_UNLOCK(ic);
157 * Simple-minded scanner module support.
159 static const char *scan_modnames[IEEE80211_OPMODE_MAX] = {
160 "wlan_scan_sta", /* IEEE80211_M_IBSS */
161 "wlan_scan_sta", /* IEEE80211_M_STA */
162 "wlan_scan_wds", /* IEEE80211_M_WDS */
163 "wlan_scan_sta", /* IEEE80211_M_AHDEMO */
164 "wlan_scan_ap", /* IEEE80211_M_HOSTAP */
165 "wlan_scan_monitor", /* IEEE80211_M_MONITOR */
166 "wlan_scan_sta", /* IEEE80211_M_MBSS */
168 static const struct ieee80211_scanner *scanners[IEEE80211_OPMODE_MAX];
170 const struct ieee80211_scanner *
171 ieee80211_scanner_get(enum ieee80211_opmode mode)
173 if (mode >= IEEE80211_OPMODE_MAX)
175 if (scanners[mode] == NULL)
176 ieee80211_load_module(scan_modnames[mode]);
177 return scanners[mode];
181 ieee80211_scanner_register(enum ieee80211_opmode mode,
182 const struct ieee80211_scanner *scan)
184 if (mode >= IEEE80211_OPMODE_MAX)
186 scanners[mode] = scan;
190 ieee80211_scanner_unregister(enum ieee80211_opmode mode,
191 const struct ieee80211_scanner *scan)
193 if (mode >= IEEE80211_OPMODE_MAX)
195 if (scanners[mode] == scan)
196 scanners[mode] = NULL;
200 ieee80211_scanner_unregister_all(const struct ieee80211_scanner *scan)
204 for (m = 0; m < IEEE80211_OPMODE_MAX; m++)
205 if (scanners[m] == scan)
210 * Update common scanner state to reflect the current
211 * operating mode. This is called when the state machine
212 * is transitioned to RUN state w/o scanning--e.g. when
213 * operating in monitor mode. The purpose of this is to
214 * ensure later callbacks find ss_ops set to properly
215 * reflect current operating mode.
218 ieee80211_scan_update_locked(struct ieee80211vap *vap,
219 const struct ieee80211_scanner *scan)
221 struct ieee80211com *ic = vap->iv_ic;
222 struct ieee80211_scan_state *ss = ic->ic_scan;
224 IEEE80211_LOCK_ASSERT(ic);
226 #ifdef IEEE80211_DEBUG
227 if (ss->ss_vap != vap || ss->ss_ops != scan) {
228 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
229 "%s: current scanner is <%s:%s>, switch to <%s:%s>\n",
232 ss->ss_vap->iv_ifp->if_xname : "none",
234 ieee80211_opmode_name[ss->ss_vap->iv_opmode] : "none",
235 vap->iv_ifp->if_xname,
236 ieee80211_opmode_name[vap->iv_opmode]);
240 if (ss->ss_ops != scan) {
242 * Switch scanners; detach old, attach new. Special
243 * case where a single scan module implements multiple
244 * policies by using different scan ops but a common
245 * core. We assume if the old and new attach methods
246 * are identical then it's ok to just change ss_ops
247 * and not flush the internal state of the module.
249 if (scan == NULL || ss->ss_ops == NULL ||
250 ss->ss_ops->scan_attach != scan->scan_attach) {
251 if (ss->ss_ops != NULL)
252 ss->ss_ops->scan_detach(ss);
253 if (scan != NULL && !scan->scan_attach(ss)) {
254 /* XXX attach failure */
264 ieee80211_scan_dump_channels(const struct ieee80211_scan_state *ss)
266 struct ieee80211com *ic = ss->ss_ic;
271 for (i = ss->ss_next; i < ss->ss_last; i++) {
272 const struct ieee80211_channel *c = ss->ss_chans[i];
274 printf("%s%u%c", sep, ieee80211_chan2ieee(ic, c),
275 ieee80211_channel_type_char(c));
280 #ifdef IEEE80211_DEBUG
282 ieee80211_scan_dump(struct ieee80211_scan_state *ss)
284 struct ieee80211vap *vap = ss->ss_vap;
286 if_printf(vap->iv_ifp, "scan set ");
287 ieee80211_scan_dump_channels(ss);
288 printf(" dwell min %lums max %lums\n",
289 ticks_to_msecs(ss->ss_mindwell), ticks_to_msecs(ss->ss_maxdwell));
291 #endif /* IEEE80211_DEBUG */
294 ieee80211_scan_copy_ssid(struct ieee80211vap *vap, struct ieee80211_scan_state *ss,
295 int nssid, const struct ieee80211_scan_ssid ssids[])
297 if (nssid > IEEE80211_SCAN_MAX_SSID) {
299 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
300 "%s: too many ssid %d, ignoring all of them\n",
304 memcpy(ss->ss_ssid, ssids, nssid * sizeof(ssids[0]));
305 ss->ss_nssid = nssid;
309 * Start a scan unless one is already going.
312 ieee80211_start_scan_locked(const struct ieee80211_scanner *scan,
313 struct ieee80211vap *vap, int flags, u_int duration,
314 u_int mindwell, u_int maxdwell,
315 u_int nssid, const struct ieee80211_scan_ssid ssids[])
317 struct ieee80211com *ic = vap->iv_ic;
318 struct ieee80211_scan_state *ss = ic->ic_scan;
320 IEEE80211_LOCK_ASSERT(ic);
322 if (ic->ic_flags & IEEE80211_F_CSAPENDING) {
323 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
324 "%s: scan inhibited by pending channel change\n", __func__);
325 } else if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) {
326 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
327 "%s: %s scan, duration %u mindwell %u maxdwell %u, desired mode %s, %s%s%s%s%s%s\n"
329 , flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive"
330 , duration, mindwell, maxdwell
331 , ieee80211_phymode_name[vap->iv_des_mode]
332 , flags & IEEE80211_SCAN_FLUSH ? "flush" : "append"
333 , flags & IEEE80211_SCAN_NOPICK ? ", nopick" : ""
334 , flags & IEEE80211_SCAN_NOJOIN ? ", nojoin" : ""
335 , flags & IEEE80211_SCAN_NOBCAST ? ", nobcast" : ""
336 , flags & IEEE80211_SCAN_PICK1ST ? ", pick1st" : ""
337 , flags & IEEE80211_SCAN_ONCE ? ", once" : ""
340 ieee80211_scan_update_locked(vap, scan);
341 if (ss->ss_ops != NULL) {
342 if ((flags & IEEE80211_SCAN_NOSSID) == 0)
343 ieee80211_scan_copy_ssid(vap, ss, nssid, ssids);
345 /* NB: top 4 bits for internal use */
346 ss->ss_flags = flags & 0xfff;
347 if (ss->ss_flags & IEEE80211_SCAN_ACTIVE)
348 vap->iv_stats.is_scan_active++;
350 vap->iv_stats.is_scan_passive++;
351 if (flags & IEEE80211_SCAN_FLUSH)
352 ss->ss_ops->scan_flush(ss);
353 if (flags & IEEE80211_SCAN_BGSCAN)
354 ic->ic_flags_ext |= IEEE80211_FEXT_BGSCAN;
356 /* Set duration for this particular scan */
357 ieee80211_swscan_set_scan_duration(vap, duration);
360 ss->ss_mindwell = mindwell;
361 ss->ss_maxdwell = maxdwell;
362 /* NB: scan_start must be before the scan runtask */
363 ss->ss_ops->scan_start(ss, vap);
364 #ifdef IEEE80211_DEBUG
365 if (ieee80211_msg_scan(vap))
366 ieee80211_scan_dump(ss);
367 #endif /* IEEE80211_DEBUG */
368 ic->ic_flags |= IEEE80211_F_SCAN;
370 /* Start scan task */
371 ieee80211_swscan_run_scan_task(vap);
375 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
376 "%s: %s scan already in progress\n", __func__,
377 ss->ss_flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive");
383 * Start a scan unless one is already going.
386 ieee80211_start_scan(struct ieee80211vap *vap, int flags,
387 u_int duration, u_int mindwell, u_int maxdwell,
388 u_int nssid, const struct ieee80211_scan_ssid ssids[])
390 const struct ieee80211_scanner *scan;
392 scan = ieee80211_scanner_get(vap->iv_opmode);
394 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
395 "%s: no scanner support for %s mode\n",
396 __func__, ieee80211_opmode_name[vap->iv_opmode]);
402 return ieee80211_swscan_start_scan(scan, vap, flags, duration,
403 mindwell, maxdwell, nssid, ssids);
407 * Check the scan cache for an ap/channel to use; if that
408 * fails then kick off a new scan.
411 ieee80211_check_scan(struct ieee80211vap *vap, int flags,
412 u_int duration, u_int mindwell, u_int maxdwell,
413 u_int nssid, const struct ieee80211_scan_ssid ssids[])
415 struct ieee80211com *ic = vap->iv_ic;
416 struct ieee80211_scan_state *ss = ic->ic_scan;
417 const struct ieee80211_scanner *scan;
420 scan = ieee80211_scanner_get(vap->iv_opmode);
422 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
423 "%s: no scanner support for %s mode\n",
424 __func__, vap->iv_opmode);
430 * Check if there's a list of scan candidates already.
431 * XXX want more than the ap we're currently associated with
435 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
436 "%s: %s scan, %s%s%s%s%s\n"
438 , flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive"
439 , flags & IEEE80211_SCAN_FLUSH ? "flush" : "append"
440 , flags & IEEE80211_SCAN_NOPICK ? ", nopick" : ""
441 , flags & IEEE80211_SCAN_NOJOIN ? ", nojoin" : ""
442 , flags & IEEE80211_SCAN_PICK1ST ? ", pick1st" : ""
443 , flags & IEEE80211_SCAN_ONCE ? ", once" : ""
446 if (ss->ss_ops != scan) {
447 /* XXX re-use cache contents? e.g. adhoc<->sta */
448 flags |= IEEE80211_SCAN_FLUSH;
452 * XXX TODO: separate things out a bit better.
455 ieee80211_scan_update_locked(vap, scan);
457 result = ieee80211_swscan_check_scan(scan, vap, flags, duration,
458 mindwell, maxdwell, nssid, ssids);
460 IEEE80211_UNLOCK(ic);
466 * Check the scan cache for an ap/channel to use; if that fails
467 * then kick off a scan using the current settings.
470 ieee80211_check_scan_current(struct ieee80211vap *vap)
472 return ieee80211_check_scan(vap,
473 IEEE80211_SCAN_ACTIVE,
474 IEEE80211_SCAN_FOREVER, 0, 0,
475 vap->iv_des_nssid, vap->iv_des_ssid);
479 * Restart a previous scan. If the previous scan completed
480 * then we start again using the existing channel list.
483 ieee80211_bg_scan(struct ieee80211vap *vap, int flags)
485 const struct ieee80211_scanner *scan;
487 // IEEE80211_UNLOCK_ASSERT(sc);
489 scan = ieee80211_scanner_get(vap->iv_opmode);
491 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
492 "%s: no scanner support for %s mode\n",
493 __func__, vap->iv_opmode);
499 * XXX TODO: pull apart the bgscan logic into whatever
500 * belongs here and whatever belongs in the software
505 return (ieee80211_swscan_bg_scan(scan, vap, flags));
509 * Cancel any scan currently going on for the specified vap.
512 ieee80211_cancel_scan(struct ieee80211vap *vap)
516 ieee80211_swscan_cancel_scan(vap);
520 * Cancel any scan currently going on.
523 ieee80211_cancel_anyscan(struct ieee80211vap *vap)
527 ieee80211_swscan_cancel_anyscan(vap);
531 * Public access to scan_next for drivers that manage
532 * scanning themselves (e.g. for firmware-based devices).
535 ieee80211_scan_next(struct ieee80211vap *vap)
539 ieee80211_swscan_scan_next(vap);
543 * Public access to scan_next for drivers that are not able to scan single
544 * channels (e.g. for firmware-based devices).
547 ieee80211_scan_done(struct ieee80211vap *vap)
549 struct ieee80211com *ic = vap->iv_ic;
550 struct ieee80211_scan_state *ss;
552 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s: called\n", __func__);
556 ss->ss_next = ss->ss_last; /* all channels are complete */
559 ieee80211_swscan_scan_done(vap);
561 IEEE80211_UNLOCK(ic);
565 * Probe the curent channel, if allowed, while scanning.
566 * If the channel is not marked passive-only then send
567 * a probe request immediately. Otherwise mark state and
568 * listen for beacons on the channel; if we receive something
569 * then we'll transmit a probe request.
572 ieee80211_probe_curchan(struct ieee80211vap *vap, int force)
574 struct ieee80211com *ic = vap->iv_ic;
576 if ((ic->ic_curchan->ic_flags & IEEE80211_CHAN_PASSIVE) && !force) {
577 ic->ic_flags_ext |= IEEE80211_FEXT_PROBECHAN;
582 ieee80211_swscan_probe_curchan(vap, force);
585 #ifdef IEEE80211_DEBUG
587 dump_country(const uint8_t *ie)
589 const struct ieee80211_country_ie *cie =
590 (const struct ieee80211_country_ie *) ie;
591 int i, nbands, schan, nchan;
594 printf(" <bogus country ie, len %d>", cie->len);
597 printf(" country [%c%c%c", cie->cc[0], cie->cc[1], cie->cc[2]);
598 nbands = (cie->len - 3) / sizeof(cie->band[0]);
599 for (i = 0; i < nbands; i++) {
600 schan = cie->band[i].schan;
601 nchan = cie->band[i].nchan;
603 printf(" %u-%u,%u", schan, schan + nchan-1,
604 cie->band[i].maxtxpwr);
606 printf(" %u,%u", schan, cie->band[i].maxtxpwr);
612 ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew,
613 const uint8_t mac[IEEE80211_ADDR_LEN],
614 const struct ieee80211_scanparams *sp, int rssi)
617 printf("[%s] %s%s on chan %u (bss chan %u) ",
618 ether_sprintf(mac), isnew ? "new " : "",
619 ieee80211_mgt_subtype_name[subtype >> IEEE80211_FC0_SUBTYPE_SHIFT],
620 sp->chan, sp->bchan);
621 ieee80211_print_essid(sp->ssid + 2, sp->ssid[1]);
622 printf(" rssi %d\n", rssi);
625 printf("[%s] caps 0x%x bintval %u erp 0x%x",
626 ether_sprintf(mac), sp->capinfo, sp->bintval, sp->erp);
627 if (sp->country != NULL)
628 dump_country(sp->country);
632 #endif /* IEEE80211_DEBUG */
635 * Process a beacon or probe response frame.
638 ieee80211_add_scan(struct ieee80211vap *vap,
639 const struct ieee80211_scanparams *sp,
640 const struct ieee80211_frame *wh,
641 int subtype, int rssi, int noise)
644 return (ieee80211_swscan_add_scan(vap, sp, wh, subtype, rssi, noise));
648 * Timeout/age scan cache entries; called from sta timeout
649 * timer (XXX should be self-contained).
652 ieee80211_scan_timeout(struct ieee80211com *ic)
654 struct ieee80211_scan_state *ss = ic->ic_scan;
656 if (ss->ss_ops != NULL)
657 ss->ss_ops->scan_age(ss);
661 * Mark a scan cache entry after a successful associate.
664 ieee80211_scan_assoc_success(struct ieee80211vap *vap, const uint8_t mac[])
666 struct ieee80211_scan_state *ss = vap->iv_ic->ic_scan;
668 if (ss->ss_ops != NULL) {
669 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_SCAN,
670 mac, "%s", __func__);
671 ss->ss_ops->scan_assoc_success(ss, mac);
676 * Demerit a scan cache entry after failing to associate.
679 ieee80211_scan_assoc_fail(struct ieee80211vap *vap,
680 const uint8_t mac[], int reason)
682 struct ieee80211_scan_state *ss = vap->iv_ic->ic_scan;
684 if (ss->ss_ops != NULL) {
685 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_SCAN, mac,
686 "%s: reason %u", __func__, reason);
687 ss->ss_ops->scan_assoc_fail(ss, mac, reason);
692 * Iterate over the contents of the scan cache.
695 ieee80211_scan_iterate(struct ieee80211vap *vap,
696 ieee80211_scan_iter_func *f, void *arg)
698 struct ieee80211_scan_state *ss = vap->iv_ic->ic_scan;
700 if (ss->ss_ops != NULL)
701 ss->ss_ops->scan_iterate(ss, f, arg);
705 * Flush the contents of the scan cache.
708 ieee80211_scan_flush(struct ieee80211vap *vap)
710 struct ieee80211_scan_state *ss = vap->iv_ic->ic_scan;
712 if (ss->ss_ops != NULL && ss->ss_vap == vap) {
713 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s\n", __func__);
714 ss->ss_ops->scan_flush(ss);
719 * Check the scan cache for an ap/channel to use; if that
720 * fails then kick off a new scan.
722 struct ieee80211_channel *
723 ieee80211_scan_pickchannel(struct ieee80211com *ic, int flags)
725 struct ieee80211_scan_state *ss = ic->ic_scan;
727 IEEE80211_LOCK_ASSERT(ic);
729 if (ss == NULL || ss->ss_ops == NULL || ss->ss_vap == NULL) {
733 if (ss->ss_ops->scan_pickchan == NULL) {
734 IEEE80211_DPRINTF(ss->ss_vap, IEEE80211_MSG_SCAN,
735 "%s: scan module does not support picking a channel, "
736 "opmode %s\n", __func__, ss->ss_vap->iv_opmode);
739 return ss->ss_ops->scan_pickchan(ss, flags);