1 --- a/net80211/ieee80211_scan_sta.c
2 +++ b/net80211/ieee80211_scan_sta.c
7 -static struct ieee80211_channel *
8 -find11gchannel(struct ieee80211com *ic, int i, int freq)
10 - struct ieee80211_channel *c;
14 - * The normal ordering in the channel list is b channel
15 - * immediately followed by g so optimize the search for
16 - * this. We'll still do a full search just in case.
18 - for (j = i+1; j < ic->ic_nchans; j++) {
19 - c = &ic->ic_channels[j];
20 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
23 - for (j = 0; j < i; j++) {
24 - c = &ic->ic_channels[j];
25 - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
30 -static const u_int chanflags[] = {
31 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
32 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
33 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
34 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
35 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
36 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
37 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
38 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
42 -add_channels(struct ieee80211com *ic,
43 - struct ieee80211_scan_state *ss,
44 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
46 - struct ieee80211_channel *c, *cg;
50 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
51 - modeflags = chanflags[mode];
52 - for (i = 0; i < nfreq; i++) {
53 - c = ieee80211_find_channel(ic, freq[i], modeflags);
54 - if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
56 - if (mode == IEEE80211_MODE_AUTO) {
58 - * XXX special-case 11b/g channels so we select
59 - * the g channel if both are present.
61 - if (IEEE80211_IS_CHAN_B(c) &&
62 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
65 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
67 - ss->ss_chans[ss->ss_last++] = c;
71 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64, 36, 40, 44, 48 */
72 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
73 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
74 -{ 5170, 5190, 5210, 5230 };
75 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
76 -{ 2412, 2437, 2462, 2442, 2472 };
77 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
78 -{ 5745, 5765, 5785, 5805, 5825 };
79 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100,104,108,112,116,120,124,128,132,136,140 */
80 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
81 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
82 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
83 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
85 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
86 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
87 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
88 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
89 -#ifdef ATH_TURBO_SCAN
90 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
91 -{ 5210, 5250, 5290 };
92 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
94 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
95 -{ 5540, 5580, 5620, 5660 };
96 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
98 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
99 -{ 5200, 5240, 5280, 5765, 5805 };
100 -#endif /* ATH_TURBO_SCAN */
105 - const u_int16_t *list;
108 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
109 -#define X(a) .count = sizeof(a)/sizeof(a[0]), .list = a
111 -static const struct scanlist staScanTable[] = {
112 - { IEEE80211_MODE_11B, X(rcl3) },
113 - { IEEE80211_MODE_11A, X(rcl1) },
114 - { IEEE80211_MODE_11A, X(rcl2) },
115 - { IEEE80211_MODE_11B, X(rcl8) },
116 - { IEEE80211_MODE_11B, X(rcl9) },
117 - { IEEE80211_MODE_11A, X(rcl4) },
118 -#ifdef ATH_TURBO_SCAN
119 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
120 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
121 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
122 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
123 -#endif /* ATH_TURBO_SCAN */
124 - { IEEE80211_MODE_11A, X(rcl7) },
125 - { IEEE80211_MODE_11B, X(rcl10) },
126 - { IEEE80211_MODE_11A, X(rcl11) },
127 -#ifdef ATH_TURBO_SCAN
128 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
129 -#endif /* ATH_TURBO_SCAN */
136 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
140 - for (; scan->list != NULL; scan++) {
141 - for (i = 0; i < scan->count; i++)
142 - if (scan->list[i] == c->ic_freq)
149 * Start a station-mode scan by populating the channel list.
151 @@ -467,81 +326,11 @@
153 struct ieee80211com *ic = vap->iv_ic;
154 struct sta_table *st = ss->ss_priv;
155 - const struct scanlist *scan;
156 - enum ieee80211_phymode mode;
157 - struct ieee80211_channel *c;
162 - * Use the table of ordered channels to construct the list
163 - * of channels for scanning. Any channels in the ordered
164 - * list not in the master list will be discarded.
166 - for (scan = staScanTable; scan->list != NULL; scan++) {
168 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
170 - * If a desired mode was specified, scan only
171 - * channels that satisfy that constraint.
173 - if (vap->iv_des_mode != mode) {
175 - * The scan table marks 2.4Ghz channels as b
176 - * so if the desired mode is 11g, then use
177 - * the 11b channel list but upgrade the mode.
179 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
180 - mode != IEEE80211_MODE_11B)
182 - mode = IEEE80211_MODE_11G; /* upgrade */
186 - * This lets ieee80211_scan_add_channels
187 - * upgrade an 11b channel to 11g if available.
189 - if (mode == IEEE80211_MODE_11B)
190 - mode = IEEE80211_MODE_AUTO;
192 - /* XR does not operate on turbo channels */
193 - if ((vap->iv_flags & IEEE80211_F_XR) &&
194 - (mode == IEEE80211_MODE_TURBO_A ||
195 - mode == IEEE80211_MODE_TURBO_G))
198 - * Add the list of the channels; any that are not
199 - * in the master channel list will be discarded.
201 - add_channels(ic, ss, mode, scan->list, scan->count);
205 - * Add the channels from the ic (from HAL) that are not present
206 - * in the staScanTable.
208 - for (i = 0; i < ic->ic_nchans; i++) {
209 - c = &ic->ic_channels[i];
211 - * scan dynamic turbo channels in normal mode.
213 - if (IEEE80211_IS_CHAN_DTURBO(c))
215 - mode = ieee80211_chan2mode(c);
216 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
218 - * If a desired mode was specified, scan only
219 - * channels that satisfy that constraint.
221 - if (vap->iv_des_mode != mode)
225 - if (!checktable(staScanTable, c))
226 - ss->ss_chans[ss->ss_last++] = c;
229 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
234 * The scanner will stay on station for ss_maxdwell ms (using a
237 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, se->se_chan)))
240 - * NB: normally the desired mode is used to construct
241 - * the channel list, but it's possible for the scan
242 - * cache to include entries for stations outside this
243 - * list so we check the desired mode here to weed them
246 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
247 - (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
248 - chanflags[vap->iv_des_mode])
251 if (vap->iv_opmode == IEEE80211_M_IBSS) {
252 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
254 @@ -1175,78 +954,6 @@
255 .scan_default = ieee80211_sta_join,
259 - * Start an adhoc-mode scan by populating the channel list.
262 -adhoc_start(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
264 - struct ieee80211com *ic = vap->iv_ic;
265 - struct sta_table *st = ss->ss_priv;
266 - const struct scanlist *scan;
267 - enum ieee80211_phymode mode;
271 - * Use the table of ordered channels to construct the list
272 - * of channels for scanning. Any channels in the ordered
273 - * list not in the master list will be discarded.
275 - for (scan = staScanTable; scan->list != NULL; scan++) {
277 - if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
279 - * If a desired mode was specified, scan only
280 - * channels that satisfy that constraint.
282 - if (vap->iv_des_mode != mode) {
284 - * The scan table marks 2.4Ghz channels as b
285 - * so if the desired mode is 11g, then use
286 - * the 11b channel list but upgrade the mode.
288 - if (vap->iv_des_mode != IEEE80211_MODE_11G ||
289 - mode != IEEE80211_MODE_11B)
291 - mode = IEEE80211_MODE_11G; /* upgrade */
295 - * This lets ieee80211_scan_add_channels
296 - * upgrade an 11b channel to 11g if available.
298 - if (mode == IEEE80211_MODE_11B)
299 - mode = IEEE80211_MODE_AUTO;
301 - /* XR does not operate on turbo channels */
302 - if ((vap->iv_flags & IEEE80211_F_XR) &&
303 - (mode == IEEE80211_MODE_TURBO_A ||
304 - mode == IEEE80211_MODE_TURBO_G))
307 - * Add the list of the channels; any that are not
308 - * in the master channel list will be discarded.
310 - add_channels(ic, ss, mode, scan->list, scan->count);
314 - ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
315 - ss->ss_maxdwell = msecs_to_jiffies(200); /* 200ms */
317 -#ifdef IEEE80211_DEBUG
318 - if (ieee80211_msg_scan(vap)) {
319 - printk("%s: scan set ", vap->iv_dev->name);
320 - ieee80211_scan_dump_channels(ss);
321 - printk(" dwell min %ld max %ld\n",
322 - ss->ss_mindwell, ss->ss_maxdwell);
324 -#endif /* IEEE80211_DEBUG */
326 - st->st_newscan = 1;
332 * Select a channel to start an adhoc network on.
333 @@ -1412,7 +1119,7 @@
334 .scan_name = "default",
335 .scan_attach = sta_attach,
336 .scan_detach = sta_detach,
337 - .scan_start = adhoc_start,
338 + .scan_start = sta_start,
339 .scan_restart = sta_restart,
340 .scan_cancel = sta_cancel,
341 .scan_end = adhoc_pick_bss,
342 --- a/net80211/ieee80211.c
343 +++ b/net80211/ieee80211.c
345 ("channel with bogus ieee number %u", c->ic_ieee));
346 setbit(ic->ic_chan_avail, c->ic_ieee);
348 + if (c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT)
349 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
351 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
353 /* Identify mode capabilities. */
354 if (IEEE80211_IS_CHAN_A(c))
355 ic->ic_modecaps |= 1 << IEEE80211_MODE_11A;
356 --- a/net80211/_ieee80211.h
357 +++ b/net80211/_ieee80211.h
359 IEEE80211_SCAN_FIRST = 2, /* take first suitable candidate */
362 +enum ieee80211_scanflags {
363 + IEEE80211_NOSCAN_DEFAULT = (1 << 0),
364 + IEEE80211_NOSCAN_SET = (1 << 1),
368 * Channels are specified by frequency and attributes.
371 int8_t ic_maxregpower; /* maximum regulatory tx power in dBm */
372 int8_t ic_maxpower; /* maximum tx power in dBm */
373 int8_t ic_minpower; /* minimum tx power in dBm */
374 + u_int8_t ic_scanflags;
377 #define IEEE80211_CHAN_MAX 255
378 --- a/net80211/ieee80211_ioctl.h
379 +++ b/net80211/ieee80211_ioctl.h
381 #define IEEE80211_IOCTL_WDSADDMAC (SIOCIWFIRSTPRIV+26)
382 #define IEEE80211_IOCTL_WDSDELMAC (SIOCIWFIRSTPRIV+28)
383 #define IEEE80211_IOCTL_KICKMAC (SIOCIWFIRSTPRIV+30)
384 +#define IEEE80211_IOCTL_SETSCANLIST (SIOCIWFIRSTPRIV+31)
387 IEEE80211_WMMPARAMS_CWMIN = 1,
388 --- a/net80211/ieee80211_scan_ap.c
389 +++ b/net80211/ieee80211_scan_ap.c
390 @@ -200,131 +200,7 @@
392 static int ap_flush(struct ieee80211_scan_state *);
393 static void action_tasklet(IEEE80211_TQUEUE_ARG);
394 -static struct ieee80211_channel *find11gchannel(struct ieee80211com *ic,
397 -static const u_int chanflags[] = {
398 - IEEE80211_CHAN_B, /* IEEE80211_MODE_AUTO */
399 - IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
400 - IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
401 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
402 - IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
403 - IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode
407 - IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
408 - IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
411 -static const u_int16_t rcl1[] = /* 8 FCC channel: 52, 56, 60, 64,
412 - * 36, 40, 44, 48 */
413 -{ 5260, 5280, 5300, 5320, 5180, 5200, 5220, 5240 };
414 -static const u_int16_t rcl2[] = /* 4 MKK channels: 34, 38, 42, 46 */
415 -{ 5170, 5190, 5210, 5230 };
416 -static const u_int16_t rcl3[] = /* 2.4Ghz ch: 1,6,11,7,13 */
417 -{ 2412, 2437, 2462, 2442, 2472 };
418 -static const u_int16_t rcl4[] = /* 5 FCC channel: 149, 153, 161, 165 */
419 -{ 5745, 5765, 5785, 5805, 5825 };
420 -static const u_int16_t rcl7[] = /* 11 ETSI channel: 100, 104, 108, 112,
421 - * 116, 120, 124, 128,
423 -{ 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680, 5700 };
424 -static const u_int16_t rcl8[] = /* 2.4Ghz ch: 2,3,4,5,8,9,10,12 */
425 -{ 2417, 2422, 2427, 2432, 2447, 2452, 2457, 2467 };
426 -static const u_int16_t rcl9[] = /* 2.4Ghz ch: 14 */
428 -static const u_int16_t rcl10[] = /* Added Korean channels 2312-2372 */
429 -{ 2312, 2317, 2322, 2327, 2332, 2337, 2342, 2347, 2352, 2357, 2362, 2367, 2372 };
430 -static const u_int16_t rcl11[] = /* Added Japan channels in 4.9/5.0 spectrum */
431 -{ 5040, 5060, 5080, 4920, 4940, 4960, 4980 };
432 -#ifdef ATH_TURBO_SCAN
433 -static const u_int16_t rcl5[] = /* 3 static turbo channels */
434 -{ 5210, 5250, 5290 };
435 -static const u_int16_t rcl6[] = /* 2 static turbo channels */
437 -static const u_int16_t rcl6x[] = /* 4 FCC3 turbo channels */
438 -{ 5540, 5580, 5620, 5660 };
439 -static const u_int16_t rcl12[] = /* 2.4Ghz Turbo channel 6 */
441 -static const u_int16_t rcl13[] = /* dynamic Turbo channels */
442 -{ 5200, 5240, 5280, 5765, 5805 };
443 -#endif /* ATH_TURBO_SCAN */
448 - const u_int16_t *list;
451 -#define IEEE80211_MODE_TURBO_STATIC_A IEEE80211_MODE_MAX
452 -#define X(a) .count = ARRAY_SIZE(a), .list = a
454 -static const struct scanlist staScanTable[] = {
455 - { IEEE80211_MODE_11B, X(rcl3) },
456 - { IEEE80211_MODE_11A, X(rcl1) },
457 - { IEEE80211_MODE_11A, X(rcl2) },
458 - { IEEE80211_MODE_11B, X(rcl8) },
459 - { IEEE80211_MODE_11B, X(rcl9) },
460 - { IEEE80211_MODE_11A, X(rcl4) },
461 -#ifdef ATH_TURBO_SCAN
462 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl5) },
463 - { IEEE80211_MODE_TURBO_STATIC_A, X(rcl6) },
464 - { IEEE80211_MODE_TURBO_A, X(rcl6x) },
465 - { IEEE80211_MODE_TURBO_A, X(rcl13) },
466 -#endif /* ATH_TURBO_SCAN */
467 - { IEEE80211_MODE_11A, X(rcl7) },
468 - { IEEE80211_MODE_11B, X(rcl10) },
469 - { IEEE80211_MODE_11A, X(rcl11) },
470 -#ifdef ATH_TURBO_SCAN
471 - { IEEE80211_MODE_TURBO_G, X(rcl12) },
472 -#endif /* ATH_TURBO_SCAN */
477 -/* This function must be invoked with locks acquired */
479 -add_channels(struct ieee80211com *ic,
480 - struct ieee80211_scan_state *ss,
481 - enum ieee80211_phymode mode, const u_int16_t freq[], int nfreq)
483 - struct ieee80211_channel *c, *cg;
487 - KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
488 - modeflags = chanflags[mode];
489 - for (i = 0; i < nfreq; i++) {
490 - c = ieee80211_find_channel(ic, freq[i], modeflags);
491 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
493 - if (mode == IEEE80211_MODE_AUTO) {
494 - /* XXX special-case 11b/g channels so we select
495 - * the g channel if both are present. */
496 - if (IEEE80211_IS_CHAN_B(c) &&
497 - (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
500 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
502 - ss->ss_chans[ss->ss_last++] = c;
506 -/* This function must be invoked with locks acquired */
508 -checktable(const struct scanlist *scan, const struct ieee80211_channel *c)
512 - for (; scan->list != NULL; scan++) {
513 - for (i = 0; i < scan->count; i++)
514 - if (scan->list[i] == c->ic_freq)
521 * Attach prior to any scanning work.
523 ieee80211_saveie(iep, ie);
526 -/* This function must be invoked with locks acquired */
527 -static struct ieee80211_channel *
528 -find11gchannel(struct ieee80211com *ic, int i, int freq)
530 - struct ieee80211_channel *c;
533 - /* The normal ordering in the channel list is b channel
534 - * immediately followed by g so optimize the search for
535 - * this. We'll still do a full search just in case. */
536 - for (j = i + 1; j < ic->ic_nchans; j++) {
537 - c = &ic->ic_channels[j];
538 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
541 - for (j = 0; j < i; j++) {
542 - c = &ic->ic_channels[j];
543 - if ((c->ic_freq == freq) && IEEE80211_IS_CHAN_ANYG(c))
550 * Start an ap scan by populating the channel list.
552 @@ -429,90 +282,14 @@
554 struct ap_state *as = ss->ss_priv;
555 struct ieee80211com *ic = NULL;
556 - const struct scanlist *sl = NULL;
557 - struct ieee80211_channel *c = NULL;
559 - unsigned int mode = 0;
561 SCAN_AP_LOCK_IRQ(as);
563 /* Determine mode flags to match, or leave zero for auto mode */
564 as->as_vap_desired_mode = vap->iv_des_mode;
565 as->as_required_mode = 0;
566 - if (as->as_vap_desired_mode != IEEE80211_MODE_AUTO) {
567 - as->as_required_mode = chanflags[as->as_vap_desired_mode];
568 - if ((vap->iv_ath_cap & IEEE80211_ATHC_TURBOP) &&
569 - (as->as_required_mode != IEEE80211_CHAN_ST)) {
570 - /* Fixup for dynamic turbo flags */
571 - if (as->as_vap_desired_mode == IEEE80211_MODE_11G)
572 - as->as_required_mode = IEEE80211_CHAN_108G;
574 - as->as_required_mode = IEEE80211_CHAN_108A;
579 - /* Use the table of ordered channels to construct the list
580 - * of channels for scanning. Any channels in the ordered
581 - * list not in the master list will be discarded. */
582 - for (sl = staScanTable; sl->list != NULL; sl++) {
585 - /* The scan table marks 2.4Ghz channels as b
586 - * so if the desired mode is 11g, then use
587 - * the 11b channel list but upgrade the mode. */
588 - if (as->as_vap_desired_mode &&
589 - (as->as_vap_desired_mode != mode) &&
590 - (as->as_vap_desired_mode == IEEE80211_MODE_11G) &&
591 - (mode == IEEE80211_MODE_11B))
592 - mode = IEEE80211_MODE_11G;
594 - /* If we are in "AUTO" mode, upgrade the mode to auto.
595 - * This lets add_channels upgrade an 11b channel to
596 - * 11g if available. */
597 - if (!as->as_vap_desired_mode && (mode == IEEE80211_MODE_11B))
598 - mode = IEEE80211_MODE_AUTO;
600 - /* Add the list of the channels; any that are not
601 - * in the master channel list will be discarded. */
602 - add_channels(ic, ss, mode, sl->list, sl->count);
605 - /* Add the channels from the ic (from HAL) that are not present
606 - * in the staScanTable, assuming they pass the sanity checks... */
607 - for (i = 0; i < ic->ic_nchans; i++) {
608 - c = &ic->ic_channels[i];
610 - /* XR is not supported on turbo channels */
611 - if (IEEE80211_IS_CHAN_TURBO(c) && vap->iv_flags & IEEE80211_F_XR)
613 + ieee80211_scan_add_channels(ic, ss, vap->iv_des_mode);
615 - /* Dynamic channels are scanned in base mode */
616 - if (!as->as_required_mode && !IEEE80211_IS_CHAN_ST(c))
619 - /* Use any 11g channel instead of 11b one. */
620 - if (vap->iv_des_mode == IEEE80211_MODE_AUTO &&
621 - IEEE80211_IS_CHAN_B(c) &&
622 - find11gchannel(ic, i, c->ic_freq))
625 - /* Do not add channels already put into the scan list by the
626 - * scan table - these have already been filtered by mode
627 - * and for whether they are in the active channel list. */
628 - if (checktable(staScanTable, c))
631 - /* Make sure the channel is active */
632 - if ((c == NULL) || isclr(ic->ic_chan_active, c->ic_ieee))
635 - /* Don't overrun */
636 - if (ss->ss_last >= IEEE80211_SCAN_MAX)
639 - ss->ss_chans[ss->ss_last++] = c;
643 ss->ss_mindwell = msecs_to_jiffies(200); /* 200ms */
645 if (IEEE80211_IS_CHAN_RADAR(c->chan))
648 - /* Do not select 802.11a ST if mode is specified and is not
650 - if (as->as_required_mode &&
651 - IEEE80211_IS_CHAN_STURBO(c->chan) &&
652 - (as->as_vap_desired_mode != IEEE80211_MODE_TURBO_STATIC_A))
655 /* Verify mode matches any fixed mode specified */
656 if ((c->chan->ic_flags & as->as_required_mode) !=
657 as->as_required_mode)
658 --- a/net80211/ieee80211_scan.c
659 +++ b/net80211/ieee80211_scan.c
664 +static const u_int chanflags[] = {
665 + 0, /* IEEE80211_MODE_AUTO */
666 + IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
667 + IEEE80211_CHAN_B, /* IEEE80211_MODE_11B */
668 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_11G */
669 + IEEE80211_CHAN_FHSS, /* IEEE80211_MODE_FH */
670 + IEEE80211_CHAN_A, /* IEEE80211_MODE_TURBO_A */ /* for turbo mode look for AP in normal channel */
671 + IEEE80211_CHAN_PUREG, /* IEEE80211_MODE_TURBO_G */
672 + IEEE80211_CHAN_ST, /* IEEE80211_MODE_TURBO_STATIC_A */
675 +static struct ieee80211_channel *
676 +find11gchannel(struct ieee80211com *ic, int i, int freq)
678 + struct ieee80211_channel *c;
682 + * The normal ordering in the channel list is b channel
683 + * immediately followed by g so optimize the search for
684 + * this. We'll still do a full search just in case.
686 + for (j = i+1; j < ic->ic_nchans; j++) {
687 + c = &ic->ic_channels[j];
688 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
691 + for (j = 0; j < i; j++) {
692 + c = &ic->ic_channels[j];
693 + if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c))
701 +ieee80211_scan_add_channels(struct ieee80211com *ic,
702 + struct ieee80211_scan_state *ss,
703 + enum ieee80211_phymode mode)
705 + struct ieee80211_channel *c, *cg;
709 + KASSERT(mode < ARRAY_SIZE(chanflags), ("Unexpected mode %u", mode));
710 + modeflags = chanflags[mode];
711 + for (i = 0; i < ic->ic_nchans; i++) {
712 + c = &ic->ic_channels[i];
713 + if (c == NULL || isclr(ic->ic_chan_active, c->ic_ieee))
715 + if (c->ic_scanflags & IEEE80211_NOSCAN_SET)
718 + ((c->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
719 + (modeflags & IEEE80211_CHAN_ALLTURBO)))
721 + if (mode == IEEE80211_MODE_AUTO) {
723 + * XXX special-case 11b/g channels so we select
724 + * the g channel if both are present.
726 + if (IEEE80211_IS_CHAN_B(c) &&
727 + (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
730 + if (ss->ss_last >= IEEE80211_SCAN_MAX)
732 + ss->ss_chans[ss->ss_last++] = c;
735 +EXPORT_SYMBOL(ieee80211_scan_add_channels);
739 * Execute radar channel change. This is called when a radar/dfs
740 * signal is detected. AP mode only. Return 1 on success, 0 on
741 --- a/net80211/ieee80211_scan.h
742 +++ b/net80211/ieee80211_scan.h
744 void ieee80211_scanner_unregister(enum ieee80211_opmode,
745 const struct ieee80211_scanner *);
746 void ieee80211_scanner_unregister_all(const struct ieee80211_scanner *);
747 +void ieee80211_scan_add_channels(struct ieee80211com *ic,
748 + struct ieee80211_scan_state *ss,
749 + enum ieee80211_phymode mode);
750 #endif /* _NET80211_IEEE80211_SCAN_H_ */
751 --- a/net80211/ieee80211_wireless.c
752 +++ b/net80211/ieee80211_wireless.c
753 @@ -3911,6 +3911,106 @@
754 return ieee80211_ioctl_setmlme(dev, info, w, (char *)&mlme);
757 +static inline void setflag(struct ieee80211_channel *c, int flag)
760 + c->ic_scanflags |= IEEE80211_NOSCAN_SET;
762 + c->ic_scanflags &= ~IEEE80211_NOSCAN_SET;
765 +static void setscanflag(struct ieee80211com *ic, int min, int max, int set)
769 + for (i = 0; i < ic->ic_nchans; i++) {
770 + struct ieee80211_channel *c = &ic->ic_channels[i];
773 + if (!(c->ic_scanflags & IEEE80211_NOSCAN_DEFAULT))
775 + } else if ((c->ic_freq >= min) && (c->ic_freq <= max)) {
782 +ieee80211_ioctl_setscanlist(struct net_device *dev,
783 + struct iw_request_info *info,
784 + struct iw_point *data, char *extra)
786 + struct ieee80211vap *vap = dev->priv;
787 + struct ieee80211com *ic = vap->iv_ic;
791 + if (data->length <= 0)
794 + s = kmalloc(data->length + 1, GFP_KERNEL);
798 + memset(s, 0, data->length + 1);
799 + if (copy_from_user(s, data->pointer, data->length))
802 + s[data->length - 1] = '\0'; /* ensure null termination */
817 + next = strchr(s, ',');
822 + if (!strcmp(s, "ALL")) {
823 + setscanflag(ic, 0, 10000, val);
824 + } else if (!strcmp(s, "REG")) {
825 + setscanflag(ic, -1, -1, val);
828 + char *n, *end = NULL;
830 + n = strchr(s, '-');
835 + min = simple_strtoul(s, &end, 10);
839 + max = simple_strtoul(n, &end, 10);
845 + setscanflag(ic, min, max, val);
858 ieee80211_ioctl_addmac(struct net_device *dev, struct iw_request_info *info,
859 void *w, char *extra)
860 @@ -5712,6 +5812,8 @@
861 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "minrate"},
862 {IEEE80211_PARAM_MINRATE,
863 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_minrate"},
864 + { IEEE80211_IOCTL_SETSCANLIST,
865 + IW_PRIV_TYPE_CHAR | 255, 0, "setscanlist"},
867 #ifdef ATH_REVERSE_ENGINEERING
869 @@ -5809,6 +5911,7 @@
870 set_priv(IEEE80211_IOCTL_WDSADDMAC, ieee80211_ioctl_wdsmac),
871 set_priv(IEEE80211_IOCTL_WDSDELMAC, ieee80211_ioctl_wdsdelmac),
872 set_priv(IEEE80211_IOCTL_KICKMAC, ieee80211_ioctl_kickmac),
873 + set_priv(IEEE80211_IOCTL_SETSCANLIST, ieee80211_ioctl_setscanlist),
874 #ifdef ATH_REVERSE_ENGINEERING
875 set_priv(IEEE80211_IOCTL_READREG, ieee80211_ioctl_readreg),
876 set_priv(IEEE80211_IOCTL_WRITEREG, ieee80211_ioctl_writereg),